From 9f6a3094343810fc3a8baa51ee406386b683ee60 Mon Sep 17 00:00:00 2001 From: phosit Date: Sun, 9 Aug 2026 09:15:19 +0200 Subject: [PATCH] Readd description for gatherers to the tooltip It was removed in dee2b73c7d since it wasn't noticed that it referred to the number in the top panel. Adding the number should make this more clear. The color is only applied to the number instead of the whole line so that it's harder to mistake it with just some fancy formatting. Fixes: #7851 --- .../gui/session/top_panel/CounterPopulation.js | 15 +++++++++++++-- .../gui/session/top_panel/CounterResource.js | 8 ++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/binaries/data/mods/public/gui/session/top_panel/CounterPopulation.js b/binaries/data/mods/public/gui/session/top_panel/CounterPopulation.js index e2cf030d49..5e9e363038 100644 --- a/binaries/data/mods/public/gui/session/top_panel/CounterPopulation.js +++ b/binaries/data/mods/public/gui/session/top_panel/CounterPopulation.js @@ -25,13 +25,16 @@ class CounterPopulation for (const resCode of g_ResourceData.GetCodes()) total += playerState.resourceGatherers[resCode]; - this.stats.caption = coloredText(total, total ? this.DefaultTotalGatherersColor : this.DefaultTotalGatherersColorZero); + const colorizedTotal = coloredText(total, + total ? this.DefaultTotalGatherersColor : this.DefaultTotalGatherersColorZero); + this.stats.caption = colorizedTotal; this.isTrainingBlocked = playerState.trainingBlocked; this.panel.tooltip = setStringTags(translate(this.PopulationTooltip), CounterManager.ResourceTitleTags) + - getAllyStatTooltip(this.getTooltipData.bind(this)); + getAllyStatTooltip(this.getTooltipData.bind(this)) + "\n" + + sprintf(this.CurrentGatherersTooltip, { "currentGatherers": colorizedTotal }); } getTooltipData(playerState, playername) @@ -66,6 +69,14 @@ CounterPopulation.prototype.PopulationTooltip = markForTranslation("Population: CounterPopulation.prototype.AllyPopulationTooltip = markForTranslation("%(popCount)s/%(popLimit)s (%(popMax)s)"); +/** + * Storing the translated and formatted gatherer string in the prototype. + * Including the number might seem redundant but is required since the collor + * isn't enough to associate it with the number in the top panel. + */ +CounterPopulation.prototype.CurrentGatherersTooltip = + setStringTags(translate("Current gatherers: %(currentGatherers)s"), { "font": "sans-14" }); + /** * Color to highlight the total number of gatherers at zero. */ diff --git a/binaries/data/mods/public/gui/session/top_panel/CounterResource.js b/binaries/data/mods/public/gui/session/top_panel/CounterResource.js index de8b7bec51..16f93d6e31 100644 --- a/binaries/data/mods/public/gui/session/top_panel/CounterResource.js +++ b/binaries/data/mods/public/gui/session/top_panel/CounterResource.js @@ -17,7 +17,9 @@ class CounterResource this.count.caption = abbreviateLargeNumbers(Math.floor(playerState.resourceCounts[this.resCode])); const gatherers = playerState.resourceGatherers[this.resCode]; - this.stats.caption = coloredText(gatherers, gatherers ? this.DefaultResourceGatherersColor : this.DefaultResourceGatherersColorZero); + const colorizedGatherers = coloredText(gatherers, + gatherers ? this.DefaultResourceGatherersColor : this.DefaultResourceGatherersColorZero); + this.stats.caption = colorizedGatherers; // TODO: Set the tooltip only if hovered? @@ -28,7 +30,9 @@ class CounterResource this.panel.tooltip = setStringTags(resourceNameFirstWord(this.resCode), CounterManager.ResourceTitleTags) + description + - getAllyStatTooltip(this.getTooltipData.bind(this)); + getAllyStatTooltip(this.getTooltipData.bind(this)) + "\n" + + sprintf(CounterPopulation.prototype.CurrentGatherersTooltip, + { "currentGatherers": colorizedGatherers }); } getTooltipData(playerState, playername)