MZ Replacing Gauges with Standard Text

Hey all,

I assume this is a very simple thing to do but I've been banging my head against the wall on it for a while now and googling the issue turns up nothing. All I want to do is remove the gauges for HP and MP in the battle and menu screens, and turn them into standard text on the format of HP: XX/XX, etc. Here's a mockup of what I mean: top is how it looks now, bottom is what I want it to look like (pretend the fond is the same as the names lol).

1758676118354.png
👋 I did a quick test and this seemed to work for me:
Spoiler: plugin code
JavaScript:
/*:
 * @target MZ
 * @plugindesc Replace gauges with text values.
 * @author Caethyril
 * @url https://forums.rpgmakerweb.com/threads/180268/
 * @help Free to use and/or modify for any project, no credit required.
 */
;void (() => {
"use strict";

  /** Divider between current & max values. @type {string} */
  const D = "/";

  /** Non-conflicting identifier for divider width cache. */
  const S = Symbol();

  // Override - draw text instead of gauge. Because we get bounds here.
  Sprite_Gauge.prototype.drawGaugeRect = function(x, y, w, h) {
    this.setupValueFont();
    const s = this[S] ??= this.bitmap.measureTextWidth(D);
    const p = w - s >> 1;
    const v0 = (v => v % 1 ? v.toFixed(2) : v)(this._value);	// TPB
    const v1 = this._maxValue;
    this.bitmap.drawText(v0, x,         y, p, h, "right");
    this.bitmap.drawText(D,  x + p,     y, s, h, "center");
    this.bitmap.drawText(v1, x + p + s, y, p, h, "left");
  };

  // Override - don't draw usual value.
  Sprite_Gauge.prototype.drawValue = function() {};

})();

Edit - OK, here's an updated version with a position adjustment and support for main font face:
Spoiler: plugin code v4
JavaScript:
/*:
 * @target MZ
 * @plugindesc v4 - Replace gauges with text values.
 * @author Caethyril
 * @url https://forums.rpgmakerweb.com/threads/180268/
 * @help Free to use and/or modify for any project, no credit required.
 */
;void (() => {
"use strict";

  /** Divider between current & max values. @type {string} */
  const D = "/";

  /**
   * Determines font for gauge values.
   * - `false` = number font.
   * - `true` = main font.
   * @type {boolean}
   * @since v2
   */
  const USE_MAIN_FONT = false;

  /** Non-conflicting identifier for divider width cache. */
  const S = Symbol();

  // Override - draw text instead of gauge. Because we get bounds here.
  Sprite_Gauge.prototype.drawGaugeRect = function(x, y, w, h) {
    this.setupValueFont();
    const s = this[S] ??= this.bitmap.measureTextWidth(D);
    const p = w - s >> 1;
    const r = this._statusType === "time" ? 2 : 0;  // v4 - rounding
    const v0 = this._value.toFixed(r);
    const v1 = this._maxValue.toFixed(0); // assume integer max
    this.bitmap.drawText(v0, x,         y, p, h, "right");
    this.bitmap.drawText(D,  x + p,     y, s, h, "center");
    this.bitmap.drawText(v1, x + p + s, y, p, h, "left");
  };

  // Override - don't draw usual value.
  Sprite_Gauge.prototype.drawValue = function() {};

  // Override - use main font for gauge values instead of number font.
  if (USE_MAIN_FONT)
    for (const m of ["FontFace", "FontSize", "OutlineColor", "OutlineWidth"])
      Sprite_Gauge.prototype["value" + m] = function() {
        return this["label" + m]();  // v3
      };

  // Override - match gauge area to label area.
  Sprite_Gauge.prototype.gaugeHeight = function() {
    return this.labelFontSize() - this.labelY();
  };

  // Override - update values instantly (default is 20 frames of "scroll").
  // Sprite_Gauge.prototype.smoothness = function() { return 1; };

})();
To use the main font face, change this line from false to true:
JavaScript:
  const USE_MAIN_FONT = false;
[Edit 2: corrected return Sprite_Gauge.prototype.etc to return this.etc (updated to v3). Makes no difference without other plugins because none of those methods reference this in the core scripts.]

[Edit 3: changed rounding to be based on gauge type rather than whether the input is an integer or not (updated to v4).]
👋 I did a quick test and this seemed to work for me:

This is great! Almost exactly what I need. The only thing I'd need to change is making it so the font for the new text and numbers matches the default font used for the names/command list.
The only thing I'd need to change is making it so the font for the new text and numbers matches the default font used for the names/command list.
OK! I've just edited my previous post to include an updated version of the plugin code, with a toggle for font face and a fix for a 3-pixel position offset that I hadn't noticed before.
OK! I've just edited my previous post to include an updated version of the plugin code, with a toggle for font face and a fix for a 3-pixel position offset that I hadn't noticed before.

Wow, this looks great!

1758726352080.png


Though, when I open the menu while on a map using the escape key, I get this error:

1758726391141.png
I cannot reproduce that error. It suggests that you have another plugin that modifies the Sprite_Gauge instances on the pause menu in some way, because Sprite_Gauge#labelFontSize is certainly a function that is defined in the MZ core scripts.

(I also just updated the code again, to v3, correcting a small oversight. You should see no difference unless you're using another plugin to make the gauge label font face, size, and/or outline colour/width depend on instance properties.)
I cannot reproduce that error. It suggests that you have another plugin that modifies the Sprite_Gauge instances on the pause menu in some way, because Sprite_Gauge#labelFontSize is certainly a function that is defined in the MZ core scripts.

(I also just updated the code again, to v3, correcting a small oversight. You should see no difference unless you're using another plugin to make the gauge label font face, size, and/or outline colour/width depend on instance properties.)

Ah, that does seem to be the issue. I am using the Visustella Core Engine plugin, and if I disable that then the error goes away.

Thanks for putting this together!
I made a small edit to the script which removes the decimal that appeared in the Current HP value when a character takes damage.

Spoiler: Code
Code:
/*:
 * @target MZ
 * @plugindesc v3 - Replace gauges with text values.
 * @author Caethyril
 * @url https://forums.rpgmakerweb.com/threads/180268/
 * @help Free to use and/or modify for any project, no credit required.
 */
;void (() => {
"use strict";

  /** Divider between current & max values. @type {string} */
  const D = "/";

  /**
   * Determines font for gauge values.
   * - `false` = number font.
   * - `true` = main font.
   * @type {boolean}
   * @since v2
   */
  const USE_MAIN_FONT = true;

  /** Non-conflicting identifier for divider width cache. */
  const S = Symbol();

  // Override - draw text instead of gauge. Because we get bounds here.
  Sprite_Gauge.prototype.drawGaugeRect = function(x, y, w, h) {
    this.setupValueFont();
    const s = this[S] ??= this.bitmap.measureTextWidth(D);
    const p = w - s >> 1;
    const v0 = (v => v % 1 ? v.toFixed(2) : v)(this._value);    // TPB
    const v1 = this._maxValue;
    this.bitmap.drawText(parseInt(v0), x,         y-3, p, h, "right");
    this.bitmap.drawText(D,  x + p,     y-3, s, h, "center");
    this.bitmap.drawText(v1, x + p + s, y-3, p, h, "left");
  };

  // Override - don't draw usual value.
  Sprite_Gauge.prototype.drawValue = function() {};

  // Override - use main font for gauge values instead of number font.
  if (USE_MAIN_FONT)
    for (const m of ["FontFace", "FontSize", "OutlineColor", "OutlineWidth"])
      Sprite_Gauge.prototype["value" + m] = function() {
        return this["label" + m]();  // v3
      };

  // Override - match gauge area to label area.
  Sprite_Gauge.prototype.gaugeHeight = function() {
    return this.labelFontSize() - this.labelY();
  };

})();

While I'm at it, I'd also like to remove the "scrolling" effect for the current HP value when taking damage. So if a character goes from 35 HP to 27 HP, the number just instantly changes to 27 instead of "scrolling" through all of the numbers between.
I made a small edit to the script which removes the decimal that appeared in the Current HP value when a character takes damage.
Ah, I see! I hadn't recognised that that would happen...for my quick tests I accidentally picked changes that were multiples of 20 (the transition time) so I didn't see it. I've updated my code to v4, now it rounds the value based on gauge type (hp, mp, tp, time). 😮‍💨

I'd also like to remove the "scrolling" effect for the current HP value when taking damage.
You can do this by setting the gauge "smoothness" (update duration) to 1. Add this code:
JavaScript:
// Override - instant value change.
Sprite_Gauge.prototype.smoothness = function() { return 1; };
Hey @caethyril

Sorry to bug you again about this, but i noticed a small issue with the plugin with larger text values. Once HP or MP ranges get into 3 digits, the text width is shortened to make the text fit.

Ideally, I'd want to create more space between the HP and MP text blocks, and force it to use the standard width of the text even if there are 3 (or 4) digits to the numbers. I tried fiddling with some of the parameters in the plugin (and in the rmmz_windows js file) but I can't seem to change the X position of the HP and MP text. Is there an easy way to just modify the X offsets of the text?


1759851559762.png
@myolden - as-is, my plugin literally just changes all gauges, wherever they appear (pause menu, battle status, etc). What you're asking now is a layout question, which will have to be addressed separately for each applicable game window.

You're not using the default MZ battle status layout, so any solution will have to be tailored for the plugin(s) you're using. I suggest you post screenshot(s) of your Plugin Manager so we can see which plugins you're using and their load order.
Oh wow, that does seem to complicate things a bit. Here's my plugin manager.

1760012945587.png


I should note that VisuMZ_1_BattleCore does have a setting that adjusts the gauges X and Y offsets, but updating those values doesn't seem to work in conjunction with the NoGauges plugin. The Y offsets I had updated before implementing NoGauges, and now updating the X values don't see to do anything.

1760013088568.png
Apologies for the double post, but I need to issue a correction. Updating the Gauge offsets in VisuMZ_1_BattleCore does adjust the X offsets for the gauges, it's just that the numbers need to be pretty big in order to actually notice it. For example, this is with the X offset of the MP gauges set to 100:

1760016076757.png


The issue of the smushed text remains, though. Ideally all of the letters/numbers would be uniform in width to emulate that NES style I'm trying to go for.
Position would be the more awkward part, so good thing that's already handled! 😮‍💨

For the width adjustment, you could try adding this to the very end of my plugin code, i.e. after the final line })();:
JavaScript:
// Patch - different width for gauges on battle scene.
;void (alias => {
  Sprite_Gauge.prototype.bitmapWidth = function() {
    const w = alias.apply(this, arguments);  // normal width
    if (SceneManager._scene instanceof Scene_Battle)
      return w + 100;  // battle gauges are 100 px wider
    return w;
  };
})(Sprite_Gauge.prototype.bitmapWidth);
I haven't tested this example specifically, but I've used this kind of approach before in other cases and it has worked for me. Change the + 100 as you like~

Edit - alternatively, to make all gauges wider:
JavaScript:
;void (alias => {
  Sprite_Gauge.prototype.bitmapWidth = function() {
    return alias.apply(this, arguments) + 100;  // 100 px wider
  };
})(Sprite_Gauge.prototype.bitmapWidth);
That works perfectly. I ended up going with the second bit of code, so that the issue would be fixed in the menu as well. Thank you so much!
Great, you're welcome! 👋

Original thread: https://forums.rpgmakerweb.com/threads/replacing-gauges-with-standard-text.180268/