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.Dead => Color.MediumPurple,
|
||||
ChatChannel.Admin => Color.Red,
|
||||
_ => Color.DarkGray
|
||||
ChatChannel.Whisper => Color.DarkGray,
|
||||
_ => Color.LightGray
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,9 @@ namespace Content.Client.Chat
|
||||
inputManager.SetInputCommand(ContentKeyFunctions.FocusLocalChat,
|
||||
InputCmdHandler.FromDelegate(_ => GameScreen.FocusChannel(chatBox, ChatSelectChannel.Local)));
|
||||
|
||||
inputManager.SetInputCommand(ContentKeyFunctions.FocusWhisperChat,
|
||||
InputCmdHandler.FromDelegate(_ => GameScreen.FocusChannel(chatBox, ChatSelectChannel.Whisper)));
|
||||
|
||||
inputManager.SetInputCommand(ContentKeyFunctions.FocusOOC,
|
||||
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
|
||||
FilterableChannels |= ChatChannel.Local;
|
||||
FilterableChannels |= ChatChannel.Whisper;
|
||||
FilterableChannels |= ChatChannel.Radio;
|
||||
FilterableChannels |= ChatChannel.Emotes;
|
||||
|
||||
@@ -206,6 +207,7 @@ namespace Content.Client.Chat.Managers
|
||||
if (!IsGhost)
|
||||
{
|
||||
SelectableChannels |= ChatSelectChannel.Local;
|
||||
SelectableChannels |= ChatSelectChannel.Whisper;
|
||||
SelectableChannels |= ChatSelectChannel.Radio;
|
||||
SelectableChannels |= ChatSelectChannel.Emotes;
|
||||
}
|
||||
@@ -353,6 +355,10 @@ namespace Content.Client.Chat.Managers
|
||||
_consoleHost.ExecuteCommand($"say \"{CommandParsing.Escape(str)}\"");
|
||||
break;
|
||||
|
||||
case ChatSelectChannel.Whisper:
|
||||
_consoleHost.ExecuteCommand($"whisper \"{CommandParsing.Escape(str)}\"");
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(channel), channel, null);
|
||||
}
|
||||
@@ -405,6 +411,10 @@ namespace Content.Client.Chat.Managers
|
||||
AddSpeechBubble(msg, SpeechBubble.SpeechType.Say);
|
||||
break;
|
||||
|
||||
case ChatChannel.Whisper:
|
||||
AddSpeechBubble(msg, SpeechBubble.SpeechType.Whisper);
|
||||
break;
|
||||
|
||||
case ChatChannel.Dead:
|
||||
if (!IsGhost)
|
||||
break;
|
||||
|
||||
@@ -30,6 +30,7 @@ namespace Content.Client.Chat.UI
|
||||
private static readonly ChatChannel[] ChannelFilterOrder =
|
||||
{
|
||||
ChatChannel.Local,
|
||||
ChatChannel.Whisper,
|
||||
ChatChannel.Emotes,
|
||||
ChatChannel.Radio,
|
||||
ChatChannel.OOC,
|
||||
@@ -42,6 +43,7 @@ namespace Content.Client.Chat.UI
|
||||
private static readonly ChatSelectChannel[] ChannelSelectorOrder =
|
||||
{
|
||||
ChatSelectChannel.Local,
|
||||
ChatSelectChannel.Whisper,
|
||||
ChatSelectChannel.Emotes,
|
||||
ChatSelectChannel.Radio,
|
||||
ChatSelectChannel.LOOC,
|
||||
@@ -59,10 +61,12 @@ namespace Content.Client.Chat.UI
|
||||
public const char AliasEmotes = '@';
|
||||
public const char AliasAdmin = ']';
|
||||
public const char AliasRadio = ';';
|
||||
public const char AliasWhisper = ',';
|
||||
|
||||
private static readonly Dictionary<char, ChatSelectChannel> PrefixToChannel = new()
|
||||
{
|
||||
{AliasLocal, ChatSelectChannel.Local},
|
||||
{AliasWhisper, ChatSelectChannel.Whisper},
|
||||
{AliasConsole, ChatSelectChannel.Console},
|
||||
{AliasOOC, ChatSelectChannel.OOC},
|
||||
{AliasEmotes, ChatSelectChannel.Emotes},
|
||||
|
||||
@@ -16,7 +16,8 @@ namespace Content.Client.Chat.UI
|
||||
public enum SpeechType : byte
|
||||
{
|
||||
Emote,
|
||||
Say
|
||||
Say,
|
||||
Whisper
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -52,17 +53,20 @@ namespace Content.Client.Chat.UI
|
||||
switch (type)
|
||||
{
|
||||
case SpeechType.Emote:
|
||||
return new EmoteSpeechBubble(text, senderEntity, eyeManager, chatManager, entityManager);
|
||||
return new TextSpeechBubble(text, senderEntity, eyeManager, chatManager, entityManager, "emoteBox");
|
||||
|
||||
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:
|
||||
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;
|
||||
_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.
|
||||
RectClipContent = true;
|
||||
|
||||
var bubble = BuildBubble(text);
|
||||
var bubble = BuildBubble(text, speechStyleClass);
|
||||
|
||||
AddChild(bubble);
|
||||
|
||||
@@ -83,7 +87,7 @@ namespace Content.Client.Chat.UI
|
||||
_verticalOffsetAchieved = -ContentHeight;
|
||||
}
|
||||
|
||||
protected abstract Control BuildBubble(string text);
|
||||
protected abstract Control BuildBubble(string text, string speechStyleClass);
|
||||
|
||||
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)
|
||||
: base(text, senderEntity, eyeManager, chatManager, entityManager)
|
||||
public TextSpeechBubble(string text, EntityUid senderEntity, IEyeManager eyeManager, IChatManager chatManager, IEntityManager entityManager, string speechStyleClass)
|
||||
: 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
|
||||
{
|
||||
@@ -180,33 +184,7 @@ namespace Content.Client.Chat.UI
|
||||
|
||||
var panel = new PanelContainer
|
||||
{
|
||||
StyleClasses = { "speechBox", "emoteBox" },
|
||||
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" },
|
||||
StyleClasses = { "speechBox", speechStyleClass },
|
||||
Children = { label },
|
||||
ModulateSelfOverride = Color.White.WithAlpha(0.75f)
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user