1
0
forked from mirrors/0ad

Display phase emblems in the middle panel

This patch introduces phase emblems on both sides of the player's name
band in the middle panel. The emblems represent the current phase of
the selected player's civilization: I (Village), II (Town), III (City).
This information is also added to the associated tooltip and is
displayed only to mutual allies and observers.

Fixes #6849
See also: https://wildfiregames.com/forum/topic/107851-introduce-badge-to-indicate-the-phase-6849/
This commit is contained in:
abian
2024-10-10 20:16:34 +02:00
committed by Nicolas Auvray
parent fe16b919fe
commit 42052b69d9
6 changed files with 38 additions and 2 deletions
@@ -317,9 +317,31 @@ function displaySingle(entState)
});
secondaryObject.hidden = hideSecondary;
let isGaia = playerState.civ == "gaia";
const isGaia = playerState.civ == "gaia";
Engine.GetGUIObjectByName("playerCivIcon").sprite = isGaia ? "" : "cropped:1.0, 0.15625 center:grayscale:" + civEmblem;
Engine.GetGUIObjectByName("civilizationTooltip").tooltip = isGaia ? "" : civName;
if (isGaia)
{
Engine.GetGUIObjectByName("phaseEmblems").sprite = "";
Engine.GetGUIObjectByName("civilizationTooltip").tooltip = "";
}
else
{
let civilizationTooltip = civName;
let civPhaseEmblems = "session/panel_phase_emblems_hidden.png";
// Reveal phases to mutual allies and observers
if (g_ViewedPlayer == -1 || playerState.isMutualAlly[g_ViewedPlayer])
{
const civPhase = g_SimState.players[entState.player].phase
civPhaseEmblems = "session/panel_phase_emblems_" + civPhase + ".png";
const civPhaseData = GetTechnologyData("phase_" + civPhase + "_" + playerState.civ, playerState.civ) ||
GetTechnologyData("phase_" + civPhase, playerState.civ);
civilizationTooltip += " — " + getEntityNames(civPhaseData);
}
Engine.GetGUIObjectByName("phaseEmblems").sprite = "cropped:1.0, 1.0 center:" + civPhaseEmblems;
Engine.GetGUIObjectByName("civilizationTooltip").tooltip = civilizationTooltip;
}
// TODO: we should require all entities to have icons
Engine.GetGUIObjectByName("icon").sprite = template.icon ? ("stretched:session/portraits/" + template.icon) : "BackgroundBlack";
@@ -12,6 +12,8 @@
<object size="50%-64 50%-10 50%+64 50%+10" name="playerCivIcon" type="image" ghost="true"/>
<!-- Player color band. -->
<object name="playerColorBackground" type="image" sprite="playerColorBackground" ghost="true"/>
<!-- Phase emblems. -->
<object size="0 0 100% 100%" name="phaseEmblems" type="image" ghost="true"/>
<object type="image" sprite="bottomEdgedPanelShader" ghost="true"/>
<!-- Player name. -->
<object size="0 50%-10 100% 50%+10" name="player" type="text" style="largeCenteredOutlinedText"/>