Chaos Project

RPG Maker => RPG Maker Scripts => Script Troubleshooting => Topic started by: prioran on December 18, 2010, 10:07:59 am

Title: [XP] Images instead of text in Scene_Menu [Resolved]
Post by: prioran on December 18, 2010, 10:07:59 am
Hello all,

This is a woefully basic question, but I've been trying to edit my Scene_Menu and simply can't get what I want. Could someone please tell me how I might replace the text on the left column of the default menu system (Item, Skill, etc.) with images?

Thanks for your patience and assistance! I'm still trying to teach myself how to script, but my courses are absorbing too much time. :(

Title: Re: [XP] Images instead of text in Scene_Menu
Post by: stripe103 on December 18, 2010, 10:25:32 am
If you want a nice menu easily, then you can use Moghunters Menu (http://atelier-rgss.com/RGSS/Menu/XP_Menu01.html).
Title: Re: [XP] Images instead of text in Scene_Menu
Post by: prioran on December 18, 2010, 11:35:09 am
Thanks much for the suggestion, but I'm familiar with that menu system and won't be using it because I have custom systems within each option that are difficult to reconcile with the MOG scripts. All I wish to do is replace the text of my default menu system with images.  :)
Title: Re: [XP] Images instead of text in Scene_Menu
Post by: stripe103 on December 19, 2010, 11:21:13 am
Just found this on RPG Revolution. It is made by Redd

Tested it as well, it adds icons in the menu before the choice words. If you don't want the text, just remove them in the Scene_Menu.
#==============================================================================
# ** Redd's MenuIcons
#==============================================================================
#  Gives the menu the ability to have icons in the choices
#==============================================================================
#  Instructions
#
#  After configuring what you want your icons to be, go into Scene_Menu, look
#  for line 26, and change
#  @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6])
#  to...
#  @command_window = Window_MenuIcons.new(160, [s1, s2, s3, s4, s5, s6])
#
#  And there you have it. If you need any support just email redredd@live.com
#==============================================================================

class Window_MenuIcons < Window_Command
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    for i in 0...@item_max
      draw_item(i, normal_color)
      # Draw the icon associated with the index.
      draw_icon(i)
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #--------------------------------------------------------------------------
  def draw_item(index, color)
    self.contents.font.color = color
    # rect = Rect.new(x, y, width, height) Note the x is 32, not the default 4.
    rect = Rect.new(32, 32 * index, self.contents.width - 8, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.contents.draw_text(rect, @commands[index])
  end
  #--------------------------------------------------------------------------
  # * Draw Icon
  #--------------------------------------------------------------------------
  def draw_icon(index)
    # Case index
    case index
    # Conditional branch
    when 0
      # Sets the icon name (Case Sensitive)
      icon = '032-Item01'
    when 1
      icon = '050-Skill07'
    when 2
      icon = '013-Body01'
    when 3
      icon = '040-Item09'
    when 4
      icon = '035-Item04'
    when 5
      icon = '046-Skill03'
    # If there are more than 6 commands:
    else
      # Don't draw anything.
      icon = ''
    end
    # Create the bitmap image for the icon
    bitmap = RPG::Cache.icon(icon)
    # Make the rectangle for the image to be in
    src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
    # Draw the bitmap inside the rectangle, at 4 pixels across,
    # and down according to the index
    self.contents.blt(4, 32*index+5, bitmap, src_rect)
  end
end
Title: Re: [XP] Images instead of text in Scene_Menu
Post by: prioran on December 19, 2010, 05:47:22 pm
Great idea. It worked perfectly! *levels up*