MZ Namebox text padding / alignment

Hey there! I've been at this for hours, I have been defeated, the namebox window is simply too powerful for me, i require assistance.

So for context: I'm using DK_Message_Busts to show the characters during dialogue, but the namebox would always be on top of the bust, causing this obvious problem:
1758171969243.png

After researching for a while I find out RPG maker handles layering depending on which window function was called first, so I look into the JS files and spot the Window_NameBox function in rmmz_scenes.js. I swap it around with the Window_Message function, which is what I assumed the plugin linked the busts to, and sure enough, the namebox is behind the portrait now! Awesome!

1758171882406.png

New problem: Now the namebox window is generated even if there is no name to show. Man.
1758172661043.png

So how do I get rid of that? Is there a check somewhere in the message window function that I should move over to the namebox function? how likely is that to make the whole engine explode considering I don't know javascript very well?

Second, most important new problem: now the bust covers the text. Well it'd look good if the text was aligned to the right, or if I added padding to the left! Should be easy, right? (narrator: it was not easy)
There is a padding parameter in the code, but that's padding in all directions, which doesn't work here. I've tried paddingLeft in a js file, nope, i've tried newLineX, tried a bunch of other things, nothing. So big question two, how do I add 272 pixels of left padding to the namebox text, so it appears to the right of the bust?
Do you use any custom plugins that affect message windows?
Do you use any custom plugins that affect message windows?
I have VisuMZ_1_MessageCore for text wrap, and I've added a line to AML_nameAlign to get the namebox resized (this.width = 272 + 100;)

UPDATE: Found a solution for question one! Solved it by adding if (!this._name) return 0; in the AML_nameAlign plugin. Still stuck on the position of the text tho
Bump
Have you browsed the MZ text code reference?

http://www.yanfly.moe/wiki/Category:Text_Codes_(MZ)
This is really a workaround rather than solution, but...

Regarding the name, you could also use the default option but never use the namebox (or at least never use it when showing the bust) and then make name part of the bust picture... unless you want the player to able to rename the character(s) of course.

When using default setting, that would then keep padding to your text (where face is usually located, like in your original screenshot).
Have you browsed the MZ text code reference?

http://www.yanfly.moe/wiki/Category:Text_Codes_(MZ)
Just did, aand there's not really anything helpful there, the only text codes I'm seeing related to the name box would move the whole box to the right, not the text inside it
1758756372646.png

This is really a workaround rather than solution, but...

Regarding the name, you could also use the default option but never use the namebox (or at least never use it when showing the bust) and then make name part of the bust picture... unless you want the player to able to rename the character(s) of course.

When using default setting, that would then keep padding to your text (where face is usually located, like in your original screenshot).
Cool idea actually! I tried just to see what it'd look like, and well
1758756573141.png

the padding of the textbox was not kept
Soo what do you mean with "default setting?"

Having said that, i'd rather not rely on a workaround like this. Also cause I already have a bunch of dialogue where i'd have to go and remove the names of all the characters and I reaally don't wanna do that
I could do this as a last resort if there is LITERALLY no other way to align the name in the namebox to the right
Soo what do you mean with "default setting?"
Sorry! I misunderstood the second problem. I assumed the bust obscured the left side of the text after your tweaking, so I thought removing whatever you added due to the nametag would then put the message text back (as a bonus to not having to deal with the nametag directly).

I thought you would not use the namebox at all and place the name over the bust (because in your case that made the bust wider, moving the position of the text too much to the right) - that would make it less artificial too. Something like this:
bust.png


As I understand it, the plugin should automatically align with the bust picture in its vanilla form.

If you prefer using th standard namebox, would it be okay to just align it right so you don't have to deal with vertical priorities at all?
example.png
I assumed the bust obscured the left side of the text after your tweaking, so I thought removing whatever you added due to the nametag would then put the message text back (as a bonus to not having to deal with the nametag directly).
Oh! I see! No i don't have any problem with the text. As you said:
As I understand it, the plugin should automatically align with the bust picture in its vanilla form.
This is correct! The only problem is the text in the namebox.
If you prefer using th standard namebox, would it be okay to just align it right so you don't have to deal with vertical priorities at all?
Thaat would be another workaround, but I'm not a big fan of how it looks. It feels detached from the character, having it all the way to the right.
1758814592045.png

Even moving it back a few pixels I just don't like it nearly as much as I would like, just... Having it right next to the character. Which I did do btw!
1758815294620.png
1758815511329.png

This looks ALMOST exactly the way I wanted it, the only problem is that it feels really weird when the textbox extends all the way to the end of the screen, but the namebox doesn't. It's like it's coming out of nowhere, it's just kind of.. there. Especially with Rufus, since his portrait has a lot of empty space around him. Hence the last iteration:
1758815017282.png

Aaand hence my problem. I'd like just the name to be aligned to the right, or for some padding on the left so the name ends up on the right of the bust, just like the text does.
I actually like how this looks! But you do you 😉 Good luck with your project!
Bump
You can always use the \PX[x] text code to push text to the right even in the namebox.

If you don't want to do that for all text boxes and don't need VS stuff for the namebox, I guess you could try to just return the refresh method (where it draws the name) back to original (or alias the VS one and add at the end to clear and draw):

Window_NameBox.prototype.refresh = function() {
const rect = this.baseTextRect();
this.contents.clear();
this.drawTextEx(this._name, rect.x, rect.y, rect.width);
};

Then you have to change the x-coordinate where it draws the name (currently rect.x). You get the name text widh with like this.textSizeEx(this._name) method. So like I guess subtract that from the rect.width and also subtract the padding and then you'll get a position for x.

EDIT: Might need to give another value for the last argument width too, haven't checked how that works.
If you don't want to do that for all text boxes and don't need VS stuff for the namebox, I guess you could try to just return the refresh method (where it draws the name) back to original (or alias the VS one and add at the end to clear and draw):

Window_NameBox.prototype.refresh = function() {
const rect = this.baseTextRect();
this.contents.clear();
this.drawTextEx(this._name, rect.x, rect.y, rect.width);
};

Then you have to change the x-coordinate where it draws the name (currently rect.x). You get the name text widh with like this.textSizeEx(this._name) method. So like I guess subtract that from the rect.width and also subtract the padding and then you'll get a position for x.
Yesssss this worked perfectly! Since all busts will be the same size I actually don't need to do math on that, just changing it to (rect.x + 268) did it. I added the function in the other plugin I was using, AML_nameAlign, and it seems to do just fine!

1759186747112.png

1759186911368.png


Thank you all for the help and suggestions, and thanks rpgLord69 (nice) for the solution!

Original thread: https://forums.rpgmakerweb.com/threads/namebox-text-padding-alignment.180129/