Use proper names and flags for unknown players

This commit is contained in:
penev92
2015-04-03 17:30:44 +03:00
parent a26be8188c
commit 2c108a1845
4 changed files with 10 additions and 3 deletions

View File

@@ -27,6 +27,7 @@ namespace OpenRA
public bool LockRace = false;
public string Race;
public string RaceFlagName;
// ColorRamp naming retained for backward compatibility
public bool LockColor = false;

View File

@@ -46,7 +46,9 @@ namespace OpenRA
public Shroud Shroud;
public World World { get; private set; }
static CountryInfo ChooseCountry(World world, string name, bool requireSelectable = true)
string selectedCountryName;
CountryInfo ChooseCountry(World world, string name, bool requireSelectable = true)
{
var selectableCountries = world.Map.Rules.Actors["world"].Traits
.WithInterface<CountryInfo>().Where(c => !requireSelectable || c.Selectable)
@@ -55,6 +57,8 @@ namespace OpenRA
var selected = selectableCountries.FirstOrDefault(c => c.Race == name)
?? selectableCountries.Random(world.SharedRandom);
selectedCountryName = selected.Name;
// Don't loop infinite
for (var i = 0; i <= 10 && selected.RandomRaceMembers.Any(); i++)
{
@@ -83,6 +87,8 @@ namespace OpenRA
PlayerName = client.Name;
botType = client.Bot;
Country = ChooseCountry(world, client.Race);
pr.Race = selectedCountryName;
pr.RaceFlagName = client.Race;
}
else
{

View File

@@ -62,7 +62,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
}
else
{
flag.GetImageName = () => pp.PlayerReference.Race;
flag.GetImageName = () => pp.PlayerReference.RaceFlagName;
item.Get<LabelWidget>("FACTION").GetText = () => pp.PlayerReference.Race;
}

View File

@@ -466,7 +466,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var flag = template.Get<ImageWidget>("FLAG");
flag.GetImageCollection = () => "flags";
if (player.World.RenderPlayer != null && player.World.RenderPlayer.Stances[player] != Stance.Ally)
flag.GetImageName = () => player.PlayerReference.Race;
flag.GetImageName = () => player.PlayerReference.RaceFlagName;
else
flag.GetImageName = () => player.Country.Race;