Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

[RESOLVED] Horizontal Menu Bar

I've searched and only found a few things for this, but none of them fully explained in detail how to do this. I've been working on learning how to script, so I thought I'd start with making some simple edits to the menu screen. I've gotten about what I want, expcept that I can't figure out how to make the menu go horizontal. If it's not too much trouble to someone, I want them to help out with this, by explaining how to do this step by step. I don't want just the pieces of scripts that I need to change, but I want why so that i can learn from it. Thanks to anyone who helps here.

Also, if there is already a topic like this, and I just passed over it while searching, post the link here. Thanks..

Edit: ok, I found a way to make this almost the way that I want it. I've gotten the menu bar scaled down to the size that I want,  but I can't figure out how to spread out the choices horizontally. I was able to shrink down the menu bar by creating a second Window_Command2. I ended up changing everything in the Scene_Menu from Window_Command, to Window Command2, which specifies the hight of the command box. I have not been able to figure out how to make the options horizontal yet though. Help anyone? Thanks.
 
I created this class while back:
Code:
#==============================================================================
# ** Window_HorizCommand
#------------------------------------------------------------------------------
#  This window deals with general command choices. (Horizontal)
#==============================================================================

class Window_HorizCommand < Window_Selectable
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader   :commands
  attr_accessor :c_spacing
  attr_accessor :alignment
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(width, commands, c_spacing = (width - 32) / commands.size)
    # Compute window height from command quantity
    super(0, 0, width, 64)
    @commands     = commands
    @item_max     = commands.size
    @column_max   = @item_max
    @c_spacing    = c_spacing
    @alignment    = 1
    self.contents = Bitmap.new(@item_max * @c_spacing, height - 32)
    refresh
    self.index = 0
  end
  #--------------------------------------------------------------------------
  # * Command
  #--------------------------------------------------------------------------
  def command(index = self.index)
    return @commands[index]
  end
  #--------------------------------------------------------------------------
  # * Commands
  #--------------------------------------------------------------------------
  def commands=(commands)
    # Return if Commands Are Same
    return if @commands == commands
    # Reset Commands
    @commands = commands
    # Resets Item Max
    item_max    = @item_max
    @item_max   = @commands.size
    @column_max = @item_max
    # If Item Max Changes
    unless item_max == @item_max
      # Deletes Existing Contents (If Exist)
      unless self.contents.nil?
        self.contents.dispose
        self.contents = nil
      end
      # Recreates Contents
    self.contents = Bitmap.new(@item_max * @c_spacing, height - 32)
    end
    # Refresh Window
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    for i in 0...@item_max
      draw_item(i, normal_color)
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #--------------------------------------------------------------------------
  def draw_item(index, color)
    command = commands[index]
    x = index * @c_spacing + 4
    self.contents.font.color = color
    self.contents.draw_text(x, 0, @c_spacing - 8, 32, command, @alignment)
  end
  #--------------------------------------------------------------------------
  # * Disable Item
  #--------------------------------------------------------------------------
  def disable_item(index)
    draw_item(index, disabled_color)
  end
  #--------------------------------------------------------------------------
  # * Cursor Rectangle Update
  #--------------------------------------------------------------------------
  def update_cursor_rect
    if @index < 0
      self.cursor_rect.empty
    else
      self.cursor_rect.set(@c_spacing * @index, 0, @c_spacing, 32)
    end
  end
end

Just like when you make a Window_Command, you use:
Code:
your_window = Window_HorizCommand.new(width, commands)

width = the width of the window
commands = array of strings

Let me know if you run into any difficulties
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top