]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Use different chatbox placeholder when dependent keys unbound (#22747)
authorLordCarve <27449516+LordCarve@users.noreply.github.com>
Fri, 22 Dec 2023 19:39:29 +0000 (20:39 +0100)
committerGitHub <noreply@github.com>
Fri, 22 Dec 2023 19:39:29 +0000 (11:39 -0800)
Content.Client/UserInterface/BoundKeyHelpers.cs
Content.Client/UserInterface/Systems/Chat/Controls/ChatInputBox.cs
Resources/Locale/en-US/chat/ui/chat-box.ftl

index 7413481ca3e3f029c5d9c3bae1db32cfea337cc2..a4a09a4507a291f60ebac2c21aed1f2413c891a0 100644 (file)
@@ -13,6 +13,11 @@ public static class BoundKeyHelper
         return TryGetShortKeyName(keyFunction, out var name) ? Loc.GetString(name) : " ";
     }
 
+    public static bool IsBound(BoundKeyFunction keyFunction)
+    {
+        return TryGetShortKeyName(keyFunction, out _);
+    }
+
     private static string? DefaultShortKeyName(BoundKeyFunction keyFunction)
     {
         var name = FormattedMessage.EscapeText(IoCManager.Resolve<IInputManager>().GetKeyFunctionButtonString(keyFunction));
index 22d50f93ff69d740ca4d0da7d9c3bcb86f663a71..843fd46c1a0a21872a5857494b41c102d81fc200 100644 (file)
@@ -33,7 +33,7 @@ public class ChatInputBox : PanelContainer
         Input = new HistoryLineEdit
         {
             Name = "Input",
-            PlaceHolder = Loc.GetString("hud-chatbox-info", ("talk-key", BoundKeyHelper.ShortKeyName(ContentKeyFunctions.FocusChat)), ("cycle-key", BoundKeyHelper.ShortKeyName(ContentKeyFunctions.CycleChatChannelForward))),
+            PlaceHolder = GetChatboxInfoPlaceholder(),
             HorizontalExpand = true,
             StyleClasses = {"chatLineEdit"}
         };
@@ -51,4 +51,15 @@ public class ChatInputBox : PanelContainer
     {
         ActiveChannel = (ChatChannel) selectedChannel;
     }
+
+    private static string GetChatboxInfoPlaceholder()
+    {
+        return (BoundKeyHelper.IsBound(ContentKeyFunctions.FocusChat), BoundKeyHelper.IsBound(ContentKeyFunctions.CycleChatChannelForward)) switch
+        {
+            (true, true) => Loc.GetString("hud-chatbox-info", ("talk-key", BoundKeyHelper.ShortKeyName(ContentKeyFunctions.FocusChat)), ("cycle-key", BoundKeyHelper.ShortKeyName(ContentKeyFunctions.CycleChatChannelForward))),
+            (true, false) => Loc.GetString("hud-chatbox-info-talk", ("talk-key", BoundKeyHelper.ShortKeyName(ContentKeyFunctions.FocusChat))),
+            (false, true) => Loc.GetString("hud-chatbox-info-cycle", ("cycle-key", BoundKeyHelper.ShortKeyName(ContentKeyFunctions.CycleChatChannelForward))),
+            (false, false) => Loc.GetString("hud-chatbox-info-unbound")
+        };
+    }
 }
index ddf52d8be8a42b2121a3644670cd524c770fa5db..797b029f8e1a0e6d5509f5809a9fe47dca94c82e 100644 (file)
@@ -1,4 +1,7 @@
 hud-chatbox-info = {$talk-key} to talk, {$cycle-key} to cycle channels.
+hud-chatbox-info-talk = {$talk-key} to talk.
+hud-chatbox-info-cycle = Click here to talk, {$cycle-key} to cycle channels.
+hud-chatbox-info-unbound = Click here to talk.
 
 hud-chatbox-select-name-prefixed = {$prefix} {$name}
 hud-chatbox-select-channel-Admin = Admin