Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/common/tooltips.js
Show First 20 Lines • Show All 375 Lines • ▼ Show 20 Lines | function getStatusEffectsTooltip(template) | ||||
let tooltipAttributes = []; | let tooltipAttributes = []; | ||||
let tooltipString = ""; | let tooltipString = ""; | ||||
if (template.Tooltip) | if (template.Tooltip) | ||||
{ | { | ||||
tooltipAttributes.push("%(tooltip)s"); | tooltipAttributes.push("%(tooltip)s"); | ||||
tooltipString = translate(template.Tooltip); | tooltipString = translate(template.Tooltip); | ||||
} | } | ||||
let attackEffectsString = ""; | let attackEffectsString = ""; | ||||
wraitii: From my current understanding of our translation system, this is equivalent to:
```… | |||||
if (template.Damage || template.Capture) | if (template.Damage || template.Capture) | ||||
{ | { | ||||
tooltipAttributes.push("%(effects)s"); | tooltipAttributes.push("%(effects)s"); | ||||
attackEffectsString = attackEffectsDetails(template); | attackEffectsString = attackEffectsDetails(template); | ||||
} | } | ||||
let intervalString = ""; | let intervalString = ""; | ||||
Done Inline Actionssame wraitii: same | |||||
if (template.Interval) | if (template.Interval) | ||||
{ | { | ||||
tooltipAttributes.push("%(rate)s"); | tooltipAttributes.push("%(rate)s"); | ||||
intervalString = sprintf(translate("%(interval)s"), { | intervalString = sprintf(translate("%(interval)s"), { | ||||
"interval": attackRateDetails(+template.Interval) | "interval": attackRateDetails(+template.Interval) | ||||
}); | }); | ||||
} | } | ||||
Done Inline Actionssame wraitii: same | |||||
let durationString = ""; | let durationString = ""; | ||||
if (template.Duration) | if (template.Duration) | ||||
{ | { | ||||
tooltipAttributes.push("%(duration)s"); | tooltipAttributes.push("%(duration)s"); | ||||
durationString = sprintf(translate("%(durName)s: %(duration)s"), { | durationString = sprintf(translate("%(durName)s: %(duration)s"), { | ||||
"durName": headerFont(translate("Duration")), | "durName": headerFont(translate("Duration")), | ||||
"duration": getSecondsString((template._timeElapsed ? +template.Duration - template._timeElapsed : +template.Duration) / 1000), | "duration": getSecondsString((template._timeElapsed ? +template.Duration - template._timeElapsed : +template.Duration) / 1000), | ||||
}); | }); | ||||
} | } | ||||
let stackabilityString = ""; | |||||
if (template.Stackability && template.Stackability != "Ignore") | |||||
{ | |||||
tooltipAttributes.push("%(stackability)s"); | |||||
Done Inline ActionstooltipAttributes.push("%(stackability)s") you probably mean to use translation for the string, otherwise there is probably no use case for using the sprintf format. elexis: `tooltipAttributes.push("%(stackability)s")` you probably mean to use translation for the… | |||||
if (template.Stackability == "Extend") | |||||
stackabilityString = translateWithContext("status effect stackability", "(extends)"); | |||||
else if (template.Stackability == "Replace") | |||||
stackabilityString = translateWithContext("status effect stackability", "(replaces)"); | |||||
else if (template.Stackability == "Stack") | |||||
stackabilityString = translateWithContext("status effect stackability", "(stacks)"); | |||||
} | |||||
return sprintf(translate("%(statusName)s: " + tooltipAttributes.join(translate(commaFont(", ")))), { | return sprintf(translate("%(statusName)s: " + tooltipAttributes.join(translate(commaFont(", ")))), { | ||||
Done Inline ActionsThis translation is broken translate("%(statusName)s: " + foo) elexis: This translation is broken `translate("%(statusName)s: " + foo)` | |||||
"statusName": headerFont(translateWithContext("status effect", template.Name)), | "statusName": headerFont(translateWithContext("status effect", template.Name)), | ||||
"tooltip": tooltipString, | "tooltip": tooltipString, | ||||
"effects": attackEffectsString, | "effects": attackEffectsString, | ||||
"rate": intervalString, | "rate": intervalString, | ||||
"duration": durationString | "duration": durationString, | ||||
"stackability": stackabilityString | |||||
}); | }); | ||||
} | } | ||||
function getGarrisonTooltip(template) | function getGarrisonTooltip(template) | ||||
{ | { | ||||
if (!template.garrisonHolder) | if (!template.garrisonHolder) | ||||
return ""; | return ""; | ||||
let tooltips = [ | let tooltips = [ | ||||
sprintf(translate("%(label)s: %(garrisonLimit)s"), { | sprintf(translate("%(label)s: %(garrisonLimit)s"), { | ||||
"label": headerFont(translate("Garrison Limit")), | "label": headerFont(translate("Garrison Limit")), | ||||
"garrisonLimit": template.garrisonHolder.capacity | "garrisonLimit": template.garrisonHolder.capacity | ||||
}) | }) | ||||
]; | ]; | ||||
if (template.garrisonHolder.buffHeal) | if (template.garrisonHolder.buffHeal) | ||||
tooltips.push( | tooltips.push( | ||||
sprintf(translate("%(healRateLabel)s %(value)s %(health)s / %(second)s"), { | sprintf(translate("%(healRateLabel)s %(value)s %(health)s / %(second)s"), { | ||||
"healRateLabel": headerFont(translate("Heal:")), | "healRateLabel": headerFont(translate("Heal:")), | ||||
"value": Math.round(template.garrisonHolder.buffHeal), | "value": Math.round(template.garrisonHolder.buffHeal), | ||||
Not Done Inline ActionsPending question about ===. I also wonder if having enums and checking integers would have any perf impact. Probably irrelevant here. Stan: Pending question about ===.
I also wonder if having enums and checking integers would have any… | |||||
"health": unitFont(translate("Health")), | "health": unitFont(translate("Health")), | ||||
"second": unitFont(translate("second")), | "second": unitFont(translate("second")), | ||||
}) | }) | ||||
); | ); | ||||
return tooltips.join(commaFont(translate(", "))); | return tooltips.join(commaFont(translate(", "))); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 477 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
From my current understanding of our translation system, this is equivalent to:
and requires Tooltip to be a translatable string pulled from elsewhere (which it is since rP23681)