Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/common/tooltips.js
Show First 20 Lines • Show All 327 Lines • ▼ Show 20 Lines | if (template.buildingAI) | ||||
projectiles = template.buildingAI.arrowCount || template.buildingAI.defaultArrowCount; | projectiles = template.buildingAI.arrowCount || template.buildingAI.defaultArrowCount; | ||||
// Show the effects of status effects below | // Show the effects of status effects below | ||||
let statusEffectsDetails = []; | let statusEffectsDetails = []; | ||||
if (attackTypeTemplate.ApplyStatus) | if (attackTypeTemplate.ApplyStatus) | ||||
for (let status in attackTypeTemplate.ApplyStatus) | for (let status in attackTypeTemplate.ApplyStatus) | ||||
{ | { | ||||
let status_template = g_StatusEffectsMetadata.augment(status, attackTypeTemplate.ApplyStatus[status]); | let status_template = g_StatusEffectsMetadata.augment(status, attackTypeTemplate.ApplyStatus[status]); | ||||
statusEffectsDetails.push("\n " + getStatusEffectsTooltip(status_template)); | statusEffectsDetails.push("\n " + getStatusEffectsTooltip(status_template, true)); | ||||
} | } | ||||
statusEffectsDetails = statusEffectsDetails.join(""); | statusEffectsDetails = statusEffectsDetails.join(""); | ||||
tooltips.push(sprintf(translate("%(attackLabel)s: %(effects)s, %(range)s, %(rate)s%(statusEffects)s"), { | tooltips.push(sprintf(translate("%(attackLabel)s: %(effects)s, %(range)s, %(rate)s%(statusEffects)s"), { | ||||
"attackLabel": attackLabel, | "attackLabel": attackLabel, | ||||
"effects": attackEffectsDetails(attackTypeTemplate), | "effects": attackEffectsDetails(attackTypeTemplate), | ||||
"range": rangeDetails(attackTypeTemplate), | "range": rangeDetails(attackTypeTemplate), | ||||
"rate": attackRateDetails(attackTypeTemplate.repeatTime, projectiles), | "rate": attackRateDetails(attackTypeTemplate.repeatTime, projectiles), | ||||
Show All 30 Lines | for (let attackType in template.attack) | ||||
tooltips.push(splashDamageTooltip); | tooltips.push(splashDamageTooltip); | ||||
} | } | ||||
// If multiple attack types deal splash damage, the attack type should be shown to differentiate. | // If multiple attack types deal splash damage, the attack type should be shown to differentiate. | ||||
return tooltips.join("\n"); | return tooltips.join("\n"); | ||||
} | } | ||||
function getStatusEffectsTooltip(template) | /** | ||||
* @param applier - if true, return the tooltip for the Applier. If false, Receiver is returned. | |||||
*/ | |||||
function getStatusEffectsTooltip(template, applier) | |||||
{ | { | ||||
let tooltipAttributes = []; | let tooltipAttributes = []; | ||||
let tooltipString = ""; | if (applier && template.ApplierTooltip) | ||||
if (template.StatusTooltip) | tooltipAttributes.push(translate(template.ApplierTooltip)); | ||||
{ | else if (!applier && template.ReceiverTooltip) | ||||
wraitii: From my current understanding of our translation system, this is equivalent to:
```… | |||||
tooltipAttributes.push("%(tooltip)s"); | tooltipAttributes.push(translate(template.ReceiverTooltip)); | ||||
tooltipString = translate(template.StatusTooltip); | |||||
} | |||||
let attackEffectsString = ""; | |||||
if (template.Damage || template.Capture) | if (template.Damage || template.Capture) | ||||
{ | tooltipAttributes.push(attackEffectsDetails(template)); | ||||
tooltipAttributes.push("%(effects)s"); | |||||
attackEffectsString = attackEffectsDetails(template); | |||||
} | |||||
let intervalString = ""; | |||||
if (template.Interval) | if (template.Interval) | ||||
Done Inline Actionssame wraitii: same | |||||
{ | tooltipAttributes.push(attackRateDetails(+template.Interval)); | ||||
Done Inline Actionssame wraitii: same | |||||
tooltipAttributes.push("%(rate)s"); | |||||
intervalString = sprintf(translate("%(interval)s"), { | if (template.Duration) | ||||
"interval": attackRateDetails(+template.Interval) | tooltipAttributes.push(getStatusEffectDurationTooltip(template)); | ||||
if (applier) | |||||
return sprintf(translate("%(statusName)s: %(statusInfo)s %(stackability)s"), { | |||||
"statusName": headerFont(translateWithContext("status effect", template.StatusName)), | |||||
"statusInfo": tooltipAttributes.join(commaFont(translate(", "))), | |||||
"stackability": getStatusEffectStackabilityTooltip(template) | |||||
}); | |||||
else | |||||
return sprintf(translate("%(statusName)s: %(statusInfo)s"), { | |||||
"statusName": headerFont(translateWithContext("status effect", template.StatusName)), | |||||
"statusInfo": tooltipAttributes.join(commaFont(translate(", "))) | |||||
}); | }); | ||||
} | } | ||||
Done Inline ActionsThis translation is broken translate("%(statusName)s: " + foo) elexis: This translation is broken `translate("%(statusName)s: " + foo)` | |||||
let durationString = ""; | function getStatusEffectDurationTooltip(template) | ||||
if (template.Duration) | |||||
{ | { | ||||
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… | |||||
tooltipAttributes.push("%(duration)s"); | if (!template.Duration) | ||||
durationString = sprintf(translate("%(durName)s: %(duration)s"), { | return ""; | ||||
return 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) | |||||
}); | }); | ||||
} | } | ||||
return sprintf(translate("%(statusName)s: " + tooltipAttributes.join(translate(commaFont(", ")))), { | function getStatusEffectStackabilityTooltip(template) | ||||
"statusName": headerFont(translateWithContext("status effect", template.StatusName)), | { | ||||
"tooltip": tooltipString, | if (!template.Stackability || template.Stackability == "Ignore") | ||||
"effects": attackEffectsString, | return ""; | ||||
"rate": intervalString, | |||||
"duration": durationString | let stackabilityString = ""; | ||||
if (template.Stackability == "Extend") | |||||
StanUnsubmitted 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… | |||||
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("%(stackability)s"), { | |||||
"stackability": stackabilityString | |||||
}); | }); | ||||
} | } | ||||
function getGarrisonTooltip(template) | function getGarrisonTooltip(template) | ||||
{ | { | ||||
if (!template.garrisonHolder) | if (!template.garrisonHolder) | ||||
return ""; | return ""; | ||||
▲ Show 20 Lines • Show All 497 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)