#==============================================================================
# ** Window_Item
#------------------------------------------------------------------------------
# This window displays items in possession on the item and battle screens.
#==============================================================================
class Window_Item
attr_reader :pic_window # pic window
alias pic_window_init initialize
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 64, 478, 416)
@column_max = 2
refresh
self.index = 0
# If in battle, move window to center of screen
# and make it semi-transparent
if $game_temp.in_battle
self.y = 64
self.height = 256
self.back_opacity = 160
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 = 4 + index % 2 * (207 + 32)
y = index / 2 * 32
rect = Rect.new(x - 4, y, self.width / @column_max - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(item.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 135, 32, item.name, 0)
self.contents.draw_text(x + 165, y, 5, 32, ":", 0)
self.contents.draw_text(x + 170, y, 24, 32, number.to_s, 2)
end
#--------------------------------------------------------------------------
# * Picture Window Update
#--------------------------------------------------------------------------
def update_pic
if self.item != nil
@pic_window.refresh(self.item)
end
end
#--------------------------------------------------------------------------
# * Set pic Window
# help_window : new help window
#--------------------------------------------------------------------------
def pic_window=(pic_window)
@pic_window = pic_window
# Update help text (update_help is defined by the subclasses)
if self.active and @pic_window != nil
update_pic
end
end
alias pic_window_update update
def update
pic_window_update
update_pic
end
end