Simple Item menu EDIT

Started by Zexion, February 26, 2012, 02:20:15 pm

Previous topic - Next topic

Zexion

Well Im using the default item menu, and I just want to know one thing. How do I make items show by type? Like list all the weapons first, then items, then accessories etc.

KK20

The default item menu can be found by locating 'Window_Item' in your list of scripts. Scroll down until you find 'def refresh'. The key part that you want to look at is this:
Spoiler: ShowHide
    @data = []
    # Add item
    for i in 1...$data_items.size
      if $game_party.item_number(i) > 0
        @data.push($data_items[i])
      end
    end
    # Also add weapons and items if outside of battle
    unless $game_temp.in_battle
      for i in 1...$data_weapons.size
        if $game_party.weapon_number(i) > 0
          @data.push($data_weapons[i])
        end
      end
      for i in 1...$data_armors.size
        if $game_party.armor_number(i) > 0
          @data.push($data_armors[i])
        end
      end
    end
The game will first check for items (potions, antidotes, etc), then weapons, then armors. Because 'Window_Item' is used in battles as well, the line
unless $game_temp.in_battle
is needed. This way, it won't draw your weapons and armors when in battle--only your potions and key-items.

Accessories, shields, clothes, and helms are all considered as Armor. By using '$data_armors[index].kind', you can change the order of what is drawn first. So in your example, it would look like this:
Spoiler: ShowHide
    @data = []
    #Adds weapons to the list
    unless $game_temp.in_battle
      for i in 1...$data_weapons.size
        if $game_party.weapon_number(i) > 0
          @data.push($data_weapons[i])
        end
      end
    end
    # Adds items to the list
    for i in 1...$data_items.size
      if $game_party.item_number(i) > 0
        @data.push($data_items[i])
      end
    end
    # Adds accessories to the list
    unless $game_temp.in_battle
      for i in 1...$data_armors.size
        # 0 = shield, 1 = helm, 2 = body, 3 = accessories
        if $game_party.armor_number(i) > 0 and $data_armors[i].kind == 3
          @data.push($data_armors[i])
        end
      end
    end
    # Continue on with the list...

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Zexion

Thanks for the info, but now I need to know another thing :P How do I add a window with a description of the item, because the default one is too high and is difficult to work with.

KK20

Think you can explain that a bit more for me? From what I'm understanding, you're saying that the default 'Window_Help' is not working out for you. What more do you need other than the item's description? Obviously you'll have to create a new type of window, but because I don't know what you want, I don't know where I'd begin.  :hm:

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Zexion

February 26, 2012, 04:00:08 pm #4 Last Edit: February 26, 2012, 04:02:27 pm by Darth noob
Yes sorry for being so vague, but Well the default window is just placed at the top of the screen, but I want it to be at the bottom.
I guess what I am asking for is if you could remake me the help/description box, but make it easier to move around the screen, because right now if I edit the default it acts wierd and starts messing up the windowskin for some reason.

This is the problem:
Spoiler: ShowHide


This is what I want:
Spoiler: ShowHide


Yes I am using a resolution script :p but if you make me a normal window that shows the description, I will know how to move it around and stuff.

KK20

So...all I did was copy 'Window_Help' a bit and made a new type of Window class designed specifically for item descriptions. I only went ahead and changed 'Scene_Item' to incorporate this new window. You can just change the values of how the window is set up to fit your needs.
Spoiler: ShowHide
#==============================================================================
# ** Window_Item_Desc
#------------------------------------------------------------------------------
#  This window shows an item's description.
#==============================================================================

class Window_Item_Desc < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    #(x, y, width, height)
    super(100, 300, 640, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
  end
  #--------------------------------------------------------------------------
  # * Set Text
  #  text  : text string displayed in window
  #  align : alignment (0..flush left, 1..center, 2..flush right)
  #--------------------------------------------------------------------------
  def set_text(text, align = 0)
    # If at least one part of text and alignment differ from last time
    if text != @text or align != @align
      # Redraw text
      self.contents.clear
      self.contents.font.color = normal_color
      self.contents.draw_text(4, 0, self.width - 40, 32, text, align)
      @text = text
      @align = align
      @actor = nil
    end
    self.visible = true
  end
end
#==============================================================================
# ** Scene_Item
#------------------------------------------------------------------------------
#  This class performs item screen processing.
#==============================================================================

class Scene_Item
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Make help window, item window
    @item_window = Window_Item.new
    @help_window = Window_Item_Desc.new
    # Associate help window
    @item_window.help_window = @help_window
    # Make target window (set to invisible / inactive)
    @target_window = Window_Target.new
    @target_window.visible = false
    @target_window.active = false
    # Execute transition
    Graphics.transition
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    # Prepare for transition
    Graphics.freeze
    # Dispose of windows
    @help_window.dispose
    @item_window.dispose
    @target_window.dispose
  end
end
I am curious to know what you meant in 'editting the default', saying how the windowskin gets weird.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Zexion

Thank you I will try this out right now!

And by it looking wierd, I mean I edited the part in window_help that says
Quotedef initialize
    super(0, 0, 640, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
  end


To

Quotedef initialize
    super(0, 0, 320, 32)
    self.contents = Bitmap.new(width - 16, height - 16)
  end


Which is exactly half because the resolution is exactly half. This is usually what I do, but this time it made the window look like:
Spoiler: ShowHide