diff --git a/OpenRA.Mods.Common/Widgets/HotkeyEntryWidget.cs b/OpenRA.Mods.Common/Widgets/HotkeyEntryWidget.cs index e17fc21313..7b0d310d61 100644 --- a/OpenRA.Mods.Common/Widgets/HotkeyEntryWidget.cs +++ b/OpenRA.Mods.Common/Widgets/HotkeyEntryWidget.cs @@ -88,7 +88,6 @@ namespace OpenRA.Mods.Common.Widgets Keycode.RCTRL, Keycode.LCTRL, Keycode.RALT, Keycode.LALT, Keycode.RGUI, Keycode.LGUI, - Keycode.RETURN, Keycode.KP_ENTER }; public override bool HandleKeyPress(KeyInput e) diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameChatLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameChatLogic.cs index dc08c74fde..3ee73bb022 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameChatLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameChatLogic.cs @@ -13,6 +13,7 @@ using System; using System.Collections.Generic; using System.Linq; using OpenRA.Mods.Common.Commands; +using OpenRA.Mods.Common.Lint; using OpenRA.Mods.Common.Traits; using OpenRA.Network; using OpenRA.Primitives; @@ -20,6 +21,7 @@ using OpenRA.Widgets; namespace OpenRA.Mods.Common.Widgets.Logic { + [ChromeLogicArgsHotkeys("OpenTeamChat", "OpenGeneralChat")] public class IngameChatLogic : ChromeLogic { readonly OrderManager orderManager; @@ -135,14 +137,15 @@ namespace OpenRA.Mods.Common.Widgets.Logic return true; }; - chatText.OnTabKey = _ => + chatText.OnTabKey = e => { - var previousText = chatText.Text; - chatText.Text = tabCompletion.Complete(chatText.Text); - chatText.CursorPosition = chatText.Text.Length; - - if (chatText.Text == previousText && !disableTeamChat) - teamChat ^= true; + if (!chatMode.Key.IsActivatedBy(e) || chatMode.IsDisabled()) + { + chatText.Text = tabCompletion.Complete(chatText.Text); + chatText.CursorPosition = chatText.Text.Length; + } + else + chatMode.OnKeyPress(e); return true; }; @@ -159,6 +162,14 @@ namespace OpenRA.Mods.Common.Widgets.Logic if (!isMenuChat) { + var openTeamChatKey = new HotkeyReference(); + if (logicArgs.TryGetValue("OpenTeamChatKey", out var hotkeyArg)) + openTeamChatKey = modData.Hotkeys[hotkeyArg.Value]; + + var openGeneralChatKey = new HotkeyReference(); + if (logicArgs.TryGetValue("OpenGeneralChatKey", out hotkeyArg)) + openGeneralChatKey = modData.Hotkeys[hotkeyArg.Value]; + var chatClose = chatChrome.Get("CHAT_CLOSE"); chatClose.OnClick += CloseChat; @@ -167,8 +178,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic if (e.Event == KeyInputEvent.Up) return false; - if (!chatChrome.IsVisible() && (e.Key == Keycode.RETURN || e.Key == Keycode.KP_ENTER)) + if (!chatChrome.IsVisible() && (openTeamChatKey.IsActivatedBy(e) || openGeneralChatKey.IsActivatedBy(e))) { + teamChat = !disableTeamChat && !openGeneralChatKey.IsActivatedBy(e); + OpenChat(); return true; } @@ -229,6 +242,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic chatChrome.Visible = false; chatText.YieldKeyboardFocus(); chatOverlay.Visible = true; + Ui.ResetTooltips(); } public void AddChatLineWrapper(string name, Color nameColor, string text, Color textColor) diff --git a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs index d9a42f1b8e..055e60f451 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs @@ -423,16 +423,17 @@ namespace OpenRA.Mods.Common.Widgets.Logic return true; }; - chatTextField.OnTabKey = _ => + chatTextField.OnTabKey = e => { - var previousText = chatTextField.Text; - chatTextField.Text = tabCompletion.Complete(chatTextField.Text); - chatTextField.CursorPosition = chatTextField.Text.Length; - - if (chatTextField.Text == previousText) - return SwitchTeamChat(); + if (!chatMode.Key.IsActivatedBy(e) || chatMode.IsDisabled()) + { + chatTextField.Text = tabCompletion.Complete(chatTextField.Text); + chatTextField.CursorPosition = chatTextField.Text.Length; + } else - return true; + chatMode.OnKeyPress(e); + + return true; }; chatTextField.OnEscKey = _ => { chatTextField.Text = ""; return true; }; @@ -501,13 +502,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic Game.Sound.PlayNotification(modRules, null, "Sounds", chatLineSound, null); } - bool SwitchTeamChat() - { - if (!disableTeamChat) - teamChat ^= true; - return true; - } - void UpdateCurrentMap() { mapStatus = orderManager.LobbyInfo.GlobalSettings.MapStatus; diff --git a/mods/cnc/chrome/ingame-chat.yaml b/mods/cnc/chrome/ingame-chat.yaml index 991da74634..42ae19d1a2 100644 --- a/mods/cnc/chrome/ingame-chat.yaml +++ b/mods/cnc/chrome/ingame-chat.yaml @@ -4,6 +4,8 @@ Container@CHAT_PANEL: Width: 550 Height: 194 Logic: IngameChatLogic + OpenTeamChatKey: OpenTeamChat + OpenGeneralChatKey: OpenGeneralChat Children: Container@CHAT_OVERLAY: Width: PARENT_RIGHT - 24 @@ -25,6 +27,9 @@ Container@CHAT_PANEL: Height: 25 Text: Team Font: Bold + Key: Tab SHIFT + TooltipText: Toggle chat mode + TooltipContainer: TOOLTIP_CONTAINER TextField@CHAT_TEXTFIELD: X: 55 Y: PARENT_BOTTOM - HEIGHT diff --git a/mods/cnc/chrome/ingame-infochat.yaml b/mods/cnc/chrome/ingame-infochat.yaml index d59bcc36e1..1747eb0e21 100644 --- a/mods/cnc/chrome/ingame-infochat.yaml +++ b/mods/cnc/chrome/ingame-infochat.yaml @@ -15,6 +15,9 @@ Container@CHAT_CONTAINER: Height: 25 Text: Team Font: Bold + Key: Tab SHIFT + TooltipText: Toggle chat mode + TooltipContainer: TOOLTIP_CONTAINER TextField@CHAT_TEXTFIELD: X: 55 Y: PARENT_BOTTOM - HEIGHT diff --git a/mods/cnc/chrome/lobby.yaml b/mods/cnc/chrome/lobby.yaml index e77b62b755..36041c40ba 100644 --- a/mods/cnc/chrome/lobby.yaml +++ b/mods/cnc/chrome/lobby.yaml @@ -128,6 +128,9 @@ Container@SERVER_LOBBY: Height: 25 Text: Team Font: Bold + Key: Tab SHIFT + TooltipText: Toggle chat mode + TooltipContainer: TOOLTIP_CONTAINER TextField@CHAT_TEXTFIELD: X: 55 Y: PARENT_BOTTOM - HEIGHT diff --git a/mods/cnc/chrome/settings-hotkeys.yaml b/mods/cnc/chrome/settings-hotkeys.yaml index c2760e3994..95e789df68 100644 --- a/mods/cnc/chrome/settings-hotkeys.yaml +++ b/mods/cnc/chrome/settings-hotkeys.yaml @@ -25,6 +25,9 @@ Container@HOTKEYS_PANEL: Music Commands: Template: TWO_COLUMN Types: Music + Chat Commands: + Template: TWO_COLUMN + Types: Chat Width: PARENT_RIGHT Height: PARENT_BOTTOM Children: diff --git a/mods/cnc/mod.yaml b/mods/cnc/mod.yaml index cc8bd55427..eb51506252 100644 --- a/mods/cnc/mod.yaml +++ b/mods/cnc/mod.yaml @@ -153,6 +153,7 @@ Hotkeys: common|hotkeys/production-peractor.yaml common|hotkeys/supportpowers.yaml common|hotkeys/viewport.yaml + common|hotkeys/chat.yaml cnc|hotkeys.yaml LoadScreen: CncLoadScreen diff --git a/mods/common/chrome/ingame-chat.yaml b/mods/common/chrome/ingame-chat.yaml index 991da74634..42ae19d1a2 100644 --- a/mods/common/chrome/ingame-chat.yaml +++ b/mods/common/chrome/ingame-chat.yaml @@ -4,6 +4,8 @@ Container@CHAT_PANEL: Width: 550 Height: 194 Logic: IngameChatLogic + OpenTeamChatKey: OpenTeamChat + OpenGeneralChatKey: OpenGeneralChat Children: Container@CHAT_OVERLAY: Width: PARENT_RIGHT - 24 @@ -25,6 +27,9 @@ Container@CHAT_PANEL: Height: 25 Text: Team Font: Bold + Key: Tab SHIFT + TooltipText: Toggle chat mode + TooltipContainer: TOOLTIP_CONTAINER TextField@CHAT_TEXTFIELD: X: 55 Y: PARENT_BOTTOM - HEIGHT diff --git a/mods/common/chrome/ingame-infochat.yaml b/mods/common/chrome/ingame-infochat.yaml index e7af126d2b..0cd9c36d79 100644 --- a/mods/common/chrome/ingame-infochat.yaml +++ b/mods/common/chrome/ingame-infochat.yaml @@ -15,6 +15,9 @@ Container@CHAT_CONTAINER: Height: 25 Text: Team Font: Bold + Key: Tab SHIFT + TooltipText: Toggle chat mode + TooltipContainer: TOOLTIP_CONTAINER TextField@CHAT_TEXTFIELD: X: 55 Y: PARENT_BOTTOM - HEIGHT diff --git a/mods/common/chrome/lobby.yaml b/mods/common/chrome/lobby.yaml index 4b653ee76a..713d0f06f3 100644 --- a/mods/common/chrome/lobby.yaml +++ b/mods/common/chrome/lobby.yaml @@ -131,6 +131,9 @@ Background@SERVER_LOBBY: Height: 25 Text: Team Font: Bold + Key: Tab SHIFT + TooltipText: Toggle chat mode + TooltipContainer: TOOLTIP_CONTAINER TextField@CHAT_TEXTFIELD: X: 55 Y: PARENT_BOTTOM - HEIGHT diff --git a/mods/common/chrome/settings-hotkeys.yaml b/mods/common/chrome/settings-hotkeys.yaml index 15c8c49367..1583478f0d 100644 --- a/mods/common/chrome/settings-hotkeys.yaml +++ b/mods/common/chrome/settings-hotkeys.yaml @@ -25,6 +25,9 @@ Container@HOTKEYS_PANEL: Music Commands: Template: TWO_COLUMN Types: Music + Chat Commands: + Template: TWO_COLUMN + Types: Chat Width: PARENT_RIGHT - 10 Height: PARENT_BOTTOM Children: diff --git a/mods/common/hotkeys/chat.yaml b/mods/common/hotkeys/chat.yaml new file mode 100644 index 0000000000..eda2545565 --- /dev/null +++ b/mods/common/hotkeys/chat.yaml @@ -0,0 +1,7 @@ +OpenTeamChat: Return + Description: Open Team Chat + Types: Chat, Player, Spectator + +OpenGeneralChat: Return Shift + Description: Open General Chat + Types: Chat, Player, Spectator diff --git a/mods/d2k/mod.yaml b/mods/d2k/mod.yaml index e7ec6f4976..0fcff6a995 100644 --- a/mods/d2k/mod.yaml +++ b/mods/d2k/mod.yaml @@ -138,6 +138,7 @@ Hotkeys: common|hotkeys/production-common.yaml common|hotkeys/supportpowers.yaml common|hotkeys/viewport.yaml + common|hotkeys/chat.yaml d2k|hotkeys.yaml LoadScreen: LogoStripeLoadScreen diff --git a/mods/ra/mod.yaml b/mods/ra/mod.yaml index f9320c8178..0989c401ed 100644 --- a/mods/ra/mod.yaml +++ b/mods/ra/mod.yaml @@ -159,6 +159,7 @@ Hotkeys: common|hotkeys/production-common.yaml common|hotkeys/supportpowers.yaml common|hotkeys/viewport.yaml + common|hotkeys/chat.yaml ra|hotkeys.yaml LoadScreen: LogoStripeLoadScreen diff --git a/mods/ts/mod.yaml b/mods/ts/mod.yaml index 0c9f2757d0..19d7e70f1b 100644 --- a/mods/ts/mod.yaml +++ b/mods/ts/mod.yaml @@ -196,6 +196,7 @@ Hotkeys: common|hotkeys/production-common.yaml common|hotkeys/supportpowers.yaml common|hotkeys/viewport.yaml + common|hotkeys/chat.yaml ts|hotkeys.yaml LoadScreen: LogoStripeLoadScreen