Use different chatbox placeholder when dependent keys unbound (#22747)

This commit is contained in:
LordCarve
2023-12-22 20:39:29 +01:00
committed by GitHub
parent 524dbf9a78
commit 7d69055291
3 changed files with 20 additions and 1 deletions

View 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")
};
}
}