Yanfly Menu Engine - Aligning actor status texts

I was experimenting with Yanfly's menu engine and run in to a problem.

I want my characters name and lastname (which is "nickname" in the engine) align with one another and character class and level align with one another. Doing it with the method I'm using just gives static positions for text for every character which of course makes me run in to problems when characters have names of different lengths. If any one knows a method where I can get one space between character name and last name(nickname) and one space between class and level I would die to hear it! Thank you in advance!

EDIT: Also if someone knows a way to create frame/border with window menu skin between the characters I would also die to know that too!

Spoiler
Game%202014-02-02%2021-10-57-37.jpg
Spoiler
#==============================================================================

# ■ Window_Base

#==============================================================================

 

class Window_Base < Window

  

  #--------------------------------------------------------------------------

  # overwrite method: draw_actor_simple_status

  #--------------------------------------------------------------------------

  def draw_actor_simple_status(actor, dx, dy)

    dy -= line_height / 2

    draw_actor_name(actor, dx, dy)

    draw_actor_icons(actor, dx, dy + line_height * 2)

    dw = contents.width - dx - 124

    draw_actor_class(actor, dx + 220, dy, dw)

    draw_actor_level(actor, dx + 290, dy)

    draw_actor_nickname(actor, dx + 90, dy, dw)

    draw_actor_hp(actor, dx, dy + line_height * 1, dw + 124)

    if YEA::MENU:😀RAW_TP_GAUGE && actor.draw_tp? && !actor.draw_mp?

      draw_actor_tp(actor, dx, dy + line_height * 2, dw + 124)

    elsif YEA::MENU:😀RAW_TP_GAUGE && actor.draw_tp? && actor.draw_mp?

      if $imported["YEA-BattleEngine"]

        draw_actor_tp(actor, dx, dy + line_height * 2, dw/2 + 1 + 124)

        draw_actor_mp(actor, dx + dw/2, dy + line_height * 2, dw/2 + 124)

      else

        draw_actor_mp(actor, dx, dy + line_height * 2, dw/2 + 1 + 124)

        draw_actor_tp(actor, dx + dw/2, dy + line_height * 2, dw/2 + 124)

      end

    else

      draw_actor_mp(actor, dx, dy + line_height * 2, dw + 124)

    end

  end

  

end # Window_Base
Comment out the lines with draw_actor_name and draw_actor_nickname (just put a "#" at the beginning of the line), and then put this above the line with draw_actor_icons:

draw_actor_full_name(actor, dx, dy)Then put this at the top, just under where it says "class Window_Base < Window":

def draw_actor_full_name(actor, dx, dy, dw = 292) change_color(hp_color(actor)) draw_text(dx, dy, dw, line_height, actor.name + " " + actor.nickname)endFor the class, replace the line with draw_actor_class with this:

draw_actor_class(actor, dx + 200, dy, dw)That won't put a space between class and level, but it'll at least make it so they won't overlap.
Thank you ! One problem solved. Now how about aligning Class and level just like that full name or frame/border between actors?
Hm... I can't seem to get the class and level to work because the level's value is a fixed number, and in order to have the space there it needs to be a string or else it causes an error. I don't really know how to fix that, unfortunately.  🙁 But if you replace the draw_actor_class line with what I suggested it should still make the text look better and not overlap like it is.
 
I did, however, add a border between the actors. Replace Yanfly's Window_Base with this and let me know how it works: Okay, nevermind I just tested it again and it only seems to draw the border once. 🙁 I'm still learning Ruby, so maybe someone a bit more experienced could help you better. :/
Hmh. Well thank you for that name thing, it looks a lot better now. And I also aligned those icons correctly. Would love to get that border thing between characters still thou. Can even throw 5$ for this if anyone is interested...
I'll look into this later tonight (5 hours from now) if noone is taking it yet by then.

No need any sort of payment.
Thank you!

Here is what I have at the moment in the script:

Spoiler
#==============================================================================

# ■ Window_Base

#==============================================================================

 

