2021-03-10 14:48:29 +01:00
|
|
|
|
using System.Linq;
|
2021-06-09 22:19:39 +02:00
|
|
|
|
using Content.Shared.Crayon;
|
2021-12-03 15:35:57 +01:00
|
|
|
|
using Content.Shared.Decals;
|
2021-02-11 01:13:03 -08:00
|
|
|
|
using Robust.Client.GameObjects;
|
|
|
|
|
|
using Robust.Shared.GameObjects;
|
2021-03-10 14:48:29 +01:00
|
|
|
|
using Robust.Shared.IoC;
|
|
|
|
|
|
using Robust.Shared.Prototypes;
|
2020-10-13 13:40:05 +02:00
|
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
|
namespace Content.Client.Crayon.UI
|
2020-10-13 13:40:05 +02:00
|
|
|
|
{
|
2022-02-16 00:23:23 -07:00
|
|
|
|
public sealed class CrayonBoundUserInterface : BoundUserInterface
|
2020-10-13 13:40:05 +02:00
|
|
|
|
{
|
|
|
|
|
|
public CrayonBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-03-10 14:48:29 +01:00
|
|
|
|
private CrayonWindow? _menu;
|
2020-10-13 13:40:05 +02:00
|
|
|
|
|
|
|
|
|
|
protected override void Open()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.Open();
|
|
|
|
|
|
_menu = new CrayonWindow(this);
|
|
|
|
|
|
|
|
|
|
|
|
_menu.OnClose += Close;
|
|
|
|
|
|
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
|
2021-12-03 15:35:57 +01:00
|
|
|
|
var crayonDecals = prototypeManager.EnumeratePrototypes<DecalPrototype>().Where(x => x.Tags.Contains("crayon"));
|
|
|
|
|
|
_menu.Populate(crayonDecals);
|
2020-10-13 13:40:05 +02:00
|
|
|
|
_menu.OpenCentered();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override void UpdateState(BoundUserInterfaceState state)
|
|
|
|
|
|
{
|
|
|
|
|
|
base.UpdateState(state);
|
2021-03-10 14:48:29 +01:00
|
|
|
|
|
|
|
|
|
|
_menu?.UpdateState((CrayonBoundUserInterfaceState) state);
|
2020-10-13 13:40:05 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Select(string state)
|
|
|
|
|
|
{
|
|
|
|
|
|
SendMessage(new CrayonSelectMessage(state));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override void Dispose(bool disposing)
|
|
|
|
|
|
{
|
|
|
|
|
|
base.Dispose(disposing);
|
|
|
|
|
|
|
2021-03-10 14:48:29 +01:00
|
|
|
|
if (disposing)
|
|
|
|
|
|
{
|
|
|
|
|
|
_menu?.Close();
|
2022-02-06 23:32:32 +11:00
|
|
|
|
_menu = null;
|
2021-03-10 14:48:29 +01:00
|
|
|
|
}
|
2020-10-13 13:40:05 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|