Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/common/tooltips.js
Show First 20 Lines • Show All 149 Lines • ▼ Show 20 Lines | function getCurrentHealthTooltip(entState, label) | ||||
return sprintf(translate("%(healthLabel)s %(current)s / %(max)s"), { | return sprintf(translate("%(healthLabel)s %(current)s / %(max)s"), { | ||||
"healthLabel": headerFont(label || translate("Health:")), | "healthLabel": headerFont(label || translate("Health:")), | ||||
"current": Math.round(entState.hitpoints), | "current": Math.round(entState.hitpoints), | ||||
"max": Math.round(entState.maxHitpoints) | "max": Math.round(entState.maxHitpoints) | ||||
}); | }); | ||||
} | } | ||||
/** | /** | ||||
* Converts an armor level into the actual reduction percentage | * Converts an resistance level into the actual reduction percentage. | ||||
*/ | */ | ||||
function armorLevelToPercentageString(level) | function resistanceLevelToPercentageString(level) | ||||
{ | { | ||||
return sprintf(translate("%(percentage)s%%"), { | return sprintf(translate("%(percentage)s%%"), { | ||||
"percentage": (100 - Math.round(Math.pow(0.9, level) * 100)) | "percentage": (100 - Math.round(Math.pow(0.9, level) * 100)) | ||||
}); | }); | ||||
} | } | ||||
function getArmorTooltip(template) | function getResistanceTooltip(template) | ||||
Freagarach: Really improvable,,, | |||||
{ | { | ||||
if (!template.armour) | if (!template.resistance) | ||||
return ""; | |||||
let details = []; | |||||
let resistanceTemplate = template.resistance; | |||||
Done Inline ActionsNot sure if we really need this variable, used a couple of times, meh bb: Not sure if we really need this variable, used a couple of times, meh | |||||
if (resistanceTemplate.Damage) | |||||
details.push(getDamageResistanceTooltip(resistanceTemplate.Damage)); | |||||
if (resistanceTemplate.Capture) | |||||
details.push(getCaptureResistanceTooltip(resistanceTemplate.Capture)); | |||||
// ToDo: Status effects resistance. | |||||
return sprintf(translate("%(label)s:\n %(details)s"), { | |||||
Done Inline ActionsIIRC all other tooltips have the : in headerfont and translation too. bb: IIRC all other tooltips have the `:` in headerfont and translation too. | |||||
"label": headerFont(translate("Resistance")), | |||||
"details": details.join("\n ") | |||||
}); | |||||
} | |||||
function getDamageResistanceTooltip(resistanceTypeTemplate) | |||||
{ | |||||
if (!resistanceTypeTemplate) | |||||
return ""; | return ""; | ||||
return sprintf(translate("%(label)s %(details)s"), { | return sprintf(translate("%(label)s %(details)s"), { | ||||
"label": headerFont(translate("Armor:")), | "label": headerFont(translate("Damage Resistance:")), | ||||
"details": | "details": | ||||
g_DamageTypesMetadata.sort(Object.keys(template.armour)).map( | g_DamageTypesMetadata.sort(Object.keys(resistanceTypeTemplate)).map( | ||||
dmgType => sprintf(translate("%(damage)s %(damageType)s %(armorPercentage)s"), { | dmgType => sprintf(translate("%(damage)s %(damageType)s %(resistancePercentage)s"), { | ||||
"damage": template.armour[dmgType].toFixed(1), | "damage": resistanceTypeTemplate[dmgType].toFixed(1), | ||||
"damageType": unitFont(translateWithContext("damage type", g_DamageTypesMetadata.getName(dmgType))), | "damageType": unitFont(translateWithContext("damage type", g_DamageTypesMetadata.getName(dmgType))), | ||||
"armorPercentage": | "resistancePercentage": | ||||
'[font="sans-10"]' + | '[font="sans-10"]' + | ||||
Done Inline Actionsshouldn't we just pass template.Damage to this function? Same below bb: shouldn't we just pass template.Damage to this function? Same below | |||||
sprintf(translate("(%(armorPercentage)s)"), { | sprintf(translate("(%(resistancePercentage)s)"), { | ||||
"armorPercentage": armorLevelToPercentageString(template.armour[dmgType]) | "resistancePercentage": resistanceLevelToPercentageString(resistanceTypeTemplate[dmgType]) | ||||
}) + '[/font]' | }) + '[/font]' | ||||
}) | }) | ||||
).join(commaFont(translate(", "))) | ).join(commaFont(translate(", "))) | ||||
}); | }); | ||||
} | } | ||||
function getCaptureResistanceTooltip(resistanceTypeTemplate) | |||||
{ | |||||
Done Inline Actionswill it display to do in the interface ? Stan: will it display to do in the interface ? | |||||
Done Inline ActionsOnly if someone adds a statusEffect resistance. Freagarach: Only if someone adds a statusEffect resistance. | |||||
if (!resistanceTypeTemplate) | |||||
return ""; | |||||
return sprintf(translate("%(label)s %(details)s"), { | |||||
"label": headerFont(translate("Capture Resistance:")), | |||||
"details": | |||||
sprintf(translate("%(damage)s %(damageType)s %(resistancePercentage)s"), { | |||||
"damage": resistanceTypeTemplate.toFixed(1), | |||||
"damageType": unitFont(translateWithContext("damage type", "Capture")), | |||||
"resistancePercentage": | |||||
'[font="sans-10"]' + | |||||
sprintf(translate("(%(resistancePercentage)s)"), { | |||||
"resistancePercentage": resistanceLevelToPercentageString(resistanceTypeTemplate) | |||||
}) + '[/font]' | |||||
}) | |||||
}); | |||||
} | |||||
function attackRateDetails(interval, projectiles) | function attackRateDetails(interval, projectiles) | ||||
{ | { | ||||
if (!interval) | if (!interval) | ||||
return ""; | return ""; | ||||
if (projectiles === 0) | if (projectiles === 0) | ||||
return translate("Garrison to fire arrows"); | return translate("Garrison to fire arrows"); | ||||
▲ Show 20 Lines • Show All 770 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Really improvable,,,