diff --git a/Content.Client/Revenant/Ui/RevenantBoundUserInterface.cs b/Content.Client/Revenant/Ui/RevenantBoundUserInterface.cs index 9fc45e3aff..17f7d88875 100644 --- a/Content.Client/Revenant/Ui/RevenantBoundUserInterface.cs +++ b/Content.Client/Revenant/Ui/RevenantBoundUserInterface.cs @@ -1,6 +1,4 @@ -using Content.Client.Traitor.Uplink; using Content.Shared.Revenant; -using Content.Shared.Traitor.Uplink; using JetBrains.Annotations; using Robust.Client.GameObjects; diff --git a/Content.Client/Store/Ui/StoreBoundUserInterface.cs b/Content.Client/Store/Ui/StoreBoundUserInterface.cs new file mode 100644 index 0000000000..0122decdc2 --- /dev/null +++ b/Content.Client/Store/Ui/StoreBoundUserInterface.cs @@ -0,0 +1,79 @@ +using Content.Shared.Store; +using JetBrains.Annotations; +using Robust.Client.GameObjects; +using System.Linq; + +namespace Content.Client.Store.Ui; + +[UsedImplicitly] +public sealed class StoreBoundUserInterface : BoundUserInterface +{ + private StoreMenu? _menu; + + private string _windowName = Loc.GetString("store-ui-default-title"); + + public StoreBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey) + { + + } + + protected override void Open() + { + _menu = new StoreMenu(_windowName); + + _menu.OpenCentered(); + _menu.OnClose += Close; + + _menu.OnListingButtonPressed += (_, listing) => + { + if (_menu.CurrentBuyer != null) + SendMessage(new StoreBuyListingMessage(_menu.CurrentBuyer.Value, listing)); + }; + + _menu.OnCategoryButtonPressed += (_, category) => + { + _menu.CurrentCategory = category; + if (_menu.CurrentBuyer != null) + SendMessage(new StoreRequestUpdateInterfaceMessage(_menu.CurrentBuyer.Value)); + }; + + _menu.OnWithdrawAttempt += (_, type, amount) => + { + if (_menu.CurrentBuyer != null) + SendMessage(new StoreRequestWithdrawMessage(_menu.CurrentBuyer.Value, type, amount)); + }; + } + protected override void UpdateState(BoundUserInterfaceState state) + { + base.UpdateState(state); + + if (_menu == null) + return; + + switch (state) + { + case StoreUpdateState msg: + if (msg.Buyer != null) + _menu.CurrentBuyer = msg.Buyer; + _menu.UpdateBalance(msg.Balance); + _menu.PopulateStoreCategoryButtons(msg.Listings); + _menu.UpdateListing(msg.Listings.ToList()); + break; + case StoreInitializeState msg: + _windowName = msg.Name; + if (_menu != null && _menu.Window != null) + _menu.Window.Title = msg.Name; + break; + } + } + + protected override void Dispose(bool disposing) + { + base.Dispose(disposing); + if (!disposing) + return; + + _menu?.Close(); + _menu?.Dispose(); + } +} diff --git a/Content.Client/Store/Ui/StoreListingControl.xaml b/Content.Client/Store/Ui/StoreListingControl.xaml new file mode 100644 index 0000000000..aefeec17cc --- /dev/null +++ b/Content.Client/Store/Ui/StoreListingControl.xaml @@ -0,0 +1,21 @@ + + + +