From 0ffef4baef883fe597adc70cca18813d58848307 Mon Sep 17 00:00:00 2001 From: Milon Date: Mon, 4 Nov 2024 20:36:41 +0100 Subject: [PATCH] address reviews --- .../Cartridges/PriceHistoryTable.xaml | 25 +++ ...toryTable.cs => PriceHistoryTable.xaml.cs} | 62 +---- .../Cartridges/StockTradingUi.cs | 2 +- .../Cartridges/StockTradingUiFragment.xaml | 6 +- .../Cartridges/StockTradingUiFragment.xaml.cs | 68 +++--- .../Components/StationStockMarketComponent.cs | 67 ++---- Content.Server/DeltaV/Cargo/StocksCommands.cs | 79 +++++-- .../DeltaV/Cargo/Systems/StockMarketSystem.cs | 212 ++++++------------ .../Cartridges/StockTradingCartridgeSystem.cs | 34 ++- .../Cartridges/StockTradingUiMessageEvent.cs | 16 +- .../Cartridges/StockTradingUiState.cs | 29 ++- .../en-US/deltav/cargo/stocks-comapnies.ftl | 6 + .../en-US/deltav/cargo/stocks-commands.ftl | 15 +- .../deltav/cartridge-loader/cartridges.ftl | 38 +++- .../DeltaV/Entities/Stations/base.yml | 70 ++---- 15 files changed, 333 insertions(+), 396 deletions(-) create mode 100644 Content.Client/DeltaV/CartridgeLoader/Cartridges/PriceHistoryTable.xaml rename Content.Client/DeltaV/CartridgeLoader/Cartridges/{PriceHistoryTable.cs => PriceHistoryTable.xaml.cs} (56%) create mode 100644 Resources/Locale/en-US/deltav/cargo/stocks-comapnies.ftl diff --git a/Content.Client/DeltaV/CartridgeLoader/Cartridges/PriceHistoryTable.xaml b/Content.Client/DeltaV/CartridgeLoader/Cartridges/PriceHistoryTable.xaml new file mode 100644 index 00000000000..058bde07e9c --- /dev/null +++ b/Content.Client/DeltaV/CartridgeLoader/Cartridges/PriceHistoryTable.xaml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + diff --git a/Content.Client/DeltaV/CartridgeLoader/Cartridges/PriceHistoryTable.cs b/Content.Client/DeltaV/CartridgeLoader/Cartridges/PriceHistoryTable.xaml.cs similarity index 56% rename from Content.Client/DeltaV/CartridgeLoader/Cartridges/PriceHistoryTable.cs rename to Content.Client/DeltaV/CartridgeLoader/Cartridges/PriceHistoryTable.xaml.cs index 465958ab982..f5798f44c42 100644 --- a/Content.Client/DeltaV/CartridgeLoader/Cartridges/PriceHistoryTable.cs +++ b/Content.Client/DeltaV/CartridgeLoader/Cartridges/PriceHistoryTable.xaml.cs @@ -1,46 +1,22 @@ using System.Linq; +using Robust.Client.AutoGenerated; using Robust.Client.Graphics; using Robust.Client.UserInterface.Controls; +using Robust.Client.UserInterface.XAML; namespace Content.Client.DeltaV.CartridgeLoader.Cartridges; -public sealed class PriceHistoryTable : BoxContainer +[GenerateTypedNameReferences] +public sealed partial class PriceHistoryTable : BoxContainer { - private readonly GridContainer _grid; - public PriceHistoryTable() { - Orientation = LayoutOrientation.Vertical; - HorizontalExpand = true; - Margin = new Thickness(0, 5, 0, 0); + RobustXamlLoader.Load(this); - // Create header - var header = new BoxContainer - { - Orientation = LayoutOrientation.Horizontal, - HorizontalExpand = true, - }; - - header.AddChild(new Label - { - Text = "Price History", - HorizontalExpand = true, - StyleClasses = { "LabelSubText" } - }); - - AddChild(header); - - // Create a panel container with styled background - var panel = new PanelContainer - { - HorizontalExpand = true, - Margin = new Thickness(0, 2, 0, 0) - }; - - // Create and apply the style + // Create the stylebox here so we can use the colors from StockTradingUi var styleBox = new StyleBoxFlat { - BackgroundColor = StockTradingUiFragment.BackgroundColor, + BackgroundColor = StockTradingUiFragment.PriceBackgroundColor, ContentMarginLeftOverride = 6, ContentMarginRightOverride = 6, ContentMarginTopOverride = 4, @@ -49,30 +25,12 @@ public PriceHistoryTable() BorderThickness = new Thickness(1), }; - panel.PanelOverride = styleBox; - - // Create a centering container - var centerContainer = new BoxContainer - { - Orientation = LayoutOrientation.Horizontal, - HorizontalExpand = true, - HorizontalAlignment = HAlignment.Center, - }; - - // Create grid for price history - _grid = new GridContainer - { - Columns = 5, // Display 5 entries per row - }; - - centerContainer.AddChild(_grid); - panel.AddChild(centerContainer); - AddChild(panel); + HistoryPanel.PanelOverride = styleBox; } public void Update(List priceHistory) { - _grid.RemoveAllChildren(); + PriceGrid.RemoveAllChildren(); // Take last 5 prices var lastFivePrices = priceHistory.TakeLast(5).ToList(); @@ -111,7 +69,7 @@ public void Update(List priceHistory) entryContainer.AddChild(priceLabel); entryContainer.AddChild(changeLabel); - _grid.AddChild(entryContainer); + PriceGrid.AddChild(entryContainer); } } } diff --git a/Content.Client/DeltaV/CartridgeLoader/Cartridges/StockTradingUi.cs b/Content.Client/DeltaV/CartridgeLoader/Cartridges/StockTradingUi.cs index 07d3f24d920..45704ee2349 100644 --- a/Content.Client/DeltaV/CartridgeLoader/Cartridges/StockTradingUi.cs +++ b/Content.Client/DeltaV/CartridgeLoader/Cartridges/StockTradingUi.cs @@ -36,7 +36,7 @@ public override void UpdateState(BoundUserInterfaceState state) } } - private static void SendStockTradingUiMessage(StockTradingUiAction action, string company, float amount, BoundUserInterface userInterface) + private static void SendStockTradingUiMessage(StockTradingUiAction action, int company, float amount, BoundUserInterface userInterface) { var newsMessage = new StockTradingUiMessageEvent(action, company, amount); var message = new CartridgeUiMessage(newsMessage); diff --git a/Content.Client/DeltaV/CartridgeLoader/Cartridges/StockTradingUiFragment.xaml b/Content.Client/DeltaV/CartridgeLoader/Cartridges/StockTradingUiFragment.xaml index 08491be8280..00b45584cc4 100644 --- a/Content.Client/DeltaV/CartridgeLoader/Cartridges/StockTradingUiFragment.xaml +++ b/Content.Client/DeltaV/CartridgeLoader/Cartridges/StockTradingUiFragment.xaml @@ -11,12 +11,12 @@ - @@ -27,7 +27,7 @@