Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Need help with my menu - Current issue is item grid layout
#17
Yep. Found the issue... My bad.

Code:
#===========================================================#
# ICON ITEMS                                                                  
# Version: 1.0                                                                
# By: Polraudio                                              
# Haphazardly butchered by LilyFrog                                            
# Exclusive to RMU or GDU                                                      
#===========================================================#

module LilyItems
  
  
  # DIMENSIONS
  # ==========
  #
    MENU_DIMENSIONS = [4,4] # Number of columns across, and rows down
  
  
  # POSITIONING
  # ===========
  #
    MENU_COORD    = [10,40] # X Position / Y position
    BATTLE_COORD  = [10,40] # X Position / Y position
    
    
  # SPACING
  # =======
  #
    X_SPACING     = 18      # Horizontal spacing between icons
    Y_SPACING     = 18      # Vertical spacing between icons    
  
    WINDOWSKIN    = "Bluish"
  
    BACKGROUND    = nil
    HELP_DISPLAY  = nil
  
end



#==============================================================================
# ** Window_Item
#------------------------------------------------------------------------------
#  This window displays items in possession on the item and battle screens.
#==============================================================================

class Window_Item < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    # Get Columns for basic system
    @column_max = LilyItems::MENU_DIMENSIONS[1]
    # Calculate width of window (icon width x columns) + 32px border
    width  = ((32 + LilyItems::X_SPACING) * @column_max) + 32
    # Calculate height of window (icon width x icons down) + 32px border
    height = ((32 + LilyItems::Y_SPACING) * LilyItems::MENU_DIMENSIONS[0]) + 32
    # Super (as in inheriting from Window_Selectable class)
    super(0, 0, width, height)
    # Define position in menu
    self.x = LilyItems::MENU_COORD[0]
    self.y = LilyItems::MENU_COORD[1]
    # If in battle, reposition based on config
    # and make it semi-transparent
    if $game_temp.in_battle
      self.x = LilyItems::BATTLE_COORD[0]
      self.y = LilyItems::BATTLE_COORD[1]
      self.back_opacity = 160
    end
    #
    if LilyItems::BACKGROUND.nil?
      self.opacity = 0
      self.back_opacity = 0
    end
    # Special Windowskin only for this menu.....
    self.windowskin = RPG::Cache.windowskin(LilyItems::WINDOWSKIN)
    # Ensure newly loaded content
    refresh
    self.index = 0
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @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
    # If item count is not 0, make a bit map and draw all items
    @item_max = @data.size
    if @item_max > 0
      # THE CHANGE HERE ---------------------------
      height = LilyItems::MENU_DIMENSIONS[0] * 32
      self.contents = Bitmap.new(width - 32, height)
      # END OF CHANGE HERE ------------------------
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #--------------------------------------------------------------------------
  def draw_item(index)
    item = @data[index]
    case item
      when RPG::Item : number = $game_party.item_number(item.id)
      when RPG::Weapon : number = $game_party.weapon_number(item.id)
      when RPG::Armor : number = $game_party.armor_number(item.id)
    end
    if item.is_a?(RPG::Item) and $game_party.item_can_use?(item.id)
      self.contents.font.color = normal_color
    else
      self.contents.font.color = disabled_color
    end
    x = index % 4 * (32 + LilyItems::X_SPACING)
    y = index / 4 * (32 + LilyItems::Y_SPACING)
    rect = Rect.new(x, y, 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    bitmap = RPG::Cache.icon(item.icon_name)
    # Change icon opacity if disabled color
    opacity = self.contents.font.color == normal_color ? 255 : 128
    # Draw the icon
    self.contents.blt(x+4, y+4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  end
  #--------------------------------------------------------------------------
  # * Help Text Update
  #--------------------------------------------------------------------------
  def update_help
    return if LilyItems::HELP_DISPLAY.nil?
    @help_window.set_text(self.item == nil ? "" : self.item.name+": "+self.item.description)
  end
  #--------------------------------------------------------------------------
  # * Get Row Count
  #--------------------------------------------------------------------------
  def row_max
    # Compute rows from number of items and columns
    x = LilyItems::MENU_DIMENSIONS[0]
    y = LilyItems::MENU_DIMENSIONS[1]
    return (@item_max + (x * y) - 1) / (x * y)
  end
  #--------------------------------------------------------------------------
  # * Update Cursor Rectangle
  #--------------------------------------------------------------------------
  def update_cursor_rect
    # If cursor position is less than 0
    return self.cursor_rect.empty if @index < 0
    # Deal with rectangle settings
    x     = @index % 4 * (32 + LilyItems::X_SPACING)
    y     = @index / 4 * (32 + LilyItems::Y_SPACING)
    width = 32
    # Draw Rectangle
    self.cursor_rect.set(x, y, width, 32)
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # If cursor is movable
    if self.active and @item_max > 0 and @index >= 0
      # If pressing down on the directional buttons
      if Input.repeat?(Input::DOWN)
        # If the cursor position is above the bottom-most row
        if (@index / 4) < (LilyItems::MENU_DIMENSIONS[0] - 1)
          # Move cursor right
          $game_system.se_play($data_system.cursor_se)
          @index += 4
        end
      end
      # If the up directional button was pressed
      if Input.repeat?(Input::UP)
        # If the cursor position is below the top-most row
        if (@index / 4) > 0
          # Move cursor right
          $game_system.se_play($data_system.cursor_se)
          @index -= 4
        end
      end
      # If the right directional button was pressed
      if Input.repeat?(Input::RIGHT)
        # If the cursor position is to the left of the right-most columb
        if (@index % 4) < (LilyItems::MENU_DIMENSIONS[1] - 1)
          # Move cursor right
          $game_system.se_play($data_system.cursor_se)
          @index += 1
        end
      end
      # If the left directional button was pressed
      if Input.repeat?(Input::LEFT)
        # If the cursor position is to the right of the left-most columb
        if (@index % 4) > 0
          # Move cursor right
          $game_system.se_play($data_system.cursor_se)
          @index -= 1
        end
      end
      # Ensure not beyond the item limits ^_^
      @index = 0 if @index < 0
      @index = @item_max-1 if @index >= @item_max
    end
    # Update help text (update_help is defined by the subclasses)
    if self.active and @help_window != nil
      update_help
    end
    # Update cursor rectangle
    update_cursor_rect
  end
end

Haphazard stupidity by the Resident Werewolf. Laughing
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)
[Image: QrnbKlx.jpg]
[Image: sGz1ErF.png] [Image: liM4ikn.png] [Image: fdzKgZA.png] [Image: sj0H81z.png]
[Image: QL7oRau.png] [Image: uSqjY09.png] [Image: GAA3qE9.png] [Image: 2Hmnx1G.png] [Image: BwtNdKw.png%5B]
Above are clickable links

Reply }


