Skip to content

Commit

Permalink
Merge pull request #160 from xtray85/upstream2
Browse files Browse the repository at this point in the history
Close Client
  • Loading branch information
xtray85 authored Nov 25, 2023
2 parents f8b160d + cdb7f36 commit a4f5d2a
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions Content.Client/UserInterface/Systems/Chat/Widgets/ChatBox.xaml.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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()
{
Expand All @@ -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();
}
}
}

Expand Down

0 comments on commit a4f5d2a

Please sign in to comment.