Files
tbd-station-14/Content.Client/Thief/ThiefBackpackMenu.xaml.cs
Nemanja cb0ba66be3 Revert "Remove some BUI boilerplate" (#30214)
Revert "Remove some BUI boilerplate (#28399)"

This reverts commit cbf329a82d.
2024-07-20 20:42:27 -04:00

58 lines
1.7 KiB
C#

using Content.Client.UserInterface.Controls;
using Content.Shared.Thief;
using Robust.Client.AutoGenerated;
using Robust.Client.GameObjects;
using Robust.Client.UserInterface.XAML;
namespace Content.Client.Thief;
[GenerateTypedNameReferences]
public sealed partial class ThiefBackpackMenu : FancyWindow
{
[Dependency] private readonly IEntitySystemManager _sysMan = default!;
private readonly SpriteSystem _spriteSystem;
private readonly ThiefBackpackBoundUserInterface _owner;
public ThiefBackpackMenu(ThiefBackpackBoundUserInterface owner)
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);
_spriteSystem = _sysMan.GetEntitySystem<SpriteSystem>();
_owner = owner;
ApproveButton.OnButtonDown += (args) =>
{
_owner.SendApprove();
};
}
public void UpdateState(ThiefBackpackBoundUserInterfaceState state)
{
SetsGrid.RemoveAllChildren();
int count = 0;
int selectedNumber = 0;
foreach (var set in state.Sets)
{
var child = new ThiefBackpackSet(set.Value, _spriteSystem);
child.SetButton.OnButtonDown += (args) =>
{
_owner.SendChangeSelected(set.Key);
};
SetsGrid.AddChild(child);
count++;
if (set.Value.Selected)
selectedNumber++;
}
Description.Text = Loc.GetString("thief-backpack-window-description", ("maxCount", state.MaxSelectedSets));
SelectedSets.Text = Loc.GetString("thief-backpack-window-selected", ("selectedCount", selectedNumber), ("maxCount", state.MaxSelectedSets));
ApproveButton.Disabled = selectedNumber == state.MaxSelectedSets ? false : true;
}
}