Messages In This Thread
RE: Need help with my menu - Current issue is item grid layout - by DerVVulfman - 09-17-2018, 03:19 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
   I want to merge item classification and description extensions. zlsl 7 8,206 11-25-2019, 06:46 AM
Last Post: kyonides
   Handling very long Item Names Melana 4 7,404 09-24-2018, 06:37 PM
Last Post: Melana
   Special Items Separate Menu Diorm 41 36,315 02-10-2018, 06:06 PM
Last Post: Diorm
Question  Mog Menu script: help me stop the crazy picture movement during transitions Zachariad 4 8,618 05-31-2017, 05:10 AM
Last Post: Zachariad
   A fourth column in MOG Scene Item Laura V1.2 Noctis 13 17,457 11-27-2016, 05:12 PM
Last Post: DerVVulfman
   Bizarre issue with Lanzer counter script. Steel Beast 6Beets 2 6,604 10-04-2016, 11:46 AM
Last Post: Steel Beast 6Beets
   XAIL MENU from RPG VX ACE to RPG XP RASHIDA12 46 44,931 05-02-2016, 08:08 PM
Last Post: RASHIDA12
Tongue  Healing Spell doesn't work right in Menu? Bounty Hunter Lani 8 11,025 01-15-2015, 07:45 PM
Last Post: Bounty Hunter Lani
   My Options Menu needs help firestalker 0 2,983 08-11-2014, 02:31 PM
Last Post: firestalker
   Vx Ace Custom Menu help? Skitzen 1 4,896 10-07-2013, 03:10 PM
Last Post: JayRay



Users browsing this thread: