MZ Different gauge sizes for battle and for menus

I'm trying to simplify the UI as I don't want to use actor face graphics, and to fill some of the blank space, I decided to make the gauges longer by making a plugin that modifies the following:

Code:
Sprite_Gauge.prototype.bitmapWidth = function() {
    return 300;
};

However, this also modifies the gauges in battle UI, which creates a lot of overlap. It seems like it uses the same function to draw the gauges as the menu, so I have no idea what to change to make it so that it stays at the default size in battle, but keeps the longer length in the other windows.
Hi there!

That is because both Scene Menu and Scene Battle uses the same Sprite_Gauge class to create the gauges. So I believe you can perform a check and see if the game is on scene battle, you use a value, otherwise, you use another.

Like below:

JavaScript:
Sprite_Gauge.prototype.bitmapWidth = function() {
    return SceneManager._scene instanceof Scene_Battle ? 300 : old value
}
Thanks for the quick reply! I replaced my code with yours like so:
Code:
Sprite_Gauge.prototype.bitmapWidth = function() {
    return SceneManager._scene instanceof Scene_Battle ? 300 : 128
};
However, it doesn't seem to do anything so I'm stumped.
The results are backwards. Try:

JavaScript:
Sprite_Gauge.prototype.bitmapWidth = function() {
    return SceneManager._scene instanceof Scene_Battle ? 128 : 300;
};
Wow, that is silly of me. It works perfectly, thanks.
I did a thing where I modified the constructor of Sprite_Gauge to take a bitmapWidth parameter. If it's there, I save it off to a private variable. If not, I use the default of 300. Then, wherever I need a different width, I construct it with that alternate value. I had to modify the internals of Sprite_Gauge a bit, as I recall, but it wasn't too hard. Then I could use whatever width I needed in whatever context.

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/different-gauge-sizes-for-battle-and-for-menus.152662/