diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/CncLobbyLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/CncLobbyLogic.cs index c5d17fff3a..7b858b39a6 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/CncLobbyLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/CncLobbyLogic.cs @@ -298,23 +298,6 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic } } - void ShowRaceDropDown(DropDownButtonWidget dropdown, Session.Client client) - { - Func setupItem = (race, itemTemplate) => - { - var item = ScrollItemWidget.Setup(itemTemplate, - () => client.Country == race, - () => orderManager.IssueOrder(Order.Command("race {0} {1}".F(client.Index, race)))); - item.GetWidget("LABEL").GetText = () => CountryNames[race]; - var flag = item.GetWidget("FLAG"); - flag.GetImageCollection = () => "flags"; - flag.GetImageName = () => race; - return item; - }; - - dropdown.ShowDropDown("RACE_DROPDOWN_TEMPLATE", 150, CountryNames.Keys.ToList(), setupItem); - } - void ShowSpawnDropDown(DropDownButtonWidget dropdown, Session.Client client) { Func setupItem = (ii, itemTemplate) => @@ -434,7 +417,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic var faction = template.GetWidget("FACTION"); faction.IsDisabled = () => slot.LockRace || ready; - faction.OnMouseDown = _ => ShowRaceDropDown(faction, client); + faction.OnMouseDown = _ => LobbyUtils.ShowRaceDropDown(faction, client, orderManager, CountryNames); var factionname = faction.GetWidget("FACTIONNAME"); factionname.GetText = () => CountryNames[client.Country]; diff --git a/OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs index c0f2011752..6af11f0dcd 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs @@ -207,23 +207,6 @@ namespace OpenRA.Mods.RA.Widgets.Logic title.Text = "OpenRA Multiplayer Lobby - " + orderManager.LobbyInfo.GlobalSettings.ServerName; } - void ShowRaceDropDown(DropDownButtonWidget dropdown, Session.Client client) - { - Func setupItem = (race, itemTemplate) => - { - var item = ScrollItemWidget.Setup(itemTemplate, - () => client.Country == race, - () => orderManager.IssueOrder(Order.Command("race {0} {1}".F(client.Index, race)))); - item.GetWidget("LABEL").GetText = () => CountryNames[race]; - var flag = item.GetWidget("FLAG"); - flag.GetImageCollection = () => "flags"; - flag.GetImageName = () => race; - return item; - }; - - dropdown.ShowDropDown("RACE_DROPDOWN_TEMPLATE", 150, CountryNames.Keys.ToList(), setupItem); - } - void ShowColorDropDown(DropDownButtonWidget color, Session.Client client) { var colorChooser = Game.modData.WidgetLoader.LoadWidget( new WidgetArgs() { {"worldRenderer", worldRenderer} }, null, "COLOR_CHOOSER" ); @@ -308,7 +291,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic var faction = template.GetWidget("FACTION"); faction.IsDisabled = () => s.LockRace; - faction.OnMouseDown = _ => ShowRaceDropDown(faction, c); + faction.OnMouseDown = _ => LobbyUtils.ShowRaceDropDown(faction, c, orderManager, CountryNames); var factionname = faction.GetWidget("FACTIONNAME"); factionname.GetText = () => CountryNames[c.Country]; @@ -500,5 +483,23 @@ namespace OpenRA.Mods.RA.Widgets.Logic var options = Graphics.Util.MakeArray(map.SpawnPoints.Count() + 1, i => i).ToList(); dropdown.ShowDropDown("TEAM_DROPDOWN_TEMPLATE", 150, options, setupItem); } + + public static void ShowRaceDropDown(DropDownButtonWidget dropdown, Session.Client client, + OrderManager orderManager, Dictionary countryNames) + { + Func setupItem = (race, itemTemplate) => + { + var item = ScrollItemWidget.Setup(itemTemplate, + () => client.Country == race, + () => orderManager.IssueOrder(Order.Command("race {0} {1}".F(client.Index, race)))); + item.GetWidget("LABEL").GetText = () => countryNames[race]; + var flag = item.GetWidget("FLAG"); + flag.GetImageCollection = () => "flags"; + flag.GetImageName = () => race; + return item; + }; + + dropdown.ShowDropDown("RACE_DROPDOWN_TEMPLATE", 150, countryNames.Keys.ToList(), setupItem); + } } }