Changeset View
Standalone View
binaries/data/mods/public/gui/common/tooltips.js
Show First 20 Lines • Show All 257 Lines • ▼ Show 20 Lines | let rate = sprintf(translate("%(label)s %(details)s"), { | ||||
"label": | "label": | ||||
headerFont( | headerFont( | ||||
template.buildingAI && type == "Ranged" ? | template.buildingAI && type == "Ranged" ? | ||||
translate("Interval:") : | translate("Interval:") : | ||||
translate("Rate:")), | translate("Rate:")), | ||||
"details": attackRateDetails(template, type) | "details": attackRateDetails(template, type) | ||||
}); | }); | ||||
let attackLabel = headerFont(g_AttackTypes[type]); | let attackLabel = headerFont(g_AttackTypes[type]); | ||||
elexis: missing translate | |||||
if (type == "Capture" || type != "Ranged") | if (type == "Capture" || type != "Ranged") | ||||
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 | |||||
{ | { | ||||
tooltips.push(sprintf(translate("%(attackLabel)s %(details)s, %(rate)s"), { | tooltips.push(sprintf(translate("%(attackLabel)s %(details)s, %(rate)s"), { | ||||
"attackLabel": attackLabel, | "attackLabel": attackLabel, | ||||
"details": | "details": | ||||
type == "Capture" ? | type == "Capture" ? | ||||
template.attack.Capture.value : | template.attack.Capture.value : | ||||
damageTypesToText(template.attack[type].damage), | damageTypesToText(template.attack[type].damage), | ||||
"rate": rate | "rate": rate | ||||
})); | })); | ||||
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… | |||||
continue; | continue; | ||||
} | } | ||||
let minRange = Math.round(template.attack[type].minRange); | let minRange = Math.round(template.attack[type].minRange); | ||||
let maxRange = Math.round(template.attack[type].maxRange); | let maxRange = Math.round(template.attack[type].maxRange); | ||||
let realRange = template.attack[type].elevationAdaptedRange; | let realRange = template.attack[type].elevationAdaptedRange; | ||||
let relativeRange = realRange ? Math.round(realRange - maxRange) : 0; | let relativeRange = realRange ? Math.round(realRange - maxRange) : 0; | ||||
tooltips.push(sprintf(g_RangeTooltipString[relativeRange ? "relative" : "non-relative"][minRange ? "minRange" : "no-minRange"], { | tooltips.push(sprintf(g_RangeTooltipString[relativeRange ? "relative" : "non-relative"][minRange ? "minRange" : "no-minRange"], { | ||||
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, | "attackLabel": attackLabel, | ||||
"damageTypes": damageTypesToText(template.attack[type].damage), | "damageTypes": damageTypesToText(template.attack[type].damage), | ||||
"rangeLabel": headerFont(translate("Range:")), | "rangeLabel": headerFont(translate("Range:")), | ||||
"minRange": minRange, | "minRange": minRange, | ||||
"maxRange": maxRange, | "maxRange": maxRange, | ||||
"relativeRange": relativeRange > 0 ? sprintf(translate("+%(number)s"), { "number": relativeRange }) : relativeRange, | "relativeRange": relativeRange > 0 ? sprintf(translate("+%(number)s"), { "number": relativeRange }) : relativeRange, | ||||
"rangeUnit": | "rangeUnit": | ||||
unitFont(minRange || relativeRange ? | unitFont(minRange || relativeRange ? | ||||
▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | function getGarrisonTooltip(template) | ||||
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), | ||||
"health": unitFont(translate("Health")), | "health": unitFont(translate("Health")), | ||||
"second": unitFont(translate("second")), | "second": unitFont(translate("second")), | ||||
}) | }) | ||||
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… | |||||
); | ); | ||||
return tooltips.join(commaFont(translate(", "))); | return tooltips.join(commaFont(translate(", "))); | ||||
} | } | ||||
function getProjectilesTooltip(template) | function getProjectilesTooltip(template) | ||||
{ | { | ||||
if (!template.garrisonHolder || !template.buildingAI) | if (!template.garrisonHolder || !template.buildingAI) | ||||
▲ Show 20 Lines • Show All 455 Lines • ▼ Show 20 Lines | if (!lootLabels.length) | ||||
return ""; | return ""; | ||||
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 getCountersTooltip(template) | |||||
{ | |||||
if (!template.attack) | |||||
Done Inline ActionsAccidentally left this in wraitii: Accidentally left this in | |||||
return ""; | |||||
let result = []; | |||||
for (let attackType in template.attack) | |||||
{ | |||||
if (!template.attack[attackType].bonuses) | |||||
continue; | |||||
let bonusesBody = []; | |||||
for (let key in template.attack[attackType].bonuses) | |||||
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) | |||||
{ | |||||
let bonus = template.attack[attackType].bonuses[key]; | |||||
if(bonus.multiplier == 1) | |||||
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: "), { | |||||
continue; | |||||
bonusesBody.push(sprintf(translate("%(multiplier) vs %(classes)s"), { | |||||
NescioUnsubmitted Done Inline ActionsShouldn't there be a s after %(multiplier)? Nescio: Shouldn't there be a `s` after `%(multiplier)`?
Also, `×`. | |||||
StanUnsubmitted Done Inline ActionsRight Stan: Right | |||||
"multiplier": bonus.multiplier, | |||||
"classes": translate(bonus.classes) | |||||
})); | |||||
} | |||||
Done Inline ActionsbonusesBody.push(sprintf(translate("%(multiplier)s× vs %(classes)s"), { Nescio: bonusesBody.push(sprintf(translate("%(multiplier)s× vs %(classes)s"), { | |||||
if(!bonusesBody.length) | |||||
continue; | |||||
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. | |||||
let string = headerFont(sprintf(translate("Counters %(attackType)s : "), { | |||||
"attackType": translate(attackType) | |||||
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. | |||||
})); | |||||
result.push(string + bodyFont(bonusesBody.join(", "))); | |||||
} | |||||
return result.join("\n"); | |||||
} | |||||
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. | ||||
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."); | ||||
} | } |
missing translate