2023-08-14 12:06:21 +00:00
|
|
|
using Content.Shared.SprayPainter;
|
2024-02-01 22:30:46 +00:00
|
|
|
using Content.Shared.SprayPainter.Components;
|
2024-07-21 14:48:13 +10:00
|
|
|
using Robust.Client.UserInterface;
|
2023-08-14 12:06:21 +00:00
|
|
|
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();
|
|
|
|
|
|
2024-07-21 14:48:13 +10:00
|
|
|
_window = this.CreateWindow<SprayPainterWindow>();
|
2023-08-14 12:06:21 +00:00
|
|
|
|
|
|
|
|
_window.OnSpritePicked = OnSpritePicked;
|
|
|
|
|
_window.OnColorPicked = OnColorPicked;
|
2024-02-01 22:30:46 +00:00
|
|
|
|
2024-07-21 14:48:13 +10:00
|
|
|
if (EntMan.TryGetComponent(Owner, out SprayPainterComponent? comp))
|
|
|
|
|
{
|
|
|
|
|
_window.Populate(EntMan.System<SprayPainterSystem>().Entries, comp.Index, comp.PickedColor, comp.ColorPalette);
|
|
|
|
|
}
|
2023-08-14 12:06:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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));
|
|
|
|
|
}
|
|
|
|
|
}
|