foreach (var ((_, amount), proto) in currency)
{
balanceStr += Loc.GetString("store-ui-balance-display", ("amount", amount),
- ("currency", Loc.GetString(proto.DisplayName, ("amount", 1))));
+ ("currency", Loc.GetString(proto.DisplayName, ("amount", 1)))) + "\n";
}
BalanceInfo.SetMarkup(balanceStr.TrimEnd());
foreach (var type in currency)
{
if (type.Value.CanWithdraw && type.Value.Cash != null && type.Key.Item2 > 0)
+ {
disabled = false;
+ break;
+ }
}
WithdrawButton.Disabled = disabled;
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
- private Dictionary<FixedPoint2, CurrencyPrototype> _validCurrencies = new();
+ private Dictionary<CurrencyPrototype, FixedPoint2> _validCurrencies = new();
private HashSet<CurrencyWithdrawButton> _buttons = new();
public event Action<BaseButton.ButtonEventArgs, string, int>? OnWithdrawAttempt;
if (!_prototypeManager.TryIndex(currency.Key, out var proto))
continue;
- _validCurrencies.Add(currency.Value, proto);
+ _validCurrencies.Add(proto, currency.Value);
}
//this shouldn't ever happen but w/e
_buttons.Clear();
foreach (var currency in _validCurrencies)
{
+ if (!currency.Key.CanWithdraw)
+ continue;
+
var button = new CurrencyWithdrawButton()
{
- Id = currency.Value.ID,
- Amount = currency.Key,
+ Id = currency.Key.ID,
+ Amount = currency.Value,
MinHeight = 20,
- Text = Loc.GetString("store-withdraw-button-ui", ("currency",Loc.GetString(currency.Value.DisplayName, ("amount", currency.Key)))),
+ Text = Loc.GetString("store-withdraw-button-ui", ("currency",Loc.GetString(currency.Key.DisplayName, ("amount", currency.Value)))),
+ Disabled = false,
};
- button.Disabled = false;
button.OnPressed += args =>
{
OnWithdrawAttempt?.Invoke(args, button.Id, WithdrawSlider.Value);
ButtonContainer.AddChild(button);
}
- var maxWithdrawAmount = _validCurrencies.Keys.Max().Int();
+ var maxWithdrawAmount = _validCurrencies.Values.Max().Int();
// setup withdraw slider
WithdrawSlider.MinValue = 1;