Show Population Cost in unit training buttons

Show Population Bonus in unit construction buttons

This was SVN commit r8559.
This commit is contained in:
WhiteTreePaladin
2010-11-08 23:23:52 +00:00
parent 6e74c53ee9
commit dde2cd38be
3 changed files with 14 additions and 1 deletions
@@ -212,9 +212,10 @@ function setupUnitPanel(guiName, usedPanels, unitEntState, items, callback)
case CONSTRUCTION: case CONSTRUCTION:
var tooltip = getEntityNameWithGenericType(template); var tooltip = getEntityNameWithGenericType(template);
if (template.tooltip) if (template.tooltip)
tooltip += "\n[font=\"serif-13\"]" + template.tooltip + "[/font]"; tooltip += "\n[font=\"serif-13\"]" + template.tooltip + " " + getPopulationBonus(template) + "[/font]";
tooltip += "\n" + getEntityCost(template); tooltip += "\n" + getEntityCost(template);
break; break;
case COMMAND: case COMMAND:
@@ -238,12 +238,22 @@ function getEntityCost(template)
if (template.cost.wood) costs.push("[font=\"serif-bold-13\"]Wood:[/font] " + template.cost.wood); if (template.cost.wood) costs.push("[font=\"serif-bold-13\"]Wood:[/font] " + template.cost.wood);
if (template.cost.metal) costs.push("[font=\"serif-bold-13\"]Metal:[/font] " + template.cost.metal); if (template.cost.metal) costs.push("[font=\"serif-bold-13\"]Metal:[/font] " + template.cost.metal);
if (template.cost.stone) costs.push("[font=\"serif-bold-13\"]Stone:[/font] " + template.cost.stone); if (template.cost.stone) costs.push("[font=\"serif-bold-13\"]Stone:[/font] " + template.cost.stone);
if (template.cost.population) costs.push("[font=\"serif-bold-13\"]Population:[/font] " + template.cost.population);
if (costs.length) if (costs.length)
return costs.join(", "); return costs.join(", ");
} }
return ""; return "";
} }
function getPopulationBonus(template)
{
var popBonus = "";
if (template.cost.populationBonus)
popBonus = "[font=\"serif-bold-13\"]Population Bonus:[/font] " + template.cost.populationBonus;
return popBonus;
}
function getEntityName(template) function getEntityName(template)
{ {
return template.name.specific || template.name.generic || "???"; return template.name.specific || template.name.generic || "???";
@@ -196,6 +196,8 @@ GuiInterface.prototype.GetTemplateData = function(player, name)
if (template.Cost.Resources.wood) ret.cost.wood = +template.Cost.Resources.wood; if (template.Cost.Resources.wood) ret.cost.wood = +template.Cost.Resources.wood;
if (template.Cost.Resources.stone) ret.cost.stone = +template.Cost.Resources.stone; if (template.Cost.Resources.stone) ret.cost.stone = +template.Cost.Resources.stone;
if (template.Cost.Resources.metal) ret.cost.metal = +template.Cost.Resources.metal; if (template.Cost.Resources.metal) ret.cost.metal = +template.Cost.Resources.metal;
if (template.Cost.Population) ret.cost.population = +template.Cost.Population;
if (template.Cost.PopulationBonus) ret.cost.populationBonus = +template.Cost.PopulationBonus;
} }
return ret; return ret;