From a26be8188c9698ab80254d47c32e6ef967823e66 Mon Sep 17 00:00:00 2001 From: penev92 Date: Mon, 23 Mar 2015 19:24:24 +0200 Subject: [PATCH 1/2] Hide faction for players who randomed in diplomacy and objectives panels --- .../Widgets/Logic/Ingame/GameInfoStatsLogic.cs | 13 +++++++++++-- .../Widgets/Logic/Lobby/LobbyUtils.cs | 5 ++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/GameInfoStatsLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/GameInfoStatsLogic.cs index 2bebdb5108..2cba17939c 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/GameInfoStatsLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/GameInfoStatsLogic.cs @@ -11,6 +11,7 @@ using System.Drawing; using System.Linq; using OpenRA.Mods.Common.Traits; +using OpenRA.Traits; using OpenRA.Widgets; namespace OpenRA.Mods.Common.Widgets.Logic @@ -53,9 +54,17 @@ namespace OpenRA.Mods.Common.Widgets.Logic nameLabel.GetColor = () => pp.Color.RGB; var flag = item.Get("FACTIONFLAG"); - flag.GetImageName = () => pp.Country.Race; flag.GetImageCollection = () => "flags"; - item.Get("FACTION").GetText = () => pp.Country.Name; + if (lp.Stances[pp] == Stance.Ally || lp.WinState != WinState.Undefined) + { + flag.GetImageName = () => pp.Country.Race; + item.Get("FACTION").GetText = () => pp.Country.Name; + } + else + { + flag.GetImageName = () => pp.PlayerReference.Race; + item.Get("FACTION").GetText = () => pp.PlayerReference.Race; + } var team = item.Get("TEAM"); var teamNumber = (client == null) ? 0 : client.Team; diff --git a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyUtils.cs b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyUtils.cs index 163987b45d..b1e8720728 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyUtils.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyUtils.cs @@ -464,8 +464,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic public static void AddPlayerFlagAndName(ScrollItemWidget template, Player player) { var flag = template.Get("FLAG"); - flag.GetImageName = () => player.Country.Race; flag.GetImageCollection = () => "flags"; + if (player.World.RenderPlayer != null && player.World.RenderPlayer.Stances[player] != Stance.Ally) + flag.GetImageName = () => player.PlayerReference.Race; + else + flag.GetImageName = () => player.Country.Race; var playerName = template.Get("PLAYER"); var client = player.World.LobbyInfo.ClientWithIndex(player.ClientIndex); From 2c108a18451e2a0b22f55162d2b2f3d8b5f92a24 Mon Sep 17 00:00:00 2001 From: penev92 Date: Fri, 3 Apr 2015 17:30:44 +0300 Subject: [PATCH 2/2] Use proper names and flags for unknown players --- OpenRA.Game/Map/PlayerReference.cs | 1 + OpenRA.Game/Player.cs | 8 +++++++- .../Widgets/Logic/Ingame/GameInfoStatsLogic.cs | 2 +- OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyUtils.cs | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/OpenRA.Game/Map/PlayerReference.cs b/OpenRA.Game/Map/PlayerReference.cs index c77da7606c..32fda208fa 100644 --- a/OpenRA.Game/Map/PlayerReference.cs +++ b/OpenRA.Game/Map/PlayerReference.cs @@ -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; diff --git a/OpenRA.Game/Player.cs b/OpenRA.Game/Player.cs index a04346a9d2..d23e3d7930 100644 --- a/OpenRA.Game/Player.cs +++ b/OpenRA.Game/Player.cs @@ -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().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 { diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/GameInfoStatsLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/GameInfoStatsLogic.cs index 2cba17939c..699bc7996a 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/GameInfoStatsLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/GameInfoStatsLogic.cs @@ -62,7 +62,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic } else { - flag.GetImageName = () => pp.PlayerReference.Race; + flag.GetImageName = () => pp.PlayerReference.RaceFlagName; item.Get("FACTION").GetText = () => pp.PlayerReference.Race; } diff --git a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyUtils.cs b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyUtils.cs index b1e8720728..afb0ba75f4 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyUtils.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyUtils.cs @@ -466,7 +466,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic var flag = template.Get("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;