1
0
forked from 0ad/0ad

Increase the spacing in the top panel and synchronize the colour in the tooltip for gatherers.

With the addition of the new resource icons for stone and metal, the
text was too close to the icon so the distance between the text and the
icon is increased.
Also, synchronises the colour of the number of gatherers in the top
panel with the colour in the tooltip explanation.

Patch by: @Langbart
Differential revision: https://code.wildfiregames.com/D4032
Comments by: @Stan, @wraitii
This was SVN commit r25922.
This commit is contained in:
Freagarach 2021-09-15 06:27:11 +00:00
parent 2d1ed7ecd5
commit 21be3944f4
3 changed files with 21 additions and 8 deletions

View File

@ -23,13 +23,13 @@ class CounterPopulation
for (let resCode of g_ResourceData.GetCodes()) for (let resCode of g_ResourceData.GetCodes())
total += playerState.resourceGatherers[resCode]; total += playerState.resourceGatherers[resCode];
this.stats.caption = total ? coloredText(total, this.DefaultTotalGatherersColor) : 0; this.stats.caption = coloredText(total, total ? this.DefaultTotalGatherersColor : this.DefaultTotalGatherersColorZero);
this.isTrainingBlocked = playerState.trainingBlocked; this.isTrainingBlocked = playerState.trainingBlocked;
this.panel.tooltip = this.panel.tooltip =
setStringTags(translate(this.PopulationTooltip), CounterManager.ResourceTitleTags) + setStringTags(translate(this.PopulationTooltip), CounterManager.ResourceTitleTags) +
getAllyStatTooltip(this.getTooltipData.bind(this)) + "\n" + this.CurrentGatherersTooltip; getAllyStatTooltip(this.getTooltipData.bind(this)) + "\n" + coloredText(this.CurrentGatherersTooltip, total ? this.DefaultTotalGatherersColor : this.DefaultTotalGatherersColorZero);
} }
getTooltipData(playerState, playername) getTooltipData(playerState, playername)
@ -68,10 +68,17 @@ CounterPopulation.prototype.AllyPopulationTooltip = markForTranslation("%(popCou
* Storing the translated and formatted gatherer string in the prototype. * Storing the translated and formatted gatherer string in the prototype.
*/ */
CounterPopulation.prototype.CurrentGatherersTooltip = setStringTags(translate("Gatherers: current"), {"font": "sans-bold-16"}); CounterPopulation.prototype.CurrentGatherersTooltip = setStringTags(translate("Gatherers: current"), {"font": "sans-bold-16"});
/** /**
* Color to highlight the total gatherers. * Color to highlight the total number of gatherers at zero.
*/
CounterPopulation.prototype.DefaultTotalGatherersColorZero = "200 200 200";
/**
* Color to highlight the total number of gatherers.
*/ */
CounterPopulation.prototype.DefaultTotalGatherersColor = "gold"; CounterPopulation.prototype.DefaultTotalGatherersColor = "gold";
/** /**
* Colors to flash when pop limit reached. * Colors to flash when pop limit reached.
*/ */

View File

@ -17,7 +17,8 @@ class CounterResource
this.count.caption = abbreviateLargeNumbers(Math.floor(playerState.resourceCounts[this.resCode])); this.count.caption = abbreviateLargeNumbers(Math.floor(playerState.resourceCounts[this.resCode]));
let gatherers = playerState.resourceGatherers[this.resCode]; let gatherers = playerState.resourceGatherers[this.resCode];
this.stats.caption = gatherers ? coloredText(gatherers, this.DefaultResourceGatherersColor) : 0; this.stats.caption = coloredText(gatherers, gatherers ? this.DefaultResourceGatherersColor : this.DefaultResourceGatherersColorZero);
// 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;
@ -27,7 +28,7 @@ class CounterResource
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)) + "\n" + CounterPopulation.prototype.CurrentGatherersTooltip; getAllyStatTooltip(this.getTooltipData.bind(this)) + "\n" + coloredText(CounterPopulation.prototype.CurrentGatherersTooltip, gatherers ? this.DefaultResourceGatherersColor : this.DefaultResourceGatherersColorZero);
} }
getTooltipData(playerState, playername) getTooltipData(playerState, playername)
@ -40,6 +41,11 @@ class CounterResource
} }
} }
/**
* Color to highlight the resource gatherers at zero.
*/
CounterResource.prototype.DefaultResourceGatherersColorZero = "200 200 200";
/** /**
* Color to highlight the resource gatherers. * Color to highlight the resource gatherers.
*/ */

View File

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- This list encompasses resources and population --> <!-- This list encompasses resources and population -->
<object size="0 0 50%-90-52 100%" name="resourceCounts"> <object size="0 0 50%-142 100%" name="resourceCounts">
<repeat count="5"> <repeat count="5">
<object name="resource[n]" size="0 0 73 100%" type="button" style="resourceCounter" tooltip_style="sessionToolTipBold"> <object name="resource[n]" size="0 0 73 100%" type="button" style="resourceCounter" tooltip_style="sessionToolTipBold">
<object size="0 -2 40 38" type="image" name="resource[n]_icon" ghost="true"/> <object size="0 -2 40 38" type="image" name="resource[n]_icon" ghost="true"/>
<object size="30 4 180 22" type="text" style="resourceText" name="resource[n]_count"/> <object size="33 4 180 22" type="text" style="resourceText" name="resource[n]_count"/>
<object size="30 1 200 34" type="text" style="gathererCounts" name="resource[n]_stats"/> <object size="33 1 200 34" type="text" style="gathererCounts" name="resource[n]_stats"/>
</object> </object>
</repeat> </repeat>
</object> </object>