* trading portal replace traveling storeship * clean up content * clean up content 2 * seel and buy realization * fixes * Update migration.yml * Update migration.yml * Update dev_map.yml * Update dev_map.yml * thats work correctly now * bugfies and visual * factions * faction restruct + name reduce * unnesting sell cargo positions * unnesting cargo positions * more cargo content * Update buy.yml * improve tradeportal visual * Update migration.yml * Bank ad Commandant removal * merchant objectives * finish * clean up content * Update migration.yml * fix goal calculation * Update comoss.yml * Update dev_map.yml
61 lines
1.8 KiB
C#
61 lines
1.8 KiB
C#
using Content.Shared._CP14.Cargo;
|
|
using Robust.Client.AutoGenerated;
|
|
using Robust.Client.UserInterface.CustomControls;
|
|
using Robust.Client.UserInterface.XAML;
|
|
using Robust.Shared.Timing;
|
|
|
|
namespace Content.Client._CP14.TravelingStoreShip;
|
|
|
|
[GenerateTypedNameReferences]
|
|
public sealed partial class CP14StoreWindow : DefaultWindow
|
|
{
|
|
[Dependency] private readonly IGameTiming _timing = default!;
|
|
|
|
public CP14StoreWindow()
|
|
{
|
|
RobustXamlLoader.Load(this);
|
|
IoCManager.InjectDependencies(this);
|
|
|
|
Tabs.SetTabTitle(0, Loc.GetString("cp14-store-ui-tab-buy"));
|
|
Tabs.SetTabTitle(1, Loc.GetString("cp14-store-ui-tab-sell"));
|
|
}
|
|
|
|
public void UpdateUI(CP14StoreUiState state)
|
|
{
|
|
Window.Title = Loc.GetString("cp14-store-ui-title", ("name", state.ShopName));
|
|
UpdateProducts(state);
|
|
}
|
|
|
|
private void UpdateProducts(CP14StoreUiState state)
|
|
{
|
|
BuyProductsContainer.RemoveAllChildren();
|
|
SellProductsContainer.RemoveAllChildren();
|
|
|
|
foreach (var product in state.ProductsBuy)
|
|
{
|
|
var control = new CP14StoreProductControl(product);
|
|
control.ProductButton.OnPressed += _ =>
|
|
{
|
|
SelectProduct(product);
|
|
};
|
|
BuyProductsContainer.AddChild(control);
|
|
}
|
|
|
|
foreach (var product in state.ProductsSell)
|
|
{
|
|
var control = new CP14StoreProductControl(product);
|
|
control.ProductButton.OnPressed += _ =>
|
|
{
|
|
SelectProduct(product);
|
|
};
|
|
SellProductsContainer.AddChild(control);
|
|
}
|
|
}
|
|
|
|
private void SelectProduct(CP14StoreUiProductEntry? entry)
|
|
{
|
|
SelectedName.Text = entry is null ? string.Empty : $"[bold]{entry.Value.Name}[/bold]";
|
|
SelectedDesc.Text = entry is null ? string.Empty : entry.Value.Desc;
|
|
}
|
|
}
|