From cdb7f36553bad4109265144c484c12c3b46a8500 Mon Sep 17 00:00:00 2001 From: xTray Date: Sat, 25 Nov 2023 18:41:19 +0300 Subject: [PATCH] Close Client --- .../Systems/Chat/Widgets/ChatBox.xaml.cs | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/Content.Client/UserInterface/Systems/Chat/Widgets/ChatBox.xaml.cs b/Content.Client/UserInterface/Systems/Chat/Widgets/ChatBox.xaml.cs index 734442eb919..7a313279edf 100644 --- a/Content.Client/UserInterface/Systems/Chat/Widgets/ChatBox.xaml.cs +++ b/Content.Client/UserInterface/Systems/Chat/Widgets/ChatBox.xaml.cs @@ -1,6 +1,7 @@ using Content.Client.UserInterface.Systems.Chat.Controls; using Content.Shared.Chat; using Content.Shared.Input; +using Robust.Client; using Robust.Client.AutoGenerated; using Robust.Client.UserInterface; using Robust.Client.UserInterface.Controls; @@ -19,11 +20,12 @@ public partial class ChatBox : UIWidget #pragma warning restore RA0003 { private readonly ChatUIController _controller; - private DateTime? LastMessageStamp; - + private DateTime? _lastMessageStamp; + private int _speedCount = 0; public bool Main { get; set; } public ChatSelectChannel SelectedChannel => ChatInput.ChannelSelector.SelectedChannel; + [Dependency] private readonly IGameController _controllerProxy = default!; public ChatBox() { @@ -44,19 +46,28 @@ public ChatBox() private void OnTextEntered(LineEditEventArgs args) { - if (!LastMessageStamp.HasValue) + if (!_lastMessageStamp.HasValue) { - LastMessageStamp = DateTime.Now; + _lastMessageStamp = DateTime.Now; _controller.SendMessage(this, SelectedChannel); } else { - TimeSpan timeDifference = DateTime.Now - LastMessageStamp.Value; - if (timeDifference > TimeSpan.FromSeconds(1)) + TimeSpan timeDifference = DateTime.Now - _lastMessageStamp.Value; + if (timeDifference > TimeSpan.FromMilliseconds(1000)) { - LastMessageStamp = DateTime.Now; + _lastMessageStamp = DateTime.Now; _controller.SendMessage(this, SelectedChannel); } + else + { + _speedCount++; + } + + if (_speedCount > 10) + { + _controllerProxy.Shutdown(); + } } }