diff --git a/Content.Client/Chemistry/EntitySystems/FillableOneTimeInjectorSystem.cs b/Content.Client/Chemistry/EntitySystems/FillableOneTimeInjectorSystem.cs new file mode 100644 index 00000000000..6a34621b6eb --- /dev/null +++ b/Content.Client/Chemistry/EntitySystems/FillableOneTimeInjectorSystem.cs @@ -0,0 +1,16 @@ +using Content.Client.Chemistry.UI; +using Content.Client.Items; +using Content.Shared.Chemistry.Components; +using Content.Shared.Chemistry.EntitySystems; +using Robust.Shared.GameStates; + +namespace Content.Client.Chemistry.EntitySystems; + +public sealed class FillableOneTimeInjectorSystem : SharedFillableOneTimeInjectorSystem +{ + public override void Initialize() + { + base.Initialize(); + Subs.ItemStatus(ent => new FillableOneTimeInjectorStatusControl(ent, SolutionContainers)); + } +} diff --git a/Content.Client/Chemistry/UI/FillableOneTimeInjectorStatusControl.cs b/Content.Client/Chemistry/UI/FillableOneTimeInjectorStatusControl.cs new file mode 100644 index 00000000000..2c9e28138f3 --- /dev/null +++ b/Content.Client/Chemistry/UI/FillableOneTimeInjectorStatusControl.cs @@ -0,0 +1,84 @@ +using Content.Client.Message; +using Content.Client.Stylesheets; +using Content.Shared.Chemistry.Components; +using Content.Shared.Chemistry.EntitySystems; +using Content.Shared.FixedPoint; +using Robust.Client.UserInterface; +using Robust.Client.UserInterface.Controls; +using Robust.Shared.Timing; + +namespace Content.Client.Chemistry.UI; + +public sealed class FillableOneTimeInjectorStatusControl : Control +{ + private readonly Entity _parent; + private readonly SharedSolutionContainerSystem _solutionContainers; + private readonly RichTextLabel _label; + + private FixedPoint2 PrevVolume; + private FixedPoint2 PrevMaxVolume; + private FixedPoint2 PrevTransferAmount; + private FillableOneTimeInjectorToggleMode PrevToggleStateIndex; + + public FillableOneTimeInjectorStatusControl(Entity parent, SharedSolutionContainerSystem solutionContainers) + { + _parent = parent; + _solutionContainers = solutionContainers; + _label = new RichTextLabel { StyleClasses = { StyleNano.StyleClassItemStatus } }; + AddChild(_label); + } + + protected override void FrameUpdate(FrameEventArgs args) + { + base.FrameUpdate(args); + + if (!_solutionContainers.TryGetSolution(_parent.Owner, _parent.Comp.SolutionName, out _, out var solution)) + return; + + // only updates the UI if any of the details are different than they previously were + if (PrevVolume == solution.Volume + && PrevMaxVolume == solution.MaxVolume + && PrevTransferAmount == _parent.Comp.TransferAmount) + return; + + PrevVolume = solution.Volume; + PrevMaxVolume = solution.MaxVolume; + PrevTransferAmount = _parent.Comp.TransferAmount; + var modeStringLocalized = ""; + + // only updates the UI if any of the details are different than they previously were + if(PrevToggleStateIndex == _parent.Comp.ToggleState) + return; + + PrevToggleStateIndex = _parent.Comp.ToggleState; + + // Update current volume and injector state + modeStringLocalized = Loc.GetString( + _parent.Comp.ToggleState switch + { + FillableOneTimeInjectorToggleMode.Draw => "injector-draw-text", + FillableOneTimeInjectorToggleMode.Inject => "injector-inject-text", + FillableOneTimeInjectorToggleMode.Spent => "injector-spent-text", + _ => "injector-invalid-injector-toggle-mode" + }); + + if (_parent.Comp.ToggleState != FillableOneTimeInjectorToggleMode.Draw) + { + _label.SetMarkup( + Loc.GetString( + "onetime-injector-simple-volume-label", + ("currentVolume", solution.Volume), + ("modeString", modeStringLocalized))); + } + else + { + _label.SetMarkup( + Loc.GetString( + "injector-volume-label", + ("currentVolume", solution.Volume), + ("totalVolume", solution.MaxVolume), + ("modeString", modeStringLocalized), + ("transferVolume", _parent.Comp.TransferAmount))); + } + } +} diff --git a/Content.Client/DeltaV/CartridgeLoader/Cartridges/StockTradingUi.cs b/Content.Client/DeltaV/CartridgeLoader/Cartridges/StockTradingUi.cs index 45704ee2349..7468d96b7a4 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, int company, float amount, BoundUserInterface userInterface) + private static void SendStockTradingUiMessage(StockTradingUiAction action, int company, int 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.cs b/Content.Client/DeltaV/CartridgeLoader/Cartridges/StockTradingUiFragment.xaml.cs index b44e8f44c70..7aaed6e49df 100644 --- a/Content.Client/DeltaV/CartridgeLoader/Cartridges/StockTradingUiFragment.xaml.cs +++ b/Content.Client/DeltaV/CartridgeLoader/Cartridges/StockTradingUiFragment.xaml.cs @@ -14,8 +14,8 @@ public sealed partial class StockTradingUiFragment : BoxContainer private readonly Dictionary _companyEntries = new(); // Event handlers for the parent UI - public event Action? OnBuyButtonPressed; - public event Action? OnSellButtonPressed; + public event Action? OnBuyButtonPressed; + public event Action? OnSellButtonPressed; // Define colors public static readonly Color PositiveColor = Color.FromHex("#00ff00"); // Green @@ -70,8 +70,8 @@ private sealed class CompanyEntry public CompanyEntry(int companyIndex, string displayName, - Action? onBuyPressed, - Action? onSellPressed) + Action? onBuyPressed, + Action? onSellPressed) { Container = new BoxContainer { @@ -216,13 +216,13 @@ public CompanyEntry(int companyIndex, // Button click events _buyButton.OnPressed += _ => { - if (float.TryParse(_amountEdit.Text, out var amount) && amount > 0) + if (int.TryParse(_amountEdit.Text, out var amount) && amount > 0) onBuyPressed?.Invoke(companyIndex, amount); }; _sellButton.OnPressed += _ => { - if (float.TryParse(_amountEdit.Text, out var amount) && amount > 0) + if (int.TryParse(_amountEdit.Text, out var amount) && amount > 0) onSellPressed?.Invoke(companyIndex, amount); }; @@ -235,7 +235,7 @@ public CompanyEntry(int companyIndex, }; } - public void Update(StockCompanyStruct company, int ownedStocks) + public void Update(StockCompany company, int ownedStocks) { _nameLabel.Text = company.LocalizedDisplayName; _priceLabel.Text = $"${company.CurrentPrice:F2}"; diff --git a/Content.Client/Guidebook/Controls/GuidebookWindow.xaml b/Content.Client/Guidebook/Controls/GuidebookWindow.xaml index cc6cc6e82b0..b52eacfa722 100644 --- a/Content.Client/Guidebook/Controls/GuidebookWindow.xaml +++ b/Content.Client/Guidebook/Controls/GuidebookWindow.xaml @@ -2,7 +2,7 @@ xmlns:cc="clr-namespace:Content.Client.Administration.UI.CustomControls" xmlns:fancyTree="clr-namespace:Content.Client.UserInterface.Controls.FancyTree" xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls" - SetSize="750 700" + SetSize="850 700" MinSize="100 200" Resizable="True" Title="{Loc 'guidebook-window-title'}"> @@ -21,9 +21,13 @@ Margin="0 5 10 5"> + +