* Remove some BUI boilerplate - The disposals overrides got removed due to the helper method handling it. - Replace window creation with CreateWindow helper. - Fixed some stinky code which would cause exceptions. * More * moar * weh * done * More BUIs * More updates * weh * moar * look who it is * weh * merge * weh * fixes
45 lines
1.2 KiB
C#
45 lines
1.2 KiB
C#
using Content.Client.Clothing.Systems;
|
|
using Content.Shared.Clothing.Components;
|
|
using JetBrains.Annotations;
|
|
using Robust.Client.GameObjects;
|
|
using Robust.Client.UserInterface;
|
|
|
|
namespace Content.Client.Clothing.UI;
|
|
|
|
[UsedImplicitly]
|
|
public sealed class ChameleonBoundUserInterface : BoundUserInterface
|
|
{
|
|
private readonly ChameleonClothingSystem _chameleon;
|
|
|
|
[ViewVariables]
|
|
private ChameleonMenu? _menu;
|
|
|
|
public ChameleonBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
|
|
{
|
|
_chameleon = EntMan.System<ChameleonClothingSystem>();
|
|
}
|
|
|
|
protected override void Open()
|
|
{
|
|
base.Open();
|
|
|
|
_menu = this.CreateWindow<ChameleonMenu>();
|
|
_menu.OnIdSelected += OnIdSelected;
|
|
}
|
|
|
|
protected override void UpdateState(BoundUserInterfaceState state)
|
|
{
|
|
base.UpdateState(state);
|
|
if (state is not ChameleonBoundUserInterfaceState st)
|
|
return;
|
|
|
|
var targets = _chameleon.GetValidTargets(st.Slot);
|
|
_menu?.UpdateState(targets, st.SelectedId);
|
|
}
|
|
|
|
private void OnIdSelected(string selectedId)
|
|
{
|
|
SendMessage(new ChameleonPrototypeSelectedMessage(selectedId));
|
|
}
|
|
}
|