forked from 0ad/0ad
Adds useful stats to training and construction tooltips, based on patch from pejuko. Fixes #872.
This was SVN commit r10518.
This commit is contained in:
parent
99e012ba56
commit
ff064aca95
@ -214,25 +214,39 @@ function setupUnitPanel(guiName, usedPanels, unitEntState, items, callback)
|
||||
|
||||
case TRAINING:
|
||||
var tooltip = getEntityNameWithGenericType(template);
|
||||
|
||||
if (template.tooltip)
|
||||
tooltip += "\n[font=\"serif-13\"]" + template.tooltip + "[/font]";
|
||||
|
||||
var [batchSize, batchIncrement] = getTrainingQueueBatchStatus(unitEntState.id, entType);
|
||||
var trainNum = batchSize ? batchSize+batchIncrement : batchIncrement;
|
||||
|
||||
tooltip += "\n" + getEntityCost(template);
|
||||
|
||||
var [batchSize, batchIncrement] = getTrainingQueueBatchStatus(unitEntState.id, entType);
|
||||
if (batchSize)
|
||||
{
|
||||
tooltip += "\n[font=\"serif-13\"]Training [font=\"serif-bold-13\"]" + batchSize + "[font=\"serif-13\"] units; " +
|
||||
"Shift-click to train [font=\"serif-bold-13\"]"+ (batchSize+batchIncrement) + "[font=\"serif-13\"] units[/font]";
|
||||
}
|
||||
if (template.health)
|
||||
tooltip += "\n[font=\"serif-bold-13\"]Health:[/font] " + template.health;
|
||||
if (template.armour)
|
||||
tooltip += "\n[font=\"serif-bold-13\"]Armour:[/font] " + damageTypesToText(template.armour);
|
||||
if (template.attack)
|
||||
tooltip += "\n" + getEntityAttack(template);
|
||||
if (template.speed)
|
||||
tooltip += "\n" + getEntitySpeed(template);
|
||||
|
||||
tooltip += "\n\n[font=\"serif-bold-13\"]Shift-click[/font][font=\"serif-13\"] to train " + trainNum + ".[/font]";
|
||||
|
||||
break;
|
||||
|
||||
case CONSTRUCTION:
|
||||
var tooltip = getEntityNameWithGenericType(template);
|
||||
if (template.tooltip)
|
||||
tooltip += "\n[font=\"serif-13\"]" + template.tooltip + getPopulationBonus(template) + "[/font]";
|
||||
tooltip += "\n[font=\"serif-13\"]" + template.tooltip + "[/font]";
|
||||
|
||||
tooltip += "\n" + getEntityCost(template);
|
||||
|
||||
tooltip += getPopulationBonus(template);
|
||||
if (template.health)
|
||||
tooltip += "\n[font=\"serif-bold-13\"]Health:[/font] " + template.health;
|
||||
|
||||
break;
|
||||
|
||||
case COMMAND:
|
||||
|
@ -245,19 +245,19 @@ function getEntityCommandsList(entState)
|
||||
|
||||
function getEntityCost(template)
|
||||
{
|
||||
var cost = "";
|
||||
if (template.cost)
|
||||
{
|
||||
var costs = [];
|
||||
if (template.cost.food) costs.push("[font=\"serif-bold-13\"]Food:[/font] " + template.cost.food);
|
||||
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.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 (template.cost.food) costs.push(template.cost.food + " [font=\"serif-12\"]Food[/font]");
|
||||
if (template.cost.wood) costs.push(template.cost.wood + " [font=\"serif-12\"]Wood[/font]");
|
||||
if (template.cost.metal) costs.push(template.cost.metal + " [font=\"serif-12\"]Metal[/font]");
|
||||
if (template.cost.stone) costs.push(template.cost.stone + " [font=\"serif-12\"]Stone[/font]");
|
||||
if (template.cost.population) costs.push(template.cost.population + " [font=\"serif-12\"]Population[/font]");
|
||||
|
||||
if (costs.length)
|
||||
return costs.join(", ");
|
||||
cost += "[font=\"serif-bold-13\"]Costs:[/font] " + costs.join(", ");
|
||||
}
|
||||
return "";
|
||||
return cost;
|
||||
}
|
||||
|
||||
function getPopulationBonus(template)
|
||||
@ -268,6 +268,34 @@ function getPopulationBonus(template)
|
||||
return popBonus;
|
||||
}
|
||||
|
||||
function getEntitySpeed(template)
|
||||
{
|
||||
var speed = "";
|
||||
if (template.speed)
|
||||
{
|
||||
speed += "[font=\"serif-bold-13\"]Speed:[/font] ";
|
||||
var speeds = [];
|
||||
if (template.speed.walk) speeds.push(template.speed.walk + " [font=\"serif-12\"]Walk[/font]");
|
||||
if (template.speed.run) speeds.push(template.speed.run + " [font=\"serif-12\"]Run[/font]");
|
||||
|
||||
speed += speeds.join(", ");
|
||||
}
|
||||
return speed;
|
||||
}
|
||||
|
||||
function getEntityAttack(template)
|
||||
{
|
||||
var attacks = [];
|
||||
if (template.attack)
|
||||
{
|
||||
for (var type in template.attack)
|
||||
{
|
||||
attacks.push("[font=\"serif-bold-13\"]" + type + " Attack:[/font] " + damageTypesToText(template.attack[type]));
|
||||
}
|
||||
}
|
||||
return attacks.join("\n");
|
||||
}
|
||||
|
||||
function getEntityName(template)
|
||||
{
|
||||
return template.name.specific || template.name.generic || "???";
|
||||
|
@ -270,15 +270,26 @@ GuiInterface.prototype.GetTemplateData = function(player, name)
|
||||
|
||||
var ret = {};
|
||||
|
||||
if (template.Identity)
|
||||
if (template.Armour)
|
||||
{
|
||||
ret.selectionGroupName = template.Identity.SelectionGroupName;
|
||||
ret.name = {
|
||||
"specific": (template.Identity.SpecificName || template.Identity.GenericName),
|
||||
"generic": template.Identity.GenericName
|
||||
ret.armour = {
|
||||
"hack": +template.Armour.Hack,
|
||||
"pierce": +template.Armour.Pierce,
|
||||
"crush": +template.Armour.Crush,
|
||||
};
|
||||
ret.icon = template.Identity.Icon;
|
||||
ret.tooltip = template.Identity.Tooltip;
|
||||
}
|
||||
|
||||
if (template.Attack)
|
||||
{
|
||||
ret.attack = {};
|
||||
for (var type in template.Attack)
|
||||
{
|
||||
ret.attack[type] = {
|
||||
"hack": (+template.Attack[type].Hack || 0),
|
||||
"pierce": (+template.Attack[type].Pierce || 0),
|
||||
"crush": (+template.Attack[type].Crush || 0),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (template.Cost)
|
||||
@ -292,6 +303,30 @@ GuiInterface.prototype.GetTemplateData = function(player, name)
|
||||
if (template.Cost.PopulationBonus) ret.cost.populationBonus = +template.Cost.PopulationBonus;
|
||||
}
|
||||
|
||||
if (template.Health)
|
||||
{
|
||||
ret.health = +template.Health.Max;
|
||||
}
|
||||
|
||||
if (template.Identity)
|
||||
{
|
||||
ret.selectionGroupName = template.Identity.SelectionGroupName;
|
||||
ret.name = {
|
||||
"specific": (template.Identity.SpecificName || template.Identity.GenericName),
|
||||
"generic": template.Identity.GenericName
|
||||
};
|
||||
ret.icon = template.Identity.Icon;
|
||||
ret.tooltip = template.Identity.Tooltip;
|
||||
}
|
||||
|
||||
if (template.UnitMotion)
|
||||
{
|
||||
ret.speed = {
|
||||
"walk": +template.UnitMotion.WalkSpeed,
|
||||
};
|
||||
if (template.UnitMotion.Run) ret.speed.run = +template.UnitMotion.Run.Speed;
|
||||
}
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user