From 2152914acc666d8dd7b1f1a8864d5738fa5ff7c4 Mon Sep 17 00:00:00 2001 From: Nemanja <98561806+EmoGarbage404@users.noreply.github.com> Date: Wed, 17 Aug 2022 00:34:25 -0400 Subject: [PATCH] Generalized Store System (#10201) --- .../Revenant/Ui/RevenantBoundUserInterface.cs | 2 - .../Store/Ui/StoreBoundUserInterface.cs | 79 ++ .../Store/Ui/StoreListingControl.xaml | 21 + .../Store/Ui/StoreListingControl.xaml.cs | 24 + Content.Client/Store/Ui/StoreMenu.xaml | 54 ++ Content.Client/Store/Ui/StoreMenu.xaml.cs | 222 +++++ .../Store/Ui/StoreWithdrawWindow.xaml | 16 + .../Store/Ui/StoreWithdrawWindow.xaml.cs | 102 +++ .../Uplink/UplinkBoundUserInterface.cs | 65 -- .../Traitor/Uplink/UplinkListingControl.xaml | 22 - .../Uplink/UplinkListingControl.xaml.cs | 28 - Content.Client/Traitor/Uplink/UplinkMenu.xaml | 53 -- .../Traitor/Uplink/UplinkMenu.xaml.cs | 163 ---- .../Traitor/Uplink/UplinkWithdrawWindow.xaml | 22 - .../Uplink/UplinkWithdrawWindow.xaml.cs | 34 - .../GameTicking/Rules/NukeopsRuleSystem.cs | 3 + .../GameTicking/Rules/SuspicionRuleSystem.cs | 13 +- .../Rules/TraitorDeathMatchRuleSystem.cs | 34 +- .../GameTicking/Rules/TraitorRuleSystem.cs | 18 +- Content.Server/PDA/PDASystem.cs | 36 +- .../Store/Components/CurrencyComponent.cs | 22 + .../Store/Components/StoreComponent.cs | 91 +++ .../Store/Conditions/BuyerAntagCondition.cs | 63 ++ .../Store/Conditions/BuyerJobCondition.cs | 63 ++ .../Conditions/BuyerWhitelistCondition.cs | 41 + .../ListingLimitedStockCondition.cs | 20 + .../Conditions/StoreWhitelistCondition.cs | 44 + .../Store/Systems/StoreSystem.Listings.cs | 127 +++ .../Store/Systems/StoreSystem.Ui.cs | 226 ++++++ Content.Server/Store/Systems/StoreSystem.cs | 154 ++++ .../Uplink/Account/UplinkAccountEvents.cs | 30 - .../Uplink/Account/UplinkAccountsSystem.cs | 108 --- .../Uplink/Commands/AddUplinkCommand.cs | 14 +- .../SurplusBundle/SurplusBundleComponent.cs | 10 + .../SurplusBundle/SurplusBundleSystem.cs | 41 +- .../Telecrystal/TelecrystalComponent.cs | 7 - .../Uplink/Telecrystal/TelecrystalSystem.cs | 52 -- .../Traitor/Uplink/UplinkComponent.cs | 38 - Content.Server/Traitor/Uplink/UplinkEvents.cs | 18 - .../Traitor/Uplink/UplinkListingSytem.cs | 53 -- Content.Server/Traitor/Uplink/UplinkSystem.cs | 256 +----- .../TraitorDeathMatchRedemptionSystem.cs | 51 +- Content.Shared.Database/LogType.cs | 1 + Content.Shared/PDA/UplinkCategory.cs | 17 - .../PDA/UplinkStoreListingPrototype.cs | 40 - Content.Shared/Store/CurrencyPrototype.cs | 43 + Content.Shared/Store/ListingCondition.cs | 23 + Content.Shared/Store/ListingPrototype.cs | 133 +++ .../Store/StoreCategoryPrototype.cs | 22 + Content.Shared/Store/StorePresetPrototype.cs | 41 + Content.Shared/Store/StoreUi.cs | 84 ++ .../Traitor/Uplink/UplinkAccount.cs | 14 - .../Traitor/Uplink/UplinkAccountData.cs | 17 - .../Traitor/Uplink/UplinkListingData.cs | 41 - .../Traitor/Uplink/UplinkMessagesUI.cs | 35 - .../Traitor/Uplink/UplinkNetworkEvents.cs | 14 - .../Traitor/Uplink/UplinkUpdateState.cs | 17 - .../Traitor/Uplink/UplinkVisuals.cs | 10 - Resources/Locale/en-US/store/currency.ftl | 11 + Resources/Locale/en-US/store/store.ftl | 4 + Resources/Prototypes/Catalog/catalog.yml | 44 + .../Prototypes/Catalog/uplink_catalog.yml | 761 +++++++++++------- .../Entities/Objects/Devices/pda.yml | 4 +- .../Entities/Objects/Specific/syndicate.yml | 54 +- Resources/Prototypes/Store/categories.yml | 60 ++ Resources/Prototypes/Store/currency.yml | 12 + Resources/Prototypes/Store/presets.yml | 16 + Resources/Prototypes/tags.yml | 3 + 68 files changed, 2493 insertions(+), 1568 deletions(-) create mode 100644 Content.Client/Store/Ui/StoreBoundUserInterface.cs create mode 100644 Content.Client/Store/Ui/StoreListingControl.xaml create mode 100644 Content.Client/Store/Ui/StoreListingControl.xaml.cs create mode 100644 Content.Client/Store/Ui/StoreMenu.xaml create mode 100644 Content.Client/Store/Ui/StoreMenu.xaml.cs create mode 100644 Content.Client/Store/Ui/StoreWithdrawWindow.xaml create mode 100644 Content.Client/Store/Ui/StoreWithdrawWindow.xaml.cs delete mode 100644 Content.Client/Traitor/Uplink/UplinkBoundUserInterface.cs delete mode 100644 Content.Client/Traitor/Uplink/UplinkListingControl.xaml delete mode 100644 Content.Client/Traitor/Uplink/UplinkListingControl.xaml.cs delete mode 100644 Content.Client/Traitor/Uplink/UplinkMenu.xaml delete mode 100644 Content.Client/Traitor/Uplink/UplinkMenu.xaml.cs delete mode 100644 Content.Client/Traitor/Uplink/UplinkWithdrawWindow.xaml delete mode 100644 Content.Client/Traitor/Uplink/UplinkWithdrawWindow.xaml.cs create mode 100644 Content.Server/Store/Components/CurrencyComponent.cs create mode 100644 Content.Server/Store/Components/StoreComponent.cs create mode 100644 Content.Server/Store/Conditions/BuyerAntagCondition.cs create mode 100644 Content.Server/Store/Conditions/BuyerJobCondition.cs create mode 100644 Content.Server/Store/Conditions/BuyerWhitelistCondition.cs create mode 100644 Content.Server/Store/Conditions/ListingLimitedStockCondition.cs create mode 100644 Content.Server/Store/Conditions/StoreWhitelistCondition.cs create mode 100644 Content.Server/Store/Systems/StoreSystem.Listings.cs create mode 100644 Content.Server/Store/Systems/StoreSystem.Ui.cs create mode 100644 Content.Server/Store/Systems/StoreSystem.cs delete mode 100644 Content.Server/Traitor/Uplink/Account/UplinkAccountEvents.cs delete mode 100644 Content.Server/Traitor/Uplink/Account/UplinkAccountsSystem.cs delete mode 100644 Content.Server/Traitor/Uplink/Telecrystal/TelecrystalComponent.cs delete mode 100644 Content.Server/Traitor/Uplink/Telecrystal/TelecrystalSystem.cs delete mode 100644 Content.Server/Traitor/Uplink/UplinkComponent.cs delete mode 100644 Content.Server/Traitor/Uplink/UplinkEvents.cs delete mode 100644 Content.Server/Traitor/Uplink/UplinkListingSytem.cs delete mode 100644 Content.Shared/PDA/UplinkCategory.cs delete mode 100644 Content.Shared/PDA/UplinkStoreListingPrototype.cs create mode 100644 Content.Shared/Store/CurrencyPrototype.cs create mode 100644 Content.Shared/Store/ListingCondition.cs create mode 100644 Content.Shared/Store/ListingPrototype.cs create mode 100644 Content.Shared/Store/StoreCategoryPrototype.cs create mode 100644 Content.Shared/Store/StorePresetPrototype.cs create mode 100644 Content.Shared/Store/StoreUi.cs delete mode 100644 Content.Shared/Traitor/Uplink/UplinkAccount.cs delete mode 100644 Content.Shared/Traitor/Uplink/UplinkAccountData.cs delete mode 100644 Content.Shared/Traitor/Uplink/UplinkListingData.cs delete mode 100644 Content.Shared/Traitor/Uplink/UplinkMessagesUI.cs delete mode 100644 Content.Shared/Traitor/Uplink/UplinkNetworkEvents.cs delete mode 100644 Content.Shared/Traitor/Uplink/UplinkUpdateState.cs delete mode 100644 Content.Shared/Traitor/Uplink/UplinkVisuals.cs create mode 100644 Resources/Locale/en-US/store/currency.ftl create mode 100644 Resources/Locale/en-US/store/store.ftl create mode 100644 Resources/Prototypes/Catalog/catalog.yml create mode 100644 Resources/Prototypes/Store/categories.yml create mode 100644 Resources/Prototypes/Store/currency.yml create mode 100644 Resources/Prototypes/Store/presets.yml 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 @@ + + + +