class Window_Base < Window

  

  #--------------------------------------------------------------------------

  # overwrite method: draw_actor_simple_status

  #--------------------------------------------------------------------------

  def draw_actor_simple_status(actor, dx, dy)

    dy -= line_height / 2

    draw_actor_full_name(actor, dx, dy)

    draw_actor_icons(actor, dx, dy + line_height * 3)

    dw = contents.width - dx - 124

    draw_actor_class(actor, dx + 200, dy, dw)

    draw_actor_level(actor, dx + 290, dy)

    draw_actor_hp(actor, dx, dy + line_height * 1, dw + 124)

    if YEA::MENU:😀RAW_TP_GAUGE && actor.draw_tp? && !actor.draw_mp?

      draw_actor_tp(actor, dx, dy + line_height * 2, dw + 124)

    elsif YEA::MENU:😀RAW_TP_GAUGE && actor.draw_tp? && actor.draw_mp?

      if $imported["YEA-BattleEngine"]

        draw_actor_tp(actor, dx, dy + line_height * 2, dw/2 + 1 + 124)

        draw_actor_mp(actor, dx + dw/2, dy + line_height * 2, dw/2 + 124)

      else

        draw_actor_mp(actor, dx, dy + line_height * 2, dw/2 + 1 + 124)

        draw_actor_tp(actor, dx + dw/2, dy + line_height * 2, dw/2 + 124)

      end

    else

      draw_actor_mp(actor, dx, dy + line_height * 2, dw + 124)

    end

  end

  def draw_actor_full_name(actor, dx, dy, dw = 292) 

  change_color(hp_color(actor))

  draw_text(dx, dy, dw, line_height, actor.name + " " + actor.nickname)

end

end # Window_Base
 

Yanfly Engine Ace - Ace Menu Engine v1.07 is the script in question.
Actually seems pretty simple, gimme 20-30 mins. : x

I don't have any material to test it on, but I believe you do, so I'll have you as my guinea pig if you don't mind. : x

Edit:

Try this:

What do you get?

Spoiler
Code:
#==============================================================================# ■ Window_Base#============================================================================== class Window_Base < Window  def draw_actor_simple_status(actor, dx, dy)    dy -= line_height / 2    draw_actor_full_name(actor, dx, dy)    draw_actor_icons(actor, dx, dy + line_height * 3)    dw = contents.width - dx - 124    draw_actor_class(actor, dx + 200, dy, dw)    draw_actor_hp(actor, dx, dy + line_height * 1, dw + 124)    if YEA::MENU::DRAW_TP_GAUGE && actor.draw_tp? && !actor.draw_mp?      draw_actor_tp(actor, dx, dy + line_height * 2, dw + 124)    elsif YEA::MENU::DRAW_TP_GAUGE && actor.draw_tp? && actor.draw_mp?      if $imported["YEA-BattleEngine"]        draw_actor_tp(actor, dx, dy + line_height * 2, dw/2 + 1 + 124)        draw_actor_mp(actor, dx + dw/2, dy + line_height * 2, dw/2 + 124)      else        draw_actor_mp(actor, dx, dy + line_height * 2, dw/2 + 1 + 124)        draw_actor_tp(actor, dx + dw/2, dy + line_height * 2, dw/2 + 124)      end    else      draw_actor_mp(actor, dx, dy + line_height * 2, dw + 124)    end  end  def draw_actor_full_name(actor, dx, dy, dw = 292)     change_color(hp_color(actor))    draw_text(dx, dy, dw, line_height, actor.name + " " + actor.nickname)  end  def draw_actor_class(actor, x, y, width = 112)    change_color(normal_color)    draw_text(x, y, width, line_height, actor.class.name + " " + Vocab::level_a + "     " + actor.level, 2)    change_color(system_color)    draw_text(x, y, width, line_height, actor.class.name + " " + Vocab::level_a)    change_color(normal_color)    draw_text(x, y, width, line_height, actor.class.name)  endend # Window_Base 
Got this error: TypeError. Can't convert Fixnum into String on line 343 which is this: draw_text(x, y, width, line_height, actor.class.name + " " + Vocab::level_a + "     " + actor.level, 2)
Then change the line to:

Code:
draw_text(x, y, width, line_height, actor.class.name + " " + Vocab::level_a + "     " + actor.level.to_s, 2)
It actually did'nt come back with an error however it was all mess; it drew the class and lvl few times.

Experimented with it a bit and got it working properly by deleting few lines and adjusting position. However, now the class name, LVL and level number are all same color. How to change f. e. LVL back to the color it was (blue)?

Spoiler
  def draw_actor_class(actor, x, y, width = 112)

    change_color(normal_color)

    draw_text(x - 75, y, width, line_height, actor.class.name + " " + Vocab::level_a + " " + actor.level.to_s, 2)

  end
I'd like to give you credit for this so feel free to PM me with the name you want to appear in my credit list.

PS. Came up anything for that border thing?
Well, I was testing my hypothesis on the draw_text and change_color function. I told you that I don't have material to test with.

I could make a code to counter that color thingy, but beware, it might not be flexible. If you change the font type, bunch of weird stuff might come up. : p

Try this and let me know what happened:

