store system currency rework (#10893)

This commit is contained in:
Nemanja
2022-09-11 02:54:16 -04:00
committed by GitHub
parent 5760151fb2
commit e43ee216f6
9 changed files with 80 additions and 97 deletions

View File

@@ -43,16 +43,14 @@ public sealed partial class StoreMenu : DefaultWindow
{
Balance = balance;
var currency = new Dictionary<(string, FixedPoint2), CurrencyPrototype>();
foreach (var type in balance)
{
currency.Add((type.Key, type.Value), _prototypeManager.Index<CurrencyPrototype>(type.Key));
}
var currency = balance.ToDictionary(type =>
(type.Key, type.Value), type => _prototypeManager.Index<CurrencyPrototype>(type.Key));
var balanceStr = string.Empty;
foreach (var type in currency)
foreach (var ((type, amount),proto) in currency)
{
balanceStr += $"{Loc.GetString(type.Value.BalanceDisplay, ("amount", type.Key.Item2))}\n";
balanceStr += Loc.GetString("store-ui-balance-display", ("amount", amount),
("currency", Loc.GetString(proto.DisplayName, ("amount", 1))));
}
BalanceInfo.SetMarkup(balanceStr.TrimEnd());
@@ -60,7 +58,7 @@ public sealed partial class StoreMenu : DefaultWindow
var disabled = true;
foreach (var type in currency)
{
if (type.Value.CanWithdraw && type.Value.EntityId != null && type.Key.Item2 > 0)
if (type.Value.CanWithdraw && type.Value.Cash != null && type.Key.Item2 > 0)
disabled = false;
}
@@ -155,14 +153,17 @@ public sealed partial class StoreMenu : DefaultWindow
{
var text = string.Empty;
foreach (var type in listing.Cost)
{
var currency = _prototypeManager.Index<CurrencyPrototype>(type.Key);
text += $"{Loc.GetString(currency.PriceDisplay, ("amount", type.Value))}\n";
}
if (listing.Cost.Count < 1)
text = Loc.GetString("store-currency-free");
else
{
foreach (var (type, amount) in listing.Cost)
{
var currency = _prototypeManager.Index<CurrencyPrototype>(type);
text += Loc.GetString("store-ui-price-display", ("amount", amount),
("currency", Loc.GetString(currency.DisplayName, ("amount", amount))));
}
}
return text.TrimEnd();
}

View File

@@ -2,18 +2,8 @@ using System.Linq;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Localization;
using Content.Shared.FixedPoint;
using Content.Shared.Store;
using Robust.Client.UserInterface;
using Robust.Client.AutoGenerated;
using Robust.Client.GameObjects;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Prototypes;
using Robust.Client.Graphics;
using Content.Shared.Actions.ActionTypes;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Prototypes;
@@ -57,13 +47,12 @@ public sealed partial class StoreWithdrawWindow : DefaultWindow
_buttons.Clear();
foreach (var currency in _validCurrencies)
{
Logger.Debug((currency.Value.PriceDisplay));
var button = new CurrencyWithdrawButton()
{
Id = currency.Value.ID,
Amount = currency.Key,
MinHeight = 20,
Text = Loc.GetString("store-withdraw-button-ui", ("currency",Loc.GetString(currency.Value.PriceDisplay))),
Text = Loc.GetString("store-withdraw-button-ui", ("currency",Loc.GetString(currency.Value.DisplayName, ("amount", currency.Key)))),
};
button.Disabled = false;
button.OnPressed += args =>