Rebind chat hotkeys to prevent Tab changing chat mode
Enter/Shift+Enter now toggle team/all chat respectively and Shift+Tab switches chat mode instead of Tab
This commit is contained in:
committed by
Paul Chote
parent
6967c1fff3
commit
a8900d9860
@@ -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)
|
||||
|
||||
@@ -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<ButtonWidget>("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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
7
mods/common/hotkeys/chat.yaml
Normal file
7
mods/common/hotkeys/chat.yaml
Normal file
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user