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:
|
case TRAINING:
|
||||||
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 + "[/font]";
|
||||||
|
|
||||||
|
var [batchSize, batchIncrement] = getTrainingQueueBatchStatus(unitEntState.id, entType);
|
||||||
|
var trainNum = batchSize ? batchSize+batchIncrement : batchIncrement;
|
||||||
|
|
||||||
tooltip += "\n" + getEntityCost(template);
|
tooltip += "\n" + getEntityCost(template);
|
||||||
|
|
||||||
var [batchSize, batchIncrement] = getTrainingQueueBatchStatus(unitEntState.id, entType);
|
if (template.health)
|
||||||
if (batchSize)
|
tooltip += "\n[font=\"serif-bold-13\"]Health:[/font] " + template.health;
|
||||||
{
|
if (template.armour)
|
||||||
tooltip += "\n[font=\"serif-13\"]Training [font=\"serif-bold-13\"]" + batchSize + "[font=\"serif-13\"] units; " +
|
tooltip += "\n[font=\"serif-bold-13\"]Armour:[/font] " + damageTypesToText(template.armour);
|
||||||
"Shift-click to train [font=\"serif-bold-13\"]"+ (batchSize+batchIncrement) + "[font=\"serif-13\"] units[/font]";
|
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;
|
break;
|
||||||
|
|
||||||
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 + getPopulationBonus(template) + "[/font]";
|
tooltip += "\n[font=\"serif-13\"]" + template.tooltip + "[/font]";
|
||||||
|
|
||||||
tooltip += "\n" + getEntityCost(template);
|
tooltip += "\n" + getEntityCost(template);
|
||||||
|
|
||||||
|
tooltip += getPopulationBonus(template);
|
||||||
|
if (template.health)
|
||||||
|
tooltip += "\n[font=\"serif-bold-13\"]Health:[/font] " + template.health;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COMMAND:
|
case COMMAND:
|
||||||
|
@ -245,19 +245,19 @@ function getEntityCommandsList(entState)
|
|||||||
|
|
||||||
function getEntityCost(template)
|
function getEntityCost(template)
|
||||||
{
|
{
|
||||||
|
var cost = "";
|
||||||
if (template.cost)
|
if (template.cost)
|
||||||
{
|
{
|
||||||
var costs = [];
|
var costs = [];
|
||||||
if (template.cost.food) costs.push("[font=\"serif-bold-13\"]Food:[/font] " + template.cost.food);
|
if (template.cost.food) costs.push(template.cost.food + " [font=\"serif-12\"]Food[/font]");
|
||||||
if (template.cost.wood) costs.push("[font=\"serif-bold-13\"]Wood:[/font] " + template.cost.wood);
|
if (template.cost.wood) costs.push(template.cost.wood + " [font=\"serif-12\"]Wood[/font]");
|
||||||
if (template.cost.metal) costs.push("[font=\"serif-bold-13\"]Metal:[/font] " + template.cost.metal);
|
if (template.cost.metal) costs.push(template.cost.metal + " [font=\"serif-12\"]Metal[/font]");
|
||||||
if (template.cost.stone) costs.push("[font=\"serif-bold-13\"]Stone:[/font] " + template.cost.stone);
|
if (template.cost.stone) costs.push(template.cost.stone + " [font=\"serif-12\"]Stone[/font]");
|
||||||
if (template.cost.population) costs.push("[font=\"serif-bold-13\"]Population:[/font] " + template.cost.population);
|
if (template.cost.population) costs.push(template.cost.population + " [font=\"serif-12\"]Population[/font]");
|
||||||
|
|
||||||
if (costs.length)
|
cost += "[font=\"serif-bold-13\"]Costs:[/font] " + costs.join(", ");
|
||||||
return costs.join(", ");
|
|
||||||
}
|
}
|
||||||
return "";
|
return cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPopulationBonus(template)
|
function getPopulationBonus(template)
|
||||||
@ -268,20 +268,48 @@ function getPopulationBonus(template)
|
|||||||
return popBonus;
|
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)
|
function getEntityName(template)
|
||||||
{
|
{
|
||||||
return template.name.specific || template.name.generic || "???";
|
return template.name.specific || template.name.generic || "???";
|
||||||
}
|
}
|
||||||
|
|
||||||
function getEntityNameWithGenericType(template)
|
function getEntityNameWithGenericType(template)
|
||||||
{
|
{
|
||||||
var name;
|
var name;
|
||||||
if ((template.name.specific && template.name.generic) && (template.name.specific != template.name.generic))
|
if ((template.name.specific && template.name.generic) && (template.name.specific != template.name.generic))
|
||||||
name = template.name.specific + " (" + template.name.generic + ")";
|
name = template.name.specific + " (" + template.name.generic + ")";
|
||||||
else
|
else
|
||||||
name = template.name.specific || template.name.generic || "???";
|
name = template.name.specific || template.name.generic || "???";
|
||||||
|
|
||||||
return "[font=\"serif-bold-16\"]" + name + "[/font]";
|
return "[font=\"serif-bold-16\"]" + name + "[/font]";
|
||||||
}
|
}
|
||||||
|
|
||||||
function getEntityRankedName(entState)
|
function getEntityRankedName(entState)
|
||||||
|
@ -270,15 +270,26 @@ GuiInterface.prototype.GetTemplateData = function(player, name)
|
|||||||
|
|
||||||
var ret = {};
|
var ret = {};
|
||||||
|
|
||||||
if (template.Identity)
|
if (template.Armour)
|
||||||
{
|
{
|
||||||
ret.selectionGroupName = template.Identity.SelectionGroupName;
|
ret.armour = {
|
||||||
ret.name = {
|
"hack": +template.Armour.Hack,
|
||||||
"specific": (template.Identity.SpecificName || template.Identity.GenericName),
|
"pierce": +template.Armour.Pierce,
|
||||||
"generic": template.Identity.GenericName
|
"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)
|
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.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;
|
return ret;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user