Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/common/tooltips.js
Show First 20 Lines • Show All 201 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
/** | /** | ||||
* Converts an armor level into the actual reduction percentage | * Converts an armor level into the actual reduction percentage | ||||
*/ | */ | ||||
function armorLevelToPercentageString(level) | function armorLevelToPercentageString(level) | ||||
{ | { | ||||
return sprintf(translate("%(percentage)s%%"), { | return sprintf(translate("%(percentage)s%%"), { | ||||
"percentage": (100 - Math.round(Math.pow(0.9, level) * 100)) | "percentage": level == "Infinity" ? 100 : (100 - Math.round(Math.pow(0.9, level) * 100)) | ||||
}); | }); | ||||
} | } | ||||
function getArmorTooltip(template) | function getArmorTooltip(template) | ||||
{ | { | ||||
if (!template.armour) | if (!template.armour) | ||||
return ""; | return ""; | ||||
return sprintf(translate("%(label)s %(details)s"), { | return sprintf(translate("%(label)s %(details)s"), { | ||||
"label": headerFont(translate("Armor:")), | "label": headerFont(translate("Armor:")), | ||||
"details": | "details": | ||||
Object.keys(template.armour).map( | Object.keys(template.armour).map( | ||||
dmgType => sprintf(translate("%(damage)s %(damageType)s %(armorPercentage)s"), { | dmgType => sprintf(translate("%(damage)s %(damageType)s %(armorPercentage)s"), { | ||||
"damage": template.armour[dmgType].toFixed(1), | "damage": template.armour[dmgType] == "Infinity" ? "∞" : template.armour[dmgType].toFixed(1), | ||||
"damageType": unitFont(translateWithContext("damage type", g_DamageTypes.GetNames()[dmgType])), | "damageType": unitFont(translateWithContext("damage type", g_DamageTypes.GetNames()[dmgType])), | ||||
"armorPercentage": | "armorPercentage": | ||||
'[font="sans-10"]' + | '[font="sans-10"]' + | ||||
sprintf(translate("(%(armorPercentage)s)"), { | sprintf(translate("(%(armorPercentage)s)"), { | ||||
"armorPercentage": armorLevelToPercentageString(template.armour[dmgType]) | "armorPercentage": armorLevelToPercentageString(template.armour[dmgType]) | ||||
}) + '[/font]' | }) + '[/font]' | ||||
}) | }) | ||||
).join(commaFont(translate(", "))) | ).join(commaFont(translate(", "))) | ||||
▲ Show 20 Lines • Show All 603 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator