Rid SpawnSelectorTooltipLogic from "Country"

This commit is contained in:
Pavel Penev
2015-08-05 17:35:07 +03:00
parent 957af9ac5e
commit 50f4508123

View File

@@ -33,7 +33,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var cachedWidth = 0; var cachedWidth = 0;
var labelText = ""; var labelText = "";
string playerCountry = null; string playerFaction = null;
var playerTeam = -1; var playerTeam = -1;
tooltipContainer.BeforeRender = () => tooltipContainer.BeforeRender = () =>
@@ -44,20 +44,20 @@ namespace OpenRA.Mods.Common.Widgets.Logic
if (occupant == null) if (occupant == null)
{ {
labelText = "Available spawn"; labelText = "Available spawn";
playerCountry = null; playerFaction = null;
playerTeam = 0; playerTeam = 0;
widget.Bounds.Height = singleHeight; widget.Bounds.Height = singleHeight;
} }
else else
{ {
labelText = occupant.PlayerName; labelText = occupant.PlayerName;
playerCountry = occupant.Faction; playerFaction = occupant.Faction;
playerTeam = occupant.Team; playerTeam = occupant.Team;
widget.Bounds.Height = playerTeam > 0 ? doubleHeight : singleHeight; widget.Bounds.Height = playerTeam > 0 ? doubleHeight : singleHeight;
teamWidth = teamFont.Measure(team.GetText()).X; teamWidth = teamFont.Measure(team.GetText()).X;
} }
label.Bounds.X = playerCountry != null ? flag.Bounds.Right + labelMargin : labelMargin; label.Bounds.X = playerFaction != null ? flag.Bounds.Right + labelMargin : labelMargin;
var textWidth = ownerFont.Measure(labelText).X; var textWidth = ownerFont.Measure(labelText).X;
if (textWidth != cachedWidth) if (textWidth != cachedWidth)
@@ -71,9 +71,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
}; };
label.GetText = () => labelText; label.GetText = () => labelText;
flag.IsVisible = () => playerCountry != null; flag.IsVisible = () => playerFaction != null;
flag.GetImageCollection = () => "flags"; flag.GetImageCollection = () => "flags";
flag.GetImageName = () => playerCountry; flag.GetImageName = () => playerFaction;
team.GetText = () => "Team {0}".F(playerTeam); team.GetText = () => "Team {0}".F(playerTeam);
team.IsVisible = () => playerTeam > 0; team.IsVisible = () => playerTeam > 0;
} }