Differential D3911 Diff 17669 ps/trunk/binaries/data/mods/public/gui/session/top_panel/CounterPopulation.js
Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/gui/session/top_panel/CounterPopulation.js
Show All 16 Lines | class CounterPopulation | ||||
} | } | ||||
rebuild(playerState, getAllyStatTooltip) | rebuild(playerState, getAllyStatTooltip) | ||||
{ | { | ||||
this.count.caption = sprintf(translate(this.CounterCaption), playerState); | this.count.caption = sprintf(translate(this.CounterCaption), playerState); | ||||
let total = 0; | let total = 0; | ||||
for (let resCode of g_ResourceData.GetCodes()) | for (let resCode of g_ResourceData.GetCodes()) | ||||
total += playerState.resourceGatherers[resCode]; | total += playerState.resourceGatherers[resCode]; | ||||
// Do not show zeroes. | |||||
this.stats.caption = total || ""; | this.stats.caption = total ? coloredText(total, this.DefaultTotalGatherersColor) : 0; | ||||
this.isTrainingBlocked = playerState.trainingBlocked; | this.isTrainingBlocked = playerState.trainingBlocked; | ||||
this.panel.tooltip = | this.panel.tooltip = | ||||
setStringTags(translate(this.PopulationTooltip), CounterManager.ResourceTitleTags) + "\n" + | setStringTags(translate(this.PopulationTooltip), CounterManager.ResourceTitleTags) + | ||||
sprintf(translate(this.MaximumPopulationTooltip), { "popCap": playerState.popMax }) + | getAllyStatTooltip(this.getTooltipData.bind(this)) + "\n" + this.CurrentGatherersTooltip; | ||||
getAllyStatTooltip(this.getTooltipData.bind(this)) + "\n" + | |||||
(total > 0 ? sprintf(translate("Current gatherers: %(amount)s"), { "amount" : total }) : ""); | |||||
} | } | ||||
getTooltipData(playerState, playername) | getTooltipData(playerState, playername) | ||||
{ | { | ||||
return { | return { | ||||
"playername": playername, | "playername": playername, | ||||
"statValue": sprintf(translate(this.AllyPopulationTooltip), playerState), | "statValue": sprintf(translate(this.AllyPopulationTooltip), playerState), | ||||
"orderValue": playerState.popCount | "orderValue": playerState.popCount | ||||
Show All 11 Lines | onTick() | ||||
if (newColor == this.color) | if (newColor == this.color) | ||||
return; | return; | ||||
this.color = newColor; | this.color = newColor; | ||||
this.count.textcolor = newColor; | this.count.textcolor = newColor; | ||||
} | } | ||||
} | } | ||||
// Translation: Do not insert spaces around the slash symbol for this exact string. Keep only one space between popLimit and popMax. | |||||
CounterPopulation.prototype.CounterCaption = markForTranslation("%(popCount)s/%(popLimit)s (%(popMax)s)"); | |||||
CounterPopulation.prototype.CounterCaption = markForTranslation("%(popCount)s/%(popLimit)s"); | CounterPopulation.prototype.PopulationTooltip = markForTranslation("Population: current/limit (max)"); | ||||
CounterPopulation.prototype.PopulationTooltip = markForTranslation("Population (current / limit)"); | |||||
CounterPopulation.prototype.MaximumPopulationTooltip = markForTranslation("Maximum population: %(popCap)s"); | CounterPopulation.prototype.AllyPopulationTooltip = markForTranslation("%(popCount)s/%(popLimit)s (%(popMax)s)"); | ||||
CounterPopulation.prototype.AllyPopulationTooltip = markForTranslation("%(popCount)s/%(popLimit)s/%(popMax)s"); | |||||
/** | /** | ||||
* Storing the translated and formatted gatherer string in the prototype. | |||||
*/ | |||||
CounterPopulation.prototype.CurrentGatherersTooltip = setStringTags(translate("Gatherers: current"), {"font": "sans-bold-16"}); | |||||
/** | |||||
* Color to highlight the total gatherers. | |||||
*/ | |||||
CounterPopulation.prototype.DefaultTotalGatherersColor = "gold"; | |||||
/** | |||||
* Colors to flash when pop limit reached. | * Colors to flash when pop limit reached. | ||||
*/ | */ | ||||
CounterPopulation.prototype.DefaultPopulationColor = "white"; | CounterPopulation.prototype.DefaultPopulationColor = "white"; | ||||
CounterPopulation.prototype.PopulationAlertColor = "orange"; | CounterPopulation.prototype.PopulationAlertColor = "orange"; |
Wildfire Games · Phabricator