Merge branch 'master' into mathmerge

This commit is contained in:
Pieter-Jan Briers
2020-08-20 20:33:43 +02:00
808 changed files with 18173 additions and 5666 deletions

View File

@@ -35,6 +35,8 @@ namespace Content.Client.Chat
public bool ReleaseFocusOnEnter { get; set; } = true;
public bool ClearOnEnter { get; set; } = true;
public ChatBox()
{
/*MarginLeft = -475.0f;
@@ -166,12 +168,18 @@ namespace Content.Client.Chat
private void Input_OnTextEntered(LineEdit.LineEditEventArgs args)
{
// We set it there to true so it's set to false by TextSubmitted.Invoke if necessary
ClearOnEnter = true;
if (!string.IsNullOrWhiteSpace(args.Text))
{
TextSubmitted?.Invoke(this, args.Text);
}
Input.Clear();
if (ClearOnEnter)
{
Input.Clear();
}
if (ReleaseFocusOnEnter)
{

View File

@@ -1,17 +1,21 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using Content.Client.Interfaces.Chat;
using Content.Shared.Chat;
using Robust.Client.Console;
using Robust.Client.Interfaces.Graphics.ClientEye;
using Robust.Client.Interfaces.UserInterface;
using Robust.Client.Player;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Network;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Log;
using Robust.Shared.Maths;
using Robust.Shared.Network;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
@@ -45,6 +49,11 @@ namespace Content.Client.Chat
/// </summary>
private const int SpeechBubbleCap = 4;
/// <summary>
/// The max amount of characters an entity can send in one message
/// </summary>
private int _maxMessageLength = 1000;
private const char ConCmdSlash = '/';
private const char OOCAlias = '[';
private const char MeAlias = '@';
@@ -89,11 +98,15 @@ namespace Content.Client.Chat
public void Initialize()
{
_netManager.RegisterNetMessage<MsgChatMessage>(MsgChatMessage.NAME, _onChatMessage);
_netManager.RegisterNetMessage<ChatMaxMsgLengthMessage>(ChatMaxMsgLengthMessage.NAME, _onMaxLengthReceived);
_speechBubbleRoot = new LayoutContainer();
LayoutContainer.SetAnchorPreset(_speechBubbleRoot, LayoutContainer.LayoutPreset.Wide);
_userInterfaceManager.StateRoot.AddChild(_speechBubbleRoot);
_speechBubbleRoot.SetPositionFirst();
// When connexion is achieved, request the max chat message length
_netManager.Connected += new EventHandler<NetChannelArgs>(RequestMaxLength);
}
public void FrameUpdate(FrameEventArgs delta)
@@ -213,6 +226,15 @@ namespace Content.Client.Chat
if (string.IsNullOrWhiteSpace(text))
return;
// Check if message is longer than the character limit
if (text.Length > _maxMessageLength)
{
string locWarning = Loc.GetString("Your message exceeds {0} character limit", _maxMessageLength);
_currentChatBox?.AddLine(locWarning, ChatChannel.Server, Color.Orange);
_currentChatBox.ClearOnEnter = false; // The text shouldn't be cleared if it hasn't been sent
return;
}
switch (text[0])
{
case ConCmdSlash:
@@ -225,13 +247,17 @@ namespace Content.Client.Chat
case OOCAlias:
{
var conInput = text.Substring(1);
if (string.IsNullOrWhiteSpace(conInput))
return;
_console.ProcessCommand($"ooc \"{CommandParsing.Escape(conInput)}\"");
break;
}
case AdminChatAlias:
{
var conInput = text.Substring(1);
if(_groupController.CanCommand("asay")){
if (string.IsNullOrWhiteSpace(conInput))
return;
if (_groupController.CanCommand("asay")){
_console.ProcessCommand($"asay \"{CommandParsing.Escape(conInput)}\"");
}
else
@@ -243,6 +269,8 @@ namespace Content.Client.Chat
case MeAlias:
{
var conInput = text.Substring(1);
if (string.IsNullOrWhiteSpace(conInput))
return;
_console.ProcessCommand($"me \"{CommandParsing.Escape(conInput)}\"");
break;
}
@@ -323,8 +351,6 @@ namespace Content.Client.Chat
private void _onChatMessage(MsgChatMessage msg)
{
Logger.Debug($"{msg.Channel}: {msg.Message}");
// Log all incoming chat to repopulate when filter is un-toggled
var storedMessage = new StoredChatMessage(msg);
filteredHistory.Add(storedMessage);
@@ -347,6 +373,17 @@ namespace Content.Client.Chat
}
}
private void _onMaxLengthReceived(ChatMaxMsgLengthMessage msg)
{
_maxMessageLength = msg.MaxMessageLength;
}
private void RequestMaxLength(object sender, NetChannelArgs args)
{
ChatMaxMsgLengthMessage msg = _netManager.CreateNetMessage<ChatMaxMsgLengthMessage>();
_netManager.ClientSendMessage(msg);
}
private void AddSpeechBubble(MsgChatMessage msg, SpeechBubble.SpeechType speechType)
{
if (!_entityManager.TryGetEntity(msg.SenderEntity, out var entity))