Skip to content

Commit

Permalink
Tet-a-tet
Browse files Browse the repository at this point in the history
  • Loading branch information
Farrellka-dev committed Oct 30, 2024
1 parent 54a328d commit 43fe744
Show file tree
Hide file tree
Showing 15 changed files with 153 additions and 10 deletions.
4 changes: 4 additions & 0 deletions Content.Client/Chat/Managers/ChatManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ public void SendMessage(string text, ChatSelectChannel channel)
_consoleHost.ExecuteCommand($"me \"{CommandParsing.Escape(str)}\"");
break;

case ChatSelectChannel.HiddenEmotes:
_consoleHost.ExecuteCommand($"hme \"{CommandParsing.Escape(str)}\"");
break;

case ChatSelectChannel.Dead:
if (_systems.GetEntitySystemOrNull<GhostSystem>() is {IsGhost: true})
goto case ChatSelectChannel.Local;
Expand Down
4 changes: 4 additions & 0 deletions Content.Client/Chat/UI/SpeechBubble.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public abstract class SpeechBubble : Control
public enum SpeechType : byte
{
Emote,
HiddenEmote,
Say,
Whisper,
Looc
Expand Down Expand Up @@ -65,6 +66,9 @@ public static SpeechBubble CreateSpeechBubble(SpeechType type, ChatMessage messa
case SpeechType.Emote:
return new TextSpeechBubble(message, senderEntity, "emoteBox");

case SpeechType.HiddenEmote:
return new TextSpeechBubble(message, senderEntity, "emoteBox", Color.FromHex("#ffd29e"));

case SpeechType.Say:
return new FancyTextSpeechBubble(message, senderEntity, "sayBox");

Expand Down
1 change: 1 addition & 0 deletions Content.Client/Input/ContentContexts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public static void SetupContexts(IInputContextContainer contexts)
common.AddFunction(ContentKeyFunctions.FocusChat);
common.AddFunction(ContentKeyFunctions.FocusLocalChat);
common.AddFunction(ContentKeyFunctions.FocusEmote);
common.AddFunction(ContentKeyFunctions.FocusHiddenEmote);
common.AddFunction(ContentKeyFunctions.FocusWhisperChat);
common.AddFunction(ContentKeyFunctions.FocusRadio);
common.AddFunction(ContentKeyFunctions.FocusLOOC);
Expand Down
1 change: 1 addition & 0 deletions Content.Client/Options/UI/Tabs/KeyRebindTab.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ void AddCheckBox(string checkBoxName, bool currentState, Action<BaseButton.Butto
AddButton(ContentKeyFunctions.FocusChat);
AddButton(ContentKeyFunctions.FocusLocalChat);
AddButton(ContentKeyFunctions.FocusEmote);
AddButton(ContentKeyFunctions.FocusHiddenEmote);
AddButton(ContentKeyFunctions.FocusWhisperChat);
AddButton(ContentKeyFunctions.FocusRadio);
AddButton(ContentKeyFunctions.FocusLOOC);
Expand Down
11 changes: 11 additions & 0 deletions Content.Client/UserInterface/Systems/Chat/ChatUIController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public sealed class ChatUIController : UIController
{SharedChatSystem.OOCPrefix, ChatSelectChannel.OOC},
{SharedChatSystem.EmotesPrefix, ChatSelectChannel.Emotes},
{SharedChatSystem.EmotesAltPrefix, ChatSelectChannel.Emotes},
{SharedChatSystem.HiddenEmotesPrefix, ChatSelectChannel.HiddenEmotes},
{SharedChatSystem.AdminPrefix, ChatSelectChannel.Admin},
{SharedChatSystem.RadioCommonPrefix, ChatSelectChannel.Radio},
{SharedChatSystem.DeadPrefix, ChatSelectChannel.Dead},
Expand All @@ -92,6 +93,7 @@ public sealed class ChatUIController : UIController
{ChatSelectChannel.LOOC, SharedChatSystem.LOOCPrefix},
{ChatSelectChannel.OOC, SharedChatSystem.OOCPrefix},
{ChatSelectChannel.Emotes, SharedChatSystem.EmotesPrefix},
{ChatSelectChannel.HiddenEmotes, SharedChatSystem.HiddenEmotesPrefix},
{ChatSelectChannel.Admin, SharedChatSystem.AdminPrefix},
{ChatSelectChannel.Radio, SharedChatSystem.RadioCommonPrefix},
{ChatSelectChannel.Dead, SharedChatSystem.DeadPrefix},
Expand Down Expand Up @@ -199,6 +201,9 @@ public override void Initialize()
_input.SetInputCommand(ContentKeyFunctions.FocusEmote,
InputCmdHandler.FromDelegate(_ => FocusChannel(ChatSelectChannel.Emotes)));

_input.SetInputCommand(ContentKeyFunctions.FocusHiddenEmote,
InputCmdHandler.FromDelegate(_ => FocusChannel(ChatSelectChannel.HiddenEmotes)));

_input.SetInputCommand(ContentKeyFunctions.FocusWhisperChat,
InputCmdHandler.FromDelegate(_ => FocusChannel(ChatSelectChannel.Whisper)));

Expand Down Expand Up @@ -529,6 +534,7 @@ private void UpdateChannelPermissions()
FilterableChannels |= ChatChannel.Whisper;
FilterableChannels |= ChatChannel.Radio;
FilterableChannels |= ChatChannel.Emotes;
FilterableChannels |= ChatChannel.HiddenEmotes;
FilterableChannels |= ChatChannel.Notifications;

// Can only send local / radio / emote when attached to a non-ghost entity.
Expand All @@ -539,6 +545,7 @@ private void UpdateChannelPermissions()
CanSendChannels |= ChatSelectChannel.Whisper;
CanSendChannels |= ChatSelectChannel.Radio;
CanSendChannels |= ChatSelectChannel.Emotes;
CanSendChannels |= ChatSelectChannel.HiddenEmotes;
}
}

Expand Down Expand Up @@ -875,6 +882,10 @@ public void ProcessChatMessage(ChatMessage msg, bool speechBubble = true)
AddSpeechBubble(msg, SpeechBubble.SpeechType.Emote);
break;

case ChatChannel.HiddenEmotes:
AddSpeechBubble(msg, SpeechBubble.SpeechType.HiddenEmote);
break;

case ChatChannel.LOOC:
if (_config.GetCVar(CCVars.LoocAboveHeadShow))
AddSpeechBubble(msg, SpeechBubble.SpeechType.Looc);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public sealed partial class ChannelFilterPopup : Popup
ChatChannel.Local,
ChatChannel.Whisper,
ChatChannel.Emotes,
ChatChannel.HiddenEmotes,
ChatChannel.Radio,
ChatChannel.Telepathic, //Nyano - Summary: adds telepathic chat to where it belongs in order in the chat.
ChatChannel.Notifications,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public sealed class ChannelSelectorPopup : Popup
ChatSelectChannel.Local,
ChatSelectChannel.Whisper,
ChatSelectChannel.Emotes,
ChatSelectChannel.HiddenEmotes,
ChatSelectChannel.Radio,
ChatSelectChannel.Telepathic, //Nyano - Summary: determines the order in which telepathic shows.
ChatSelectChannel.LOOC,
Expand Down
44 changes: 44 additions & 0 deletions Content.Server/Chat/Commands/HiddenMeCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using Content.Server.Chat.Systems;
using Content.Shared.Administration;
using Content.Shared.Chat;
using Robust.Shared.Console;
using Robust.Shared.Enums;

namespace Content.Server.Chat.Commands
{
[AnyCommand]
internal sealed class HiddenMeCommand : IConsoleCommand
{
public string Command => "hme";
public string Description => "Perform an action.";
public string Help => "hme <text>";

public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (shell.Player is not { } 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<IEntitySystemManager>().GetEntitySystem<ChatSystem>()
.TrySendInGameICMessage(playerEntity, message, InGameICChatType.HiddenEmote, ChatTransmitRange.GhostRangeLimit, false, shell, player);
}
}
}
61 changes: 60 additions & 1 deletion Content.Server/Chat/Systems/ChatSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public void TrySendInGameICMessage(

var language = languageOverride ?? _language.GetLanguage(source);

bool shouldCapitalize = (desiredType != InGameICChatType.Emote);
bool shouldCapitalize = (desiredType != InGameICChatType.Emote && desiredType != InGameICChatType.HiddenEmote);
bool shouldPunctuate = _configurationManager.GetCVar(CCVars.ChatPunctuation);
// Capitalizing the word I only happens in English, so we check language here
bool shouldCapitalizeTheWordI = (!CultureInfo.CurrentCulture.IsNeutralCulture && CultureInfo.CurrentCulture.Parent.Name == "en")
Expand Down Expand Up @@ -273,6 +273,9 @@ public void TrySendInGameICMessage(
case InGameICChatType.Emote:
SendEntityEmote(source, message, range, nameOverride, language, hideLog: hideLog, ignoreActionBlocker: ignoreActionBlocker);
break;
case InGameICChatType.HiddenEmote:
SendHiddenEntityEmote(source, message, range, nameOverride, language, hideLog: hideLog, ignoreActionBlocker: ignoreActionBlocker);
break;
//Nyano - Summary: case adds the telepathic chat sending ability.
case InGameICChatType.Telepathic:
_telepath.SendTelepathicChat(source, message, range == ChatTransmitRange.HideChat);
Expand Down Expand Up @@ -601,6 +604,62 @@ private void SendEntityEmote(
_adminLogger.Add(LogType.Chat, LogImpact.Low, $"Emote from {ToPrettyString(source):user}: {action}");
}


private void SendHiddenEntityEmote(
EntityUid source,
string action,
ChatTransmitRange range,
string? nameOverride,
LanguagePrototype language,
bool hideLog = false,
bool checkEmote = true,
bool ignoreActionBlocker = false,
NetUserId? author = null
)
{
if (!_actionBlocker.CanEmote(source) && !ignoreActionBlocker)
return;

var ent = Identity.Entity(source, EntityManager);
string name = FormattedMessage.EscapeText(nameOverride ?? Name(ent));

var coloredName = $"[color=#FFD29E]{name}[/color]";
var coloredAction = $"[color=#FFD29E]{FormattedMessage.RemoveMarkup(action)}[/color]";

var wrappedMessage = Loc.GetString("chat-manager-entity-me-wrap-message",
("entityName", coloredName),
("entity", ent),
("message", coloredAction));

if (checkEmote)
TryEmoteChatInput(source, action);

float hiddenEmoteRange = 0.3f;

foreach (var (session, data) in GetRecipients(source, hiddenEmoteRange))
{
if (session.AttachedEntity is not { Valid: true } listener)
continue;

if (Transform(session.AttachedEntity.Value).GridUid != Transform(source).GridUid
&& !CheckAttachedGrids(source, session.AttachedEntity.Value))
continue;

if (data.Range <= hiddenEmoteRange)
{
_chatManager.ChatMessageToOne(ChatChannel.HiddenEmotes, action, wrappedMessage, source, false, session.Channel);
}
}

if (!hideLog)
if (name != Name(source))
_adminLogger.Add(LogType.Chat, LogImpact.Low, $"Hidden emote from {ToPrettyString(source):user} as {name}: {action}");
else
_adminLogger.Add(LogType.Chat, LogImpact.Low, $"Hidden emote from {ToPrettyString(source):user}: {action}");
}



// ReSharper disable once InconsistentNaming
private void SendLOOC(EntityUid source, ICommonSession player, string message, bool hideChat)
{
Expand Down
21 changes: 13 additions & 8 deletions Content.Shared/Chat/ChatChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace Content.Shared.Chat
/// Represents chat channels that the player can filter chat tabs by.
/// </summary>
[Flags, Serializable]
public enum ChatChannel : ushort
public enum ChatChannel : uint
{
None = 0,

Expand Down Expand Up @@ -60,40 +60,45 @@ public enum ChatChannel : ushort
/// </summary>
Emotes = 1 << 9,

/// <summary>
/// HiddenEmotes
/// </summary>
HiddenEmotes = 1 << 10,

/// <summary>
/// Deadchat
/// </summary>
Dead = 1 << 10,
Dead = 1 << 11,

/// <summary>
/// Misc admin messages
/// </summary>
Admin = 1 << 11,
Admin = 1 << 12,

/// <summary>
/// Admin alerts, messages likely of elevated importance to admins
/// </summary>
AdminAlert = 1 << 12,
AdminAlert = 1 << 13,

/// <summary>
/// Admin chat
/// </summary>
AdminChat = 1 << 13,
AdminChat = 1 << 14,

/// <summary>
/// Unspecified.
/// </summary>
Unspecified = 1 << 14,
Unspecified = 1 << 15,

/// <summary>
/// Nyano - Summary:: Telepathic channel for all psionic entities.
/// </summary>
Telepathic = 1 << 15,
Telepathic = 1 << 16,

/// <summary>
/// Channels considered to be IC.
/// </summary>
IC = Local | Whisper | Radio | Dead | Emotes | Damage | Visual | Telepathic | Notifications, //Nyano - Summary: Adds telepathic as an 'IC' labelled chat..
IC = Local | Whisper | Radio | Dead | Emotes | HiddenEmotes | Damage | Visual | Telepathic | Notifications, //Nyano - Summary: Adds telepathic as an 'IC' labelled chat..

AdminRelated = Admin | AdminAlert | AdminChat,
}
Expand Down
7 changes: 6 additions & 1 deletion Content.Shared/Chat/ChatSelectChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/// Maps to <see cref="ChatChannel"/>, giving better names.
/// </remarks>
[Flags]
public enum ChatSelectChannel : ushort
public enum ChatSelectChannel : uint
{
None = 0,

Expand Down Expand Up @@ -41,6 +41,11 @@ public enum ChatSelectChannel : ushort
/// </summary>
Emotes = ChatChannel.Emotes,

/// <summary>
/// HiddenEmotes
/// </summary>
HiddenEmotes = ChatChannel.HiddenEmotes,

/// <summary>
/// Deadchat
/// </summary>
Expand Down
2 changes: 2 additions & 0 deletions Content.Shared/Chat/SharedChatSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public abstract class SharedChatSystem : EntitySystem
public const char OOCPrefix = '[';
public const char EmotesPrefix = '%'; // Corvax-Localization
public const char EmotesAltPrefix = '*';
public const char HiddenEmotesPrefix = '+';
public const char AdminPrefix = ']';
public const char WhisperPrefix = ',';
public const char TelepathicPrefix = '='; //Nyano - Summary: Adds the telepathic channel's prefix.
Expand Down Expand Up @@ -265,6 +266,7 @@ public enum InGameICChatType : byte
{
Speak,
Emote,
HiddenEmote,
Whisper,
Telepathic
}
Expand Down
1 change: 1 addition & 0 deletions Content.Shared/Input/ContentKeyFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public static class ContentKeyFunctions
public static readonly BoundKeyFunction FocusChat = "FocusChatInputWindow";
public static readonly BoundKeyFunction FocusLocalChat = "FocusLocalChatWindow";
public static readonly BoundKeyFunction FocusEmote = "FocusEmote";
public static readonly BoundKeyFunction FocusHiddenEmote = "FocusHiddenEmote";
public static readonly BoundKeyFunction FocusWhisperChat = "FocusWhisperChatWindow";
public static readonly BoundKeyFunction FocusRadio = "FocusRadioWindow";
public static readonly BoundKeyFunction FocusLOOC = "FocusLOOCWindow";
Expand Down
2 changes: 2 additions & 0 deletions Resources/Locale/en-US/chat/ui/chat-box.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ hud-chatbox-select-channel-Admin = Admin
hud-chatbox-select-channel-Console = Console
hud-chatbox-select-channel-Dead = Dead
hud-chatbox-select-channel-Emotes = Emotes
hud-chatbox-select-channel-HiddenEmotes = Tet-a-tet
hud-chatbox-select-channel-Local = Local
hud-chatbox-select-channel-Whisper = Whisper
hud-chatbox-select-channel-LOOC = LOOC
Expand All @@ -21,6 +22,7 @@ hud-chatbox-channel-AdminAlert = Admin Alert
hud-chatbox-channel-AdminChat = Admin Chat
hud-chatbox-channel-Dead = Dead
hud-chatbox-channel-Emotes = Emotes
hud-chatbox-channel-HiddenEmotes = Tet-a-tet
hud-chatbox-channel-Local = Local
hud-chatbox-channel-Whisper = Whisper
hud-chatbox-channel-LOOC = LOOC
Expand Down
2 changes: 2 additions & 0 deletions Resources/Locale/ru-RU/chat/ui/chat-box.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ hud-chatbox-select-channel-Admin = Админ
hud-chatbox-select-channel-Console = Консоль
hud-chatbox-select-channel-Dead = Мёртвые
hud-chatbox-select-channel-Emotes = Эмоции
hud-chatbox-select-channel-HiddenEmotes = Тет-а-тет
hud-chatbox-select-channel-Local = Рядом
hud-chatbox-select-channel-Whisper = Шёпот
hud-chatbox-select-channel-LOOC = LOOC
Expand All @@ -19,6 +20,7 @@ hud-chatbox-channel-AdminAlert = Админ Уведомления
hud-chatbox-channel-AdminChat = Админ Чат
hud-chatbox-channel-Dead = Мёртвые
hud-chatbox-channel-Emotes = Эмоции
hud-chatbox-channel-HiddenEmotes = Тет-а-тет
hud-chatbox-channel-Local = Рядом
hud-chatbox-channel-Whisper = Шёпот
hud-chatbox-channel-LOOC = LOOC
Expand Down

0 comments on commit 43fe744

Please sign in to comment.