diff --git a/OpenDreamClient/Input/DreamCommandSystem.cs b/OpenDreamClient/Input/DreamCommandSystem.cs deleted file mode 100644 index b85b1e86bf..0000000000 --- a/OpenDreamClient/Input/DreamCommandSystem.cs +++ /dev/null @@ -1,50 +0,0 @@ -using OpenDreamShared.Input; -using OpenDreamClient.Interface; -using Robust.Shared.Network; - -namespace OpenDreamClient.Input { - public sealed class DreamCommandSystem : SharedDreamCommandSystem { - [Dependency] private readonly IDreamInterfaceManager _interfaceManager = default!; - - public void RunCommand(string command) { - string[] split = command.Split(" "); - string verb = split[0]; - - switch (verb) { - case ".quit": - IoCManager.Resolve().ClientDisconnect(".quit used"); - break; - - case ".screenshot": - _interfaceManager.SaveScreenshot(split.Length == 1 || split[1] != "auto"); - break; - - case ".configure": - Log.Warning(".configure command is not implemented"); - break; - - case ".winset": - // Everything after .winset, excluding the space and quotes - string winsetParams = command.Substring(verb.Length + 2, command.Length - verb.Length - 3); - - _interfaceManager.WinSet(null, winsetParams); - break; - - default: { - // Send the entire command to the server. - // It has more info about argument types so it can parse it better than we can. - RaiseNetworkEvent(new CommandEvent(command)); - break; - } - } - } - - public void StartRepeatingCommand(string command) { - RaiseNetworkEvent(new RepeatCommandEvent(command)); - } - - public void StopRepeatingCommand(string command) { - RaiseNetworkEvent(new StopRepeatCommandEvent(command)); - } - } -} diff --git a/OpenDreamClient/Interface/Controls/ControlBrowser.cs b/OpenDreamClient/Interface/Controls/ControlBrowser.cs index 3d3b4c7991..c49169b0f6 100644 --- a/OpenDreamClient/Interface/Controls/ControlBrowser.cs +++ b/OpenDreamClient/Interface/Controls/ControlBrowser.cs @@ -30,7 +30,6 @@ internal sealed class ControlBrowser : InterfaceControl { [Dependency] private readonly IResourceManager _resourceManager = default!; [Dependency] private readonly IClientNetManager _netManager = default!; - [Dependency] private readonly IDreamInterfaceManager _interfaceManager = default!; [Dependency] private readonly IDreamResourceManager _dreamResource = default!; private readonly ISawmill _sawmill = Logger.GetSawmill("opendream.browser"); diff --git a/OpenDreamClient/Interface/Controls/ControlButton.cs b/OpenDreamClient/Interface/Controls/ControlButton.cs index 40b9e06b7c..36f1f5f484 100644 --- a/OpenDreamClient/Interface/Controls/ControlButton.cs +++ b/OpenDreamClient/Interface/Controls/ControlButton.cs @@ -7,7 +7,6 @@ namespace OpenDreamClient.Interface.Controls; internal sealed class ControlButton : InterfaceControl { public const string StyleClassDMFButton = "DMFbutton"; - private Button _button; public ControlButton(ControlDescriptor controlDescriptor, ControlWindow window) : base(controlDescriptor, window) { } @@ -36,7 +35,7 @@ private void OnButtonClick(BaseButton.ButtonEventArgs args) { ControlDescriptorButton controlDescriptor = (ControlDescriptorButton)ElementDescriptor; if (controlDescriptor.Command != null) { - EntitySystem.Get().RunCommand(controlDescriptor.Command); + _interfaceManager.RunCommand(controlDescriptor.Command); } } } diff --git a/OpenDreamClient/Interface/Controls/ControlChild.cs b/OpenDreamClient/Interface/Controls/ControlChild.cs index 7afe4d9891..39c7ce5a2c 100644 --- a/OpenDreamClient/Interface/Controls/ControlChild.cs +++ b/OpenDreamClient/Interface/Controls/ControlChild.cs @@ -8,7 +8,6 @@ internal sealed class ControlChild : InterfaceControl { // todo: robust needs GridSplitter. // and a non-shit grid control. - [Dependency] private readonly IDreamInterfaceManager _dreamInterface = default!; private ControlDescriptorChild ChildDescriptor => (ControlDescriptorChild)ElementDescriptor; @@ -26,10 +25,10 @@ protected override Control CreateUIElement() { protected override void UpdateElementDescriptor() { base.UpdateElementDescriptor(); - var newLeftElement = ChildDescriptor.Left != null && _dreamInterface.Windows.TryGetValue(ChildDescriptor.Left, out var leftWindow) + var newLeftElement = ChildDescriptor.Left != null && _interfaceManager.Windows.TryGetValue(ChildDescriptor.Left, out var leftWindow) ? leftWindow.UIElement : null; - var newRightElement = ChildDescriptor.Right != null && _dreamInterface.Windows.TryGetValue(ChildDescriptor.Right, out var rightWindow) + var newRightElement = ChildDescriptor.Right != null && _interfaceManager.Windows.TryGetValue(ChildDescriptor.Right, out var rightWindow) ? rightWindow.UIElement : null; @@ -74,9 +73,9 @@ protected override void UpdateElementDescriptor() { } public override void Shutdown() { - if (ChildDescriptor.Left != null && _dreamInterface.Windows.TryGetValue(ChildDescriptor.Left, out var left)) + if (ChildDescriptor.Left != null && _interfaceManager.Windows.TryGetValue(ChildDescriptor.Left, out var left)) left.Shutdown(); - if (ChildDescriptor.Right != null && _dreamInterface.Windows.TryGetValue(ChildDescriptor.Right, out var right)) + if (ChildDescriptor.Right != null && _interfaceManager.Windows.TryGetValue(ChildDescriptor.Right, out var right)) right.Shutdown(); } diff --git a/OpenDreamClient/Interface/Controls/ControlInfo.cs b/OpenDreamClient/Interface/Controls/ControlInfo.cs index a55a390b56..a6f3bce85b 100644 --- a/OpenDreamClient/Interface/Controls/ControlInfo.cs +++ b/OpenDreamClient/Interface/Controls/ControlInfo.cs @@ -176,7 +176,7 @@ public void RefreshVerbs() { verbButton.Label.Margin = new Thickness(6, 0, 6, 2); verbButton.OnPressed += _ => { - EntitySystem.Get().RunCommand(verbId); + _dreamInterface.RunCommand(verbId); }; _grid.Children.Add(verbButton); diff --git a/OpenDreamClient/Interface/Controls/ControlInput.cs b/OpenDreamClient/Interface/Controls/ControlInput.cs index 29a1aa58c0..8059555dfb 100644 --- a/OpenDreamClient/Interface/Controls/ControlInput.cs +++ b/OpenDreamClient/Interface/Controls/ControlInput.cs @@ -7,7 +7,6 @@ namespace OpenDreamClient.Interface.Controls; internal sealed class ControlInput : InterfaceControl { private LineEdit _textBox; - public ControlInput(ControlDescriptor controlDescriptor, ControlWindow window) : base(controlDescriptor, window) { } protected override Control CreateUIElement() { @@ -18,7 +17,7 @@ protected override Control CreateUIElement() { } private void TextBox_OnSubmit(LineEdit.LineEditEventArgs lineEditEventArgs) { - EntitySystem.Get().RunCommand(_textBox.Text); + _interfaceManager.RunCommand(_textBox.Text); _textBox.Clear(); } } diff --git a/OpenDreamClient/Interface/Controls/ControlMap.cs b/OpenDreamClient/Interface/Controls/ControlMap.cs index 4d9ba1d91a..75e2689fbf 100644 --- a/OpenDreamClient/Interface/Controls/ControlMap.cs +++ b/OpenDreamClient/Interface/Controls/ControlMap.cs @@ -11,7 +11,6 @@ public sealed class ControlMap : InterfaceControl { public ScalingViewport Viewport { get; private set; } [Dependency] private readonly IEntitySystemManager _entitySystemManager = default!; - [Dependency] private readonly IDreamInterfaceManager _dreamInterfaceManager = default!; private MouseInputSystem _mouseInput; public ControlMap(ControlDescriptor controlDescriptor, ControlWindow window) : base(controlDescriptor, window) { } @@ -38,8 +37,19 @@ public void UpdateViewRange(ViewRange view) { protected override Control CreateUIElement() { Viewport = new ScalingViewport { MouseFilter = Control.MouseFilterMode.Stop }; Viewport.OnKeyBindDown += OnViewportKeyBindDown; + Viewport.OnVisibilityChanged += (args) => { + if (args.Visible) { + OnShowEvent(); + } else { + OnHideEvent(); + } + }; + if(ControlDescriptor.IsVisible) + OnShowEvent(); + else + OnHideEvent(); - UpdateViewRange(_dreamInterfaceManager.View); + UpdateViewRange(_interfaceManager.View); return new PanelContainer { StyleClasses = {"MapBackground"}, Children = { Viewport } }; } @@ -54,4 +64,18 @@ private void OnViewportKeyBindDown(GUIBoundKeyEventArgs e) { } } } + + public void OnShowEvent() { + ControlDescriptorMap controlDescriptor = (ControlDescriptorMap)ControlDescriptor; + if (controlDescriptor.OnShowCommand != null) { + _interfaceManager.RunCommand(controlDescriptor.OnShowCommand); + } + } + + public void OnHideEvent() { + ControlDescriptorMap controlDescriptor = (ControlDescriptorMap)ControlDescriptor; + if (controlDescriptor.OnHideCommand != null) { + _interfaceManager.RunCommand(controlDescriptor.OnHideCommand); + } + } } diff --git a/OpenDreamClient/Interface/Controls/ControlWindow.cs b/OpenDreamClient/Interface/Controls/ControlWindow.cs index aef84ebe0b..378f7caaa6 100644 --- a/OpenDreamClient/Interface/Controls/ControlWindow.cs +++ b/OpenDreamClient/Interface/Controls/ControlWindow.cs @@ -8,7 +8,6 @@ namespace OpenDreamClient.Interface.Controls; public sealed class ControlWindow : InterfaceControl { [Dependency] private readonly IUserInterfaceManager _uiMgr = default!; - [Dependency] private readonly IDreamInterfaceManager _dreamInterface = default!; [Dependency] private readonly IEntitySystemManager _entitySystemManager = default!; private readonly ISawmill _sawmill = Logger.GetSawmill("opendream.window"); @@ -19,7 +18,7 @@ public sealed class ControlWindow : InterfaceControl { public readonly List ChildControls = new(); - public InterfaceMacroSet Macro => _dreamInterface.MacroSets[WindowDescriptor.Macro]; + public InterfaceMacroSet Macro => _interfaceManager.MacroSets[WindowDescriptor.Macro]; private WindowDescriptor WindowDescriptor => (WindowDescriptor)ElementDescriptor; @@ -35,7 +34,7 @@ protected override void UpdateElementDescriptor() { // Don't call base.UpdateElementDescriptor(); _menuContainer.RemoveAllChildren(); - if (WindowDescriptor.Menu != null && _dreamInterface.Menus.TryGetValue(WindowDescriptor.Menu, out var menu)) { + if (WindowDescriptor.Menu != null && _interfaceManager.Menus.TryGetValue(WindowDescriptor.Menu, out var menu)) { _menuContainer.AddChild(menu.MenuBar); _menuContainer.Visible = true; } else { @@ -63,8 +62,8 @@ public OSWindow CreateWindow() { window.SetHeight = window.MaxHeight; window.Closing += _ => { // A window can have a command set to be run when it's closed - if (WindowDescriptor.OnClose != null && _entitySystemManager.TryGetEntitySystem(out DreamCommandSystem? commandSystem)) { - commandSystem.RunCommand(WindowDescriptor.OnClose); + if (WindowDescriptor.OnClose != null) { + _interfaceManager.RunCommand(WindowDescriptor.OnClose); } _openWindows.Remove((window, null)); diff --git a/OpenDreamClient/Interface/DMF/DMFParser.cs b/OpenDreamClient/Interface/DMF/DMFParser.cs index 67a34b47b4..1f6be372b9 100644 --- a/OpenDreamClient/Interface/DMF/DMFParser.cs +++ b/OpenDreamClient/Interface/DMF/DMFParser.cs @@ -188,8 +188,10 @@ private bool TryGetAttribute(out string? element, [NotNullWhen(true)] out string Token attributeToken = Current(); if (Check(_attributeTokenTypes)) { - if (Check(TokenType.DMF_Period)) { // element.attribute=value - element = attributeToken.Text; + while(Check(TokenType.DMF_Period)) { // element.attribute=value + element ??= ""; + if(element.Length > 0) element += "."; + element += attributeToken.Text; attributeToken = Current(); if (!Check(_attributeTokenTypes)) { diff --git a/OpenDreamClient/Interface/DebugWindows/MacrosWindow.cs b/OpenDreamClient/Interface/DebugWindows/MacrosWindow.cs index 85612b8c12..5c5974fa2e 100644 --- a/OpenDreamClient/Interface/DebugWindows/MacrosWindow.cs +++ b/OpenDreamClient/Interface/DebugWindows/MacrosWindow.cs @@ -11,11 +11,10 @@ namespace OpenDreamClient.Interface.DebugWindows; public sealed class MacrosWindow : OSWindow { [Dependency] private readonly IDreamInterfaceManager _interfaceManager = default!; [Dependency] private readonly IEntitySystemManager _entitySystemManager = default!; - private readonly DreamCommandSystem _commandSystem; + public MacrosWindow() { IoCManager.InjectDependencies(this); - _commandSystem = _entitySystemManager.GetEntitySystem(); Title = "Macros"; SizeToContent = WindowSizeToContent.WidthAndHeight; @@ -60,13 +59,13 @@ private GridContainer CreateMacroTable(InterfaceMacroSet macroSet) { if (value == null) return; // Cancelled - _commandSystem.RunCommand(macro.Command.Replace("[[*]]", (string)value)); + _interfaceManager.RunCommand(macro.Command.Replace("[[*]]", (string)value)); }); prompt.Owner = ClydeWindow; prompt.Show(); } else { - _commandSystem.RunCommand(macro.Command); + _interfaceManager.RunCommand(macro.Command); } }; diff --git a/OpenDreamClient/Interface/Descriptors/ControlDescriptors.cs b/OpenDreamClient/Interface/Descriptors/ControlDescriptors.cs index 98ee7ada35..5da523cc61 100644 --- a/OpenDreamClient/Interface/Descriptors/ControlDescriptors.cs +++ b/OpenDreamClient/Interface/Descriptors/ControlDescriptors.cs @@ -140,6 +140,10 @@ public sealed partial class ControlDescriptorInfo : ControlDescriptor { } public sealed partial class ControlDescriptorMap : ControlDescriptor { + [DataField("on-show")] + public string? OnShowCommand; + [DataField("on-hide")] + public string? OnHideCommand; [DataField("zoom-mode")] public string ZoomMode = "normal"; } diff --git a/OpenDreamClient/Interface/DreamInterfaceManager.cs b/OpenDreamClient/Interface/DreamInterfaceManager.cs index 444ed0e636..6110be3052 100644 --- a/OpenDreamClient/Interface/DreamInterfaceManager.cs +++ b/OpenDreamClient/Interface/DreamInterfaceManager.cs @@ -434,6 +434,47 @@ public void SaveScreenshot(bool openDialog) { }); } + public void RunCommand(string command){ + switch (command) { + case string x when x.StartsWith(".quit"): + IoCManager.Resolve().ClientDisconnect(".quit used"); + break; + + case string x when x.StartsWith(".screenshot"): + string[] split = command.Split(" "); + SaveScreenshot(split.Length == 1 || split[1] != "auto"); + break; + + case string x when x.StartsWith(".configure"): + _sawmill.Warning(".configure command is not implemented"); + break; + + case string x when x.StartsWith(".winset"): + // Everything after .winset, excluding the space and quotes + string winsetParams = command.Substring(7); //clip .winset + winsetParams = winsetParams.Trim(); //clip space + winsetParams = winsetParams.Trim('\"'); //clip quotes + + WinSet(null, winsetParams); + break; + + default: { + // Send the entire command to the server. + // It has more info about argument types so it can parse it better than we can. + _netManager.ClientSendMessage(new MsgCommand(){Command = command}); + break; + } + } + } + + public void StartRepeatingCommand(string command) { + _netManager.ClientSendMessage(new MsgCommandRepeatStart(){Command = command}); + } + + public void StopRepeatingCommand(string command) { + _netManager.ClientSendMessage(new MsgCommandRepeatStop(){Command = command}); + } + public void WinSet(string? controlId, string winsetParams) { DMFLexer lexer = new DMFLexer($"winset({controlId}, \"{winsetParams}\")", winsetParams); DMFParser parser = new DMFParser(lexer, _serializationManager); @@ -470,9 +511,7 @@ bool CheckParserErrors() { if (elementId == null) { if (winSet.Attribute == "command") { - DreamCommandSystem commandSystem = _entitySystemManager.GetEntitySystem(); - - commandSystem.RunCommand(winSet.Value); + RunCommand(winSet.Value); } else { _sawmill.Error($"Invalid global winset \"{winsetParams}\""); } @@ -485,7 +524,7 @@ bool CheckParserErrors() { if (element != null) { element.PopulateElementDescriptor(node, _serializationManager); } else { - _sawmill.Error($"Invalid element \"{controlId}\""); + _sawmill.Error($"Invalid element \"{elementId}\""); } } } @@ -701,5 +740,9 @@ public interface IDreamInterfaceManager { InterfaceElement? FindElementWithId(string id); void SaveScreenshot(bool openDialog); void LoadInterfaceFromSource(string source); + + void RunCommand(string command); + void StartRepeatingCommand(string command); + void StopRepeatingCommand(string command); void WinSet(string? controlId, string winsetParams); } diff --git a/OpenDreamClient/Interface/DummyDreamInterfaceManager.cs b/OpenDreamClient/Interface/DummyDreamInterfaceManager.cs index 0261317cde..16c167f0dc 100644 --- a/OpenDreamClient/Interface/DummyDreamInterfaceManager.cs +++ b/OpenDreamClient/Interface/DummyDreamInterfaceManager.cs @@ -43,4 +43,16 @@ public void LoadInterfaceFromSource(string source) { public void WinSet(string? controlId, string winsetParams) { } + + public void RunCommand(string command) { + + } + + public void StartRepeatingCommand(string command) { + + } + + public void StopRepeatingCommand(string command) { + + } } diff --git a/OpenDreamClient/Interface/InterfaceElement.cs b/OpenDreamClient/Interface/InterfaceElement.cs index 5f01f8adb5..20080b73ff 100644 --- a/OpenDreamClient/Interface/InterfaceElement.cs +++ b/OpenDreamClient/Interface/InterfaceElement.cs @@ -10,9 +10,10 @@ public class InterfaceElement { public string Id => ElementDescriptor.Id; public ElementDescriptor ElementDescriptor; - + [Dependency] protected readonly IDreamInterfaceManager _interfaceManager = default!; protected InterfaceElement(ElementDescriptor elementDescriptor) { ElementDescriptor = elementDescriptor; + IoCManager.InjectDependencies(this); } public void PopulateElementDescriptor(MappingDataNode node, ISerializationManager serializationManager) { diff --git a/OpenDreamClient/Interface/InterfaceMacro.cs b/OpenDreamClient/Interface/InterfaceMacro.cs index 8070956280..b3f4044ca0 100644 --- a/OpenDreamClient/Interface/InterfaceMacro.cs +++ b/OpenDreamClient/Interface/InterfaceMacro.cs @@ -224,9 +224,8 @@ public static ParsedKeybind Parse(string keybind) { public sealed class InterfaceMacro : InterfaceElement { public string Command => MacroDescriptor.Command; - - private MacroDescriptor MacroDescriptor => (MacroDescriptor)ElementDescriptor; + private MacroDescriptor MacroDescriptor => (MacroDescriptor)ElementDescriptor; private readonly IEntitySystemManager _entitySystemManager; private readonly IUserInterfaceManager _uiManager; private readonly IInputCmdContext _inputContext; @@ -293,14 +292,14 @@ private void FirstChanceKeyHandler(KeyEventArgs args, KeyEventType type) { return; } - if (_entitySystemManager.TryGetEntitySystem(out DreamCommandSystem? commandSystem)) { - string? keyName = ParsedKeybind.KeyToKeyName(args.Key); - if (keyName == null) - return; - string command = Command.Replace("[[*]]", keyName); - commandSystem.RunCommand(command); - // args.Handle() omitted on purpose, in BYOND both the "specific" keybind and the ANY keybind are triggered - } + + string? keyName = ParsedKeybind.KeyToKeyName(args.Key); + if (keyName == null) + return; + string command = Command.Replace("[[*]]", keyName); + _interfaceManager.RunCommand(command); + // args.Handle() omitted on purpose, in BYOND both the "specific" keybind and the ANY keybind are triggered + } private void OnMacroPress(ICommonSession? session) { @@ -309,26 +308,26 @@ private void OnMacroPress(ICommonSession? session) { if (_isRelease) return; - if (_entitySystemManager.TryGetEntitySystem(out DreamCommandSystem? commandSystem)) { - if (_isRepeating) { - commandSystem.StartRepeatingCommand(Command); - } else { - commandSystem.RunCommand(Command); - } + + if (_isRepeating) { + _interfaceManager.StartRepeatingCommand(Command); + } else { + _interfaceManager.RunCommand(Command); } + } private void OnMacroRelease(ICommonSession? session) { if (string.IsNullOrEmpty(Command)) return; - if (_entitySystemManager.TryGetEntitySystem(out DreamCommandSystem? commandSystem)) { - if (_isRepeating) { - commandSystem.StopRepeatingCommand(Command); - } else if (_isRelease) { - commandSystem.RunCommand(Command); - } + + if (_isRepeating) { + _interfaceManager.StopRepeatingCommand(Command); + } else if (_isRelease) { + _interfaceManager.RunCommand(Command); } + } private static KeyBindingRegistration? CreateMacroBinding(BoundKeyFunction function, ParsedKeybind keybind) { diff --git a/OpenDreamClient/Interface/InterfaceMenu.cs b/OpenDreamClient/Interface/InterfaceMenu.cs index f1edfcb19e..86caf74745 100644 --- a/OpenDreamClient/Interface/InterfaceMenu.cs +++ b/OpenDreamClient/Interface/InterfaceMenu.cs @@ -133,7 +133,7 @@ public MenuBar.MenuEntry CreateMenuEntry() { MenuElementDescriptor.IsChecked = !MenuElementDescriptor.IsChecked; _menu.CreateMenu(); if(!string.IsNullOrEmpty(MenuElementDescriptor.Command)) - EntitySystem.Get().RunCommand(Command); + _interfaceManager.RunCommand(Command); }; return menuButton; } diff --git a/OpenDreamRuntime/Input/DreamCommandSystem.cs b/OpenDreamRuntime/Input/DreamCommandSystem.cs index cd87e8ee0f..b7b63d4b08 100644 --- a/OpenDreamRuntime/Input/DreamCommandSystem.cs +++ b/OpenDreamRuntime/Input/DreamCommandSystem.cs @@ -1,17 +1,21 @@ using OpenDreamShared.Input; +using OpenDreamShared.Network.Messages; using Robust.Server.Player; +using Robust.Shared.Network; namespace OpenDreamRuntime.Input; -internal sealed class DreamCommandSystem : SharedDreamCommandSystem { +internal sealed class DreamCommandSystem : EntitySystem{ [Dependency] private readonly DreamManager _dreamManager = default!; + [Dependency] private readonly IServerNetManager _netManager = default!; + [Dependency] private readonly IPlayerManager _playerManager = default!; private readonly HashSet<(string Command, IPlayerSession session)> _repeatingCommands = new(); public override void Initialize() { - SubscribeNetworkEvent(OnCommandEvent); - SubscribeNetworkEvent(OnRepeatCommandEvent); - SubscribeNetworkEvent(OnStopRepeatCommandEvent); + _netManager.RegisterNetMessage(OnCommandEvent); + _netManager.RegisterNetMessage(OnRepeatCommandEvent); + _netManager.RegisterNetMessage(OnStopRepeatCommandEvent); } public void RunRepeatingCommands() { @@ -20,18 +24,18 @@ public void RunRepeatingCommands() { } } - private void OnCommandEvent(CommandEvent e, EntitySessionEventArgs sessionEvent) { - RunCommand(e.Command, (IPlayerSession)sessionEvent.SenderSession); + private void OnCommandEvent(MsgCommand message) { + RunCommand(message.Command, _playerManager.GetSessionByChannel(message.MsgChannel)); } - private void OnRepeatCommandEvent(RepeatCommandEvent e, EntitySessionEventArgs sessionEvent) { - var tuple = (e.Command, (IPlayerSession)sessionEvent.SenderSession); + private void OnRepeatCommandEvent(MsgCommandRepeatStart message) { + var tuple = (message.Command, _playerManager.GetSessionByChannel(message.MsgChannel)); _repeatingCommands.Add(tuple); } - private void OnStopRepeatCommandEvent(StopRepeatCommandEvent e, EntitySessionEventArgs sessionEvent) { - var tuple = (e.Command, (IPlayerSession)sessionEvent.SenderSession); + private void OnStopRepeatCommandEvent(MsgCommandRepeatStop message) { + var tuple = (message.Command, _playerManager.GetSessionByChannel(message.MsgChannel)); _repeatingCommands.Remove(tuple); } diff --git a/OpenDreamShared/Input/SharedDreamCommandSystem.cs b/OpenDreamShared/Input/SharedDreamCommandSystem.cs deleted file mode 100644 index eb6e153f8b..0000000000 --- a/OpenDreamShared/Input/SharedDreamCommandSystem.cs +++ /dev/null @@ -1,36 +0,0 @@ -using Robust.Shared.Analyzers; -using Robust.Shared.GameObjects; -using Robust.Shared.Serialization; -using System; - -namespace OpenDreamShared.Input { - [Virtual] - public class SharedDreamCommandSystem : EntitySystem { - [Serializable, NetSerializable] - public sealed class CommandEvent : EntityEventArgs { - public string Command { get; } - - public CommandEvent(string command) { - Command = command; - } - } - - [Serializable, NetSerializable] - public sealed class RepeatCommandEvent : EntityEventArgs { - public string Command { get; } - - public RepeatCommandEvent(string command) { - Command = command; - } - } - - [Serializable, NetSerializable] - public sealed class StopRepeatCommandEvent : EntityEventArgs { - public string Command { get; } - - public StopRepeatCommandEvent(string command) { - Command = command; - } - } - } -} diff --git a/OpenDreamShared/Network/Messages/MsgCommand.cs b/OpenDreamShared/Network/Messages/MsgCommand.cs new file mode 100644 index 0000000000..045afd676d --- /dev/null +++ b/OpenDreamShared/Network/Messages/MsgCommand.cs @@ -0,0 +1,48 @@ +using System; +using Lidgren.Network; +using Robust.Shared.Network; +using Robust.Shared.Serialization; + +namespace OpenDreamShared.Network.Messages { + public sealed class MsgCommand : NetMessage { + public override MsgGroups MsgGroup => MsgGroups.EntityEvent; + + public string Command = String.Empty; + + public override void ReadFromBuffer(NetIncomingMessage buffer, IRobustSerializer serializer) { + Command = buffer.ReadString(); + } + + public override void WriteToBuffer(NetOutgoingMessage buffer, IRobustSerializer serializer) { + buffer.Write(Command); + } + } + + public sealed class MsgCommandRepeatStart : NetMessage { + public override MsgGroups MsgGroup => MsgGroups.EntityEvent; + + public string Command = String.Empty; + + public override void ReadFromBuffer(NetIncomingMessage buffer, IRobustSerializer serializer) { + Command = buffer.ReadString(); + } + + public override void WriteToBuffer(NetOutgoingMessage buffer, IRobustSerializer serializer) { + buffer.Write(Command); + } + } + + public sealed class MsgCommandRepeatStop : NetMessage { + public override MsgGroups MsgGroup => MsgGroups.EntityEvent; + + public string Command = String.Empty; + + public override void ReadFromBuffer(NetIncomingMessage buffer, IRobustSerializer serializer) { + Command = buffer.ReadString(); + } + + public override void WriteToBuffer(NetOutgoingMessage buffer, IRobustSerializer serializer) { + buffer.Write(Command); + } + } +}