From: LordCarve <27449516+LordCarve@users.noreply.github.com> Date: Fri, 22 Dec 2023 19:39:29 +0000 (+0100) Subject: Use different chatbox placeholder when dependent keys unbound (#22747) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=7d6905529127d9ba390645494ab2cb27aa05c537;p=space-station-14.git Use different chatbox placeholder when dependent keys unbound (#22747) --- diff --git a/Content.Client/UserInterface/BoundKeyHelpers.cs b/Content.Client/UserInterface/BoundKeyHelpers.cs index 7413481ca3..a4a09a4507 100644 --- a/Content.Client/UserInterface/BoundKeyHelpers.cs +++ b/Content.Client/UserInterface/BoundKeyHelpers.cs @@ -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().GetKeyFunctionButtonString(keyFunction)); diff --git a/Content.Client/UserInterface/Systems/Chat/Controls/ChatInputBox.cs b/Content.Client/UserInterface/Systems/Chat/Controls/ChatInputBox.cs index 22d50f93ff..843fd46c1a 100644 --- a/Content.Client/UserInterface/Systems/Chat/Controls/ChatInputBox.cs +++ b/Content.Client/UserInterface/Systems/Chat/Controls/ChatInputBox.cs @@ -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") + }; + } } diff --git a/Resources/Locale/en-US/chat/ui/chat-box.ftl b/Resources/Locale/en-US/chat/ui/chat-box.ftl index ddf52d8be8..797b029f8e 100644 --- a/Resources/Locale/en-US/chat/ui/chat-box.ftl +++ b/Resources/Locale/en-US/chat/ui/chat-box.ftl @@ -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