diff --git a/OpenRA.Mods.RA/Widgets/Delegates/LobbyDelegate.cs b/OpenRA.Mods.RA/Widgets/Delegates/LobbyDelegate.cs index 8d1af3b77f..ab105c55e8 100755 --- a/OpenRA.Mods.RA/Widgets/Delegates/LobbyDelegate.cs +++ b/OpenRA.Mods.RA/Widgets/Delegates/LobbyDelegate.cs @@ -278,6 +278,26 @@ namespace OpenRA.Widgets.Delegates }); } + void ShowTeamDropDown(ButtonWidget team) + { + var dropDownOptions = new List>(); + for (int i = 0; i <= Map.PlayerCount; i++) + { + var ii = i; + dropDownOptions.Add(new Pair( ii == 0 ? "-" : ii.ToString(), + () => orderManager.IssueOrder( Order.Command("team "+ii) )) ); + }; + + DropDownButtonWidget.ShowDropDown( team, + dropDownOptions, + (ac, w) => new LabelWidget + { + Bounds = new Rectangle(0, 0, w, 24), + Text = " {0}".F(ac.First), + OnMouseUp = mi => { ac.Second(); return true; }, + }); + } + void UpdatePlayerList() { // This causes problems for people who are in the process of editing their names (the widgets vanish from beneath them) @@ -392,7 +412,7 @@ namespace OpenRA.Widgets.Delegates factionflag.GetImageCollection = () => "flags"; var team = template.GetWidget("TEAM"); - team.OnMouseUp = CycleTeam; + team.OnMouseDown = _ => {ShowTeamDropDown(team); return true;}; team.GetText = () => (c.Team == 0) ? "-" : c.Team.ToString(); var status = template.GetWidget("STATUS"); @@ -456,15 +476,5 @@ namespace OpenRA.Widgets.Delegates orderManager.IssueOrder(Order.Command("ready")); return true; } - - bool CycleTeam(MouseInput mi) - { - var d = (mi.Button == MouseButton.Left) ? +1 : Map.PlayerCount; - var newIndex = (orderManager.LocalClient.Team + d) % (Map.PlayerCount + 1); - - orderManager.IssueOrder( - Order.Command("team " + newIndex)); - return true; - } } }