Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/common/tooltips.js
Show First 20 Lines • Show All 140 Lines • ▼ Show 20 Lines | function getCurrentHealthTooltip(entState, label) | ||||
}); | }); | ||||
} | } | ||||
function attackRateDetails(template, type) | function attackRateDetails(template, type) | ||||
{ | { | ||||
// Either one arrow shot by UnitAI, | // Either one arrow shot by UnitAI, | ||||
let timeString = getSecondsString(template.attack[type].repeatTime / 1000); | let timeString = getSecondsString(template.attack[type].repeatTime / 1000); | ||||
// or multiple arrows shot by BuildingAI | // or multiple arrows shot by ManpowerHolder | ||||
if (!template.buildingAI || type != "Ranged") | if (!template.manpowerHolder || type != "Ranged") | ||||
return timeString; | return timeString; | ||||
// Show either current rate from simulation or default count if the sim is not running | // Show either current rate from simulation or default count if the sim is not running | ||||
let arrows = template.buildingAI.arrowCount || template.buildingAI.defaultArrowCount; | let arrows = template.manpowerHolder.arrowCount || template.manpowerHolder.defaultArrowCount; | ||||
let arrowString = sprintf(translatePlural("%(arrowcount)s %(arrows)s", "%(arrowcount)s %(arrows)s", arrows), { | let arrowString = sprintf(translatePlural("%(arrowcount)s %(arrows)s", "%(arrowcount)s %(arrows)s", arrows), { | ||||
"arrowcount": arrows, | "arrowcount": arrows, | ||||
"arrows": unitFont(translatePlural("arrow", "arrows", arrows)) | "arrows": unitFont(translatePlural("arrow", "arrows", arrows)) | ||||
}); | }); | ||||
return sprintf(translate("%(arrowString)s / %(timeString)s"), { | return sprintf(translate("%(arrowString)s / %(timeString)s"), { | ||||
"arrowString": arrowString, | "arrowString": arrowString, | ||||
"timeString": timeString | "timeString": timeString | ||||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | function getAttackTooltip(template) | ||||
for (let type in template.attack) | for (let type in template.attack) | ||||
{ | { | ||||
if (type == "Slaughter") | if (type == "Slaughter") | ||||
continue; // Slaughter is used to kill animals, so do not show it. | continue; // Slaughter is used to kill animals, so do not show it. | ||||
let rate = sprintf(translate("%(label)s %(details)s"), { | let rate = sprintf(translate("%(label)s %(details)s"), { | ||||
"label": | "label": | ||||
headerFont( | headerFont( | ||||
template.buildingAI && type == "Ranged" ? | template.manpowerHolder && type == "Ranged" ? | ||||
translate("Interval:") : | translate("Interval:") : | ||||
translate("Rate:")), | translate("Rate:")), | ||||
"details": attackRateDetails(template, type) | "details": attackRateDetails(template, type) | ||||
}); | }); | ||||
let attackLabel = headerFont(g_AttackTypes[type]); | let attackLabel = headerFont(g_AttackTypes[type]); | ||||
if (type == "Capture" || type != "Ranged") | if (type == "Capture" || type != "Ranged") | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 82 Lines • ▼ Show 20 Lines | tooltips.push( | ||||
}) | }) | ||||
); | ); | ||||
return tooltips.join(commaFont(translate(", "))); | return tooltips.join(commaFont(translate(", "))); | ||||
} | } | ||||
function getProjectilesTooltip(template) | function getProjectilesTooltip(template) | ||||
{ | { | ||||
if (!template.garrisonHolder || !template.buildingAI) | if (!template.garrisonHolder || !template.manpowerHolder) | ||||
return ""; | return ""; | ||||
let limit = Math.min( | let limit = Math.min( | ||||
template.buildingAI.maxArrowCount || Infinity, | template.manpowerHolder.maxArrowCount || Infinity, | ||||
template.buildingAI.defaultArrowCount + | template.manpowerHolder.defaultArrowCount + | ||||
Math.round(template.buildingAI.garrisonArrowMultiplier * | Math.round(template.manpowerHolder.garrisonArrowMultiplier * | ||||
template.garrisonHolder.capacity) | template.garrisonHolder.capacity) | ||||
); | ); | ||||
if (!limit) | if (!limit) | ||||
return ""; | return ""; | ||||
return [ | return [ | ||||
sprintf(translate("%(label)s: %(value)s"), { | sprintf(translate("%(label)s: %(value)s"), { | ||||
"label": headerFont(translate("Projectile Limit")), | "label": headerFont(translate("Projectile Limit")), | ||||
"value": limit | "value": limit | ||||
}), | }), | ||||
sprintf(translate("%(label)s: %(value)s"), { | sprintf(translate("%(label)s: %(value)s"), { | ||||
"label": headerFont(translateWithContext("projectiles", "Default")), | "label": headerFont(translateWithContext("projectiles", "Default")), | ||||
"value": template.buildingAI.defaultArrowCount | "value": template.manpowerHolder.defaultArrowCount | ||||
}), | }), | ||||
sprintf(translate("%(label)s: %(value)s"), { | sprintf(translate("%(label)s: %(value)s"), { | ||||
"label": headerFont(translateWithContext("projectiles", "Per Unit")), | "label": headerFont(translateWithContext("projectiles", "Per Unit")), | ||||
"value": +template.buildingAI.garrisonArrowMultiplier.toFixed(2) | "value": +template.manpowerHolder.garrisonArrowMultiplier.toFixed(2) | ||||
}) | }) | ||||
].join(commaFont(translate(", "))); | ].join(commaFont(translate(", "))); | ||||
} | } | ||||
function getRepairRateTooltip(template) | function getRepairRateTooltip(template) | ||||
{ | { | ||||
if (!template.repairRate) | if (!template.repairRate) | ||||
return ""; | return ""; | ||||
▲ Show 20 Lines • Show All 405 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator