* Reapply "Remove some BUI boilerplate" (#30214)
This reverts commit cb0ba66be3.
* Fix gas tank
* Fix PA
* Fix microwave
* Comms console underwrap
* Fix rcd
* log wehs
54 lines
1.6 KiB
C#
54 lines
1.6 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;
|
|
|
|
public event Action? OnApprove;
|
|
public event Action<int>? OnSetChange;
|
|
|
|
public ThiefBackpackMenu()
|
|
{
|
|
RobustXamlLoader.Load(this);
|
|
IoCManager.InjectDependencies(this);
|
|
_spriteSystem = _sysMan.GetEntitySystem<SpriteSystem>();
|
|
|
|
ApproveButton.OnPressed += args =>
|
|
{
|
|
OnApprove?.Invoke();
|
|
};
|
|
}
|
|
|
|
public void UpdateState(ThiefBackpackBoundUserInterfaceState state)
|
|
{
|
|
SetsGrid.DisposeAllChildren();
|
|
var selectedNumber = 0;
|
|
foreach (var (set, info) in state.Sets)
|
|
{
|
|
var child = new ThiefBackpackSet(info, _spriteSystem);
|
|
|
|
child.SetButton.OnButtonDown += (args) =>
|
|
{
|
|
OnSetChange?.Invoke(set);
|
|
};
|
|
|
|
SetsGrid.AddChild(child);
|
|
|
|
if (info.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;
|
|
}
|
|
}
|