diff --git a/OpenRA.Game/Network/Order.cs b/OpenRA.Game/Network/Order.cs index b44b03c31c..85a6a2c38a 100755 --- a/OpenRA.Game/Network/Order.cs +++ b/OpenRA.Game/Network/Order.cs @@ -189,21 +189,17 @@ namespace OpenRA // Named constructors for Orders. // Now that Orders are resolved by individual Actors, these are weird; you unpack orders manually, but not pack them. - public static Order Chat(string text) + + public static Order Chat(bool team, string text) { - return new Order("Chat", null, false) { IsImmediate = true, TargetString = text}; + return new Order(team ? "TeamChat" : "Chat", null, false) { IsImmediate = true, TargetString = text}; } - public static Order TeamChat(string text) - { - return new Order("TeamChat", null, false) { IsImmediate = true, TargetString = text }; - } - public static Order HandshakeResponse(string text) { return new Order("HandshakeResponse", null, false) { IsImmediate = true, TargetString = text }; } - + public static Order Command(string text) { return new Order("Command", null, false) { IsImmediate = true, TargetString = text }; diff --git a/OpenRA.Game/Widgets/ChatEntryWidget.cs b/OpenRA.Game/Widgets/ChatEntryWidget.cs index 9ef4f19ed2..d085bcfb7e 100755 --- a/OpenRA.Game/Widgets/ChatEntryWidget.cs +++ b/OpenRA.Game/Widgets/ChatEntryWidget.cs @@ -16,9 +16,6 @@ namespace OpenRA.Widgets // a dirty hack of a widget, which likes to steal the focus when \r is pressed, and then // refuse to give it up until \r is pressed again. - // this emulates the previous chat support, with one improvement: shift+enter can toggle the - // team/all mode *while* composing, not just on beginning to compose. - public class ChatEntryWidget : Widget { string content = ""; @@ -27,6 +24,7 @@ namespace OpenRA.Widgets public readonly bool UseContrast = false; readonly OrderManager orderManager; + [ObjectCreator.UseCtor] internal ChatEntryWidget( [ObjectCreator.Param] OrderManager orderManager ) { @@ -44,8 +42,9 @@ namespace OpenRA.Widgets Game.Renderer.Fonts["Regular"].DrawTextWithContrast(content, RenderOrigin + new float2(3 + w, 7), Color.White, Color.Black, UseContrast ? 1 : 0); } } - + public override Rectangle EventBounds { get { return Rectangle.Empty; } } + public override bool LoseFocus(MouseInput mi) { return composing ? false : base.LoseFocus(mi); @@ -67,9 +66,7 @@ namespace OpenRA.Widgets composing = false; if (content != "") - orderManager.IssueOrder(teamChat - ? Order.TeamChat(content) - : Order.Chat(content)); + orderManager.IssueOrder(Order.Chat(teamChat, content)); content = ""; LoseFocus(); @@ -79,14 +76,8 @@ namespace OpenRA.Widgets { TakeFocus(new MouseInput()); composing = true; - if (Game.Settings.Game.TeamChatToggle) - { - teamChat ^= e.Modifiers.HasModifier(Modifiers.Shift); - } - else - { - teamChat = e.Modifiers.HasModifier(Modifiers.Shift); - } + teamChat = (Game.Settings.Game.TeamChatToggle && teamChat) + ^ e.Modifiers.HasModifier(Modifiers.Shift); return true; } } diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/CncLobbyLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/CncLobbyLogic.cs index 206fcc7eee..4b3a93ad1e 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/CncLobbyLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/CncLobbyLogic.cs @@ -198,13 +198,13 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic bool teamChat = false; var chatLabel = lobby.GetWidget("LABEL_CHATTYPE"); var chatTextField = lobby.GetWidget("CHAT_TEXTFIELD"); + chatTextField.OnEnterKey = () => { if (chatTextField.Text.Length == 0) return true; - var order = (teamChat) ? Order.TeamChat(chatTextField.Text) : Order.Chat(chatTextField.Text); - orderManager.IssueOrder(order); + orderManager.IssueOrder(Order.Chat(teamChat, chatTextField.Text)); chatTextField.Text = ""; return true; }; diff --git a/OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs index 65e0adeba7..53f28c7426 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs @@ -146,8 +146,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic if (chatTextField.Text.Length == 0) return true; - var order = (teamChat) ? Order.TeamChat(chatTextField.Text) : Order.Chat(chatTextField.Text); - orderManager.IssueOrder(order); + orderManager.IssueOrder(Order.Chat(teamChat, chatTextField.Text)); chatTextField.Text = ""; return true; };