From 3d1ade9684b3a95a5a314a5b89422bb1ca9f11bd Mon Sep 17 00:00:00 2001 From: deltanedas <39013340+deltanedas@users.noreply.github.com> Date: Wed, 2 Aug 2023 10:47:18 +0100 Subject: [PATCH] add gateway for admeme (#17587) Co-authored-by: deltanedas <@deltanedas:kde.org> --- .../Gateway/UI/GatewayBoundUserInterface.cs | 43 +++++ Content.Client/Gateway/UI/GatewayWindow.xaml | 22 +++ .../Gateway/UI/GatewayWindow.xaml.cs | 180 +++++++++++++++++ .../Gateway/Components/GatewayComponent.cs | 40 ++++ .../Components/GatewayDestinationComponent.cs | 42 ++++ .../Gateway/Systems/GatewaySystem.cs | 181 ++++++++++++++++++ Content.Shared/Gateway/GatewayUi.cs | 65 +++++++ Resources/Locale/en-US/gateway/gateway.ftl | 6 + .../Entities/Structures/Machines/gateway.yml | 69 +++++++ .../Structures/Machines/gateway.rsi/frame.png | Bin 0 -> 3450 bytes .../Structures/Machines/gateway.rsi/meta.json | 34 ++++ .../Structures/Machines/gateway.rsi/on.png | Bin 0 -> 4377 bytes .../Machines/gateway.rsi/portal.png | Bin 0 -> 2752 bytes 13 files changed, 682 insertions(+) create mode 100644 Content.Client/Gateway/UI/GatewayBoundUserInterface.cs create mode 100644 Content.Client/Gateway/UI/GatewayWindow.xaml create mode 100644 Content.Client/Gateway/UI/GatewayWindow.xaml.cs create mode 100644 Content.Server/Gateway/Components/GatewayComponent.cs create mode 100644 Content.Server/Gateway/Components/GatewayDestinationComponent.cs create mode 100644 Content.Server/Gateway/Systems/GatewaySystem.cs create mode 100644 Content.Shared/Gateway/GatewayUi.cs create mode 100644 Resources/Locale/en-US/gateway/gateway.ftl create mode 100644 Resources/Prototypes/Entities/Structures/Machines/gateway.yml create mode 100644 Resources/Textures/Structures/Machines/gateway.rsi/frame.png create mode 100644 Resources/Textures/Structures/Machines/gateway.rsi/meta.json create mode 100644 Resources/Textures/Structures/Machines/gateway.rsi/on.png create mode 100644 Resources/Textures/Structures/Machines/gateway.rsi/portal.png diff --git a/Content.Client/Gateway/UI/GatewayBoundUserInterface.cs b/Content.Client/Gateway/UI/GatewayBoundUserInterface.cs new file mode 100644 index 0000000000..e3204b7ff2 --- /dev/null +++ b/Content.Client/Gateway/UI/GatewayBoundUserInterface.cs @@ -0,0 +1,43 @@ +using Content.Shared.Gateway; +using Robust.Client.GameObjects; + +namespace Content.Client.Gateway.UI; + +public sealed class GatewayBoundUserInterface : BoundUserInterface +{ + private GatewayWindow? _window; + + public GatewayBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey) + { + } + + protected override void Open() + { + base.Open(); + + _window = new GatewayWindow(); + _window.OpenPortal += destination => + { + SendMessage(new GatewayOpenPortalMessage(destination)); + }; + _window.OnClose += Close; + _window?.OpenCentered(); + } + + protected override void Dispose(bool disposing) + { + base.Dispose(disposing); + _window?.Dispose(); + _window = null; + } + + protected override void UpdateState(BoundUserInterfaceState state) + { + base.UpdateState(state); + + if (state is not GatewayBoundUserInterfaceState current) + return; + + _window?.UpdateState(current); + } +} diff --git a/Content.Client/Gateway/UI/GatewayWindow.xaml b/Content.Client/Gateway/UI/GatewayWindow.xaml new file mode 100644 index 0000000000..49e6bb679b --- /dev/null +++ b/Content.Client/Gateway/UI/GatewayWindow.xaml @@ -0,0 +1,22 @@ + + + + + + + + + + diff --git a/Content.Client/Gateway/UI/GatewayWindow.xaml.cs b/Content.Client/Gateway/UI/GatewayWindow.xaml.cs new file mode 100644 index 0000000000..b070cf3176 --- /dev/null +++ b/Content.Client/Gateway/UI/GatewayWindow.xaml.cs @@ -0,0 +1,180 @@ +using Content.Client.Computer; +using Content.Client.Stylesheets; +using Content.Client.UserInterface.Controls; +using Content.Shared.Gateway; +using Content.Shared.Shuttles.BUIStates; +using Robust.Client.AutoGenerated; +using Robust.Client.Graphics; +using Robust.Client.UserInterface; +using Robust.Client.UserInterface.Controls; +using Robust.Client.UserInterface.XAML; +using Robust.Shared.Timing; + +namespace Content.Client.Gateway.UI; + +[GenerateTypedNameReferences] +public sealed partial class GatewayWindow : FancyWindow, + IComputerWindow +{ + private readonly IGameTiming _timing; + + public event Action? OpenPortal; + private List<(EntityUid, string, TimeSpan, bool)> _destinations = default!; + private EntityUid? _current; + private TimeSpan _nextClose; + private TimeSpan _lastOpen; + private List