using Content.Client.Message; using Content.Shared.FixedPoint; using Content.Shared.Revenant; using Robust.Client.AutoGenerated; using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.CustomControls; using Robust.Client.UserInterface.XAML; using Robust.Client.Utility; namespace Content.Client.Revenant.Ui; [GenerateTypedNameReferences] public sealed partial class RevenantMenu : DefaultWindow { private FixedPoint2 _essence = 0f; public event Action? OnListingButtonPressed; public RevenantMenu() { RobustXamlLoader.Load(this); } public void UpdateEssence(float essence) { // update balance label _essence = essence; var balanceStr = Loc.GetString("revenant-user-interface-essence-amount", ("amount", Math.Round(_essence.Float()))); BalanceInfo.SetMarkup(balanceStr); } public void UpdateListing(List listings) { // should probably chunk these out instead. to-do if this clogs the internet tubes. // maybe read clients prototypes instead? ClearListings(); foreach (var item in listings) { AddListingGui(item); } } private void AddListingGui(RevenantStoreListingPrototype listing) { var listingName = listing.ListingName; var listingDesc = listing.Description; var listingPrice = listing.Price; var canBuy = _essence > listing.Price; var texture = listing.Icon?.Frame0(); var newListing = new RevenantListingControl(listingName, listingDesc, listingPrice, canBuy, texture); newListing.RevenantItemBuyButton.OnButtonDown += args => OnListingButtonPressed?.Invoke(args, listing); RevenantListingsContainer.AddChild(newListing); } private void ClearListings() { RevenantListingsContainer.Children.Clear(); } }