* 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
85 lines
2.0 KiB
C#
85 lines
2.0 KiB
C#
using Content.Client.Shuttles.UI;
|
|
using Content.Shared.Shuttles.BUIStates;
|
|
using Content.Shared.Shuttles.Events;
|
|
using JetBrains.Annotations;
|
|
using Robust.Client.UserInterface;
|
|
using Robust.Shared.Map;
|
|
|
|
namespace Content.Client.Shuttles.BUI;
|
|
|
|
[UsedImplicitly]
|
|
public sealed class ShuttleConsoleBoundUserInterface : BoundUserInterface
|
|
{
|
|
[ViewVariables]
|
|
private ShuttleConsoleWindow? _window;
|
|
|
|
public ShuttleConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
|
|
{
|
|
}
|
|
|
|
protected override void Open()
|
|
{
|
|
base.Open();
|
|
_window = this.CreateWindow<ShuttleConsoleWindow>();
|
|
|
|
_window.RequestFTL += OnFTLRequest;
|
|
_window.RequestBeaconFTL += OnFTLBeaconRequest;
|
|
_window.DockRequest += OnDockRequest;
|
|
_window.UndockRequest += OnUndockRequest;
|
|
}
|
|
|
|
private void OnUndockRequest(NetEntity entity)
|
|
{
|
|
SendMessage(new UndockRequestMessage()
|
|
{
|
|
DockEntity = entity,
|
|
});
|
|
}
|
|
|
|
private void OnDockRequest(NetEntity entity, NetEntity target)
|
|
{
|
|
SendMessage(new DockRequestMessage()
|
|
{
|
|
DockEntity = entity,
|
|
TargetDockEntity = target,
|
|
});
|
|
}
|
|
|
|
private void OnFTLBeaconRequest(NetEntity ent, Angle angle)
|
|
{
|
|
SendMessage(new ShuttleConsoleFTLBeaconMessage()
|
|
{
|
|
Beacon = ent,
|
|
Angle = angle,
|
|
});
|
|
}
|
|
|
|
private void OnFTLRequest(MapCoordinates obj, Angle angle)
|
|
{
|
|
SendMessage(new ShuttleConsoleFTLPositionMessage()
|
|
{
|
|
Coordinates = obj,
|
|
Angle = angle,
|
|
});
|
|
}
|
|
|
|
protected override void Dispose(bool disposing)
|
|
{
|
|
base.Dispose(disposing);
|
|
|
|
if (disposing)
|
|
{
|
|
_window?.Dispose();
|
|
}
|
|
}
|
|
|
|
protected override void UpdateState(BoundUserInterfaceState state)
|
|
{
|
|
base.UpdateState(state);
|
|
if (state is not ShuttleBoundUserInterfaceState cState)
|
|
return;
|
|
|
|
_window?.UpdateState(Owner, cState);
|
|
}
|
|
}
|