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, extra) | ||||||||||
{ | { | ||||||||||
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.extra = extra; | |||||||||||
} | } | ||||||||||
rebuild(playerState, getAllyStatTooltip) | rebuild(playerState, getAllyStatTooltip) | ||||||||||
{ | { | ||||||||||
this.count.caption = Math.floor(playerState.resourceCounts[this.resCode]); | this.count.caption = Math.floor(playerState.resourceCounts[this.resCode]); | ||||||||||
mammadori: Better to just have this here:
```
this.extra.caption = Math.floor(playerState. | |||||||||||
let gatherers = Math.floor(playerState.resourceGatherers.count[this.resCode]); | |||||||||||
Done Inline Actions
Stan: | |||||||||||
if (gatherers) | |||||||||||
this.extra.caption = gatherers; | |||||||||||
else | |||||||||||
this.extra.caption = ""; | |||||||||||
// 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) + | ||||||||||
description + | description + | ||||||||||
getAllyStatTooltip(this.getTooltipData.bind(this)); | getAllyStatTooltip(this.getTooltipData.bind(this)); | ||||||||||
} | } | ||||||||||
getTooltipData(playerState, playername) | getTooltipData(playerState, playername) | ||||||||||
{ | { | ||||||||||
return { | return { | ||||||||||
"playername": playername, | "playername": playername, | ||||||||||
"statValue": Math.round(playerState.resourceCounts[this.resCode]), | "statValue": Math.round(playerState.resourceCounts[this.resCode]), | ||||||||||
"orderValue": Math.round(playerState.resourceCounts[this.resCode]) | "orderValue": Math.round(playerState.resourceCounts[this.resCode]), | ||||||||||
"extra": Math.floor(playerState.resourceGatherers.count[this.resCode]) | |||||||||||
}; | }; | ||||||||||
} | } | ||||||||||
} | } |
Wildfire Games · Phabricator
Better to just have this here: