From 9ca9d9a47e742c5abb558065d24f580ac035fd0c Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Wed, 30 Jun 2010 19:49:51 +1200 Subject: [PATCH] Fix country names in lobby --- OpenRA.Game/Server/Server.cs | 2 +- OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs | 11 +++++++---- mods/cnc/chrome.xml | 14 +++++++------- mods/ra/chrome.xml | 14 +++++++------- 4 files changed, 22 insertions(+), 19 deletions(-) diff --git a/OpenRA.Game/Server/Server.cs b/OpenRA.Game/Server/Server.cs index 99db3e4f5b..e3035f358d 100644 --- a/OpenRA.Game/Server/Server.cs +++ b/OpenRA.Game/Server/Server.cs @@ -150,7 +150,7 @@ namespace OpenRA.Server Index = newConn.PlayerIndex, PaletteIndex = ChooseFreePalette(), Name = "Player {0}".F(1 + newConn.PlayerIndex), - Country = "Random", + Country = "random", State = Session.ClientState.NotReady, SpawnPoint = 0, Team = 0, diff --git a/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs b/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs index f09d84d995..2dcd230e2e 100644 --- a/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs +++ b/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs @@ -30,6 +30,7 @@ namespace OpenRA.Widgets.Delegates { Widget Players, LocalPlayerTemplate, RemotePlayerTemplate; + Dictionary CountryNames; public LobbyDelegate () { var r = Chrome.rootWidget; @@ -38,6 +39,8 @@ namespace OpenRA.Widgets.Delegates LocalPlayerTemplate = Players.GetWidget("TEMPLATE_LOCAL"); RemotePlayerTemplate = Players.GetWidget("TEMPLATE_REMOTE"); + CountryNames = Rules.Info["world"].Traits.WithInterface().ToDictionary(a => a.Race, a => a.Name); + CountryNames.Add("random", "Random"); var mapButton = lobby.GetWidget("CHANGEMAP_BUTTON"); mapButton.OnMouseUp = mi => { @@ -78,7 +81,7 @@ namespace OpenRA.Widgets.Delegates var faction = template.GetWidget("FACTION"); faction.OnMouseUp = CycleRace; var factionname = faction.GetWidget("FACTIONNAME"); - factionname.GetText = () => c.Country; + factionname.GetText = () => CountryNames[c.Country]; var factionflag = faction.GetWidget("FACTIONFLAG"); factionflag.GetImageName = () => c.Country; factionflag.GetImageCollection = () => "flags"; @@ -100,7 +103,7 @@ namespace OpenRA.Widgets.Delegates var faction = template.GetWidget("FACTION"); var factionname = faction.GetWidget("FACTIONNAME"); - factionname.GetText = () => c.Country; + factionname.GetText = () => CountryNames[c.Country]; var factionflag = faction.GetWidget("FACTIONFLAG"); factionflag.GetImageName = () => c.Country; factionflag.GetImageCollection = () => "flags"; @@ -142,10 +145,10 @@ namespace OpenRA.Widgets.Delegates return true; } - + bool CycleRace(MouseInput mi) { - var countries = new[] { "Random" }.Concat(Game.world.GetCountries().Select(c => c.Race)); + var countries = CountryNames.Select(a => a.Key); if (mi.Button == MouseButton.Right) countries = countries.Reverse(); diff --git a/mods/cnc/chrome.xml b/mods/cnc/chrome.xml index cdef465386..ae2ecbd3e7 100644 --- a/mods/cnc/chrome.xml +++ b/mods/cnc/chrome.xml @@ -12,11 +12,11 @@ - + - + - + @@ -58,11 +58,11 @@ - + - + - + @@ -199,7 +199,7 @@ - + diff --git a/mods/ra/chrome.xml b/mods/ra/chrome.xml index f41758662c..5d5f0cbda1 100644 --- a/mods/ra/chrome.xml +++ b/mods/ra/chrome.xml @@ -11,9 +11,9 @@ - - - + + + @@ -54,9 +54,9 @@ - - - + + + @@ -192,7 +192,7 @@ - +