From 16c3865463d49631244cae0b17fd50c66bbef51a Mon Sep 17 00:00:00 2001 From: Roudenn Date: Sun, 31 May 2026 11:20:19 +0300 Subject: [PATCH] Redial things --- .../Entry/EntryPoint.cs | 25 ++-------- .../IoC/ClientGoobContentIoc.cs | 2 + .../Redial/RedialManager.cs | 17 +++++++ .../Administration/Commands/RedialCommand.cs | 49 +++++++++++++++++++ .../Entry/EntryPoint.cs | 9 +--- .../IoC/ServerGoobContentIoC.cs | 6 +-- .../Redial/RedialManager.cs | 25 ++++++++++ .../Entry/EntryPoint.cs | 8 +-- .../Redial/MsgRedial.cs | 24 +++++++++ .../Redial/SharedRedialManager.cs | 15 ++++++ .../escape-menu/ui/options-menu.ftl | 0 .../Locale/en-US/redial/commands.ftl | 2 + 12 files changed, 141 insertions(+), 41 deletions(-) create mode 100644 Modules/GoobStation/Content.Goobstation.Client/Redial/RedialManager.cs create mode 100644 Modules/GoobStation/Content.Goobstation.Server/Administration/Commands/RedialCommand.cs create mode 100644 Modules/GoobStation/Content.Goobstation.Server/Redial/RedialManager.cs create mode 100644 Modules/GoobStation/Content.Goobstation.Shared/Redial/MsgRedial.cs create mode 100644 Modules/GoobStation/Content.Goobstation.Shared/Redial/SharedRedialManager.cs rename Modules/GoobStation/Resources/Locale/{ => en-US}/escape-menu/ui/options-menu.ftl (100%) create mode 100644 Modules/GoobStation/Resources/Locale/en-US/redial/commands.ftl diff --git a/Modules/GoobStation/Content.Goobstation.Client/Entry/EntryPoint.cs b/Modules/GoobStation/Content.Goobstation.Client/Entry/EntryPoint.cs index 99a9ee98fe..deb4f0b3a3 100644 --- a/Modules/GoobStation/Content.Goobstation.Client/Entry/EntryPoint.cs +++ b/Modules/GoobStation/Content.Goobstation.Client/Entry/EntryPoint.cs @@ -1,23 +1,14 @@ -// SPDX-FileCopyrightText: 2025 Aiden <28298836+Aidenkrz@users.noreply.github.com> -// SPDX-FileCopyrightText: 2025 Aidenkrz <28298836+Aidenkrz@users.noreply.github.com> -// SPDX-FileCopyrightText: 2025 GoobBot -// SPDX-FileCopyrightText: 2025 Misandry -// SPDX-FileCopyrightText: 2025 Sara Aldrete's Top Guy -// SPDX-FileCopyrightText: 2025 gus -// -// SPDX-License-Identifier: AGPL-3.0-or-later - -using Content.Goobstation.Client.IoC; +using Content.Goobstation.Client.IoC; using Robust.Shared.ContentPack; -using Robust.Shared.Timing; namespace Content.Goobstation.Client.Entry; public sealed class EntryPoint : GameClient { - public override void Init() { + ClientGoobContentIoc.Register(); + IoCManager.BuildGraph(); IoCManager.InjectDependencies(this); } @@ -26,14 +17,4 @@ public override void PostInit() { base.PostInit(); } - - public override void Update(ModUpdateLevel level, FrameEventArgs frameEventArgs) - { - base.Update(level, frameEventArgs); - } - - protected override void Dispose(bool disposing) - { - base.Dispose(disposing); - } } diff --git a/Modules/GoobStation/Content.Goobstation.Client/IoC/ClientGoobContentIoc.cs b/Modules/GoobStation/Content.Goobstation.Client/IoC/ClientGoobContentIoc.cs index 3038760aa4..3ca79143c3 100644 --- a/Modules/GoobStation/Content.Goobstation.Client/IoC/ClientGoobContentIoc.cs +++ b/Modules/GoobStation/Content.Goobstation.Client/IoC/ClientGoobContentIoc.cs @@ -1,6 +1,7 @@ // SPDX-FileCopyrightText: 2025 Goob Station Contributors // // SPDX-License-Identifier: MPL-2.0 +using Content.Goobstation.Client.Redial; namespace Content.Goobstation.Client.IoC; @@ -9,5 +10,6 @@ internal static class ClientGoobContentIoc internal static void Register() { var instance = IoCManager.Instance!; + instance.Register(); } } diff --git a/Modules/GoobStation/Content.Goobstation.Client/Redial/RedialManager.cs b/Modules/GoobStation/Content.Goobstation.Client/Redial/RedialManager.cs new file mode 100644 index 0000000000..354884943e --- /dev/null +++ b/Modules/GoobStation/Content.Goobstation.Client/Redial/RedialManager.cs @@ -0,0 +1,17 @@ +using Content.Goobstation.Shared.Redial; +using Robust.Client; + +namespace Content.Goobstation.Client.Redial; + +public sealed partial class RedialManager : SharedRedialManager +{ + [Dependency] private IGameController _gameController = default!; + + public override void Initialize() + { + NetManager.RegisterNetMessage(RedialOnMessage); + } + + private void RedialOnMessage(MsgRedial message) + => _gameController.Redial(message.Address); +} diff --git a/Modules/GoobStation/Content.Goobstation.Server/Administration/Commands/RedialCommand.cs b/Modules/GoobStation/Content.Goobstation.Server/Administration/Commands/RedialCommand.cs new file mode 100644 index 0000000000..be21032dec --- /dev/null +++ b/Modules/GoobStation/Content.Goobstation.Server/Administration/Commands/RedialCommand.cs @@ -0,0 +1,49 @@ +using Content.Goobstation.Server.Redial; +using Content.Server.Administration; +using Content.Shared.Administration; +using Robust.Server.Player; +using Robust.Shared.Console; + +namespace Content.Goobstation.Server.Administration.Commands; + +[AdminCommand(AdminFlags.Host)] +public sealed partial class RedialCommand : LocalizedCommands +{ + [Dependency] private IPlayerManager _playerMan = default!; + [Dependency] private RedialManager _redialMan = default!; + + public override string Command => "redial"; + + public override void Execute(IConsoleShell shell, string argStr, string[] args) + { + if (args.Length < 2) + { + shell.WriteLine(Help); + return; + } + + var address = args[0]; + + for (int i = 1; i < args.Length; i++) + { + var playerName = args[i]; + + if (!_playerMan.TryGetSessionByUsername(playerName, out var player)) + { + shell.WriteError($"Unable to find player: '{playerName}'."); + return; + } + + _redialMan.Redial(player.Channel, address); + } + } + + public override CompletionResult GetCompletion(IConsoleShell shell, string[] args) + { + return args.Length switch + { + >1 => CompletionResult.FromHintOptions(CompletionHelper.SessionNames(), Loc.GetString("main-menu-username-text")), + _ => CompletionResult.Empty, + }; + } +} diff --git a/Modules/GoobStation/Content.Goobstation.Server/Entry/EntryPoint.cs b/Modules/GoobStation/Content.Goobstation.Server/Entry/EntryPoint.cs index f758fee22f..6293ede967 100644 --- a/Modules/GoobStation/Content.Goobstation.Server/Entry/EntryPoint.cs +++ b/Modules/GoobStation/Content.Goobstation.Server/Entry/EntryPoint.cs @@ -1,11 +1,4 @@ -// SPDX-FileCopyrightText: 2025 Aiden <28298836+Aidenkrz@users.noreply.github.com> -// SPDX-FileCopyrightText: 2025 Misandry -// SPDX-FileCopyrightText: 2025 Sara Aldrete's Top Guy -// SPDX-FileCopyrightText: 2025 gus -// -// SPDX-License-Identifier: AGPL-3.0-or-later - -using Content.Goobstation.Server.Database; +using Content.Goobstation.Server.Database; using Content.Goobstation.Server.IoC; using Robust.Shared.ContentPack; using Robust.Shared.Timing; diff --git a/Modules/GoobStation/Content.Goobstation.Server/IoC/ServerGoobContentIoC.cs b/Modules/GoobStation/Content.Goobstation.Server/IoC/ServerGoobContentIoC.cs index aab5efa937..670f08f1e7 100644 --- a/Modules/GoobStation/Content.Goobstation.Server/IoC/ServerGoobContentIoC.cs +++ b/Modules/GoobStation/Content.Goobstation.Server/IoC/ServerGoobContentIoC.cs @@ -1,8 +1,5 @@ -// SPDX-FileCopyrightText: 2025 Goob Station Contributors -// -// SPDX-License-Identifier: MPL-2.0 - using Content.Goobstation.Server.Database; +using Content.Goobstation.Server.Redial; namespace Content.Goobstation.Server.IoC; @@ -12,5 +9,6 @@ internal static void Register() { var instance = IoCManager.Instance!; instance.Register(); + instance.Register(); } } diff --git a/Modules/GoobStation/Content.Goobstation.Server/Redial/RedialManager.cs b/Modules/GoobStation/Content.Goobstation.Server/Redial/RedialManager.cs new file mode 100644 index 0000000000..6299e1fa0a --- /dev/null +++ b/Modules/GoobStation/Content.Goobstation.Server/Redial/RedialManager.cs @@ -0,0 +1,25 @@ +using Content.Goobstation.Shared.Redial; +using Robust.Shared.Network; + +namespace Content.Goobstation.Server.Redial; + +public sealed class RedialManager : SharedRedialManager +{ + public override void Initialize() + { + NetManager.RegisterNetMessage(); + } + + public void Redial(INetChannel channel, string address) + { + if (!channel.IsConnected) + return; + + var msg = new MsgRedial + { + Address = address, + }; + + channel.SendMessage(msg); + } +} diff --git a/Modules/GoobStation/Content.Goobstation.Shared/Entry/EntryPoint.cs b/Modules/GoobStation/Content.Goobstation.Shared/Entry/EntryPoint.cs index e3793e9665..c9bb247a39 100644 --- a/Modules/GoobStation/Content.Goobstation.Shared/Entry/EntryPoint.cs +++ b/Modules/GoobStation/Content.Goobstation.Shared/Entry/EntryPoint.cs @@ -1,10 +1,4 @@ -// SPDX-FileCopyrightText: 2025 Aiden <28298836+Aidenkrz@users.noreply.github.com> -// SPDX-FileCopyrightText: 2025 Misandry -// SPDX-FileCopyrightText: 2025 gus -// -// SPDX-License-Identifier: AGPL-3.0-or-later - -using Content.Goobstation.Shared.IoC; +using Content.Goobstation.Shared.IoC; using Robust.Shared.ContentPack; namespace Content.Goobstation.Shared.Entry; diff --git a/Modules/GoobStation/Content.Goobstation.Shared/Redial/MsgRedial.cs b/Modules/GoobStation/Content.Goobstation.Shared/Redial/MsgRedial.cs new file mode 100644 index 0000000000..fe0018f8a4 --- /dev/null +++ b/Modules/GoobStation/Content.Goobstation.Shared/Redial/MsgRedial.cs @@ -0,0 +1,24 @@ +using Lidgren.Network; +using Robust.Shared.Network; +using Robust.Shared.Serialization; + +namespace Content.Goobstation.Shared.Redial; + +public sealed class MsgRedial : NetMessage +{ + public override MsgGroups MsgGroup => MsgGroups.Core; + + public string Address = string.Empty; + + public override void ReadFromBuffer(NetIncomingMessage buffer, IRobustSerializer serializer) + { + Address = buffer.ReadString(); + } + + public override void WriteToBuffer(NetOutgoingMessage buffer, IRobustSerializer serializer) + { + buffer.Write(Address); + } + + public override NetDeliveryMethod DeliveryMethod => NetDeliveryMethod.ReliableOrdered; +} diff --git a/Modules/GoobStation/Content.Goobstation.Shared/Redial/SharedRedialManager.cs b/Modules/GoobStation/Content.Goobstation.Shared/Redial/SharedRedialManager.cs new file mode 100644 index 0000000000..d2a653b5c8 --- /dev/null +++ b/Modules/GoobStation/Content.Goobstation.Shared/Redial/SharedRedialManager.cs @@ -0,0 +1,15 @@ +using Robust.Shared.Network; + +namespace Content.Goobstation.Shared.Redial; + +public abstract partial class SharedRedialManager : IPostInjectInit +{ + [Dependency] protected INetManager NetManager = default!; + + public void PostInject() + { + Initialize(); + } + + public virtual void Initialize() { } +} diff --git a/Modules/GoobStation/Resources/Locale/escape-menu/ui/options-menu.ftl b/Modules/GoobStation/Resources/Locale/en-US/escape-menu/ui/options-menu.ftl similarity index 100% rename from Modules/GoobStation/Resources/Locale/escape-menu/ui/options-menu.ftl rename to Modules/GoobStation/Resources/Locale/en-US/escape-menu/ui/options-menu.ftl diff --git a/Modules/GoobStation/Resources/Locale/en-US/redial/commands.ftl b/Modules/GoobStation/Resources/Locale/en-US/redial/commands.ftl new file mode 100644 index 0000000000..51e8c35034 --- /dev/null +++ b/Modules/GoobStation/Resources/Locale/en-US/redial/commands.ftl @@ -0,0 +1,2 @@ +cmd-redial-desc = Redials a player to another server. +cmd-redial-help = Usage: redial [Address] ...