赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 1 |
经验 | 265 |
最后登录 | 2013-2-4 |
在线时间 | 1 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 1 小时
- 注册时间
- 2007-6-23
- 帖子
- 28
|
3楼
楼主 |
发表于 2010-12-25 15:13:20
|
只看该作者
#==============================================================================
# ■ Window_Item
#------------------------------------------------------------------------------
# アイテム画面で、所持アイテムの一覧を表示するウィンドウです。
#==============================================================================
class Harts_Window_ItemList < Window_Selectable
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize
super(170, 160, 460, 180)
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# ● アイテムの取得
#--------------------------------------------------------------------------
def item
return @data[self.index]
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
end
#--------------------------------------------------------------------------
# ● アイテム一覧設定
# command : 選択中のコマンド
#--------------------------------------------------------------------------
def set_item(command)
refresh
case command
when 0
@column_max = $data_items.size
for i in 1...$data_items.size
if $game_party.item_number(i) > 0
@data.push($data_items[i])
end
end
when 1
for i in 1...$data_items.size
if $data_items[i].element_set.include?($data_system.elements.index("音乐类")) and $game_party.item_number(i) > 0
@data.push($data_items[i])
end
end
when 2
for i in 1...$data_items.size
if ($data_items[i].element_set.include?($data_system.elements.index("棋艺类")) and $game_party.item_number(i) > 0)
@data.push($data_items[i])
end
end
when 3
for i in 1...$data_items.size
if ($data_items[i].element_set.include?($data_system.elements.index("书法类")) and $game_party.item_number(i) > 0)
@data.push($data_items[i])
end
end
when 4
for i in 1...$data_items.size
if ($data_items[i].element_set.include?($data_system.elements.index("绘画类")) and $game_party.item_number(i) > 0)
@data.push($data_items[i])
end
end
when 5
for i in 1...$data_items.size
if ($data_items[i].element_set.include?($data_system.elements.index("医药类")) and $game_party.item_number(i) > 0)
@data.push($data_items[i])
end
end
when 6
for i in 1...$data_items.size
if ($data_items[i].element_set.include?($data_system.elements.index("毒药类")) and $game_party.item_number(i) > 0)
@data.push($data_items[i])
end
end
when 7
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
when 8
for i in 1...$data_items.size
if ($data_items[i].element_set.include?($data_system.elements.index("武学类")) and $game_party.item_number(i) > 0)
@data.push($data_items[i])
end
end
when 9
for i in 1...$data_items.size
if ($data_items[i].element_set.include?($data_system.elements.index("园艺类")) and $game_party.item_number(i) > 0)
@data.push($data_items[i])
end
end
when 10
for i in 1...$data_items.size
if ($data_items[i].element_set.include?($data_system.elements.index("食物类")) and $game_party.item_number(i) > 0)
@data.push($data_items[i])
end
end
when 11
for i in 1...$data_items.size
if ($data_items[i].element_set.include?($data_system.elements.index("茶酒类")) and $game_party.item_number(i) > 0)
@data.push($data_items[i])
end
end
when 12
for i in 1...$data_items.size
if ($data_items[i].element_set.include?($data_system.elements.index("其他类")) and $game_party.item_number(i) > 0)
@data.push($data_items[i])
end
end
end
# 項目数が 0 でなければビットマップを作成し、全項目を描画
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width-32, height-32)
self.contents.clear
for i in 0...@item_max
draw_item(i)
end
end
end
#--------------------------------------------------------------------------
# ● 種類別アイテム数の取得
#--------------------------------------------------------------------------
def item_number
return @item_max
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 * 24
y = 2
#self.contents.fill_rect((self.width-64)-index * 24, y, 10, 10, Color.new(0, 0, 0, 0))
self.contents.draw_text2(self.width-56-x-4, y, 50, 800, item.name, 0)
end
#--------------------------------------------------------------------------
# ● ヘルプテキスト更新
#--------------------------------------------------------------------------
def update_cursor_rect
# 光标位置不满 0 的情况下
if @index < 0
self.cursor_rect.empty
return
end
# 获取当前的行
row = @index / @column_max
# 当前行被显示开头行前面的情况下
if row < self.top_row
# 从当前行向开头行滚动
self.top_row = row
end
# 当前行被显示末尾行之后的情况下
if row > self.top_row + (self.page_row_max - 1)
# 从当前行向末尾滚动
self.top_row = row - (self.page_row_max - 1)
end
# 计算光标的宽
cursor_width = self.width / @column_max - 32
cursor_height = self.height - 4
# 计算光标坐标
x = @index * 24
y = 0
# 更新国标矩形
self.cursor_rect.set(self.width-56-x-8, y, 32, cursor_height)
end
#_________________________________________________
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end
其中分类的方法,绘制方法,窗口矩形框刷新都已经重新定义- -
都在这里了,其实我就是想知道横向移动的方法而已,如果有之类的范例也是可以的 |
|