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, Index = newConn.PlayerIndex,
PaletteIndex = ChooseFreePalette(), PaletteIndex = ChooseFreePalette(),
Name = "Player {0}".F(1 + newConn.PlayerIndex), Name = "Player {0}".F(1 + newConn.PlayerIndex),
Country = "Random", Country = "random",
State = Session.ClientState.NotReady, State = Session.ClientState.NotReady,
SpawnPoint = 0, SpawnPoint = 0,
Team = 0, Team = 0,

View File

@@ -30,6 +30,7 @@ namespace OpenRA.Widgets.Delegates
{ {
Widget Players, LocalPlayerTemplate, RemotePlayerTemplate; Widget Players, LocalPlayerTemplate, RemotePlayerTemplate;
Dictionary<string,string> CountryNames;
public LobbyDelegate () public LobbyDelegate ()
{ {
var r = Chrome.rootWidget; var r = Chrome.rootWidget;
@@ -38,6 +39,8 @@ namespace OpenRA.Widgets.Delegates
LocalPlayerTemplate = Players.GetWidget("TEMPLATE_LOCAL"); LocalPlayerTemplate = Players.GetWidget("TEMPLATE_LOCAL");
RemotePlayerTemplate = Players.GetWidget("TEMPLATE_REMOTE"); 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"); var mapButton = lobby.GetWidget("CHANGEMAP_BUTTON");
mapButton.OnMouseUp = mi => { mapButton.OnMouseUp = mi => {
@@ -78,7 +81,7 @@ namespace OpenRA.Widgets.Delegates
var faction = template.GetWidget<ButtonWidget>("FACTION"); var faction = template.GetWidget<ButtonWidget>("FACTION");
faction.OnMouseUp = CycleRace; faction.OnMouseUp = CycleRace;
var factionname = faction.GetWidget<LabelWidget>("FACTIONNAME"); var factionname = faction.GetWidget<LabelWidget>("FACTIONNAME");
factionname.GetText = () => c.Country; factionname.GetText = () => CountryNames[c.Country];
var factionflag = faction.GetWidget<ImageWidget>("FACTIONFLAG"); var factionflag = faction.GetWidget<ImageWidget>("FACTIONFLAG");
factionflag.GetImageName = () => c.Country; factionflag.GetImageName = () => c.Country;
factionflag.GetImageCollection = () => "flags"; factionflag.GetImageCollection = () => "flags";
@@ -100,7 +103,7 @@ namespace OpenRA.Widgets.Delegates
var faction = template.GetWidget<LabelWidget>("FACTION"); var faction = template.GetWidget<LabelWidget>("FACTION");
var factionname = faction.GetWidget<LabelWidget>("FACTIONNAME"); var factionname = faction.GetWidget<LabelWidget>("FACTIONNAME");
factionname.GetText = () => c.Country; factionname.GetText = () => CountryNames[c.Country];
var factionflag = faction.GetWidget<ImageWidget>("FACTIONFLAG"); var factionflag = faction.GetWidget<ImageWidget>("FACTIONFLAG");
factionflag.GetImageName = () => c.Country; factionflag.GetImageName = () => c.Country;
factionflag.GetImageCollection = () => "flags"; factionflag.GetImageCollection = () => "flags";
@@ -142,10 +145,10 @@ namespace OpenRA.Widgets.Delegates
return true; return true;
} }
bool CycleRace(MouseInput mi) 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) if (mi.Button == MouseButton.Right)
countries = countries.Reverse(); countries = countries.Reverse();

View File

@@ -12,11 +12,11 @@
<image name="bottom" x="297" y="223" width="210" height="30" /> <image name="bottom" x="297" y="223" width="210" height="30" />
<image name="bg" x="306" y="31" width="192" height="192" /> <image name="bg" x="306" y="31" width="192" height="192" />
<image name="power-indicator" x="187" y="4" width="4" height="7" /> <image name="power-indicator" x="187" y="4" width="4" height="7" />
</collection> </collection>
<collection name="power-gdi" src="chrome-gdi.png"> <collection name="power-gdi" src="chrome-gdi.png">
<image name="power-indicator" x="187" y="4" width="4" height="7" /> <image name="power-indicator" x="187" y="4" width="4" height="7" />
</collection> </collection>
<collection name="palette-gdi" src="chrome-gdi.png"> <collection name="palette-gdi" src="chrome-gdi.png">
@@ -58,11 +58,11 @@
<image name="bottom" x="297" y="223" width="210" height="30" /> <image name="bottom" x="297" y="223" width="210" height="30" />
<image name="bg" x="306" y="31" width="192" height="192" /> <image name="bg" x="306" y="31" width="192" height="192" />
<image name="power-indicator" x="187" y="4" width="4" height="7" /> <image name="power-indicator" x="187" y="4" width="4" height="7" />
</collection> </collection>
<collection name="power-nod" src="chrome-nod.png"> <collection name="power-nod" src="chrome-nod.png">
<image name="power-indicator" x="187" y="4" width="4" height="7" /> <image name="power-indicator" x="187" y="4" width="4" height="7" />
</collection> </collection>
<collection name="palette-nod" src="chrome-nod.png"> <collection name="palette-nod" src="chrome-nod.png">
@@ -199,7 +199,7 @@
<collection name="flags" src="buttons.png"> <collection name="flags" src="buttons.png">
<image name="gdi" x="30" y="84" width="30" height="15" /> <image name="gdi" x="30" y="84" width="30" height="15" />
<image name="nod" x="0" 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>
<collection name="music" src="musicplayer.png"> <collection name="music" src="musicplayer.png">
<image name="pause" x="0" y="0" width="25" height="25" /> <image name="pause" x="0" y="0" width="25" height="25" />

View File

@@ -11,9 +11,9 @@
<image name="right" x="498" y="31" width="9" height="192" /> <image name="right" x="498" y="31" width="9" height="192" />
<image name="bottom" x="297" y="223" width="210" height="30" /> <image name="bottom" x="297" y="223" width="210" height="30" />
<image name="bg" x="306" y="31" width="192" height="192" /> <image name="bg" x="306" y="31" width="192" height="192" />
</collection> </collection>
<collection name="power-allies" src="chrome-allies.png"> <collection name="power-allies" src="chrome-allies.png">
<image name="power-indicator" x="187" y="4" width="4" height="7" /> <image name="power-indicator" x="187" y="4" width="4" height="7" />
</collection> </collection>
<collection name="palette-allies" src="chrome-allies.png"> <collection name="palette-allies" src="chrome-allies.png">
<image name="top" x="297" y="288" width="201" height="9" /> <image name="top" x="297" y="288" width="201" height="9" />
@@ -54,9 +54,9 @@
<image name="bottom" x="297" y="223" width="210" height="30" /> <image name="bottom" x="297" y="223" width="210" height="30" />
<image name="bg" x="306" y="31" width="192" height="192" /> <image name="bg" x="306" y="31" width="192" height="192" />
<image name="power-indicator" x="187" y="4" width="4" height="7" /> <image name="power-indicator" x="187" y="4" width="4" height="7" />
</collection> </collection>
<collection name="power-soviet" src="chrome-soviet.png"> <collection name="power-soviet" src="chrome-soviet.png">
<image name="power-indicator" x="187" y="4" width="4" height="7" /> <image name="power-indicator" x="187" y="4" width="4" height="7" />
</collection> </collection>
<collection name="palette-soviet" src="chrome-soviet.png"> <collection name="palette-soviet" src="chrome-soviet.png">
<image name="top" x="297" y="288" width="201" height="9" /> <image name="top" x="297" y="288" width="201" height="9" />
@@ -192,7 +192,7 @@
<collection name="flags" src="buttons.png"> <collection name="flags" src="buttons.png">
<image name="allies" x="30" y="84" width="30" height="15" /> <image name="allies" x="30" y="84" width="30" height="15" />
<image name="soviet" x="0" 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>
<collection name="music" src="musicplayer.png"> <collection name="music" src="musicplayer.png">
<image name="pause" x="0" y="0" width="25" height="25" /> <image name="pause" x="0" y="0" width="25" height="25" />