2024-03-30 23:29:47 -05:00
|
|
|
using Content.Shared.RCD;
|
|
|
|
|
using Content.Shared.RCD.Components;
|
|
|
|
|
using JetBrains.Annotations;
|
|
|
|
|
using Robust.Client.Graphics;
|
|
|
|
|
using Robust.Client.Input;
|
2024-07-21 14:48:13 +10:00
|
|
|
using Robust.Client.UserInterface;
|
2024-03-30 23:29:47 -05:00
|
|
|
using Robust.Shared.Prototypes;
|
|
|
|
|
|
|
|
|
|
namespace Content.Client.RCD;
|
|
|
|
|
|
|
|
|
|
[UsedImplicitly]
|
|
|
|
|
public sealed class RCDMenuBoundUserInterface : BoundUserInterface
|
|
|
|
|
{
|
|
|
|
|
[Dependency] private readonly IClyde _displayManager = default!;
|
|
|
|
|
[Dependency] private readonly IInputManager _inputManager = default!;
|
|
|
|
|
|
|
|
|
|
private RCDMenu? _menu;
|
|
|
|
|
|
|
|
|
|
public RCDMenuBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
|
|
|
|
|
{
|
|
|
|
|
IoCManager.InjectDependencies(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void Open()
|
|
|
|
|
{
|
|
|
|
|
base.Open();
|
|
|
|
|
|
2024-07-21 14:48:13 +10:00
|
|
|
_menu = this.CreateWindow<RCDMenu>();
|
|
|
|
|
_menu.SetEntity(Owner);
|
|
|
|
|
_menu.SendRCDSystemMessageAction += SendRCDSystemMessage;
|
2024-03-30 23:29:47 -05:00
|
|
|
|
|
|
|
|
// Open the menu, centered on the mouse
|
|
|
|
|
var vpSize = _displayManager.ScreenSize;
|
|
|
|
|
_menu.OpenCenteredAt(_inputManager.MouseScreenPosition.Position / vpSize);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SendRCDSystemMessage(ProtoId<RCDPrototype> protoId)
|
|
|
|
|
{
|
2024-07-21 14:48:13 +10:00
|
|
|
// A predicted message cannot be used here as the RCD UI is closed immediately
|
2024-03-30 23:29:47 -05:00
|
|
|
// after this message is sent, which will stop the server from receiving it
|
|
|
|
|
SendMessage(new RCDSystemMessage(protoId));
|
|
|
|
|
}
|
|
|
|
|
}
|