Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/session/top_panel/CounterResource.js
/** | /** | ||||||||||
* This class manages the counter in the top panel for one resource type. | * This class manages the counter in the top panel for one resource type. | ||||||||||
*/ | */ | ||||||||||
class CounterResource | class CounterResource | ||||||||||
{ | { | ||||||||||
constructor(resCode, panel, icon, count) | constructor(resCode, panel, icon, count, stats) | ||||||||||
{ | { | ||||||||||
this.resCode = resCode; | this.resCode = resCode; | ||||||||||
this.panel = panel; | this.panel = panel; | ||||||||||
this.icon = icon; | this.icon = icon; | ||||||||||
this.count = count; | this.count = count; | ||||||||||
this.stats = stats; | |||||||||||
} | } | ||||||||||
rebuild(playerState, getAllyStatTooltip) | rebuild(playerState, getAllyStatTooltip) | ||||||||||
{ | { | ||||||||||
this.count.caption = Math.floor(playerState.resourceCounts[this.resCode]); | this.count.caption = Math.floor(playerState.resourceCounts[this.resCode]); | ||||||||||
let stat = playerState.resourceStats[this.resCode]; | |||||||||||
let total = stat.gatherers + stat.traders + stat.trickles; | |||||||||||
StanUnsubmitted Done Inline Actions
Stan: | |||||||||||
this.stats.caption = total > 0 ? total : ""; // do not show zeroes | |||||||||||
Done Inline ActionsBetter to just have this here: this.extra.caption = Math.floor(playerState.resourceGatherers.count[this.resCode]);; mammadori: Better to just have this here:
```
this.extra.caption = Math.floor(playerState. | |||||||||||
// TODO: Set the tooltip only if hovered? | // TODO: Set the tooltip only if hovered? | ||||||||||
let description = g_ResourceData.GetResource(this.resCode).description; | let description = g_ResourceData.GetResource(this.resCode).description; | ||||||||||
if (description) | if (description) | ||||||||||
description = "\n" + translate(description); | description = "\n" + translate(description); | ||||||||||
this.panel.tooltip = | this.panel.tooltip = | ||||||||||
setStringTags(resourceNameFirstWord(this.resCode), CounterManager.ResourceTitleTags) + | setStringTags(resourceNameFirstWord(this.resCode), CounterManager.ResourceTitleTags) + | ||||||||||
Show All 13 Lines |
Wildfire Games · Phabricator