mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-08-15 14:43:32 -07:00
This removes the static text "Gatherers: current" from the resource and population counter tooltips. This string was static and only changed its color depending on whether units were assigned to collect a certain resource. That information is however already available in the counter display itself.
52 lines
1.5 KiB
JavaScript
52 lines
1.5 KiB
JavaScript
/**
|
|
* This class manages the counter in the top panel for one resource type.
|
|
*/
|
|
class CounterResource
|
|
{
|
|
constructor(resCode, panel, icon, count, stats)
|
|
{
|
|
this.resCode = resCode;
|
|
this.panel = panel;
|
|
this.icon = icon;
|
|
this.count = count;
|
|
this.stats = stats;
|
|
}
|
|
|
|
rebuild(playerState, getAllyStatTooltip)
|
|
{
|
|
this.count.caption = abbreviateLargeNumbers(Math.floor(playerState.resourceCounts[this.resCode]));
|
|
|
|
let gatherers = playerState.resourceGatherers[this.resCode];
|
|
this.stats.caption = coloredText(gatherers, gatherers ? this.DefaultResourceGatherersColor : this.DefaultResourceGatherersColorZero);
|
|
|
|
|
|
// TODO: Set the tooltip only if hovered?
|
|
let description = g_ResourceData.GetResource(this.resCode).description;
|
|
if (description)
|
|
description = "\n" + translate(description);
|
|
|
|
this.panel.tooltip =
|
|
setStringTags(resourceNameFirstWord(this.resCode), CounterManager.ResourceTitleTags) +
|
|
description +
|
|
getAllyStatTooltip(this.getTooltipData.bind(this));
|
|
}
|
|
|
|
getTooltipData(playerState, playername)
|
|
{
|
|
return {
|
|
"playername": playername,
|
|
"statValue": Math.round(playerState.resourceCounts[this.resCode]),
|
|
"orderValue": Math.round(playerState.resourceCounts[this.resCode])
|
|
};
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Color to highlight the resource gatherers at zero.
|
|
*/
|
|
CounterResource.prototype.DefaultResourceGatherersColorZero = "200 200 200";
|
|
|
|
/**
|
|
* Color to highlight the resource gatherers.
|
|
*/
|
|
CounterResource.prototype.DefaultResourceGatherersColor = "gold";
|