allow TAB to switch team/all chat when nothing is auto-completed
This commit is contained in:
@@ -35,6 +35,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
|
|
||||||
readonly TabCompletionLogic tabCompletion = new TabCompletionLogic();
|
readonly TabCompletionLogic tabCompletion = new TabCompletionLogic();
|
||||||
|
|
||||||
|
bool disableTeamChat;
|
||||||
bool teamChat;
|
bool teamChat;
|
||||||
bool inDialog;
|
bool inDialog;
|
||||||
|
|
||||||
@@ -47,7 +48,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
chatTraits = world.WorldActor.TraitsImplementing<INotifyChat>().ToList();
|
chatTraits = world.WorldActor.TraitsImplementing<INotifyChat>().ToList();
|
||||||
|
|
||||||
var players = world.Players.Where(p => p != world.LocalPlayer && !p.NonCombatant && !p.IsBot);
|
var players = world.Players.Where(p => p != world.LocalPlayer && !p.NonCombatant && !p.IsBot);
|
||||||
var disableTeamChat = world.LocalPlayer == null || world.LobbyInfo.IsSinglePlayer || !players.Any(p => p.IsAlliedWith(world.LocalPlayer));
|
disableTeamChat = world.LocalPlayer == null || world.LobbyInfo.IsSinglePlayer || !players.Any(p => p.IsAlliedWith(world.LocalPlayer));
|
||||||
teamChat = !disableTeamChat;
|
teamChat = !disableTeamChat;
|
||||||
|
|
||||||
tabCompletion.Commands = chatTraits.OfType<ChatCommands>().SelectMany(x => x.Commands.Keys).ToList();
|
tabCompletion.Commands = chatTraits.OfType<ChatCommands>().SelectMany(x => x.Commands.Keys).ToList();
|
||||||
@@ -72,12 +73,6 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
chatMode.IsDisabled = () => disableTeamChat;
|
chatMode.IsDisabled = () => disableTeamChat;
|
||||||
|
|
||||||
chatText = chatChrome.Get<TextFieldWidget>("CHAT_TEXTFIELD");
|
chatText = chatChrome.Get<TextFieldWidget>("CHAT_TEXTFIELD");
|
||||||
chatText.OnAltKey = () =>
|
|
||||||
{
|
|
||||||
if (!disableTeamChat)
|
|
||||||
teamChat ^= true;
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
chatText.OnEnterKey = () =>
|
chatText.OnEnterKey = () =>
|
||||||
{
|
{
|
||||||
var team = teamChat && !disableTeamChat;
|
var team = teamChat && !disableTeamChat;
|
||||||
@@ -98,11 +93,15 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
};
|
};
|
||||||
chatText.OnTabKey = () =>
|
chatText.OnTabKey = () =>
|
||||||
{
|
{
|
||||||
|
var previousText = chatText.Text;
|
||||||
chatText.Text = tabCompletion.Complete(chatText.Text);
|
chatText.Text = tabCompletion.Complete(chatText.Text);
|
||||||
chatText.CursorPosition = chatText.Text.Length;
|
chatText.CursorPosition = chatText.Text.Length;
|
||||||
|
|
||||||
|
if (chatText.Text == previousText)
|
||||||
|
return SwitchTeamChat();
|
||||||
|
else
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
chatText.OnEscKey = () => { CloseChat(); return true; };
|
chatText.OnEscKey = () => { CloseChat(); return true; };
|
||||||
|
|
||||||
if (!inDialog)
|
if (!inDialog)
|
||||||
@@ -138,6 +137,13 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
CloseChat();
|
CloseChat();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SwitchTeamChat()
|
||||||
|
{
|
||||||
|
if (!disableTeamChat)
|
||||||
|
teamChat ^= true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void UnregisterEvents()
|
void UnregisterEvents()
|
||||||
{
|
{
|
||||||
orderManager.AddChatLine -= AddChatLineWrapper;
|
orderManager.AddChatLine -= AddChatLineWrapper;
|
||||||
|
|||||||
@@ -55,6 +55,9 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
|
|
||||||
readonly TabCompletionLogic tabCompletion = new TabCompletionLogic();
|
readonly TabCompletionLogic tabCompletion = new TabCompletionLogic();
|
||||||
|
|
||||||
|
readonly LabelWidget chatLabel;
|
||||||
|
bool teamChat;
|
||||||
|
|
||||||
// Listen for connection failures
|
// Listen for connection failures
|
||||||
void ConnectionStateChanged(OrderManager om)
|
void ConnectionStateChanged(OrderManager om)
|
||||||
{
|
{
|
||||||
@@ -487,8 +490,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
if (skirmishMode)
|
if (skirmishMode)
|
||||||
disconnectButton.Text = "Cancel";
|
disconnectButton.Text = "Cancel";
|
||||||
|
|
||||||
var teamChat = false;
|
chatLabel = lobby.Get<LabelWidget>("LABEL_CHATTYPE");
|
||||||
var chatLabel = lobby.Get<LabelWidget>("LABEL_CHATTYPE");
|
|
||||||
var chatTextField = lobby.Get<TextFieldWidget>("CHAT_TEXTFIELD");
|
var chatTextField = lobby.Get<TextFieldWidget>("CHAT_TEXTFIELD");
|
||||||
|
|
||||||
chatTextField.TakeKeyboardFocus();
|
chatTextField.TakeKeyboardFocus();
|
||||||
@@ -505,16 +507,15 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
chatTextField.Text = "";
|
chatTextField.Text = "";
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
chatTextField.OnAltKey = () =>
|
|
||||||
{
|
|
||||||
teamChat ^= true;
|
|
||||||
chatLabel.Text = teamChat ? "Team:" : "Chat:";
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
chatTextField.OnTabKey = () =>
|
chatTextField.OnTabKey = () =>
|
||||||
{
|
{
|
||||||
|
var previousText = chatTextField.Text;
|
||||||
chatTextField.Text = tabCompletion.Complete(chatTextField.Text);
|
chatTextField.Text = tabCompletion.Complete(chatTextField.Text);
|
||||||
chatTextField.CursorPosition = chatTextField.Text.Length;
|
chatTextField.CursorPosition = chatTextField.Text.Length;
|
||||||
|
|
||||||
|
if (chatTextField.Text == previousText)
|
||||||
|
return SwitchTeamChat();
|
||||||
|
else
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -592,6 +593,13 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
Sound.PlayNotification(modRules, null, "Sounds", "ChatLine", null);
|
Sound.PlayNotification(modRules, null, "Sounds", "ChatLine", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SwitchTeamChat()
|
||||||
|
{
|
||||||
|
teamChat ^= true;
|
||||||
|
chatLabel.Text = teamChat ? "Team:" : "Chat:";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void UpdateCurrentMap()
|
void UpdateCurrentMap()
|
||||||
{
|
{
|
||||||
var uid = orderManager.LobbyInfo.GlobalSettings.Map;
|
var uid = orderManager.LobbyInfo.GlobalSettings.Map;
|
||||||
|
|||||||
Reference in New Issue
Block a user