Fix country names in lobby

This commit is contained in:
Paul Chote
2010-06-30 19:49:51 +12:00
parent e5ce9196fa
commit 9ca9d9a47e
4 changed files with 22 additions and 19 deletions

View File

@@ -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,

View File

@@ -30,6 +30,7 @@ namespace OpenRA.Widgets.Delegates
{
Widget Players, LocalPlayerTemplate, RemotePlayerTemplate;
Dictionary<string,string> 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<OpenRA.Traits.CountryInfo>().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<ButtonWidget>("FACTION");
faction.OnMouseUp = CycleRace;
var factionname = faction.GetWidget<LabelWidget>("FACTIONNAME");
factionname.GetText = () => c.Country;
factionname.GetText = () => CountryNames[c.Country];
var factionflag = faction.GetWidget<ImageWidget>("FACTIONFLAG");
factionflag.GetImageName = () => c.Country;
factionflag.GetImageCollection = () => "flags";
@@ -100,7 +103,7 @@ namespace OpenRA.Widgets.Delegates
var faction = template.GetWidget<LabelWidget>("FACTION");
var factionname = faction.GetWidget<LabelWidget>("FACTIONNAME");
factionname.GetText = () => c.Country;
factionname.GetText = () => CountryNames[c.Country];
var factionflag = faction.GetWidget<ImageWidget>("FACTIONFLAG");
factionflag.GetImageName = () => c.Country;
factionflag.GetImageCollection = () => "flags";
@@ -145,7 +148,7 @@ namespace OpenRA.Widgets.Delegates
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();

View File

@@ -199,7 +199,7 @@
<collection name="flags" src="buttons.png">
<image name="gdi" x="30" y="84" width="30" height="15" />
<image name="nod" x="0" y="84" width="30" height="15" />
<image name="Random" x="60" y="84" width="30" height="15" />
<image name="random" x="60" y="84" width="30" height="15" />
</collection>
<collection name="music" src="musicplayer.png">
<image name="pause" x="0" y="0" width="25" height="25" />

View File

@@ -192,7 +192,7 @@
<collection name="flags" src="buttons.png">
<image name="allies" x="30" y="84" width="30" height="15" />
<image name="soviet" x="0" y="84" width="30" height="15" />
<image name="Random" x="60" y="84" width="30" height="15" />
<image name="random" x="60" y="84" width="30" height="15" />
</collection>
<collection name="music" src="musicplayer.png">
<image name="pause" x="0" y="0" width="25" height="25" />