#==============================================================================
# ■ Window_Item
#------------------------------------------------------------------------------
# 物品画面、战斗画面、显示浏览物品的窗口。
#==============================================================================
class Window_Item < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super(121, 60, 335, 275)
@column_max = 1
refresh
self.index = 0
self.z = 999
self.back_opacity = 0
self.opacity = 0
# 战斗中的情况下将窗口移至中央并将其半透明化
if $game_temp.in_battle
self.y = 60
self.x = 122
self.z = 999
self.height = 256
self.back_opacity = 160
[url=home.php?mod=space&uid=27569]@orz[/url] = Sprite.new
@orz.bitmap = Bitmap.new("Graphics/Pictures/道具.png")#背景的生成
@orz.x= 125
@orz.y= 42
@orz.z= 555
end
end
#--------------------------------------------------------------------------
# ● 获取物品
#--------------------------------------------------------------------------
def item
return @data[self.index]
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
# 添加报务
for i in 1...$data_items.size
if $game_party.item_number(i) > 0
@data.push($data_items[i])
end
end
# 在战斗中以外添加武器、防具
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
# 如果项目数不是 0 就生成位图、重新描绘全部项目
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 50)
for i in 0...@item_max
draw_item(i)
end
end
end
#--------------------------------------------------------------------------
# ● 描绘项目
# index : 项目编号
#--------------------------------------------------------------------------
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 % 5 * 44
y = index / 5 * 40
rect = Rect.new(x, 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, bitmap, Rect.new(-4, -2, 50, 100), opacity)
self.contents.draw_text(x , y , 0, 0, item.name, 0)
self.contents.draw_text(x + 15, y, 0, 0, "", 1)
self.contents.draw_text(x + 25, y + 25, 24, 24, number.to_s, 2)
end
#--------------------------------------------------------------------------
# ● 刷新光标矩形
#--------------------------------------------------------------------------
def page_row_max
# 窗口的高度,设置画面的高度减去 32 ,除以 1 行的高度 32
return self.height/ 52
end
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
self.opacity = 0
else
@selected
self.cursor_rect.set(index % 5 * 44,index / 5 * 44- self.oy , 43, 42)
end
end
#--------------------------------------------------------------------------
# ● 更新光标举行
#--------------------------------------------------------------------------
#def update_cursor_rect
# 光标位置不满 0 的情况下
#if @index < 0
# self.cursor_rect.empty
# return
# end
# 获取当前的行
# row = @index / @column_max
# 当前行被显示开头行前面的情况下
#if row < self.top_row + 3
# 从当前行向开头行滚动
#self.top_row = row
#self.oy = row * 50
#end
# 当前行被显示末尾行之后的情况下
#if row > self.top_row + (self.page_row_max - 3)
# 从当前行向末尾滚动
#self.top_row = row - (self.page_row_max )
#self.oy = (row_max - 4 ) * 50
#end
# 计算光标的宽
#cursor_width = 50
# 计算光标坐标
#x = index % 6 * 50
#y = index / 6 * 50 - self.oy
# 更新国标矩形
#self.cursor_rect.set(x, y, cursor_width, 50)
#end
#--------------------------------------------------------------------------
# ● 刷新帮助文本
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end