Remove gauges and move Hp/Mana numbers

Hi all.

I'm currently working on my hud/menus in MV and am trying make an adjustment to my gauges(remove them). I've toyed around with it for a few days now and while I've learned a lot from this, I've yet to find a satisfactory solution.

My aim is to remove the status gauges from both the menu and the battle hud. Instead I just want it to display the numbers in a fraction (for example) HP: 9/10

I've managed to remove the bars from combat with DreamX's battle menu plugin. I've also removed them from my menu by editing them out of the window js (thanks to some random dude's tutorial).

However, the problem at the moment is that the label for the status is too far away from the numbers associated with it.

Menu Example.png


As you can see, the 20/20 is too far away from the HP label.

I suppose in an ideal world I would move the HP: 20/20 right under the character name.

Failing that, moving just the number and label closer together would still put me in your debt.

I am also having the same issue in the battle hud.

Thank you so much for any help you can provide.

Bonus question: Is it possible to make the numbers indicating health change color dynamically? For example when they go below a certain threshold they turn red?

Bonus question 2: Any ideas on how I would go about making a resource be at max whenever I'm not in combat? I'd like my mana to always be at full whenever I'm not in combat.

Thanks again!
(Note that rather than just tell you the answer, I'm going to take you through the chain of logic I actually use to figure things like this out, so you'll have a better understanding next time you have a query).

So our problem: the HP text is too far away from the numbers. We want to move it to underneath the name.

Our first stop is Scene_Menu, as we need to find out which window we need to edit. Looking at the source, we see that it's calling a function called createStatusWindow which creates a new instance of a class called Window_MenuStatus, so let's head to rpg_windows and take a look at what's going on there.

If we look at the drawItem function, it's calling a function called drawItemStatus, which in turn calls drawActorSimpleStatus. Now that function isn't declared here, but we can see that Window_MenuStatus uses the prototype for Window_Selectable, so let's check there.

Turns out that Window_Selectable doesn't have that function either, but looking at the declaration for it, it uses the prototype for Window_Base, so it's likely that we'll find it there.

Sure enough, Window_Base does indeed have the drawActorSimpleStatus function.

From here, we can see a call to drawActorHp, so let's take a look at that.

Other than the gauge, there are two things being drawn in this function: the label text, and the current/max HP. The function calls are using the same x value, so this can't be why they're so far apart. Let's dig down a little deeper into drawCurrentAndMax.

Okay, so what this function is doing is setting a variable called labelWidth to the width of the text "HP", then one called valueWidth to the width of the text "0000" (approximately 62 pixels) and one called slashWidth to the width of the text "/" (approximately 10 pixels). We're then setting some x coordinate variables: x1 is assigned the value of the passed-in x coordinate, plus the passed-in width, minus valueWidth. x2 is assigned the value of x1 minus slashWidth. x3 is assigned the value of x2 minus valueWidth.

Taking an x coordinate of 162 and width of 186, this will make x1 162+186-62 = 286, x2 will then be 286-10 = 276, and x3 will be 276-62 = 214. This gives us the starting coordinate of the current HP, the slash, and the max HP (in reverse order).

So the issue here is that the "width" value being passed in is too high. If we trace back the function calls, we can see this line in drawActorSimpleStatus:

Code:
var width2 = Math.min(200, width - 180 - this.textPadding());

So basically what we want to do is make that value smaller. As for drawing the HP right under the name...if we look, the call to drawActorHp is using a value called x2 instead of x, and further up that variable is declared as x + 180. So all we need to do for this is call drawActorHp using x instead.

With regard to your bonus question, yes. It would be a matter of rewriting Window_Base's hpColor function to check for additional thresholds and return the appropriate colour.

Bonus question 2: The short answer is yes, you can do that. Exactly how is a more complicated question as there are various approaches, but one of the simplest would be to add a loop in Scene_Map's update function that goes through each party member and sets their MP to max.
Wow this is such an amazing response. I really appreciate you taking the time to walk me through the logic. It was immensely helpful as I now have a bit of a better handle on how some of this stuff works. I have zero background in any sort of programming so I've been trying to teach myself but alas between having two small children and a busy job I find my chances to really dig into any substantial tutorials/guides limited.

With your help I've managed to get everything working except the dynamic health text colour which I will keep plugging away at.

Thank you so much for taking the time to explain all that. I know you didn't have to be so thorough, and that it took some time to write it out so coherently.

Original thread: https://forums.rpgmakerweb.com/threads/remove-gauges-and-move-hp-mana-numbers.75689/