Skip to content

Commit

Permalink
Replace _getFontSize() for scaledFontSize getter
Browse files Browse the repository at this point in the history
  • Loading branch information
mclemente committed Apr 28, 2024
1 parent afa10f0 commit 6bd7fdf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/module/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
});
}
Expand Down
15 changes: 9 additions & 6 deletions src/module/logic.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/module/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
});
},
Expand Down

0 comments on commit 6bd7fdf

Please sign in to comment.