From b0093a43e6c92fda1fe5f5c3fc25275b849684aa Mon Sep 17 00:00:00 2001 From: bb Date: Mon, 28 Sep 2020 16:20:52 +0000 Subject: [PATCH] Redo the previous commit by actually parsing the comments in the revision: use getTextSize. This allows some nukes in the OverlayCounterManager. refs f09083c04d refs #5385 Differential Revision: D1764 This was SVN commit r24076. --- .../gui/common/OverlayCounterManager.js | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/binaries/data/mods/public/gui/common/OverlayCounterManager.js b/binaries/data/mods/public/gui/common/OverlayCounterManager.js index a96ca51031..00bfd77577 100644 --- a/binaries/data/mods/public/gui/common/OverlayCounterManager.js +++ b/binaries/data/mods/public/gui/common/OverlayCounterManager.js @@ -9,7 +9,6 @@ class OverlayCounterManager constructor(dataCounter) { this.dataCounter = dataCounter; - this.lineHeight = dataCounter.size.bottom - dataCounter.size.top; this.counters = []; this.enabledCounters = []; this.lastTick = undefined; @@ -63,7 +62,7 @@ class OverlayCounterManager /** * Handlers subscribed here will be informed then the dimension of the overlay changed. - * This allows placing the buttons below the counter. + * This allows placing the buttons away from the counter. */ registerResizeHandler(handler) { @@ -80,7 +79,6 @@ class OverlayCounterManager this.lastTick = now; let lineCount = 0; - let requiredWidth = 0; let txt = ""; for (let counter of this.enabledCounters) @@ -90,7 +88,6 @@ class OverlayCounterManager continue; ++lineCount; - requiredWidth = Math.max(requiredWidth, Engine.GetTextWidth(this.dataCounter.font, newTxt)); txt += newTxt + "\n"; } @@ -104,20 +101,19 @@ class OverlayCounterManager this.lastLineCount = lineCount; - let offset = this.lineHeight * lineCount; - if (lineCount) { + let textSize = this.dataCounter.getTextSize(); let size = this.dataCounter.size; - size.bottom = size.top + offset; - size.left = size.right - requiredWidth - this.Margin; + size.bottom = size.top + textSize.height; + size.left = size.right - textSize.width; this.dataCounter.size = size; } this.dataCounter.hidden = !lineCount; for (let handler of this.resizeHandlers) - handler(offset); + handler(textSize); } } @@ -126,8 +122,3 @@ class OverlayCounterManager * in milliseconds determines how often the caption is rebuilt. */ OverlayCounterManager.prototype.Delay = 250; - -/** - * A margin for the overlay width. The total width will be the text width + margin. - */ -OverlayCounterManager.prototype.Margin = 10;