Changeset View
Standalone View
binaries/data/mods/public/gui/common/tooltips.js
Show First 20 Lines • Show All 314 Lines • ▼ Show 20 Lines | for (let attackType in template.attack) | ||||
}); | }); | ||||
let attackTypeTemplate = template.attack[attackType]; | let attackTypeTemplate = template.attack[attackType]; | ||||
let projectiles; | let projectiles; | ||||
// Use either current rate from simulation or default count if the sim is not running. | // Use either current rate from simulation or default count if the sim is not running. | ||||
// ToDo: This ought to be extended to include units which fire multiple projectiles. | // ToDo: This ought to be extended to include units which fire multiple projectiles. | ||||
if (template.buildingAI) | if (template.buildingAI) | ||||
projectiles = template.buildingAI.arrowCount || template.buildingAI.defaultArrowCount; | projectiles = template.buildingAI.arrowCount || template.buildingAI.defaultArrowCount; | ||||
// Show the effects of status effects below | // This is what every attack ought to have and show. | ||||
let statusEffectsDetails = []; | let properties = [translate("%(attackLabel)s: %(effects)s, %(range)s, %(rate)s")]; | ||||
elexis: missing translate | |||||
let data = { | |||||
"attackLabel": attackLabel, | |||||
"effects": attackEffectsDetails(attackTypeTemplate), | |||||
"range": rangeDetails(attackTypeTemplate), | |||||
"rate": attackRateDetails(attackTypeTemplate.repeatTime, projectiles) | |||||
}; | |||||
if (attackTypeTemplate.Bonuses) | |||||
{ | |||||
properties.push(translate("%(counters)s")); | |||||
Done Inline Actionsmissing translation also one should not hardcode spaces or operators in english language, but use translated sprintf strings to concatenate strings (the one exception the code currently has are newlines). elexis: missing translation
also one should not hardcode spaces or operators in english language, but… | |||||
data.counters = getCountersTooltip(attackTypeTemplate); | |||||
} | |||||
// Show the effects of status effects below. | |||||
if (attackTypeTemplate.ApplyStatus) | if (attackTypeTemplate.ApplyStatus) | ||||
{ | |||||
let statusEffectsDetails = []; | |||||
for (let status in attackTypeTemplate.ApplyStatus) | for (let status in attackTypeTemplate.ApplyStatus) | ||||
statusEffectsDetails.push("\n " + getStatusEffectsTooltip(attackTypeTemplate.ApplyStatus[status])); | statusEffectsDetails.push("\n " + getStatusEffectsTooltip(attackTypeTemplate.ApplyStatus[status])); | ||||
statusEffectsDetails = statusEffectsDetails.join(""); | statusEffectsDetails = statusEffectsDetails.join(""); | ||||
properties.push("%(statusEffects)s"); | |||||
Done Inline Actions"%(statusEffects)s" thats weird, either a missing translate or something else elexis: `"%(statusEffects)s"` thats weird, either a missing translate or something else | |||||
data.statusEffects = statusEffectsDetails; | |||||
} | |||||
tooltips.push(sprintf(translate("%(attackLabel)s: %(effects)s, %(range)s, %(rate)s%(statusEffects)s"), { | tooltips.push(sprintf(translate(properties.join(translate(" "))), data)); | ||||
Done Inline ActionsIt seems to me we need a nicer way to add variably present tooltips, like Status Effects and Counters. Freagarach: It seems to me we need a nicer way to add variably present tooltips, like Status Effects and… | |||||
"attackLabel": attackLabel, | |||||
"effects": attackEffectsDetails(attackTypeTemplate), | |||||
"range": rangeDetails(attackTypeTemplate), | |||||
"rate": attackRateDetails(attackTypeTemplate.repeatTime, projectiles), | |||||
"statusEffects": statusEffectsDetails | |||||
})); | |||||
} | } | ||||
return tooltips.join("\n"); | return tooltips.join("\n"); | ||||
} | } | ||||
function getSplashDamageTooltip(template) | function getSplashDamageTooltip(template) | ||||
{ | { | ||||
if (!template.attack) | if (!template.attack) | ||||
return ""; | return ""; | ||||
▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | return sprintf(translate("%(statusName)s: " + tooltipAttributes.join(translate(commaFont(", ")))), { | ||||
"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 | ||||
}); | }); | ||||
} | } | ||||
function getCountersTooltip(template) | |||||
{ | |||||
if (!template.Bonuses) | |||||
return ""; | |||||
let bonusesBody = []; | |||||
for (let key in template.Bonuses) | |||||
{ | |||||
let bonus = template.Bonuses[key]; | |||||
if (bonus.Multiplier == 1) | |||||
continue; | |||||
bonusesBody.push(sprintf(translate("%(multiplier)s× vs %(classes)s"), { | |||||
"multiplier": bonus.Multiplier, | |||||
"classes": translate(bonus.Classes) | |||||
})); | |||||
} | |||||
return sprintf(translate("(%(bonuses)s)"), { | |||||
Done Inline ActionsThe extractor won't be happy about translate("(" + otherstring), the expected input is translate("foo") or translate(expr), as in either a string literal or an expression without any string literals. And thats not only an implementation bug, but there use case should be implemented using a translated sprintf strings. This way the ( and ) and order of arguments can be changed in the translation as well. elexis: The extractor won't be happy about `translate("(" + otherstring)`, the expected input is… | |||||
"bonuses": bodyFont(bonusesBody.join(commaFont(translate(", ")))) | |||||
}); | |||||
} | |||||
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")), | ||||
▲ Show 20 Lines • Show All 366 Lines • ▼ Show 20 Lines | return [ | ||||
sprintf(translatePlural("%(label)s %(val)s %(unit)s", "%(label)s %(val)s %(unit)s", range), { | sprintf(translatePlural("%(label)s %(val)s %(unit)s", "%(label)s %(val)s %(unit)s", range), { | ||||
"label": headerFont(translate("Range:")), | "label": headerFont(translate("Range:")), | ||||
"val": range, | "val": range, | ||||
"unit": unitFont(translatePlural("meter", "meters", range)) | "unit": unitFont(translatePlural("meter", "meters", range)) | ||||
}), | }), | ||||
sprintf(translatePlural("%(label)s %(val)s %(unit)s", "%(label)s %(val)s %(unit)s", rate), { | sprintf(translatePlural("%(label)s %(val)s %(unit)s", "%(label)s %(val)s %(unit)s", rate), { | ||||
"label": headerFont(translate("Rate:")), | "label": headerFont(translate("Rate:")), | ||||
"val": rate, | "val": rate, | ||||
"unit": unitFont(translatePlural("second", "seconds", rate)) | "unit": unitFont(translatePlural("second", "seconds", rate)) | ||||
Done Inline Actions-1 space elexis: -1 space | |||||
Done Inline Actionslet string = headerFont(sprintf(translate("%(attackType)s Counters: "), { Nescio: let string = headerFont(sprintf(translate("%(attackType)s Counters: "), { | |||||
}) | }) | ||||
].join(translate(", ")); | ].join(translate(", ")); | ||||
} | } | ||||
function getAurasTooltip(template) | function getAurasTooltip(template) | ||||
{ | { | ||||
let auras = template.auras || template.wallSet && GetTemplateData(template.wallSet.templates.long).auras; | let auras = template.auras || template.wallSet && GetTemplateData(template.wallSet.templates.long).auras; | ||||
Done Inline ActionsbonusesBody.push(sprintf(translate("%(multiplier)s× vs %(classes)s"), { Nescio: bonusesBody.push(sprintf(translate("%(multiplier)s× vs %(classes)s"), { | |||||
if (!auras) | if (!auras) | ||||
return ""; | return ""; | ||||
let tooltips = []; | let tooltips = []; | ||||
for (let auraID in auras) | for (let auraID in auras) | ||||
{ | { | ||||
Done Inline ActionsLooks nicer without the first and other variables, right? let bonusBody = template.attack[attackType].bonuses.map(bonus => bodyFont(...) + " " + ...) (The bonus variable could be ommitted by using template.attack[attackType].bonuses[key] twice and adding a newline. The string variable can be inlined too with some \n and indentation). multiplier + " " + classes should use a sprintf too I think, languages might reverse that or add characters somewhere, or more space or whatever. elexis: Looks nicer without the `first` and other variables, right?
Try `map` https://developer.mozilla. | |||||
Done Inline ActionsIf I try map it fails (it says it's not a function), may it be because template.attack[attackType].bonuses is an object (not array) or i failed the syntax ? Feldfeld: If I try map it fails (it says it's not a function), may it be because `template.attack… | |||||
Done Inline ActionsOh, right, sorry for the wasted time. It is an object, not an array. One could use Object.keys(bonuses).map(bonusType => bonuses[bonusType].bla) but that will mean more objects are created, making this slower than your current function, so screw that array function. elexis: Oh, right, sorry for the wasted time. It is an object, not an array. One could use Object.keys… | |||||
Done Inline Actions", " still needs a translateWithContext, but that can be fixed at committing stage too. elexis: ", " still needs a translateWithContext, but that can be fixed at committing stage too. | |||||
let tooltip = sprintf(translate("%(auralabel)s %(aurainfo)s"), { | let tooltip = sprintf(translate("%(auralabel)s %(aurainfo)s"), { | ||||
"auralabel": headerFont(sprintf(translate("%(auraname)s:"), { | "auralabel": headerFont(sprintf(translate("%(auraname)s:"), { | ||||
"auraname": translate(auras[auraID].name) | "auraname": translate(auras[auraID].name) | ||||
})), | })), | ||||
"aurainfo": bodyFont(translate(auras[auraID].description)) | "aurainfo": bodyFont(translate(auras[auraID].description)) | ||||
}); | }); | ||||
let radius = +auras[auraID].radius; | let radius = +auras[auraID].radius; | ||||
if (radius) | if (radius) | ||||
▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | function getLootTooltip(template) | ||||
return sprintf(translate("%(label)s %(details)s"), { | return sprintf(translate("%(label)s %(details)s"), { | ||||
"label": headerFont(translate("Loot:")), | "label": headerFont(translate("Loot:")), | ||||
"details": lootLabels.join(" ") | "details": lootLabels.join(" ") | ||||
}); | }); | ||||
} | } | ||||
function showTemplateViewerOnRightClickTooltip() | function showTemplateViewerOnRightClickTooltip() | ||||
{ | { | ||||
// Translation: Appears in a tooltip to indicate that right-clicking the corresponding GUI element will open the Template Details GUI page. | // Translation: Appears in a tooltip to indicate that right-clicking the corresponding GUI element will open the Template Details GUI page. | ||||
Done Inline ActionsAccidentally left this in wraitii: Accidentally left this in | |||||
return translate("Right-click to view more information."); | return translate("Right-click to view more information."); | ||||
} | } | ||||
function showTemplateViewerOnClickTooltip() | function showTemplateViewerOnClickTooltip() | ||||
{ | { | ||||
// Translation: Appears in a tooltip to indicate that clicking the corresponding GUI element will open the Template Details GUI page. | // Translation: Appears in a tooltip to indicate that clicking the corresponding GUI element will open the Template Details GUI page. | ||||
return translate("Click to view more information."); | return translate("Click to view more information."); | ||||
} | } | ||||
Done Inline ActionsShouldn't that be .every() == 1? lyv: Shouldn't that be .every() == 1?
If something isn't one, they should not be skipped over? | |||||
Done Inline ActionsCould work as well, as I understand it, !some != 1 = every = 1 no ? Stan: Could work as well, as I understand it, !some != 1 = every = 1 no ? | |||||
Done Inline ActionsI did not see that negation. lyv: I did not see that negation.
Why a double negative though?
I didn’t not see a bird
Vs
I saw a… | |||||
Done Inline ActionsYeah I didn't remember the every function. I'll fix it later it makes more sense to me :) Stan: Yeah I didn't remember the every function. I'll fix it later it makes more sense to me :) | |||||
Done Inline Actions(having all quantors in a formula first = https://en.wikipedia.org/wiki/Prenex_normal_form) elexis: (having all quantors in a formula first = https://en.wikipedia.org/wiki/Prenex_normal_form) | |||||
Done Inline ActionsThe heck happened here elexis: The heck happened here | |||||
Done Inline Actionsclip.exe not utf8 happens sometimes. Stan: clip.exe not utf8 happens sometimes. | |||||
Done Inline ActionsShouldn't there be a s after %(multiplier)? Nescio: Shouldn't there be a `s` after `%(multiplier)`?
Also, `×`. | |||||
Done Inline ActionsRight Stan: Right |
missing translate