Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # ** Window_Item
- #------------------------------------------------------------------------------
- # This window displays a list of inventory items for the item screen, etc.
- #==============================================================================
- class Window_Item < Window_Selectable
- #--------------------------------------------------------------------------
- # * Object Initialization
- # x : window x-coordinate
- # y : window y-coordinate
- # width : window width
- # height : window height
- #--------------------------------------------------------------------------
- def initialize(x, y, width, height)
- super(x, y, width, height)
- @column_max = (width-32)/WLH
- self.index = 0
- refresh
- end
- #--------------------------------------------------------------------------
- # * Refresh
- #--------------------------------------------------------------------------
- def refresh
- @data = []
- $game_party.items.each {|item|
- next unless include?(item)
- $game_party.item_number(item).times {@data << item}
- if item.is_a?(RPG::Item) && item.id == $game_party.last_item_id
- self.index = @data.size - 1
- end}
- @data.push(nil) if include?(nil)
- @item_max = @data.size
- create_contents
- @data.each_index{|i| draw_item(i)}
- end
- #--------------------------------------------------------------------------
- # * Draw Item
- # index : item number
- #--------------------------------------------------------------------------
- def draw_item(index)
- rect = item_rect(index)
- self.contents.clear_rect(rect)
- item = @data[index]
- draw_icon(item.icon_index, rect.x, rect.y, enable?(item))
- end
- #--------------------------------------------------------------------------
- # * Get rectangle for displaying items
- # index : item number
- #--------------------------------------------------------------------------
- def item_rect(index)
- rect = Rect.new(0, 0, 0, 0)
- rect.width = WLH
- rect.height = WLH
- rect.x = index % @column_max * WLH
- rect.y = index / @column_max * WLH
- return rect
- end
- #--------------------------------------------------------------------------
- # * Update Help Text
- #--------------------------------------------------------------------------
- def update_help
- @help_window.set_text(item == nil ? "" : item.name+' : '+item.description)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement