forked from 0ad/0ad
Give option to switch between specific and/or generic entity names.
As requested on the forums (e.g. https://wildfiregames.com/forum/index.php?/topic/25202-transliteration-of-ancient-greek-into-english/&tab=comments#comment-378174). Differential revision: D2126 Closes: #3397 This was SVN commit r25116.
This commit is contained in:
parent
4e728bf68f
commit
ebc2ec5498
@ -410,6 +410,7 @@ snaptoedgesdistancethreshold = 15 ; On which distance we don't snap to edges
|
||||
disjointcontrolgroups = "true" ; Whether control groups are disjoint sets or entities can be in multiple control groups at the same time.
|
||||
defaultformation = "special/formations/box" ; For walking orders, automatically put units into this formation if they don't have one already.
|
||||
formationwalkonly = "true" ; Formations are disabled when giving gather/attack/... orders.
|
||||
howtoshownames = 0 ; Whether the specific names are show as default, as opposed to the generic names. And whether the secondary names are shown. (0 - show both; specific names primary, 1 - show both; generic names primary, 2 - show only specific names, 3 - show only generic names)
|
||||
|
||||
[gui.session.minimap]
|
||||
blinkduration = 1.7 ; The blink duration while pinging
|
||||
|
@ -3,11 +3,22 @@ var g_TooltipTextFormats = {
|
||||
"header": { "font": "sans-bold-13" },
|
||||
"body": { "font": "sans-13" },
|
||||
"comma": { "font": "sans-12" },
|
||||
"nameSpecificBig": { "font": "sans-bold-16" },
|
||||
"nameSpecificSmall": { "font": "sans-bold-12" },
|
||||
"nameGeneric": { "font": "sans-bold-16" }
|
||||
"namePrimaryBig": { "font": "sans-bold-16" },
|
||||
"namePrimarySmall": { "font": "sans-bold-12" },
|
||||
"nameSecondary": { "font": "sans-bold-16" }
|
||||
};
|
||||
|
||||
var g_SpecificNamesPrimary = Engine.ConfigDB_GetValue("user", "gui.session.howtoshownames") == 0 || Engine.ConfigDB_GetValue("user", "gui.session.howtoshownames") == 2;
|
||||
var g_ShowSecondaryNames = Engine.ConfigDB_GetValue("user", "gui.session.howtoshownames") == 0 || Engine.ConfigDB_GetValue("user", "gui.session.howtoshownames") == 1;
|
||||
|
||||
function initDisplayedNames()
|
||||
{
|
||||
registerConfigChangeHandler(changes => {
|
||||
if (changes.has("gui.session.howtoshownames"))
|
||||
updateDisplayedNames();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* String of four spaces to be used as indentation in gui strings.
|
||||
*/
|
||||
@ -1046,9 +1057,18 @@ function getEntityNames(template)
|
||||
if (template.name.specific == template.name.generic)
|
||||
return template.name.specific;
|
||||
|
||||
return sprintf(translate("%(specificName)s (%(genericName)s)"), {
|
||||
"specificName": template.name.specific,
|
||||
"genericName": template.name.generic
|
||||
let primaryName = g_SpecificNamesPrimary ? template.name.specific : template.name.generic;
|
||||
let secondaryName;
|
||||
if (g_ShowSecondaryNames)
|
||||
secondaryName = g_SpecificNamesPrimary ? template.name.generic : template.name.specific;
|
||||
|
||||
if (secondaryName)
|
||||
return sprintf(translate("%(primaryName)s (%(secondaryName)s)"), {
|
||||
"primaryName": primaryName,
|
||||
"secondaryName": secondaryName
|
||||
});
|
||||
return sprintf(translate("%(primaryName)s"), {
|
||||
"primaryName": primaryName
|
||||
});
|
||||
|
||||
}
|
||||
@ -1056,24 +1076,37 @@ function getEntityNames(template)
|
||||
function getEntityNamesFormatted(template)
|
||||
{
|
||||
if (!template.name.specific)
|
||||
return setStringTags(template.name.generic, g_TooltipTextFormats.nameSpecificBig);
|
||||
return setStringTags(template.name.generic, g_TooltipTextFormats.namePrimaryBig);
|
||||
|
||||
let primaryName = g_SpecificNamesPrimary ? template.name.specific : template.name.generic;
|
||||
let secondaryName;
|
||||
if (g_ShowSecondaryNames)
|
||||
secondaryName = g_SpecificNamesPrimary ? template.name.generic : template.name.specific;
|
||||
|
||||
if (!secondaryName || primaryName == secondaryName)
|
||||
return sprintf(translate("%(primaryName)s"), {
|
||||
"primaryName":
|
||||
setStringTags(primaryName[0], g_TooltipTextFormats.namePrimaryBig) +
|
||||
setStringTags(primaryName.slice(1).toUpperCase(), g_TooltipTextFormats.namePrimarySmall)
|
||||
});
|
||||
|
||||
// Translation: Example: "Epibátēs Athēnaîos [font="sans-bold-16"](Athenian Marine)[/font]"
|
||||
return sprintf(translate("%(specificName)s %(fontStart)s(%(genericName)s)%(fontEnd)s"), {
|
||||
"specificName": getEntitySpecificNameFormatted(template),
|
||||
"genericName": template.name.generic,
|
||||
"fontStart": '[font="' + g_TooltipTextFormats.nameGeneric.font + '"]',
|
||||
"fontEnd": '[/font]'
|
||||
return sprintf(translate("%(primaryName)s (%(secondaryName)s)"), {
|
||||
"primaryName":
|
||||
setStringTags(primaryName[0], g_TooltipTextFormats.namePrimaryBig) +
|
||||
setStringTags(primaryName.slice(1).toUpperCase(), g_TooltipTextFormats.namePrimarySmall),
|
||||
"secondaryName": setStringTags(secondaryName, g_TooltipTextFormats.nameSecondary)
|
||||
});
|
||||
}
|
||||
|
||||
function getEntitySpecificNameFormatted(template)
|
||||
function getEntityPrimaryNameFormatted(template)
|
||||
{
|
||||
if (!template.name.specific)
|
||||
return setStringTags(template.name.generic, g_TooltipTextFormats.nameSpecificBig);
|
||||
let primaryName = g_SpecificNamesPrimary ? template.name.specific : template.name.generic;
|
||||
if (!primaryName)
|
||||
return setStringTags(g_SpecificNamesPrimary ? template.name.generic : template.name.specific, g_TooltipTextFormats.namePrimaryBig);
|
||||
|
||||
return setStringTags(template.name.specific[0], g_TooltipTextFormats.nameSpecificBig) +
|
||||
setStringTags(template.name.specific.slice(1).toUpperCase(), g_TooltipTextFormats.nameSpecificSmall);
|
||||
return setStringTags(primaryName[0], g_TooltipTextFormats.namePrimaryBig) +
|
||||
setStringTags(primaryName.slice(1).toUpperCase(), g_TooltipTextFormats.namePrimarySmall);
|
||||
}
|
||||
|
||||
function getVisibleEntityClassesFormatted(template)
|
||||
|
@ -81,6 +81,34 @@
|
||||
"label": "Chat timestamp",
|
||||
"tooltip": "Display the time at which a chat message was posted.",
|
||||
"config": "chat.timestamp"
|
||||
},
|
||||
{
|
||||
"type": "dropdown",
|
||||
"label": "Naming of entities.",
|
||||
"tooltip": "How to show entity names.",
|
||||
"config": "gui.session.howtoshownames",
|
||||
"list": [
|
||||
{
|
||||
"value": 0,
|
||||
"label": "Specific primary.",
|
||||
"tooltip": "Show specific names as primary and generic names as secondary."
|
||||
},
|
||||
{
|
||||
"value": 1,
|
||||
"label": "Generic primary.",
|
||||
"tooltip": "Show generic names as primary and specific names as secondary."
|
||||
},
|
||||
{
|
||||
"value": 2,
|
||||
"label": "Only Specific.",
|
||||
"tooltip": "Show only specific names for units."
|
||||
},
|
||||
{
|
||||
"value": 3,
|
||||
"label": "Only Generic.",
|
||||
"tooltip": "Show only generic names for units."
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -21,7 +21,7 @@ class Emblem
|
||||
|
||||
this.EmblemImage.sprite = "stretched:" + civData.Emblem;
|
||||
this.EmblemImage.tooltip = getAurasTooltip(template);
|
||||
this.EmblemCaption.caption = getEntitySpecificNameFormatted(template);
|
||||
this.EmblemCaption.caption = getEntityPrimaryNameFormatted(template);
|
||||
this.Emblem.hidden = false;
|
||||
return true;
|
||||
}
|
||||
|
@ -26,7 +26,9 @@ class EntityBox
|
||||
this.gui.hidden = false;
|
||||
|
||||
let caption = this.gui.children[0];
|
||||
caption.caption = translate(this.template.name.specific);
|
||||
caption.caption = g_SpecificNamesPrimary ?
|
||||
translate(this.template.name.specific) :
|
||||
translate(this.template.name.generic);
|
||||
|
||||
let icon = this.gui.children[1];
|
||||
icon.sprite = "stretched:" + this.page.IconPath + this.template.icon;
|
||||
|
@ -13,7 +13,7 @@
|
||||
<object type="image" style="TreeDisplay" size="0 24 100% 100%" name="trainers">
|
||||
<repeat count="6" var="t">
|
||||
<object type="image" style="StructBox" name="trainer[t]">
|
||||
<object type="text" style="StructNameSpecific" name="trainer[t]_name"/>
|
||||
<object type="text" style="StructNamePrimary" name="trainer[t]_name"/>
|
||||
<object type="button" style="StructIcon" name="trainer[t]_icon"/>
|
||||
<object name="trainer[t]_productionRows">
|
||||
<object style="ProdBoxRow">
|
||||
|
@ -18,7 +18,7 @@
|
||||
<object type="image" name="structures" style="TreeDisplay" size="48+16+8 0 100% 100%">
|
||||
<repeat count="40" var="s">
|
||||
<object type="image" style="StructBox" name="structure[s]">
|
||||
<object type="text" style="StructNameSpecific" name="structure[s]_name"/>
|
||||
<object type="text" style="StructNamePrimary" name="structure[s]_name"/>
|
||||
<object type="button" style="StructIcon" name="structure[s]_icon"/>
|
||||
<object name="structure[s]_productionRows">
|
||||
<repeat count="4">
|
||||
|
@ -4,7 +4,7 @@
|
||||
sprite="ModernDarkBoxGold"
|
||||
/>
|
||||
|
||||
<style name="StructNameSpecific"
|
||||
<style name="StructNamePrimary"
|
||||
font="sans-12"
|
||||
size="0 0 100% 20"
|
||||
text_align="center"
|
||||
|
@ -1,9 +1,9 @@
|
||||
/**
|
||||
* Override style so we can get a bigger specific name.
|
||||
* Override style so we can get a bigger primary name.
|
||||
*/
|
||||
g_TooltipTextFormats.nameSpecificBig.font = "sans-bold-20";
|
||||
g_TooltipTextFormats.nameSpecificSmall.font = "sans-bold-16";
|
||||
g_TooltipTextFormats.nameGeneric.font = "sans-bold-16";
|
||||
g_TooltipTextFormats.namePrimaryBig.font = "sans-bold-20";
|
||||
g_TooltipTextFormats.namePrimarySmall.font = "sans-bold-16";
|
||||
g_TooltipTextFormats.nameSecondary.font = "sans-bold-16";
|
||||
|
||||
/**
|
||||
* Page initialisation. May also eventually pre-draw/arrange objects.
|
||||
|
@ -31,7 +31,7 @@ class PanelEntity
|
||||
|
||||
let entityState = GetEntityState(entityID);
|
||||
let template = GetTemplateData(entityState.template);
|
||||
this.nameTooltip = setStringTags(template.name.specific, this.NameTags) + "\n";
|
||||
this.nameTooltip = setStringTags(g_SpecificNamesPrimary ? template.name.specific : template.name.generic, this.NameTags) + "\n";
|
||||
|
||||
Engine.GetGUIObjectByName("panelEntityHealthSection[" + buttonID + "]").hidden = !entityState.hitpoints;
|
||||
|
||||
|
@ -51,13 +51,21 @@ function updateGarrisonHealthBar(entState, selection)
|
||||
// Fills out information that most entities have
|
||||
function displaySingle(entState)
|
||||
{
|
||||
// Get general unit and player data
|
||||
let template = GetTemplateData(entState.template);
|
||||
let specificName = template.name.specific;
|
||||
let genericName = template.name.generic;
|
||||
// If packed, add that to the generic name (reduces template clutter)
|
||||
if (genericName && template.pack && template.pack.state == "packed")
|
||||
genericName = sprintf(translate("%(genericName)s — Packed"), { "genericName": genericName });
|
||||
|
||||
let primaryName = g_SpecificNamesPrimary ? template.name.specific : template.name.generic;
|
||||
let secondaryName;
|
||||
if (g_ShowSecondaryNames)
|
||||
secondaryName = g_SpecificNamesPrimary ? template.name.generic : template.name.specific;
|
||||
|
||||
// If packed, add that to the generic name (reduces template clutter).
|
||||
if (template.pack && template.pack.state == "packed")
|
||||
{
|
||||
if (secondaryName && g_ShowSecondaryNames)
|
||||
secondaryName = sprintf(translate("%(secondaryName)s — Packed"), { "secondaryName": secondaryName });
|
||||
else
|
||||
secondaryName = sprintf(translate("Packed"));
|
||||
}
|
||||
let playerState = g_Players[entState.player];
|
||||
|
||||
let civName = g_CivData[playerState.civ].Name;
|
||||
@ -288,15 +296,15 @@ function displaySingle(entState)
|
||||
resourceCarryingText.hidden = true;
|
||||
}
|
||||
|
||||
Engine.GetGUIObjectByName("specific").caption = specificName;
|
||||
Engine.GetGUIObjectByName("player").caption = playerName;
|
||||
|
||||
Engine.GetGUIObjectByName("playerColorBackground").sprite =
|
||||
"color:" + g_DiplomacyColors.getPlayerColor(entState.player, 128);
|
||||
|
||||
Engine.GetGUIObjectByName("generic").caption = genericName == specificName ? "" :
|
||||
sprintf(translate("(%(genericName)s)"), {
|
||||
"genericName": genericName
|
||||
Engine.GetGUIObjectByName("primary").caption = primaryName;
|
||||
Engine.GetGUIObjectByName("secondary").caption = !secondaryName || primaryName == secondaryName ? "" :
|
||||
sprintf(translate("(%(secondaryName)s)"), {
|
||||
"secondaryName": secondaryName
|
||||
});
|
||||
|
||||
let isGaia = playerState.civ == "gaia";
|
||||
@ -332,9 +340,7 @@ function displaySingle(entState)
|
||||
|
||||
let iconTooltips = [];
|
||||
|
||||
if (genericName)
|
||||
iconTooltips.push("[font=\"sans-bold-16\"]" + genericName + "[/font]");
|
||||
|
||||
iconTooltips.push(setStringTags(primaryName, g_TooltipTextFormats.namePrimaryBig));
|
||||
iconTooltips = iconTooltips.concat([
|
||||
getVisibleEntityClassesFormatted,
|
||||
getAurasTooltip,
|
||||
|
@ -1065,16 +1065,38 @@ g_SelectionPanels.Upgrade = {
|
||||
let modifier = "";
|
||||
if (!upgradingEntStates.length && upgradableEntStates.length)
|
||||
{
|
||||
let primaryName = g_SpecificNamesPrimary ? template.name.specific : template.name.generic;
|
||||
let secondaryName;
|
||||
if (g_ShowSecondaryNames)
|
||||
secondaryName = g_SpecificNamesPrimary ? template.name.generic : template.name.specific;
|
||||
|
||||
let tooltips = [];
|
||||
if (data.item.tooltip)
|
||||
tooltips.push(sprintf(translate("Upgrade to %(name)s. %(tooltip)s"), {
|
||||
"name": template.name.generic,
|
||||
"tooltip": translate(data.item.tooltip)
|
||||
}));
|
||||
if (g_ShowSecondaryNames)
|
||||
{
|
||||
if (data.item.tooltip)
|
||||
tooltips.push(sprintf(translate("Upgrade to a %(primaryName)s (%(secondaryName)s). %(tooltip)s"), {
|
||||
"primaryName": primaryName,
|
||||
"secondaryName": secondaryName,
|
||||
"tooltip": translate(data.item.tooltip)
|
||||
}));
|
||||
else
|
||||
tooltips.push(sprintf(translate("Upgrade to a %(primaryName)s (%(secondaryName)s)."), {
|
||||
"primaryName": primaryName,
|
||||
"secondaryName": secondaryName
|
||||
}));
|
||||
}
|
||||
else
|
||||
tooltips.push(sprintf(translate("Upgrade to %(name)s."), {
|
||||
"name": template.name.generic
|
||||
}));
|
||||
{
|
||||
if (data.item.tooltip)
|
||||
tooltips.push(sprintf(translate("Upgrade to a %(primaryName)s. %(tooltip)s"), {
|
||||
"primaryName": primaryName,
|
||||
"tooltip": translate(data.item.tooltip)
|
||||
}));
|
||||
else
|
||||
tooltips.push(sprintf(translate("Upgrade to a %(primaryName)s."), {
|
||||
"primaryName": primaryName
|
||||
}));
|
||||
}
|
||||
|
||||
tooltips.push(
|
||||
getEntityCostTooltip(data.item, undefined, undefined, data.unitEntStates.length),
|
||||
|
@ -97,10 +97,10 @@
|
||||
<!-- Names and civilization emblem etc. (This must come before the attack and resistance icon to avoid clipping issues.) -->
|
||||
<object size="0 92 100% 100%" name="statsArea" type="image" sprite="edgedPanelShader">
|
||||
|
||||
<!-- Specific and generic names. -->
|
||||
<!-- Primary and secondary names. -->
|
||||
<object z="30">
|
||||
<object size="0 2 100% 22" name="specific" ghost="true" type="text" style="SpecificNameCentered"/>
|
||||
<object size="0 17 100% 37" name="generic" ghost="true" type="text" style="GenericNameCentered"/>
|
||||
<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>
|
||||
|
||||
<!-- Civilization tooltip. -->
|
||||
|
@ -303,6 +303,7 @@ function init(initData, hotloadData)
|
||||
g_TimeNotificationOverlay = new TimeNotificationOverlay(g_PlayerViewControl);
|
||||
|
||||
initBatchTrain();
|
||||
initDisplayedNames();
|
||||
initSelectionPanels();
|
||||
LoadModificationTemplates();
|
||||
updatePlayerData();
|
||||
@ -776,6 +777,15 @@ function removeStatusBarDisplay()
|
||||
recalculateStatusBarDisplay(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the primary/secondary names in the simulation and GUI.
|
||||
*/
|
||||
function updateDisplayedNames()
|
||||
{
|
||||
g_SpecificNamesPrimary = Engine.ConfigDB_GetValue("user", "gui.session.howtoshownames") == 0 || Engine.ConfigDB_GetValue("user", "gui.session.howtoshownames") == 2;
|
||||
g_ShowSecondaryNames = Engine.ConfigDB_GetValue("user", "gui.session.howtoshownames") == 0 || Engine.ConfigDB_GetValue("user", "gui.session.howtoshownames") == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inverts the given configuration boolean and returns the current state.
|
||||
* For example "silhouettes".
|
||||
|
@ -156,7 +156,7 @@
|
||||
ghost="true"
|
||||
/>
|
||||
|
||||
<style name="SpecificNameCentered"
|
||||
<style name="PrimaryNameCentered"
|
||||
font="sans-bold-stroke-13"
|
||||
textcolor="gold"
|
||||
text_align="center"
|
||||
@ -164,7 +164,7 @@
|
||||
ghost="true"
|
||||
/>
|
||||
|
||||
<style name="GenericNameCentered"
|
||||
<style name="SecondaryNameCentered"
|
||||
font="sans-stroke-12"
|
||||
textcolor="white"
|
||||
text_align="center"
|
||||
|
Loading…
Reference in New Issue
Block a user