Help - Search - Members - Calendar
Full Version: Centering the commands in a command_window...
RPG RPG Revolution Forums > Scripting > Script Development and Support
munkis
Basically what I want to know is how do I center the text used for the menu commands? Is there a setting somewhere I can change, or do I need a script?
The Law G14
Are you talking about all Command Windows, or just the Command Window in Scene_Menu. Regardless, the simplest way to do this, is to first got to the Window_Command script within the default scripts section of the Script Editor. Next, go down to line 52 (assuming you haven't changed anything to this script), and replace it with this line:

CODE
self.contents.draw_text(rect, @commands[index], 1)


All I did was add the 1 at the end which is an optional parameter value you do not have to add to the draw_text method. Putting in 0 aligns it to the left (this is the default), 1 aligns it to the middle (which is what you requested), and 2 aligns it to the right. Hope this helps smile.gif
munkis
Yeah, I was being specific to Scene_Menu. And your method doesn't work for some reason; none of the custom scripts I have make any changes to draw_item...? huh.gif
The Law G14
Ah, only for Scene Menu, if that's the case use this script (Place this script at the bottom of all your other custom script but ABOVE Main):

CODE
#==============================================================================
# ** Window_MenuCommand
#------------------------------------------------------------------------------
#  This window deals with general command choices.
#==============================================================================

class Window_MenuCommand < Window_Command
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(width, commands, column_max = 1, row_max = 0, spacing = 32)
    # Set row max if greater than 0
    if row_max == 0
      row_max = (commands.size + column_max - 1) / column_max
    end
    # Call parent class
    super(width, commands, column_max, row_max, spacing)
    # Set commands
    @commands = commands
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #--------------------------------------------------------------------------
  def draw_item(index, enabled = true)
    # Set rect
    rect = item_rect(index)
    rect.x += 4
    rect.width -= 8
    # Clear the rect
    self.contents.clear_rect(rect)
    # Draw the text
    self.contents.font.color = normal_color
    self.contents.font.color.alpha = enabled ? 255 : 128
    self.contents.draw_text(rect, @commands[index], 1)
  end
end


Next, go to any custom menu script you have or you don't have a custom menu system go to the default Scene_Menu and press CTRL + F and search @command_window = Window_Com. From there you should be directed to a line that reads:

CODE
@command_window = Window_Command.new


Replace that with:

CODE
@command_window = Window_MenuCommand.new
munkis
I figured out what I was doing wrong with the first solution (which I like now that I can see it; it's more efficient). Now I have another question; how do I make the default command window cursor invisible so I can replace it with a picture?

EDIT: Nevermind, I figured it out.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2013 Invision Power Services, Inc.