Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/session/selection_details.js
Show First 20 Lines • Show All 106 Lines • ▼ Show 20 Lines | function displaySingle(entState) | ||||
healthSection.hidden = !showHealth; | healthSection.hidden = !showHealth; | ||||
if (showHealth) | if (showHealth) | ||||
{ | { | ||||
let unitHealthBar = Engine.GetGUIObjectByName("healthBar"); | let unitHealthBar = Engine.GetGUIObjectByName("healthBar"); | ||||
let healthSize = unitHealthBar.size; | let healthSize = unitHealthBar.size; | ||||
healthSize.rright = 100*Math.max(0, Math.min(1, entState.hitpoints / entState.maxHitpoints)); | healthSize.rright = 100*Math.max(0, Math.min(1, entState.hitpoints / entState.maxHitpoints)); | ||||
unitHealthBar.size = healthSize; | unitHealthBar.size = healthSize; | ||||
if (entState.foundation && entState.visibility == "visible" && entState.foundation.numBuilders !== 0 && entState.buildTime) | |||||
Engine.GetGUIObjectByName("health").tooltip = sprintf( | |||||
translatePlural( | |||||
"This foundation will be completed in %(seconds)s second.", | |||||
"This foundation will be completed in %(seconds)s seconds.", | |||||
Math.ceil(entState.buildTime.timeRemaining)), | |||||
{ | |||||
"seconds": Math.ceil(entState.buildTime.timeRemaining) | |||||
}); | |||||
else | |||||
Engine.GetGUIObjectByName("health").tooltip = ""; | |||||
Engine.GetGUIObjectByName("healthStats").caption = sprintf(translate("%(hitpoints)s / %(maxHitpoints)s"), { | Engine.GetGUIObjectByName("healthStats").caption = sprintf(translate("%(hitpoints)s / %(maxHitpoints)s"), { | ||||
"hitpoints": Math.ceil(entState.hitpoints), | "hitpoints": Math.ceil(entState.hitpoints), | ||||
"maxHitpoints": Math.ceil(entState.maxHitpoints) | "maxHitpoints": Math.ceil(entState.maxHitpoints) | ||||
}); | }); | ||||
healthSection.size = sectionPosTop.size; | healthSection.size = sectionPosTop.size; | ||||
captureSection.size = showResource ? sectionPosMiddle.size : sectionPosBottom.size; | captureSection.size = showResource ? sectionPosMiddle.size : sectionPosBottom.size; | ||||
resourceSection.size = showResource ? sectionPosBottom.size : sectionPosMiddle.size; | resourceSection.size = showResource ? sectionPosBottom.size : sectionPosMiddle.size; | ||||
▲ Show 20 Lines • Show All 113 Lines • ▼ Show 20 Lines | else if (entState.trader && entState.trader.goods.amount) | ||||
}); | }); | ||||
} | } | ||||
// And for number of workers | // And for number of workers | ||||
else if (entState.foundation && entState.visibility == "visible") | else if (entState.foundation && entState.visibility == "visible") | ||||
{ | { | ||||
Engine.GetGUIObjectByName("resourceCarryingIcon").hidden = false; | Engine.GetGUIObjectByName("resourceCarryingIcon").hidden = false; | ||||
Engine.GetGUIObjectByName("resourceCarryingText").hidden = false; | Engine.GetGUIObjectByName("resourceCarryingText").hidden = false; | ||||
Engine.GetGUIObjectByName("resourceCarryingIcon").sprite = "stretched:session/icons/repair.png"; | Engine.GetGUIObjectByName("resourceCarryingIcon").sprite = "stretched:session/icons/repair.png"; | ||||
Engine.GetGUIObjectByName("resourceCarryingText").caption = entState.foundation.numBuilders + " "; | Engine.GetGUIObjectByName("resourceCarryingText").caption = ""; | ||||
if (entState.foundation.numBuilders !== 0 && entState.buildTime) | Engine.GetGUIObjectByName("resourceCarryingIcon").tooltip = headerFont(translate("Number of builders: ")) + entState.foundation.numBuilders; | ||||
bb: why are there 2 spaces before the number? and why is the "number of builders:" in headerFont? | |||||
Engine.GetGUIObjectByName("resourceCarryingIcon").tooltip = sprintf( | |||||
translatePlural( | if (entState.foundation.numBuilders > 0 && entState.buildTime) | ||||
"Number of builders.\nTasking another to this foundation would speed construction up by %(speedup)s second.", | |||||
"Number of builders.\nTasking another to this foundation would speed construction up by %(speedup)s seconds.", | |||||
Math.ceil(entState.buildTime.timeSpeedup)), | |||||
{ | { | ||||
"speedup": Math.ceil(entState.buildTime.timeSpeedup) | Engine.GetGUIObjectByName("resourceCarryingText").caption = Engine.FormatMillisecondsIntoDateStringGMT(entState.buildTime.timeRemaining * 1000, translateWithContext("countdown format", "m:ss")) + " "; | ||||
bbUnsubmitted Not Done Inline Actionstimes > 1h are not displayed correctly (imo we should support that at least) bb: times > 1h are not displayed correctly (imo we should support that at least) | |||||
templeAuthorUnsubmitted Not Done Inline ActionsThat's covered in D1116. temple: That's covered in D1116. | |||||
Engine.GetGUIObjectByName("resourceCarryingIcon").tooltip += '\n' + sprintf(translatePlural( | |||||
"Adding another worker would speed up the construction by %(speedup)s second.", | |||||
"Adding another worker would speed up the construction by %(speedup)s seconds.", | |||||
bbUnsubmitted Not Done Inline Actionsnot a native, but shouldn't "would" -> "will"? bb: not a native, but shouldn't "would" -> "will"? | |||||
bbUnsubmitted Not Done Inline Actionsnot a really strong opinion but should we use a date string here too (instead of showing the number of seconds)? bb: not a really strong opinion but should we use a date string here too (instead of showing the… | |||||
Math.floor(entState.buildTime.timeSpeedup)), | |||||
{ | |||||
"speedup": Math.floor(entState.buildTime.timeSpeedup) | |||||
bbUnsubmitted Not Done Inline Actionswhen one doesn't care about the value being 0, one should use Math.round bb: when one doesn't care about the value being 0, one should use Math.round | |||||
}); | }); | ||||
else | } | ||||
bbUnsubmitted Not Done Inline Actionsthis tooltip should be as much similar to the (not implemented yet) repair tooltip, but the a repairable building has no builder icon when it is not under repair (and adding one seems odd), thus imo the tooltip should be added to the healthbar aswell (so make a function in tooltips.js and use that in both places) bb: this tooltip should be as much similar to the (not implemented yet) repair tooltip, but the a… | |||||
Engine.GetGUIObjectByName("resourceCarryingIcon").tooltip = translate("Number of builders."); | |||||
bbUnsubmitted Not Done Inline Actionsmaybe add a different string here, like "With 1 worker the construction would be finished in {time}" bb: maybe add a different string here, like "With 1 worker the construction would be finished in… | |||||
} | } | ||||
else if (entState.repairable && entState.repairable.numBuilders > 0 && entState.visibility == "visible") | else if (entState.repairable && entState.repairable.numBuilders > 0 && entState.visibility == "visible") | ||||
{ | { | ||||
Engine.GetGUIObjectByName("resourceCarryingIcon").hidden = false; | Engine.GetGUIObjectByName("resourceCarryingIcon").hidden = false; | ||||
Engine.GetGUIObjectByName("resourceCarryingText").hidden = false; | Engine.GetGUIObjectByName("resourceCarryingText").hidden = false; | ||||
Engine.GetGUIObjectByName("resourceCarryingIcon").sprite = "stretched:session/icons/repair.png"; | Engine.GetGUIObjectByName("resourceCarryingIcon").sprite = "stretched:session/icons/repair.png"; | ||||
Engine.GetGUIObjectByName("resourceCarryingText").caption = entState.repairable.numBuilders + " "; | Engine.GetGUIObjectByName("resourceCarryingText").caption = entState.repairable.numBuilders + " "; | ||||
Engine.GetGUIObjectByName("resourceCarryingIcon").tooltip = translate("Number of builders."); | Engine.GetGUIObjectByName("resourceCarryingIcon").tooltip = translate("Number of builders."); | ||||
▲ Show 20 Lines • Show All 277 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
why are there 2 spaces before the number? and why is the "number of builders:" in headerFont?