Files
tbd-station-14/Content.Client/SprayPainter/UI/SprayPainterBoundUserInterface.cs
metalgearsloth cbf329a82d Remove some BUI boilerplate (#28399)
* 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
2024-07-20 15:40:16 +10:00

43 lines
1.2 KiB
C#

using Content.Shared.SprayPainter;
using Content.Shared.SprayPainter.Components;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
namespace Content.Client.SprayPainter.UI;
public sealed class SprayPainterBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private SprayPainterWindow? _window;
public SprayPainterBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
protected override void Open()
{
base.Open();
_window = this.CreateWindow<SprayPainterWindow>();
_window.OnSpritePicked = OnSpritePicked;
_window.OnColorPicked = OnColorPicked;
if (EntMan.TryGetComponent(Owner, out SprayPainterComponent? comp))
{
_window.Populate(EntMan.System<SprayPainterSystem>().Entries, comp.Index, comp.PickedColor, comp.ColorPalette);
}
}
private void OnSpritePicked(ItemList.ItemListSelectedEventArgs args)
{
SendMessage(new SprayPainterSpritePickedMessage(args.ItemIndex));
}
private void OnColorPicked(ItemList.ItemListSelectedEventArgs args)
{
var key = _window?.IndexToColorKey(args.ItemIndex);
SendMessage(new SprayPainterColorPickedMessage(key));
}
}