def draw_actor_class(actor, x, y, width = 112) change_color(normal_color) draw_text(x, y, width, line_height, actor.class.name) counter = text_size(actor.class.name.to_s).width change_color(system_color) draw_text(x + counter, y, width, line_height, " " + Vocab::level_a) counter += text_size(" " + Vocab::level_a) change_color(normal_color) draw_text(x + counter, y, width, line_height, actor.level.to_s, 2)endAnd the default setting doesn't have inner border, if you want to work around it, you can create a window for each character. It can be done by overloading one of the window class in menu scene.
TypeError: Rect can't be coerced into Fixnum on this line:   counter += text_size(" " + Vocab::level_a)
Oh whoops, forgot the .width

counter += text_size(" " + Vocab::level_a).widthTry this now, it should work. : )

Code:
def draw_actor_class(actor, x, y, width = 112)  change_color(normal_color)  draw_text(x, y, width, line_height, actor.class.name)  counter = text_size(actor.class.name.to_s).width  change_color(system_color)  draw_text(x + counter, y, width, line_height, " " + Vocab::level_a)  counter += text_size(" " + Vocab::level_a).width  change_color(normal_color)  draw_text(x + counter, y, 24, line_height, actor.level, 2)end
Now the color works properly but the class name and level are not aligned with the right size of the screen properly. Now the text is aligned from the left side f.e :

Monk lvl 1

Sheriff lvl 1

Druid lvl 1

and its supposed to be like this:

   Monk lvl 1

 Sheriff lvl 1

   Druid lvl 1
Oh, you want it like that. Hold on. Check this thread again in 10 mins.

Edit:

Done

Here you go:

Spoiler
Code:
#==============================================================================# ■ Window_Base#============================================================================== class Window_Base < Window  def draw_actor_simple_status(actor, dx, dy)    dy -= line_height / 2    draw_actor_full_name(actor, dx, dy)    draw_actor_icons(actor, dx, dy + line_height * 3)    dw = contents.width - dx - 124    draw_actor_class(actor, dx + 290, dy, dw)    draw_actor_hp(actor, dx, dy + line_height * 1, dw + 124)    if YEA::MENU::DRAW_TP_GAUGE && actor.draw_tp? && !actor.draw_mp?      draw_actor_tp(actor, dx, dy + line_height * 2, dw + 124)    elsif YEA::MENU::DRAW_TP_GAUGE && actor.draw_tp? && actor.draw_mp?      if $imported["YEA-BattleEngine"]        draw_actor_tp(actor, dx, dy + line_height * 2, dw/2 + 1 + 124)        draw_actor_mp(actor, dx + dw/2, dy + line_height * 2, dw/2 + 124)      else        draw_actor_mp(actor, dx, dy + line_height * 2, dw/2 + 1 + 124)        draw_actor_tp(actor, dx + dw/2, dy + line_height * 2, dw/2 + 124)      end    else      draw_actor_mp(actor, dx, dy + line_height * 2, dw + 124)    end  end  def draw_actor_full_name(actor, dx, dy, dw = 292)     change_color(hp_color(actor))    draw_text(dx, dy, dw, line_height, actor.name + " " + actor.nickname)  end  def draw_actor_class(actor, x, y, width = 112)    change_color(system_color)    draw_text(x, y, width, line_height, " " + Vocab::level_a)    counter = text_size(" " + Vocab::level_a).width    change_color(normal_color)    draw_text(x + counter, y, 24, line_height, actor.level, 2)    change_color(normal_color)    counter = text_size(actor.class.name).width    draw_text(x - counter, y, width, line_height, actor.class.name)  endend # Window_Base  
It overlapped under the border from the right side changed this line draw_text(x + counter, y, 24, line_height, actor.level, 2) with this: draw_text(x + counter, y, 19, line_height, actor.level, 2).

Only one slight problem! Now the LVL Number font "tightens" when the number has 2 digits. Screenshot:



Game%202014-02-05%2023-35-54-39.jpg




Sheriff LVL 10 <- The 0 is slightly smaller in width than the 0 under it :/
Oh just changed the x, not the width, because the width is like how many spaces you're wlling to give to the text. : p

Instead of

draw_actor_class(actor, dx + 290, dy, dw)try

Code:
draw_actor_class(actor, dx + 270, dy, dw)
The text width is exactly the problem, I'll try that when I get back home from work.


I was wondering how I could cheat the border in. What if I make image of the border frame and then just add show that image to the script like on line height * 4?


Sent from my GT-P5210 using Tapatalk
Shame on our time difference, I've totaled up my time here, and it's less than 30 mins.

On the border thingy, yes, you could do that. I could make a short custom script for that rather quickly, and you just need to draw the borders, and I'll allocate the picture on the Scene Menu.

Original thread: https://forums.rpgmakerweb.com/threads/yanfly-menu-engine-aligning-actor-status-texts.23300/