mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-06-22 01:46:34 +00:00
Display rank action in tooltip
Patch by: @nwtour Differential revision: D4340 Reviewed by: @Silier The patch adds a description from the technology file to tooltip when hovering over rank icon. This was SVN commit r26300.
This commit is contained in:
@@ -80,9 +80,10 @@ function displaySingle(entState)
|
||||
// Rank
|
||||
if (entState.identity && entState.identity.rank && entState.identity.classes)
|
||||
{
|
||||
const rankObj = GetTechnologyData(entState.identity.rankTechName, playerState.civ);
|
||||
Engine.GetGUIObjectByName("rankIcon").tooltip = sprintf(translate("%(rank)s Rank"), {
|
||||
"rank": translateWithContext("Rank", entState.identity.rank)
|
||||
});
|
||||
}) + (rankObj ? "\n" + rankObj.tooltip : "");
|
||||
Engine.GetGUIObjectByName("rankIcon").sprite = "stretched:session/icons/ranks/" + entState.identity.rank + ".png";
|
||||
Engine.GetGUIObjectByName("rankIcon").hidden = false;
|
||||
}
|
||||
|
||||
@@ -234,7 +234,10 @@ function GetTechnologyData(technologyName, civ)
|
||||
|
||||
if (!(technologyName in g_TechnologyData[civ]))
|
||||
{
|
||||
let template = GetTechnologyDataHelper(TechnologyTemplates.Get(technologyName), civ, g_ResourceData);
|
||||
const tech = TechnologyTemplates.Get(technologyName);
|
||||
if (!tech)
|
||||
return;
|
||||
let template = GetTechnologyDataHelper(tech, civ, g_ResourceData);
|
||||
translateObjectKeys(template, ["specific", "generic", "description", "tooltip", "requirementsTooltip"]);
|
||||
g_TechnologyData[civ][technologyName] = deepfreeze(template);
|
||||
}
|
||||
|
||||
@@ -274,6 +274,7 @@ GuiInterface.prototype.GetEntityState = function(player, ent)
|
||||
if (cmpIdentity)
|
||||
ret.identity = {
|
||||
"rank": cmpIdentity.GetRank(),
|
||||
"rankTechName": cmpIdentity.GetRankTechName(),
|
||||
"classes": cmpIdentity.GetClassesList(),
|
||||
"selectionGroupName": cmpIdentity.GetSelectionGroupName(),
|
||||
"canDelete": !cmpIdentity.IsUndeletable(),
|
||||
|
||||
@@ -136,6 +136,11 @@ Identity.prototype.GetRank = function()
|
||||
return this.template.Rank || "";
|
||||
};
|
||||
|
||||
Identity.prototype.GetRankTechName = function()
|
||||
{
|
||||
return this.template.Rank ? "unit_" + this.template.Rank.toLowerCase() : "";
|
||||
};
|
||||
|
||||
Identity.prototype.GetClassesList = function()
|
||||
{
|
||||
return this.classesList;
|
||||
|
||||
Reference in New Issue
Block a user