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.

Changing the distance between options in a Selectable Window?

I managed to change the number of pixels between each option, as well as change the number of pixels the cursor moves with each key press. The cursor loops fine if the window doesn't scroll. However if there are enough options (ex Item Menu) where the window scrolls, the cursor doesn't scroll the window and instead moves out of the window (and off the screen sometimes).

So my question is, how do I get the cursor to loop properly if the window scrolls?
 
I want to change the distance from 32 to 19

Code:
class Window_EquipItem < Window_Selectable
  #--------------------------------------------------------------------------
  # - Object initialization
  #     actor      : Actor
  #     equip_type : Equipment region (0-3)
  #--------------------------------------------------------------------------
  def initialize(actor, equip_type)
    super(0, 0, 350, 265)
    @actor = actor
    @equip_type = equip_type
    @column_max = 1
    
    refresh
    
    self.active = false
    self.index = -1
  end
  #--------------------------------------------------------------------------
  # - Acquisition of item
  #--------------------------------------------------------------------------
  def item
    return @data[self.index]
  end
  #--------------------------------------------------------------------------
  # - Refreshment
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    # Adding the equipment possible weapon
    if @equip_type == 0
      weapon_set = $data_classes[@actor.class_id].weapon_set
      for i in 1...$data_weapons.size
        if $game_party.weapon_number(i) > 0 and weapon_set.include?(i)
          @data.push($data_weapons[i])
        end
      end
    end
    # Adding the equipment possible guard
    if @equip_type != 0
      armor_set = $data_classes[@actor.class_id].armor_set
      for i in 1...$data_armors.size
        if $game_party.armor_number(i) > 0 and armor_set.include?(i)
          if $data_armors[i].kind == @equip_type-1
            @data.push($data_armors[i])
          end
        end
      end
    end
    # Adding blank
    @data.push(nil)
    # It draws up bit map, drawing all item
    @item_max = @data.size
    self.contents = Bitmap.new(width - 32, row_max * 32)
    for i in 0...@item_max-1
      draw_item(i)
    end
  end
  #--------------------------------------------------------------------------
  # - Drawing of item
  #     index : Item number
  #--------------------------------------------------------------------------
  def draw_item(index)
    item = @data[index]
    x = 4
    y = (index * 19) - 5
    
    case item
    when RPG::Weapon
      number = $game_party.weapon_number(item.id)
    when RPG::Armor
      number = $game_party.armor_number(item.id)
    end
    
    self.contents.font.name = $fontface
    self.contents.font.size = $menu_small_1
    self.contents.font.bold = true
    self.contents.font.outline = true
    
    #bitmap = RPG::Cache.icon(item.icon_name)
    #self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
    self.contents.font.color = normal_color
    self.contents.draw_text(x + 10, y, 212, 32, item.name, 0)
    self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  end
  #--------------------------------------------------------------------------
  # - Help text renewal
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_text(self.item == nil ? "" : self.item.description)
  end
  
  def update_cursor_rect
    self.cursor_rect.set(0, @index * 19 + 10, 0, 0)
  end
end
 

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