Changeset 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) | if (entState.foundation && entState.visibility == "visible") | ||||
Engine.GetGUIObjectByName("health").tooltip = sprintf( | Engine.GetGUIObjectByName("health").tooltip = getBuildTimeTooltip(entState); | ||||
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 | else | ||||
Engine.GetGUIObjectByName("health").tooltip = ""; | 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) | ||||
}); | }); | ||||
▲ Show 20 Lines • Show All 115 Lines • ▼ Show 20 Lines | Engine.GetGUIObjectByName("resourceCarryingIcon").tooltip = sprintf(translate("Gain: %(gain)s"), { | ||||
"gain": getTradingTooltip(entState.trader.goods.amount) | "gain": getTradingTooltip(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("resourceCarryingIcon").tooltip = getBuildTimeTooltip(entState); | ||||
bb: when one doesn't care about the value being 0, one should use Math.round | |||||
Not Done Inline Actionswhy are there 2 spaces before the number? and why is the "number of builders:" in headerFont? bb: why are there 2 spaces before the number? and why is the "number of builders:" in headerFont? | |||||
if (entState.foundation.numBuilders !== 0 && entState.buildTime) | if (entState.foundation.numBuilders) | ||||
Engine.GetGUIObjectByName("resourceCarryingIcon").tooltip = sprintf( | Engine.GetGUIObjectByName("resourceCarryingText").caption = durationToString(entState.buildTime.timeRemaining * 1000) + " "; | ||||
translatePlural( | |||||
"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) | |||||
}); | |||||
else | else | ||||
Engine.GetGUIObjectByName("resourceCarryingIcon").tooltip = translate("Number of builders."); | Engine.GetGUIObjectByName("resourceCarryingText").caption = ""; | ||||
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… | |||||
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) | |||||
Not Done Inline ActionsThat's covered in D1116. temple: That's covered in D1116. | |||||
} | } | ||||
else if (entState.repairable && entState.repairable.numBuilders > 0 && entState.visibility == "visible") | else if (entState.repairable && entState.repairable.numBuilders > 0 && entState.visibility == "visible") | ||||
{ | { | ||||
Not Done Inline Actionsnot a native, but shouldn't "would" -> "will"? bb: not a native, but shouldn't "would" -> "will"? | |||||
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… | |||||
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."); | ||||
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… | |||||
} | } | ||||
else if (entState.resourceSupply && (!entState.resourceSupply.killBeforeGather || !entState.hitpoints) && entState.visibility == "visible") | else if (entState.resourceSupply && (!entState.resourceSupply.killBeforeGather || !entState.hitpoints) && 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 = sprintf(translate("%(amount)s / %(max)s"), { | Engine.GetGUIObjectByName("resourceCarryingText").caption = sprintf(translate("%(amount)s / %(max)s"), { | ||||
"amount": entState.resourceSupply.numGatherers, | "amount": entState.resourceSupply.numGatherers, | ||||
▲ Show 20 Lines • Show All 269 Lines • Show Last 20 Lines |
when one doesn't care about the value being 0, one should use Math.round