Added Whisper system for talking with players 2 tiles away. (#5994)
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
@@ -14,7 +14,8 @@ namespace Content.Client.Chat
|
|||||||
ChatChannel.OOC => Color.RoyalBlue,
|
ChatChannel.OOC => Color.RoyalBlue,
|
||||||
ChatChannel.Dead => Color.MediumPurple,
|
ChatChannel.Dead => Color.MediumPurple,
|
||||||
ChatChannel.Admin => Color.Red,
|
ChatChannel.Admin => Color.Red,
|
||||||
_ => Color.DarkGray
|
ChatChannel.Whisper => Color.DarkGray,
|
||||||
|
_ => Color.LightGray
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,9 @@ namespace Content.Client.Chat
|
|||||||
inputManager.SetInputCommand(ContentKeyFunctions.FocusLocalChat,
|
inputManager.SetInputCommand(ContentKeyFunctions.FocusLocalChat,
|
||||||
InputCmdHandler.FromDelegate(_ => GameScreen.FocusChannel(chatBox, ChatSelectChannel.Local)));
|
InputCmdHandler.FromDelegate(_ => GameScreen.FocusChannel(chatBox, ChatSelectChannel.Local)));
|
||||||
|
|
||||||
|
inputManager.SetInputCommand(ContentKeyFunctions.FocusWhisperChat,
|
||||||
|
InputCmdHandler.FromDelegate(_ => GameScreen.FocusChannel(chatBox, ChatSelectChannel.Whisper)));
|
||||||
|
|
||||||
inputManager.SetInputCommand(ContentKeyFunctions.FocusOOC,
|
inputManager.SetInputCommand(ContentKeyFunctions.FocusOOC,
|
||||||
InputCmdHandler.FromDelegate(_ => GameScreen.FocusChannel(chatBox, ChatSelectChannel.OOC)));
|
InputCmdHandler.FromDelegate(_ => GameScreen.FocusChannel(chatBox, ChatSelectChannel.OOC)));
|
||||||
|
|
||||||
|
|||||||
@@ -198,6 +198,7 @@ namespace Content.Client.Chat.Managers
|
|||||||
{
|
{
|
||||||
// can always hear local / radio / emote when in the game
|
// can always hear local / radio / emote when in the game
|
||||||
FilterableChannels |= ChatChannel.Local;
|
FilterableChannels |= ChatChannel.Local;
|
||||||
|
FilterableChannels |= ChatChannel.Whisper;
|
||||||
FilterableChannels |= ChatChannel.Radio;
|
FilterableChannels |= ChatChannel.Radio;
|
||||||
FilterableChannels |= ChatChannel.Emotes;
|
FilterableChannels |= ChatChannel.Emotes;
|
||||||
|
|
||||||
@@ -206,6 +207,7 @@ namespace Content.Client.Chat.Managers
|
|||||||
if (!IsGhost)
|
if (!IsGhost)
|
||||||
{
|
{
|
||||||
SelectableChannels |= ChatSelectChannel.Local;
|
SelectableChannels |= ChatSelectChannel.Local;
|
||||||
|
SelectableChannels |= ChatSelectChannel.Whisper;
|
||||||
SelectableChannels |= ChatSelectChannel.Radio;
|
SelectableChannels |= ChatSelectChannel.Radio;
|
||||||
SelectableChannels |= ChatSelectChannel.Emotes;
|
SelectableChannels |= ChatSelectChannel.Emotes;
|
||||||
}
|
}
|
||||||
@@ -353,6 +355,10 @@ namespace Content.Client.Chat.Managers
|
|||||||
_consoleHost.ExecuteCommand($"say \"{CommandParsing.Escape(str)}\"");
|
_consoleHost.ExecuteCommand($"say \"{CommandParsing.Escape(str)}\"");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case ChatSelectChannel.Whisper:
|
||||||
|
_consoleHost.ExecuteCommand($"whisper \"{CommandParsing.Escape(str)}\"");
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new ArgumentOutOfRangeException(nameof(channel), channel, null);
|
throw new ArgumentOutOfRangeException(nameof(channel), channel, null);
|
||||||
}
|
}
|
||||||
@@ -405,6 +411,10 @@ namespace Content.Client.Chat.Managers
|
|||||||
AddSpeechBubble(msg, SpeechBubble.SpeechType.Say);
|
AddSpeechBubble(msg, SpeechBubble.SpeechType.Say);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case ChatChannel.Whisper:
|
||||||
|
AddSpeechBubble(msg, SpeechBubble.SpeechType.Whisper);
|
||||||
|
break;
|
||||||
|
|
||||||
case ChatChannel.Dead:
|
case ChatChannel.Dead:
|
||||||
if (!IsGhost)
|
if (!IsGhost)
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ namespace Content.Client.Chat.UI
|
|||||||
private static readonly ChatChannel[] ChannelFilterOrder =
|
private static readonly ChatChannel[] ChannelFilterOrder =
|
||||||
{
|
{
|
||||||
ChatChannel.Local,
|
ChatChannel.Local,
|
||||||
|
ChatChannel.Whisper,
|
||||||
ChatChannel.Emotes,
|
ChatChannel.Emotes,
|
||||||
ChatChannel.Radio,
|
ChatChannel.Radio,
|
||||||
ChatChannel.OOC,
|
ChatChannel.OOC,
|
||||||
@@ -42,6 +43,7 @@ namespace Content.Client.Chat.UI
|
|||||||
private static readonly ChatSelectChannel[] ChannelSelectorOrder =
|
private static readonly ChatSelectChannel[] ChannelSelectorOrder =
|
||||||
{
|
{
|
||||||
ChatSelectChannel.Local,
|
ChatSelectChannel.Local,
|
||||||
|
ChatSelectChannel.Whisper,
|
||||||
ChatSelectChannel.Emotes,
|
ChatSelectChannel.Emotes,
|
||||||
ChatSelectChannel.Radio,
|
ChatSelectChannel.Radio,
|
||||||
ChatSelectChannel.LOOC,
|
ChatSelectChannel.LOOC,
|
||||||
@@ -59,10 +61,12 @@ namespace Content.Client.Chat.UI
|
|||||||
public const char AliasEmotes = '@';
|
public const char AliasEmotes = '@';
|
||||||
public const char AliasAdmin = ']';
|
public const char AliasAdmin = ']';
|
||||||
public const char AliasRadio = ';';
|
public const char AliasRadio = ';';
|
||||||
|
public const char AliasWhisper = ',';
|
||||||
|
|
||||||
private static readonly Dictionary<char, ChatSelectChannel> PrefixToChannel = new()
|
private static readonly Dictionary<char, ChatSelectChannel> PrefixToChannel = new()
|
||||||
{
|
{
|
||||||
{AliasLocal, ChatSelectChannel.Local},
|
{AliasLocal, ChatSelectChannel.Local},
|
||||||
|
{AliasWhisper, ChatSelectChannel.Whisper},
|
||||||
{AliasConsole, ChatSelectChannel.Console},
|
{AliasConsole, ChatSelectChannel.Console},
|
||||||
{AliasOOC, ChatSelectChannel.OOC},
|
{AliasOOC, ChatSelectChannel.OOC},
|
||||||
{AliasEmotes, ChatSelectChannel.Emotes},
|
{AliasEmotes, ChatSelectChannel.Emotes},
|
||||||
|
|||||||
@@ -16,7 +16,8 @@ namespace Content.Client.Chat.UI
|
|||||||
public enum SpeechType : byte
|
public enum SpeechType : byte
|
||||||
{
|
{
|
||||||
Emote,
|
Emote,
|
||||||
Say
|
Say,
|
||||||
|
Whisper
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -52,17 +53,20 @@ namespace Content.Client.Chat.UI
|
|||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case SpeechType.Emote:
|
case SpeechType.Emote:
|
||||||
return new EmoteSpeechBubble(text, senderEntity, eyeManager, chatManager, entityManager);
|
return new TextSpeechBubble(text, senderEntity, eyeManager, chatManager, entityManager, "emoteBox");
|
||||||
|
|
||||||
case SpeechType.Say:
|
case SpeechType.Say:
|
||||||
return new SaySpeechBubble(text, senderEntity, eyeManager, chatManager, entityManager);
|
return new TextSpeechBubble(text, senderEntity, eyeManager, chatManager, entityManager, "sayBox");
|
||||||
|
|
||||||
|
case SpeechType.Whisper:
|
||||||
|
return new TextSpeechBubble(text, senderEntity, eyeManager, chatManager, entityManager, "whisperBox");
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new ArgumentOutOfRangeException();
|
throw new ArgumentOutOfRangeException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public SpeechBubble(string text, EntityUid senderEntity, IEyeManager eyeManager, IChatManager chatManager, IEntityManager entityManager)
|
public SpeechBubble(string text, EntityUid senderEntity, IEyeManager eyeManager, IChatManager chatManager, IEntityManager entityManager, string speechStyleClass)
|
||||||
{
|
{
|
||||||
_chatManager = chatManager;
|
_chatManager = chatManager;
|
||||||
_senderEntity = senderEntity;
|
_senderEntity = senderEntity;
|
||||||
@@ -72,7 +76,7 @@ namespace Content.Client.Chat.UI
|
|||||||
// Use text clipping so new messages don't overlap old ones being pushed up.
|
// Use text clipping so new messages don't overlap old ones being pushed up.
|
||||||
RectClipContent = true;
|
RectClipContent = true;
|
||||||
|
|
||||||
var bubble = BuildBubble(text);
|
var bubble = BuildBubble(text, speechStyleClass);
|
||||||
|
|
||||||
AddChild(bubble);
|
AddChild(bubble);
|
||||||
|
|
||||||
@@ -83,7 +87,7 @@ namespace Content.Client.Chat.UI
|
|||||||
_verticalOffsetAchieved = -ContentHeight;
|
_verticalOffsetAchieved = -ContentHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract Control BuildBubble(string text);
|
protected abstract Control BuildBubble(string text, string speechStyleClass);
|
||||||
|
|
||||||
protected override void FrameUpdate(FrameEventArgs args)
|
protected override void FrameUpdate(FrameEventArgs args)
|
||||||
{
|
{
|
||||||
@@ -162,15 +166,15 @@ namespace Content.Client.Chat.UI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class EmoteSpeechBubble : SpeechBubble
|
public class TextSpeechBubble : SpeechBubble
|
||||||
|
|
||||||
{
|
{
|
||||||
public EmoteSpeechBubble(string text, EntityUid senderEntity, IEyeManager eyeManager, IChatManager chatManager, IEntityManager entityManager)
|
public TextSpeechBubble(string text, EntityUid senderEntity, IEyeManager eyeManager, IChatManager chatManager, IEntityManager entityManager, string speechStyleClass)
|
||||||
: base(text, senderEntity, eyeManager, chatManager, entityManager)
|
: base(text, senderEntity, eyeManager, chatManager, entityManager, speechStyleClass)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override Control BuildBubble(string text)
|
protected override Control BuildBubble(string text, string speechStyleClass)
|
||||||
{
|
{
|
||||||
var label = new RichTextLabel
|
var label = new RichTextLabel
|
||||||
{
|
{
|
||||||
@@ -180,33 +184,7 @@ namespace Content.Client.Chat.UI
|
|||||||
|
|
||||||
var panel = new PanelContainer
|
var panel = new PanelContainer
|
||||||
{
|
{
|
||||||
StyleClasses = { "speechBox", "emoteBox" },
|
StyleClasses = { "speechBox", speechStyleClass },
|
||||||
Children = { label },
|
|
||||||
ModulateSelfOverride = Color.White.WithAlpha(0.75f)
|
|
||||||
};
|
|
||||||
|
|
||||||
return panel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class SaySpeechBubble : SpeechBubble
|
|
||||||
{
|
|
||||||
public SaySpeechBubble(string text, EntityUid senderEntity, IEyeManager eyeManager, IChatManager chatManager, IEntityManager entityManager)
|
|
||||||
: base(text, senderEntity, eyeManager, chatManager, entityManager)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override Control BuildBubble(string text)
|
|
||||||
{
|
|
||||||
var label = new RichTextLabel
|
|
||||||
{
|
|
||||||
MaxWidth = 256,
|
|
||||||
};
|
|
||||||
label.SetMessage(text);
|
|
||||||
|
|
||||||
var panel = new PanelContainer
|
|
||||||
{
|
|
||||||
StyleClasses = { "speechBox", "sayBox" },
|
|
||||||
Children = { label },
|
Children = { label },
|
||||||
ModulateSelfOverride = Color.White.WithAlpha(0.75f)
|
ModulateSelfOverride = Color.White.WithAlpha(0.75f)
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -128,6 +128,7 @@ namespace Content.Client.EscapeMenu.UI.Tabs
|
|||||||
AddHeader("ui-options-header-ui");
|
AddHeader("ui-options-header-ui");
|
||||||
AddButton(ContentKeyFunctions.FocusChat);
|
AddButton(ContentKeyFunctions.FocusChat);
|
||||||
AddButton(ContentKeyFunctions.FocusLocalChat);
|
AddButton(ContentKeyFunctions.FocusLocalChat);
|
||||||
|
AddButton(ContentKeyFunctions.FocusWhisperChat);
|
||||||
AddButton(ContentKeyFunctions.FocusRadio);
|
AddButton(ContentKeyFunctions.FocusRadio);
|
||||||
AddButton(ContentKeyFunctions.FocusOOC);
|
AddButton(ContentKeyFunctions.FocusOOC);
|
||||||
AddButton(ContentKeyFunctions.FocusAdminChat);
|
AddButton(ContentKeyFunctions.FocusAdminChat);
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ namespace Content.Client.Input
|
|||||||
var common = contexts.GetContext("common");
|
var common = contexts.GetContext("common");
|
||||||
common.AddFunction(ContentKeyFunctions.FocusChat);
|
common.AddFunction(ContentKeyFunctions.FocusChat);
|
||||||
common.AddFunction(ContentKeyFunctions.FocusLocalChat);
|
common.AddFunction(ContentKeyFunctions.FocusLocalChat);
|
||||||
|
common.AddFunction(ContentKeyFunctions.FocusWhisperChat);
|
||||||
common.AddFunction(ContentKeyFunctions.FocusRadio);
|
common.AddFunction(ContentKeyFunctions.FocusRadio);
|
||||||
common.AddFunction(ContentKeyFunctions.FocusOOC);
|
common.AddFunction(ContentKeyFunctions.FocusOOC);
|
||||||
common.AddFunction(ContentKeyFunctions.FocusAdminChat);
|
common.AddFunction(ContentKeyFunctions.FocusAdminChat);
|
||||||
|
|||||||
@@ -349,6 +349,15 @@ namespace Content.Client.Stylesheets
|
|||||||
tooltipBox.SetPatchMargin(StyleBox.Margin.All, 2);
|
tooltipBox.SetPatchMargin(StyleBox.Margin.All, 2);
|
||||||
tooltipBox.SetContentMarginOverride(StyleBox.Margin.Horizontal, 7);
|
tooltipBox.SetContentMarginOverride(StyleBox.Margin.Horizontal, 7);
|
||||||
|
|
||||||
|
// Whisper box
|
||||||
|
var whisperTexture = resCache.GetTexture("/Textures/Interface/Nano/whisper.png");
|
||||||
|
var whisperBox = new StyleBoxTexture
|
||||||
|
{
|
||||||
|
Texture = whisperTexture,
|
||||||
|
};
|
||||||
|
whisperBox.SetPatchMargin(StyleBox.Margin.All, 2);
|
||||||
|
whisperBox.SetContentMarginOverride(StyleBox.Margin.Horizontal, 7);
|
||||||
|
|
||||||
// Placeholder
|
// Placeholder
|
||||||
var placeholderTexture = resCache.GetTexture("/Textures/Interface/Nano/placeholder.png");
|
var placeholderTexture = resCache.GetTexture("/Textures/Interface/Nano/placeholder.png");
|
||||||
var placeholder = new StyleBoxTexture {Texture = placeholderTexture};
|
var placeholder = new StyleBoxTexture {Texture = placeholderTexture};
|
||||||
@@ -778,6 +787,11 @@ namespace Content.Client.Stylesheets
|
|||||||
new StyleProperty(PanelContainer.StylePropertyPanel, tooltipBox)
|
new StyleProperty(PanelContainer.StylePropertyPanel, tooltipBox)
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
new StyleRule(new SelectorElement(typeof(PanelContainer), new[] {"speechBox", "whisperBox"}, null, null), new[]
|
||||||
|
{
|
||||||
|
new StyleProperty(PanelContainer.StylePropertyPanel, whisperBox)
|
||||||
|
}),
|
||||||
|
|
||||||
new StyleRule(new SelectorChild(
|
new StyleRule(new SelectorChild(
|
||||||
new SelectorElement(typeof(PanelContainer), new[] {"speechBox", "emoteBox"}, null, null),
|
new SelectorElement(typeof(PanelContainer), new[] {"speechBox", "emoteBox"}, null, null),
|
||||||
new SelectorElement(typeof(RichTextLabel), null, null, null)),
|
new SelectorElement(typeof(RichTextLabel), null, null, null)),
|
||||||
|
|||||||
@@ -18,14 +18,13 @@ namespace Content.Server.Chat.Commands
|
|||||||
|
|
||||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||||
{
|
{
|
||||||
var player = shell.Player as IPlayerSession;
|
if (shell.Player is not IPlayerSession player)
|
||||||
if (player == null)
|
|
||||||
{
|
{
|
||||||
shell.WriteLine("This command cannot be run from the server.");
|
shell.WriteError("This command cannot be run from the server.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.Status != SessionStatus.InGame || player.AttachedEntity == null)
|
if (player.Status != SessionStatus.InGame)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (args.Length < 1)
|
if (args.Length < 1)
|
||||||
@@ -35,22 +34,7 @@ namespace Content.Server.Chat.Commands
|
|||||||
if (string.IsNullOrEmpty(message))
|
if (string.IsNullOrEmpty(message))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var chat = IoCManager.Resolve<IChatManager>();
|
IoCManager.Resolve<IChatManager>().SendLOOC(player, message);
|
||||||
var mindComponent = player.ContentData()?.Mind;
|
|
||||||
|
|
||||||
if (mindComponent == null)
|
|
||||||
{
|
|
||||||
shell.WriteError("You don't have a mind!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mindComponent.OwnedEntity == null)
|
|
||||||
{
|
|
||||||
shell.WriteError("You don't have an entity!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
chat.EntityLOOC(mindComponent.OwnedEntity.Value, message);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,11 +16,9 @@ namespace Content.Server.Chat.Commands
|
|||||||
|
|
||||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||||
{
|
{
|
||||||
var player = (IPlayerSession?) shell.Player;
|
if (shell.Player is not IPlayerSession player)
|
||||||
|
|
||||||
if (player == null)
|
|
||||||
{
|
{
|
||||||
shell.WriteError("You can't run this command locally.");
|
shell.WriteError("This command cannot be run from the server.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,8 +29,7 @@ namespace Content.Server.Chat.Commands
|
|||||||
if (string.IsNullOrEmpty(message))
|
if (string.IsNullOrEmpty(message))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var chat = IoCManager.Resolve<IChatManager>();
|
IoCManager.Resolve<IChatManager>().SendOOC(player, message);
|
||||||
chat.SendOOC(player, message);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,8 @@
|
|||||||
using Content.Server.Administration;
|
|
||||||
using Content.Server.Chat.Managers;
|
using Content.Server.Chat.Managers;
|
||||||
using Content.Server.Ghost.Components;
|
|
||||||
using Content.Server.Players;
|
|
||||||
using Content.Shared.Administration;
|
using Content.Shared.Administration;
|
||||||
using Robust.Server.Player;
|
using Robust.Server.Player;
|
||||||
using Robust.Shared.Console;
|
using Robust.Shared.Console;
|
||||||
using Robust.Shared.Enums;
|
using Robust.Shared.Enums;
|
||||||
using Robust.Shared.GameObjects;
|
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
|
|
||||||
namespace Content.Server.Chat.Commands
|
namespace Content.Server.Chat.Commands
|
||||||
@@ -22,7 +18,7 @@ namespace Content.Server.Chat.Commands
|
|||||||
{
|
{
|
||||||
if (shell.Player is not IPlayerSession player)
|
if (shell.Player is not IPlayerSession player)
|
||||||
{
|
{
|
||||||
shell.WriteLine("This command cannot be run from the server.");
|
shell.WriteError("This command cannot be run from the server.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,7 +27,7 @@ namespace Content.Server.Chat.Commands
|
|||||||
|
|
||||||
if (player.AttachedEntity is not {} playerEntity)
|
if (player.AttachedEntity is not {} playerEntity)
|
||||||
{
|
{
|
||||||
shell.WriteLine("You don't have an entity!");
|
shell.WriteError("You don't have an entity!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,34 +38,7 @@ namespace Content.Server.Chat.Commands
|
|||||||
if (string.IsNullOrEmpty(message))
|
if (string.IsNullOrEmpty(message))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var chat = IoCManager.Resolve<IChatManager>();
|
IoCManager.Resolve<IChatManager>().TrySpeak(playerEntity, message, false, shell, player);
|
||||||
var chatSanitizer = IoCManager.Resolve<IChatSanitizationManager>();
|
|
||||||
|
|
||||||
if (IoCManager.Resolve<IEntityManager>().HasComponent<GhostComponent>(playerEntity))
|
|
||||||
chat.SendDeadChat(player, message);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var mindComponent = player.ContentData()?.Mind;
|
|
||||||
|
|
||||||
if (mindComponent == null)
|
|
||||||
{
|
|
||||||
shell.WriteError("You don't have a mind!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mindComponent.OwnedEntity is not {Valid: true} owned)
|
|
||||||
{
|
|
||||||
shell.WriteError("You don't have an entity!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var emote = chatSanitizer.TrySanitizeOutSmilies(message, owned, out var sanitized, out var emoteStr);
|
|
||||||
if (sanitized.Length != 0)
|
|
||||||
chat.EntitySay(owned, sanitized);
|
|
||||||
if (emote)
|
|
||||||
chat.EntityMe(owned, emoteStr!);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
44
Content.Server/Chat/Commands/WhisperCommand.cs
Normal file
44
Content.Server/Chat/Commands/WhisperCommand.cs
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
using Content.Server.Chat.Managers;
|
||||||
|
using Content.Shared.Administration;
|
||||||
|
using Robust.Server.Player;
|
||||||
|
using Robust.Shared.Console;
|
||||||
|
using Robust.Shared.Enums;
|
||||||
|
using Robust.Shared.IoC;
|
||||||
|
|
||||||
|
namespace Content.Server.Chat.Commands
|
||||||
|
{
|
||||||
|
[AnyCommand]
|
||||||
|
internal class WhisperCommand : IConsoleCommand
|
||||||
|
{
|
||||||
|
public string Command => "whisper";
|
||||||
|
public string Description => "Send chat messages to the local channel as a whisper";
|
||||||
|
public string Help => "whisper <text>";
|
||||||
|
|
||||||
|
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||||
|
{
|
||||||
|
if (shell.Player is not IPlayerSession player)
|
||||||
|
{
|
||||||
|
shell.WriteError("This command cannot be run from the server.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (player.Status != SessionStatus.InGame)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (player.AttachedEntity is not {} playerEntity)
|
||||||
|
{
|
||||||
|
shell.WriteError("You don't have an entity!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.Length < 1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var message = string.Join(" ", args).Trim();
|
||||||
|
if (string.IsNullOrEmpty(message))
|
||||||
|
return;
|
||||||
|
|
||||||
|
IoCManager.Resolve<IChatManager>().TrySpeak(playerEntity, message, true, shell, player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,9 +1,11 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
using Content.Server.Administration.Managers;
|
using Content.Server.Administration.Managers;
|
||||||
using Content.Server.Ghost.Components;
|
using Content.Server.Ghost.Components;
|
||||||
using Content.Server.Headset;
|
using Content.Server.Headset;
|
||||||
using Content.Server.MoMMI;
|
using Content.Server.MoMMI;
|
||||||
|
using Content.Server.Players;
|
||||||
using Content.Server.Preferences.Managers;
|
using Content.Server.Preferences.Managers;
|
||||||
using Content.Server.Radio.EntitySystems;
|
using Content.Server.Radio.EntitySystems;
|
||||||
using Content.Shared.ActionBlocker;
|
using Content.Shared.ActionBlocker;
|
||||||
@@ -16,12 +18,15 @@ using Robust.Server.GameObjects;
|
|||||||
using Robust.Server.Player;
|
using Robust.Server.Player;
|
||||||
using Robust.Shared.Audio;
|
using Robust.Shared.Audio;
|
||||||
using Robust.Shared.Configuration;
|
using Robust.Shared.Configuration;
|
||||||
|
using Robust.Shared.Console;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Localization;
|
using Robust.Shared.Localization;
|
||||||
using Robust.Shared.Log;
|
using Robust.Shared.Log;
|
||||||
using Robust.Shared.Network;
|
using Robust.Shared.Network;
|
||||||
using Robust.Shared.Player;
|
using Robust.Shared.Player;
|
||||||
|
using Robust.Shared.Players;
|
||||||
|
using Robust.Shared.Random;
|
||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
using static Content.Server.Chat.Managers.IChatManager;
|
using static Content.Server.Chat.Managers.IChatManager;
|
||||||
|
|
||||||
@@ -40,6 +45,7 @@ namespace Content.Server.Chat.Managers
|
|||||||
{ "revolutionary", "#aa00ff" }
|
{ "revolutionary", "#aa00ff" }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
[Dependency] private readonly IChatSanitizationManager _sanitizer = default!;
|
||||||
[Dependency] private readonly IEntityManager _entManager = default!;
|
[Dependency] private readonly IEntityManager _entManager = default!;
|
||||||
[Dependency] private readonly IServerNetManager _netManager = default!;
|
[Dependency] private readonly IServerNetManager _netManager = default!;
|
||||||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||||
@@ -47,6 +53,7 @@ namespace Content.Server.Chat.Managers
|
|||||||
[Dependency] private readonly IAdminManager _adminManager = default!;
|
[Dependency] private readonly IAdminManager _adminManager = default!;
|
||||||
[Dependency] private readonly IServerPreferencesManager _preferencesManager = default!;
|
[Dependency] private readonly IServerPreferencesManager _preferencesManager = default!;
|
||||||
[Dependency] private readonly IConfigurationManager _configurationManager = default!;
|
[Dependency] private readonly IConfigurationManager _configurationManager = default!;
|
||||||
|
[Dependency] private readonly IRobustRandom _random = default!;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The maximum length a player-sent message can be sent
|
/// The maximum length a player-sent message can be sent
|
||||||
@@ -54,6 +61,7 @@ namespace Content.Server.Chat.Managers
|
|||||||
public int MaxMessageLength => _configurationManager.GetCVar(CCVars.ChatMaxMessageLength);
|
public int MaxMessageLength => _configurationManager.GetCVar(CCVars.ChatMaxMessageLength);
|
||||||
|
|
||||||
private const int VoiceRange = 7; // how far voice goes in world units
|
private const int VoiceRange = 7; // how far voice goes in world units
|
||||||
|
private const int WhisperRange = 2; // how far whisper goes in world units
|
||||||
|
|
||||||
//TODO: make prio based?
|
//TODO: make prio based?
|
||||||
private readonly List<TransformChat> _chatTransformHandlers = new();
|
private readonly List<TransformChat> _chatTransformHandlers = new();
|
||||||
@@ -91,21 +99,15 @@ namespace Content.Server.Chat.Managers
|
|||||||
|
|
||||||
public void DispatchServerAnnouncement(string message)
|
public void DispatchServerAnnouncement(string message)
|
||||||
{
|
{
|
||||||
var msg = _netManager.CreateNetMessage<MsgChatMessage>();
|
var messageWrap = Loc.GetString("chat-manager-server-wrap-message");
|
||||||
msg.Channel = ChatChannel.Server;
|
NetMessageToAll(ChatChannel.Server, message, messageWrap);
|
||||||
msg.Message = message;
|
|
||||||
msg.MessageWrap = Loc.GetString("chat-manager-server-wrap-message");
|
|
||||||
_netManager.ServerSendToAll(msg);
|
|
||||||
Logger.InfoS("SERVER", message);
|
Logger.InfoS("SERVER", message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DispatchStationAnnouncement(string message, string sender = "CentComm", bool playDefaultSound = true)
|
public void DispatchStationAnnouncement(string message, string sender = "CentComm", bool playDefaultSound = true)
|
||||||
{
|
{
|
||||||
var msg = _netManager.CreateNetMessage<MsgChatMessage>();
|
var messageWrap = Loc.GetString("chat-manager-sender-announcement-wrap-message", ("sender", sender));
|
||||||
msg.Channel = ChatChannel.Radio;
|
NetMessageToAll(ChatChannel.Radio, message, messageWrap);
|
||||||
msg.Message = message;
|
|
||||||
msg.MessageWrap = Loc.GetString("chat-manager-sender-announcement-wrap-message", ("sender", sender));
|
|
||||||
_netManager.ServerSendToAll(msg);
|
|
||||||
if (playDefaultSound)
|
if (playDefaultSound)
|
||||||
{
|
{
|
||||||
SoundSystem.Play(Filter.Broadcast(), "/Audio/Announcements/announce.ogg", AudioParams.Default.WithVolume(-2f));
|
SoundSystem.Play(Filter.Broadcast(), "/Audio/Announcements/announce.ogg", AudioParams.Default.WithVolume(-2f));
|
||||||
@@ -114,13 +116,53 @@ namespace Content.Server.Chat.Managers
|
|||||||
|
|
||||||
public void DispatchServerMessage(IPlayerSession player, string message)
|
public void DispatchServerMessage(IPlayerSession player, string message)
|
||||||
{
|
{
|
||||||
|
var messageWrap = Loc.GetString("chat-manager-server-wrap-message");
|
||||||
var msg = _netManager.CreateNetMessage<MsgChatMessage>();
|
var msg = _netManager.CreateNetMessage<MsgChatMessage>();
|
||||||
msg.Channel = ChatChannel.Server;
|
msg.Channel = ChatChannel.Server;
|
||||||
msg.Message = message;
|
msg.Message = message;
|
||||||
msg.MessageWrap = Loc.GetString("chat-manager-server-wrap-message");
|
msg.MessageWrap = messageWrap;
|
||||||
_netManager.ServerSendMessage(msg, player.ConnectedClient);
|
_netManager.ServerSendMessage(msg, player.ConnectedClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void TrySpeak(EntityUid source, string message, bool whisper = false, IConsoleShell? shell = null, IPlayerSession? player = null)
|
||||||
|
{
|
||||||
|
// Listen it avoids the 30 lines being copy-paste and means only 1 source needs updating if something changes.
|
||||||
|
if (_entManager.HasComponent<GhostComponent>(source))
|
||||||
|
{
|
||||||
|
if (player == null) return;
|
||||||
|
SendDeadChat(player, message);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var mindComponent = player?.ContentData()?.Mind;
|
||||||
|
|
||||||
|
if (mindComponent == null)
|
||||||
|
{
|
||||||
|
shell?.WriteError("You don't have a mind!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mindComponent.OwnedEntity is not {Valid: true} owned)
|
||||||
|
{
|
||||||
|
shell?.WriteError("You don't have an entity!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var emote = _sanitizer.TrySanitizeOutSmilies(message, owned, out var sanitized, out var emoteStr);
|
||||||
|
|
||||||
|
if (sanitized.Length != 0)
|
||||||
|
{
|
||||||
|
if (whisper)
|
||||||
|
EntityWhisper(owned, sanitized);
|
||||||
|
else
|
||||||
|
EntitySay(owned, sanitized);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (emote)
|
||||||
|
EntityMe(owned, emoteStr!);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void EntitySay(EntityUid source, string message, bool hideChat=false)
|
public void EntitySay(EntityUid source, string message, bool hideChat=false)
|
||||||
{
|
{
|
||||||
if (!EntitySystem.Get<ActionBlockerSystem>().CanSpeak(source))
|
if (!EntitySystem.Get<ActionBlockerSystem>().CanSpeak(source))
|
||||||
@@ -128,14 +170,8 @@ namespace Content.Server.Chat.Managers
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if message exceeds the character limit if the sender is a player
|
if (MessageCharacterLimit(source, message))
|
||||||
if (_entManager.TryGetComponent(source, out ActorComponent? actor) &&
|
|
||||||
message.Length > MaxMessageLength)
|
|
||||||
{
|
{
|
||||||
var feedback = Loc.GetString("chat-manager-max-message-length-exceeded-message", ("limit", MaxMessageLength));
|
|
||||||
|
|
||||||
DispatchServerMessage(actor.PlayerSession, feedback);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,68 +183,76 @@ namespace Content.Server.Chat.Managers
|
|||||||
|
|
||||||
message = message.Trim();
|
message = message.Trim();
|
||||||
|
|
||||||
// We'll try to avoid using MapPosition as EntityCoordinates can early-out and potentially be faster for common use cases
|
message = SanitizeMessageCapital(source, message);
|
||||||
// Downside is it may potentially convert to MapPosition unnecessarily.
|
|
||||||
var sourceMapId = _entManager.GetComponent<TransformComponent>(source).MapID;
|
|
||||||
var sourceCoords = _entManager.GetComponent<TransformComponent>(source).Coordinates;
|
|
||||||
|
|
||||||
var clients = new List<INetChannel>();
|
|
||||||
|
|
||||||
foreach (var player in _playerManager.Sessions)
|
|
||||||
{
|
|
||||||
if (player.AttachedEntity is not {Valid: true} playerEntity)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
var transform = _entManager.GetComponent<TransformComponent>(playerEntity);
|
|
||||||
|
|
||||||
if (transform.MapID != sourceMapId ||
|
|
||||||
!_entManager.HasComponent<GhostComponent>(playerEntity) &&
|
|
||||||
!sourceCoords.InRange(_entManager, transform.Coordinates, VoiceRange))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
clients.Add(player.ConnectedClient);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (message.StartsWith(';'))
|
|
||||||
{
|
|
||||||
// Remove semicolon
|
|
||||||
message = message.Substring(1).TrimStart();
|
|
||||||
|
|
||||||
// Capitalize first letter
|
|
||||||
message = message[0].ToString().ToUpper() +
|
|
||||||
message.Remove(0, 1);
|
|
||||||
|
|
||||||
var invSystem = EntitySystem.Get<InventorySystem>();
|
|
||||||
|
|
||||||
if (invSystem.TryGetSlotEntity(source, "ears", out var entityUid) &&
|
|
||||||
_entManager.TryGetComponent(entityUid, out HeadsetComponent? headset))
|
|
||||||
{
|
|
||||||
headset.RadioRequested = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
source.PopupMessage(Loc.GetString("chat-manager-no-headset-on-message"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Capitalize first letter
|
|
||||||
message = message[0].ToString().ToUpper() +
|
|
||||||
message.Remove(0, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
var listeners = EntitySystem.Get<ListeningSystem>();
|
var listeners = EntitySystem.Get<ListeningSystem>();
|
||||||
listeners.PingListeners(source, message);
|
listeners.PingListeners(source, message);
|
||||||
|
|
||||||
message = FormattedMessage.EscapeText(message);
|
message = FormattedMessage.EscapeText(message);
|
||||||
|
|
||||||
var msg = _netManager.CreateNetMessage<MsgChatMessage>();
|
var sessions = new List<ICommonSession>();
|
||||||
msg.Channel = ChatChannel.Local;
|
ClientDistanceToList(source, VoiceRange, sessions);
|
||||||
msg.Message = message;
|
|
||||||
msg.MessageWrap = Loc.GetString("chat-manager-entity-say-wrap-message",("entityName", _entManager.GetComponent<MetaDataComponent>(source).EntityName));
|
var messageWrap = Loc.GetString("chat-manager-entity-say-wrap-message",("entityName", _entManager.GetComponent<MetaDataComponent>(source).EntityName));
|
||||||
msg.SenderEntity = source;
|
|
||||||
msg.HideChat = hideChat;
|
foreach (var session in sessions)
|
||||||
_netManager.ServerSendToMany(msg, clients);
|
{
|
||||||
|
NetMessageToOne(ChatChannel.Local, message, messageWrap, source, hideChat, session.ConnectedClient);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void EntityWhisper(EntityUid source, string message, bool hideChat=false)
|
||||||
|
{
|
||||||
|
if (!EntitySystem.Get<ActionBlockerSystem>().CanSpeak(source))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (MessageCharacterLimit(source, message))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var handler in _chatTransformHandlers)
|
||||||
|
{
|
||||||
|
//TODO: rather return a bool and use a out var?
|
||||||
|
message = handler(source, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
message = message.Trim();
|
||||||
|
|
||||||
|
message = SanitizeMessageCapital(source, message);
|
||||||
|
|
||||||
|
var listeners = EntitySystem.Get<ListeningSystem>();
|
||||||
|
listeners.PingListeners(source, message);
|
||||||
|
|
||||||
|
message = FormattedMessage.EscapeText(message);
|
||||||
|
|
||||||
|
var obfuscatedMessage = ObfuscateMessageReadability(message, 0.2f);
|
||||||
|
|
||||||
|
var sessions = new List<ICommonSession>();
|
||||||
|
ClientDistanceToList(source, VoiceRange, sessions);
|
||||||
|
|
||||||
|
var transformSource = _entManager.GetComponent<TransformComponent>(source);
|
||||||
|
var sourceCoords = transformSource.Coordinates;
|
||||||
|
var messageWrap = Loc.GetString("chat-manager-entity-whisper-wrap-message",("entityName", _entManager.GetComponent<MetaDataComponent>(source).EntityName));
|
||||||
|
|
||||||
|
foreach (var session in sessions)
|
||||||
|
{
|
||||||
|
if (session.AttachedEntity is not {Valid: true} playerEntity)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var transformEntity = _entManager.GetComponent<TransformComponent>(playerEntity);
|
||||||
|
|
||||||
|
if (sourceCoords.InRange(_entManager, transformEntity.Coordinates, WhisperRange))
|
||||||
|
{
|
||||||
|
NetMessageToOne(ChatChannel.Whisper, message, messageWrap, source, hideChat, session.ConnectedClient);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NetMessageToOne(ChatChannel.Whisper, obfuscatedMessage, messageWrap, source, hideChat, session.ConnectedClient);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void EntityMe(EntityUid source, string action)
|
public void EntityMe(EntityUid source, string action)
|
||||||
@@ -218,44 +262,28 @@ namespace Content.Server.Chat.Managers
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if entity is a player
|
if (MessageCharacterLimit(source, action))
|
||||||
if (!_entManager.TryGetComponent(source, out ActorComponent? actor))
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if message exceeds the character limit
|
|
||||||
if (action.Length > MaxMessageLength)
|
|
||||||
{
|
|
||||||
DispatchServerMessage(actor.PlayerSession, Loc.GetString("chat-manager-max-message-length-exceeded-message",("limit", MaxMessageLength)));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
action = FormattedMessage.EscapeText(action);
|
action = FormattedMessage.EscapeText(action);
|
||||||
|
|
||||||
var clients = Filter.Empty()
|
var sessions = new List<ICommonSession>();
|
||||||
.AddInRange(_entManager.GetComponent<TransformComponent>(source).MapPosition, VoiceRange)
|
|
||||||
.Recipients
|
|
||||||
.Select(p => p.ConnectedClient)
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
var msg = _netManager.CreateNetMessage<MsgChatMessage>();
|
ClientDistanceToList(source, VoiceRange, sessions);
|
||||||
msg.Channel = ChatChannel.Emotes;
|
|
||||||
msg.Message = action;
|
var messageWrap = Loc.GetString("chat-manager-entity-me-wrap-message", ("entityName", _entManager.GetComponent<MetaDataComponent>(source).EntityName));
|
||||||
msg.MessageWrap = Loc.GetString("chat-manager-entity-me-wrap-message", ("entityName", _entManager.GetComponent<MetaDataComponent>(source).EntityName));
|
|
||||||
msg.SenderEntity = source;
|
foreach (var session in sessions)
|
||||||
_netManager.ServerSendToMany(msg, clients);
|
{
|
||||||
|
NetMessageToOne(ChatChannel.Emotes, action, messageWrap, source, true, session.ConnectedClient);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void EntityLOOC(EntityUid source, string message)
|
public void SendLOOC(IPlayerSession player, string message)
|
||||||
{
|
{
|
||||||
// Check if entity is a player
|
if (_adminManager.IsAdmin(player))
|
||||||
if (!_entManager.TryGetComponent(source, out ActorComponent? actor))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_adminManager.IsAdmin(actor.PlayerSession))
|
|
||||||
{
|
{
|
||||||
if (!_adminLoocEnabled)
|
if (!_adminLoocEnabled)
|
||||||
{
|
{
|
||||||
@@ -267,17 +295,23 @@ namespace Content.Server.Chat.Managers
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check they're even attached to an entity before we potentially send a message length error.
|
||||||
|
if (player.AttachedEntity is not { } entity)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Check if message exceeds the character limit
|
// Check if message exceeds the character limit
|
||||||
if (message.Length > MaxMessageLength)
|
if (message.Length > MaxMessageLength)
|
||||||
{
|
{
|
||||||
DispatchServerMessage(actor.PlayerSession, Loc.GetString("chat-manager-max-message-length-exceeded-message", ("limit", MaxMessageLength)));
|
DispatchServerMessage(player, Loc.GetString("chat-manager-max-message-length-exceeded-message", ("limit", MaxMessageLength)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
message = FormattedMessage.EscapeText(message);
|
message = FormattedMessage.EscapeText(message);
|
||||||
|
|
||||||
var clients = Filter.Empty()
|
var clients = Filter.Empty()
|
||||||
.AddInRange(_entManager.GetComponent<TransformComponent>(source).MapPosition, VoiceRange)
|
.AddInRange(_entManager.GetComponent<TransformComponent>(entity).MapPosition, VoiceRange)
|
||||||
.Recipients
|
.Recipients
|
||||||
.Select(p => p.ConnectedClient)
|
.Select(p => p.ConnectedClient)
|
||||||
.ToList();
|
.ToList();
|
||||||
@@ -285,9 +319,10 @@ namespace Content.Server.Chat.Managers
|
|||||||
var msg = _netManager.CreateNetMessage<MsgChatMessage>();
|
var msg = _netManager.CreateNetMessage<MsgChatMessage>();
|
||||||
msg.Channel = ChatChannel.LOOC;
|
msg.Channel = ChatChannel.LOOC;
|
||||||
msg.Message = message;
|
msg.Message = message;
|
||||||
msg.MessageWrap = Loc.GetString("chat-manager-entity-looc-wrap-message", ("entityName", Name: _entManager.GetComponent<MetaDataComponent>(source).EntityName));
|
msg.MessageWrap = Loc.GetString("chat-manager-entity-looc-wrap-message", ("entityName", Name: _entManager.GetComponent<MetaDataComponent>(entity).EntityName));
|
||||||
_netManager.ServerSendToMany(msg, clients);
|
_netManager.ServerSendToMany(msg, clients);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SendOOC(IPlayerSession player, string message)
|
public void SendOOC(IPlayerSession player, string message)
|
||||||
{
|
{
|
||||||
if (_adminManager.IsAdmin(player))
|
if (_adminManager.IsAdmin(player))
|
||||||
@@ -432,12 +467,8 @@ namespace Content.Server.Chat.Managers
|
|||||||
public void SendHookOOC(string sender, string message)
|
public void SendHookOOC(string sender, string message)
|
||||||
{
|
{
|
||||||
message = FormattedMessage.EscapeText(message);
|
message = FormattedMessage.EscapeText(message);
|
||||||
|
var messageWrap = Loc.GetString("chat-manager-send-hook-ooc-wrap-message", ("senderName", sender));
|
||||||
var msg = _netManager.CreateNetMessage<MsgChatMessage>();
|
NetMessageToAll(ChatChannel.OOC, message, messageWrap);
|
||||||
msg.Channel = ChatChannel.OOC;
|
|
||||||
msg.Message = message;
|
|
||||||
msg.MessageWrap = Loc.GetString("chat-manager-send-hook-ooc-wrap-message", ("senderName", sender));
|
|
||||||
_netManager.ServerSendToAll(msg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RegisterChatTransform(TransformChat handler)
|
public void RegisterChatTransform(TransformChat handler)
|
||||||
@@ -445,5 +476,120 @@ namespace Content.Server.Chat.Managers
|
|||||||
// TODO: Literally just make this an event...
|
// TODO: Literally just make this an event...
|
||||||
_chatTransformHandlers.Add(handler);
|
_chatTransformHandlers.Add(handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string SanitizeMessageCapital(EntityUid source, string message)
|
||||||
|
{
|
||||||
|
if (message.StartsWith(';'))
|
||||||
|
{
|
||||||
|
// Remove semicolon
|
||||||
|
message = message.Substring(1).TrimStart();
|
||||||
|
|
||||||
|
// Capitalize first letter
|
||||||
|
message = message[0].ToString().ToUpper() + message.Remove(0, 1);
|
||||||
|
|
||||||
|
var invSystem = EntitySystem.Get<InventorySystem>();
|
||||||
|
|
||||||
|
if (invSystem.TryGetSlotEntity(source, "ears", out var entityUid) &&
|
||||||
|
_entManager.TryGetComponent(entityUid, out HeadsetComponent? headset))
|
||||||
|
{
|
||||||
|
headset.RadioRequested = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
source.PopupMessage(Loc.GetString("chat-manager-no-headset-on-message"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Capitalize first letter
|
||||||
|
message = message[0].ToString().ToUpper() + message.Remove(0, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void NetMessageToOne(ChatChannel channel, string message, string messageWrap, EntityUid source, bool hideChat, INetChannel client)
|
||||||
|
{
|
||||||
|
var msg = _netManager.CreateNetMessage<MsgChatMessage>();
|
||||||
|
msg.Channel = channel;
|
||||||
|
msg.Message = message;
|
||||||
|
msg.MessageWrap = messageWrap;
|
||||||
|
msg.SenderEntity = source;
|
||||||
|
msg.HideChat = hideChat;
|
||||||
|
_netManager.ServerSendMessage(msg, client);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void NetMessageToAll(ChatChannel channel, string message, string messageWrap)
|
||||||
|
{
|
||||||
|
var msg = _netManager.CreateNetMessage<MsgChatMessage>();
|
||||||
|
msg.Channel = channel;
|
||||||
|
msg.Message = message;
|
||||||
|
msg.MessageWrap = messageWrap;
|
||||||
|
_netManager.ServerSendToAll(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool MessageCharacterLimit(EntityUid source, string message)
|
||||||
|
{
|
||||||
|
var isOverLength = false;
|
||||||
|
|
||||||
|
// Check if message exceeds the character limit if the sender is a player
|
||||||
|
if (_entManager.TryGetComponent(source, out ActorComponent? actor) &&
|
||||||
|
message.Length > MaxMessageLength)
|
||||||
|
{
|
||||||
|
var feedback = Loc.GetString("chat-manager-max-message-length-exceeded-message", ("limit", MaxMessageLength));
|
||||||
|
|
||||||
|
DispatchServerMessage(actor.PlayerSession, feedback);
|
||||||
|
|
||||||
|
isOverLength = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return isOverLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ClientDistanceToList(EntityUid source, int voiceRange, List<ICommonSession> playerSessions)
|
||||||
|
{
|
||||||
|
var transformSource = _entManager.GetComponent<TransformComponent>(source);
|
||||||
|
var sourceMapId = transformSource.MapID;
|
||||||
|
var sourceCoords = transformSource.Coordinates;
|
||||||
|
|
||||||
|
foreach (var player in _playerManager.Sessions)
|
||||||
|
{
|
||||||
|
if (player.AttachedEntity is not {Valid: true} playerEntity)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var transformEntity = _entManager.GetComponent<TransformComponent>(playerEntity);
|
||||||
|
|
||||||
|
if (transformEntity.MapID != sourceMapId ||
|
||||||
|
!_entManager.HasComponent<GhostComponent>(playerEntity) &&
|
||||||
|
!sourceCoords.InRange(_entManager, transformEntity.Coordinates, voiceRange))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
playerSessions.Add(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ObfuscateMessageReadability(string message, float chance)
|
||||||
|
{
|
||||||
|
var modifiedMessage = new StringBuilder(message);
|
||||||
|
|
||||||
|
for (var i = 0; i < message.Length; i++)
|
||||||
|
{
|
||||||
|
if (char.IsWhiteSpace((modifiedMessage[i])))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_random.Prob(chance))
|
||||||
|
{
|
||||||
|
modifiedMessage[i] = modifiedMessage[i];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
modifiedMessage[i] = '~';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return modifiedMessage.ToString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ namespace Content.Server.Chat.Managers;
|
|||||||
|
|
||||||
public class ChatSanitizationManager : IChatSanitizationManager
|
public class ChatSanitizationManager : IChatSanitizationManager
|
||||||
{
|
{
|
||||||
[Dependency] private IConfigurationManager _configurationManager = default!;
|
[Dependency] private readonly IConfigurationManager _configurationManager = default!;
|
||||||
|
|
||||||
private static readonly Dictionary<string, string> SmileyToEmote = new()
|
private static readonly Dictionary<string, string> SmileyToEmote = new()
|
||||||
{
|
{
|
||||||
@@ -68,16 +68,16 @@ public class ChatSanitizationManager : IChatSanitizationManager
|
|||||||
{ "idk", "chatsan-shrugs" }
|
{ "idk", "chatsan-shrugs" }
|
||||||
};
|
};
|
||||||
|
|
||||||
private bool doSanitize = false;
|
private bool _doSanitize;
|
||||||
|
|
||||||
public void Initialize()
|
public void Initialize()
|
||||||
{
|
{
|
||||||
_configurationManager.OnValueChanged(CCVars.ChatSanitizerEnabled, x => doSanitize = x, true);
|
_configurationManager.OnValueChanged(CCVars.ChatSanitizerEnabled, x => _doSanitize = x, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool TrySanitizeOutSmilies(string input, EntityUid speaker, out string sanitized, [NotNullWhen(true)] out string? emote)
|
public bool TrySanitizeOutSmilies(string input, EntityUid speaker, out string sanitized, [NotNullWhen(true)] out string? emote)
|
||||||
{
|
{
|
||||||
if (!doSanitize)
|
if (!_doSanitize)
|
||||||
{
|
{
|
||||||
sanitized = input;
|
sanitized = input;
|
||||||
emote = null;
|
emote = null;
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
using Robust.Server.Player;
|
using Robust.Server.Player;
|
||||||
|
using Robust.Shared.Console;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
|
using Robust.Shared.Players;
|
||||||
|
|
||||||
namespace Content.Server.Chat.Managers
|
namespace Content.Server.Chat.Managers
|
||||||
{
|
{
|
||||||
@@ -22,10 +24,16 @@ namespace Content.Server.Chat.Managers
|
|||||||
|
|
||||||
void DispatchServerMessage(IPlayerSession player, string message);
|
void DispatchServerMessage(IPlayerSession player, string message);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tries to use entity say or entity whisper to speak a message.
|
||||||
|
/// </summary>
|
||||||
|
void TrySpeak(EntityUid source, string message, bool whisper = false, IConsoleShell? shell = null, IPlayerSession? player = null);
|
||||||
|
|
||||||
/// <param name="hideChat">If true, message will not be logged to chat boxes but will still produce a speech bubble.</param>
|
/// <param name="hideChat">If true, message will not be logged to chat boxes but will still produce a speech bubble.</param>
|
||||||
void EntitySay(EntityUid source, string message, bool hideChat=false);
|
void EntitySay(EntityUid source, string message, bool hideChat=false);
|
||||||
|
void EntityWhisper(EntityUid source, string message, bool hideChat = false);
|
||||||
void EntityMe(EntityUid source, string action);
|
void EntityMe(EntityUid source, string action);
|
||||||
void EntityLOOC(EntityUid source, string message);
|
void SendLOOC(IPlayerSession player, string message);
|
||||||
|
|
||||||
void SendOOC(IPlayerSession player, string message);
|
void SendOOC(IPlayerSession player, string message);
|
||||||
void SendAdminChat(IPlayerSession player, string message);
|
void SendAdminChat(IPlayerSession player, string message);
|
||||||
|
|||||||
@@ -15,60 +15,65 @@ namespace Content.Shared.Chat
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
Local = 1 << 0,
|
Local = 1 << 0,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Chat heard by players right next to each other
|
||||||
|
/// </summary>
|
||||||
|
Whisper = 1 << 1,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Messages from the server
|
/// Messages from the server
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Server = 1 << 1,
|
Server = 1 << 2,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Damage messages
|
/// Damage messages
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Damage = 1 << 2,
|
Damage = 1 << 3,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Radio messages
|
/// Radio messages
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Radio = 1 << 3,
|
Radio = 1 << 4,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Local out-of-character channel
|
/// Local out-of-character channel
|
||||||
/// </summary>
|
/// </summary>
|
||||||
LOOC = 1 << 4,
|
LOOC = 1 << 5,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Out-of-character channel
|
/// Out-of-character channel
|
||||||
/// </summary>
|
/// </summary>
|
||||||
OOC = 1 << 5,
|
OOC = 1 << 6,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Visual events the player can see.
|
/// Visual events the player can see.
|
||||||
/// Basically like visual_message in SS13.
|
/// Basically like visual_message in SS13.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Visual = 1 << 6,
|
Visual = 1 << 7,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Emotes
|
/// Emotes
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Emotes = 1 << 7,
|
Emotes = 1 << 8,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Deadchat
|
/// Deadchat
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Dead = 1 << 8,
|
Dead = 1 << 9,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Admin chat
|
/// Admin chat
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Admin = 1 << 9,
|
Admin = 1 << 10,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Unspecified.
|
/// Unspecified.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Unspecified = 1 << 10,
|
Unspecified = 1 << 11,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Channels considered to be IC.
|
/// Channels considered to be IC.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
IC = Local | Radio | Dead | Emotes | Damage | Visual,
|
IC = Local | Whisper | Radio | Dead | Emotes | Damage | Visual,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,11 @@ namespace Content.Shared.Chat
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
Local = ChatChannel.Local,
|
Local = ChatChannel.Local,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Chat heard by players right next to each other
|
||||||
|
/// </summary>
|
||||||
|
Whisper = ChatChannel.Whisper,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Radio messages
|
/// Radio messages
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ namespace Content.Shared.Chat
|
|||||||
switch (Channel)
|
switch (Channel)
|
||||||
{
|
{
|
||||||
case ChatChannel.Local:
|
case ChatChannel.Local:
|
||||||
|
case ChatChannel.Whisper:
|
||||||
case ChatChannel.Dead:
|
case ChatChannel.Dead:
|
||||||
case ChatChannel.Admin:
|
case ChatChannel.Admin:
|
||||||
case ChatChannel.Emotes:
|
case ChatChannel.Emotes:
|
||||||
@@ -71,6 +72,7 @@ namespace Content.Shared.Chat
|
|||||||
switch (Channel)
|
switch (Channel)
|
||||||
{
|
{
|
||||||
case ChatChannel.Local:
|
case ChatChannel.Local:
|
||||||
|
case ChatChannel.Whisper:
|
||||||
case ChatChannel.Dead:
|
case ChatChannel.Dead:
|
||||||
case ChatChannel.Admin:
|
case ChatChannel.Admin:
|
||||||
case ChatChannel.Emotes:
|
case ChatChannel.Emotes:
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ namespace Content.Shared.Input
|
|||||||
public static readonly BoundKeyFunction ExamineEntity = "ExamineEntity";
|
public static readonly BoundKeyFunction ExamineEntity = "ExamineEntity";
|
||||||
public static readonly BoundKeyFunction FocusChat = "FocusChatInputWindow";
|
public static readonly BoundKeyFunction FocusChat = "FocusChatInputWindow";
|
||||||
public static readonly BoundKeyFunction FocusLocalChat = "FocusLocalChatWindow";
|
public static readonly BoundKeyFunction FocusLocalChat = "FocusLocalChatWindow";
|
||||||
|
public static readonly BoundKeyFunction FocusWhisperChat = "FocusWhisperChatWindow";
|
||||||
public static readonly BoundKeyFunction FocusRadio = "FocusRadioWindow";
|
public static readonly BoundKeyFunction FocusRadio = "FocusRadioWindow";
|
||||||
public static readonly BoundKeyFunction FocusOOC = "FocusOOCWindow";
|
public static readonly BoundKeyFunction FocusOOC = "FocusOOCWindow";
|
||||||
public static readonly BoundKeyFunction FocusAdminChat = "FocusAdminChatWindow";
|
public static readonly BoundKeyFunction FocusAdminChat = "FocusAdminChatWindow";
|
||||||
|
|||||||
@@ -9,10 +9,12 @@ chat-manager-admin-ooc-chat-enabled-message = Admin OOC chat has been enabled.
|
|||||||
chat-manager-admin-ooc-chat-disabled-message = Admin OOC chat has been disabled.
|
chat-manager-admin-ooc-chat-disabled-message = Admin OOC chat has been disabled.
|
||||||
chat-manager-max-message-length-exceeded-message = Your message exceeded {$limit} character limit
|
chat-manager-max-message-length-exceeded-message = Your message exceeded {$limit} character limit
|
||||||
chat-manager-no-headset-on-message = You don't have a headset on!
|
chat-manager-no-headset-on-message = You don't have a headset on!
|
||||||
|
chat-manager-whisper-headset-on-message = You can't whisper on the radio!
|
||||||
chat-manager-server-wrap-message = SERVER: {"{0}"}
|
chat-manager-server-wrap-message = SERVER: {"{0}"}
|
||||||
chat-manager-sender-announcement-wrap-message = {$sender} Announcement:
|
chat-manager-sender-announcement-wrap-message = {$sender} Announcement:
|
||||||
{"{0}"}
|
{"{0}"}
|
||||||
chat-manager-entity-say-wrap-message = {$entityName} says: "{"{0}"}"
|
chat-manager-entity-say-wrap-message = {$entityName} says: "{"{0}"}"
|
||||||
|
chat-manager-entity-whisper-wrap-message = {$entityName} whispers: "{"{0}"}"
|
||||||
chat-manager-entity-me-wrap-message = {$entityName} {"{0}"}
|
chat-manager-entity-me-wrap-message = {$entityName} {"{0}"}
|
||||||
chat-manager-entity-looc-wrap-message = LOOC: {$entityName}: {"{0}"}
|
chat-manager-entity-looc-wrap-message = LOOC: {$entityName}: {"{0}"}
|
||||||
chat-manager-send-ooc-wrap-message = OOC: {$playerName}: {"{0}"}
|
chat-manager-send-ooc-wrap-message = OOC: {$playerName}: {"{0}"}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ hud-chatbox-select-channel-Console = Console
|
|||||||
hud-chatbox-select-channel-Dead = Dead
|
hud-chatbox-select-channel-Dead = Dead
|
||||||
hud-chatbox-select-channel-Emotes = Emotes
|
hud-chatbox-select-channel-Emotes = Emotes
|
||||||
hud-chatbox-select-channel-Local = Local
|
hud-chatbox-select-channel-Local = Local
|
||||||
|
hud-chatbox-select-channel-Whisper = Whisper
|
||||||
hud-chatbox-select-channel-LOOC = LOOC
|
hud-chatbox-select-channel-LOOC = LOOC
|
||||||
hud-chatbox-select-channel-OOC = OOC
|
hud-chatbox-select-channel-OOC = OOC
|
||||||
hud-chatbox-select-channel-Radio = Radio
|
hud-chatbox-select-channel-Radio = Radio
|
||||||
@@ -14,6 +15,7 @@ hud-chatbox-channel-Admin = Admin
|
|||||||
hud-chatbox-channel-Dead = Dead
|
hud-chatbox-channel-Dead = Dead
|
||||||
hud-chatbox-channel-Emotes = Emotes
|
hud-chatbox-channel-Emotes = Emotes
|
||||||
hud-chatbox-channel-Local = Local
|
hud-chatbox-channel-Local = Local
|
||||||
|
hud-chatbox-channel-Whisper = Whisper
|
||||||
hud-chatbox-channel-LOOC = LOOC
|
hud-chatbox-channel-LOOC = LOOC
|
||||||
hud-chatbox-channel-OOC = OOC
|
hud-chatbox-channel-OOC = OOC
|
||||||
hud-chatbox-channel-Radio = Radio
|
hud-chatbox-channel-Radio = Radio
|
||||||
|
|||||||
@@ -95,6 +95,7 @@ ui-options-function-point = Point at location
|
|||||||
|
|
||||||
ui-options-function-focus-chat-input-window = Focus chat
|
ui-options-function-focus-chat-input-window = Focus chat
|
||||||
ui-options-function-focus-local-chat-window = Focus chat (IC)
|
ui-options-function-focus-local-chat-window = Focus chat (IC)
|
||||||
|
ui-options-function-focus-whisper-chat-window = Focus chat (Whisper)
|
||||||
ui-options-function-focus-radio-window = Focus chat (Radio)
|
ui-options-function-focus-radio-window = Focus chat (Radio)
|
||||||
ui-options-function-focus-ooc-window = Focus chat (OOC)
|
ui-options-function-focus-ooc-window = Focus chat (OOC)
|
||||||
ui-options-function-focus-admin-chat-window = Focus chat (Admin)
|
ui-options-function-focus-admin-chat-window = Focus chat (Admin)
|
||||||
|
|||||||
BIN
Resources/Textures/Interface/Nano/whisper.png
Normal file
BIN
Resources/Textures/Interface/Nano/whisper.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
@@ -65,6 +65,9 @@ binds:
|
|||||||
- function: FocusLocalChatWindow
|
- function: FocusLocalChatWindow
|
||||||
type: State
|
type: State
|
||||||
key: Period
|
key: Period
|
||||||
|
- function: FocusWhisperChatWindow
|
||||||
|
type: State
|
||||||
|
key: Comma
|
||||||
- function: FocusRadioWindow
|
- function: FocusRadioWindow
|
||||||
type: State
|
type: State
|
||||||
key: SemiColon
|
key: SemiColon
|
||||||
|
|||||||
Reference in New Issue
Block a user