mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-07-24 04:32:53 +00:00
Let the Overlay width depend on the longest string in it
Based on Patch By: ramtzok1 Comments by: elexis, Polakrity, smiley, Stan Differential Revision: https://code.wildfiregames.com/D1764 fixes #5385 This was SVN commit r24075.
This commit is contained in:
@@ -80,6 +80,7 @@ class OverlayCounterManager
|
|||||||
this.lastTick = now;
|
this.lastTick = now;
|
||||||
|
|
||||||
let lineCount = 0;
|
let lineCount = 0;
|
||||||
|
let requiredWidth = 0;
|
||||||
let txt = "";
|
let txt = "";
|
||||||
|
|
||||||
for (let counter of this.enabledCounters)
|
for (let counter of this.enabledCounters)
|
||||||
@@ -89,6 +90,7 @@ class OverlayCounterManager
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
++lineCount;
|
++lineCount;
|
||||||
|
requiredWidth = Math.max(requiredWidth, Engine.GetTextWidth(this.dataCounter.font, newTxt));
|
||||||
txt += newTxt + "\n";
|
txt += newTxt + "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,6 +110,7 @@ class OverlayCounterManager
|
|||||||
{
|
{
|
||||||
let size = this.dataCounter.size;
|
let size = this.dataCounter.size;
|
||||||
size.bottom = size.top + offset;
|
size.bottom = size.top + offset;
|
||||||
|
size.left = size.right - requiredWidth - this.Margin;
|
||||||
this.dataCounter.size = size;
|
this.dataCounter.size = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,3 +126,8 @@ class OverlayCounterManager
|
|||||||
* in milliseconds determines how often the caption is rebuilt.
|
* in milliseconds determines how often the caption is rebuilt.
|
||||||
*/
|
*/
|
||||||
OverlayCounterManager.prototype.Delay = 250;
|
OverlayCounterManager.prototype.Delay = 250;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A margin for the overlay width. The total width will be the text width + margin.
|
||||||
|
*/
|
||||||
|
OverlayCounterManager.prototype.Margin = 10;
|
||||||
|
|||||||
@@ -205,6 +205,7 @@
|
|||||||
{ "nick": "qwertz" },
|
{ "nick": "qwertz" },
|
||||||
{ "nick": "Radagast" },
|
{ "nick": "Radagast" },
|
||||||
{ "nick": "Raj", "name": "Raj Sharma" },
|
{ "nick": "Raj", "name": "Raj Sharma" },
|
||||||
|
{ "nick": "ramtzok1", "name": "Ram" },
|
||||||
{ "nick": "rapidelectron", "name": "Christian Weihsbach" },
|
{ "nick": "rapidelectron", "name": "Christian Weihsbach" },
|
||||||
{ "nick": "RedFox", "name": "Jorma Rebane" },
|
{ "nick": "RedFox", "name": "Jorma Rebane" },
|
||||||
{ "nick": "RefinedCode" },
|
{ "nick": "RefinedCode" },
|
||||||
|
|||||||
Reference in New Issue
Block a user