From 6bd7fdf5a66c14d030ddcfee4b6c29c44e2fbc09 Mon Sep 17 00:00:00 2001 From: Matheus Clemente Date: Sun, 28 Apr 2024 16:41:13 -0300 Subject: [PATCH] Replace _getFontSize() for scaledFontSize getter --- src/module/hooks.js | 2 +- src/module/logic.js | 15 +++++++++------ src/module/settings.js | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/module/hooks.js b/src/module/hooks.js index bdb6978..bb5d76d 100644 --- a/src/module/hooks.js +++ b/src/module/hooks.js @@ -44,7 +44,7 @@ export class HealthEstimateHooks { .filter((t) => t.healthEstimate?.visible) .forEach((token) => { if (token.healthEstimate?._texture) { - token.healthEstimate.style.fontSize = game.healthEstimate._getFontSize(); + token.healthEstimate.style.fontSize = game.healthEstimate.scaledFontSize; } }); } diff --git a/src/module/logic.js b/src/module/logic.js index 0e78156..8b568dd 100644 --- a/src/module/logic.js +++ b/src/module/logic.js @@ -21,6 +21,13 @@ export class HealthEstimate { return this.estimationProvider; } + /** + * @type {Number} + */ + get scaledFontSize() { + return ((this.fontSize * this.gridScale) / this.zoomLevel) * 4; + } + get zoomLevel() { return this.scaleToZoom ? Math.min(1, canvas.stage.scale.x) : 1; } @@ -172,7 +179,7 @@ export class HealthEstimate { */ _updateHealthEstimate(token, config = {}) { const { desc, color, stroke, x, y } = config; - token.healthEstimate.style.fontSize = this._getFontSize(); + token.healthEstimate.style.fontSize = this.scaledFontSize; token.healthEstimate.text = desc; token.healthEstimate.style.fill = color; token.healthEstimate.style.stroke = stroke; @@ -234,10 +241,6 @@ export class HealthEstimate { return spriteMaterial; } - _getFontSize() { - return ((this.fontSize * this.gridScale) / this.zoomLevel) * 4; - } - /** * Creates a PIXI.TextStyle object. * @param {String} color @@ -248,7 +251,7 @@ export class HealthEstimate { const dropShadowColor = sGet("core.menuSettings.outline") === "brighten" ? "white" : "black"; return { // Multiply font size to increase resolution quality - fontSize: this._getFontSize(), + fontSize: this.scaledFontSize, fontFamily: this.fontFamily, fill: color, stroke, diff --git a/src/module/settings.js b/src/module/settings.js index a8f31d1..88efae9 100644 --- a/src/module/settings.js +++ b/src/module/settings.js @@ -273,7 +273,7 @@ export const registerSettings = function () { game.healthEstimate.fontSize = value; canvas.scene?.tokens.forEach((token) => { if (token.object.healthEstimate) { - token.object.healthEstimate.style.fontSize = game.healthEstimate._getFontSize(); + token.object.healthEstimate.style.fontSize = game.healthEstimate.scaledFontSize; } }); },