Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/session/top_panel/CounterPopulation.js
Show All 17 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. | // Do not show zeroes. | |||||||||||
this.stats.caption = total || ""; | this.stats.caption = total ? coloredText(total, this.DefaultGatherersColor) : ""; | |||||||||||
Freagarach: It is better to not call the coloredText function if there is no total. | ||||||||||||
Not Done Inline ActionsI meant more something like: this.stats.caption = total ? coloredText(total, "yellow") : "". Freagarach: I meant more something like: `this.stats.caption = total ? coloredText(total, "yellow") : ""`. | ||||||||||||
Not Done Inline ActionsThe colour should be part of the prototype, see e.g. the default pop colour at the end of the file. Freagarach: The colour should be part of the prototype, see e.g. the default pop colour at the end of the… | ||||||||||||
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" + | getAllyStatTooltip(this.getTooltipData.bind(this)) + "\n" + | |||||||||||
(total > 0 ? sprintf(translate("Current gatherers: %(amount)s"), { "amount" : total }) : ""); | (total > 0 ? sprintf(translate("Current gatherers: %(amount)s"), { "amount" : total }) : ""); | |||||||||||
} | } | |||||||||||
Not Done Inline Actions
I guess these can be just Current gatherers? Freagarach: I guess these can be just `Current gatherers`?
Also, since it is not dynamic anymore, we can… | ||||||||||||
Not Done Inline Actions
? Freagarach: ? | ||||||||||||
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 10 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)"); | |||||||||||
Not Done Inline ActionsI don't see the need for this, but if people like it more, I am okay with it. Freagarach: I don't see the need for this, but if people like it more, I am okay with it. | ||||||||||||
Not Done Inline ActionsAs said, it is a translation issue, so we might just add a comment to translators. I don't think adding + ' ' is the correct solution here. Freagarach: As said, it is a translation issue, so we might just add a comment to translators. I don't… | ||||||||||||
Not Done Inline ActionsAs we can see in the tooltips.js file, translation comments start with: Freagarach: As we can see in the tooltips.js file, translation comments start with:
`// Translation: ` | ||||||||||||
CounterPopulation.prototype.PopulationTooltip = markForTranslation("Population (current / limit)"); | CounterPopulation.prototype.AllyPopulationTooltip = markForTranslation("%(popCount)s/%(popLimit)s (%(popMax)s)"); | |||||||||||
Not Done Inline ActionsShall I remove this and a "max" to the line above? CounterPopulation.prototype.PopulationTooltip = markForTranslation("Population (current / limit / max)"); Langbart: Shall I remove this and a "max" to the line above?
```
CounterPopulation.prototype. | ||||||||||||
Not Done Inline ActionsYeah, might be better. Freagarach: Yeah, might be better. | ||||||||||||
CounterPopulation.prototype.MaximumPopulationTooltip = markForTranslation("Maximum population: %(popCap)s"); | ||||||||||||
CounterPopulation.prototype.AllyPopulationTooltip = markForTranslation("%(popCount)s/%(popLimit)s/%(popMax)s"); | ||||||||||||
/** | /** | |||||||||||
* Color to highlight the resource and the total gatherers. | ||||||||||||
*/ | ||||||||||||
CounterPopulation.prototype.DefaultGatherersColor = "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
It is better to not call the coloredText function if there is no total.