Center generic/specific name if just one is given and hide the other

Patch By: LangBart
Comments By: Freagarach
Differential Revision: D4290
fixes #6341

This was SVN commit r25964.
This commit is contained in:
bb
2021-10-12 20:25:09 +00:00
parent 31a6ffdd3a
commit 9c2a09067f
2 changed files with 14 additions and 5 deletions
@@ -301,11 +301,20 @@ function displaySingle(entState)
Engine.GetGUIObjectByName("playerColorBackground").sprite =
"color:" + g_DiplomacyColors.getPlayerColor(entState.player, 128);
Engine.GetGUIObjectByName("primary").caption = primaryName;
Engine.GetGUIObjectByName("secondary").caption = !secondaryName || primaryName == secondaryName ? "" :
const hideSecondary = !secondaryName || primaryName == secondaryName;
const primaryObject = Engine.GetGUIObjectByName("primary");
primaryObject.caption = primaryName;
const primaryObjectSize = primaryObject.size;
primaryObjectSize.rbottom = hideSecondary ? 100 : 50;
primaryObject.size = primaryObjectSize;
const secondaryObject = Engine.GetGUIObjectByName("secondary");
secondaryObject.caption = hideSecondary ? "" :
sprintf(translate("(%(secondaryName)s)"), {
"secondaryName": secondaryName
});
secondaryObject.hidden = hideSecondary;
let isGaia = playerState.civ == "gaia";
Engine.GetGUIObjectByName("playerCivIcon").sprite = isGaia ? "" : "cropped:1.0, 0.15625 center:grayscale:" + civEmblem;
@@ -18,9 +18,9 @@
</object>
<!-- Primary and secondary names. -->
<object>
<object size="0 2 100% 22" name="primary" ghost="true" type="text" style="PrimaryNameCentered"/>
<object size="0 17 100% 37" name="secondary" ghost="true" type="text" style="SecondaryNameCentered"/>
<object size="0 3 100% 37">
<object size="0 0 100% 50%" name="primary" ghost="true" type="text" style="PrimaryNameCentered"/>
<object size="0 50%-1 100% 100%" name="secondary" ghost="true" type="text" style="SecondaryNameCentered"/>
</object>
</object>