Window_ShopBuy

Publié le par chindan

#============================================
# ¡ Window_ShopBuy
#----------------------------------------------
# @ƒVƒ‡ƒbƒv‰æ–ʂŁAw“ü‚Å‚«‚鏤•i‚̈ꗗ‚𕎦‚·‚éƒEƒBƒ“ƒhƒE‚Å‚·B
#============================================

class Window_ShopBuy < Window_Selectable
#------------------------------------------
# œ ƒIƒuƒWƒFƒNƒg‰Šú‰»
# shop_goods : ¤•i
#------------------------------------------
def initialize(shop_goods)
super(0, 128, 368, 352)
@shop_goods = shop_goods
refresh
self.index = 0
end
#------------------------------------------
# œ ƒAƒCƒeƒ€‚̎擾
#------------------------------------------
def item
return @data[self.index]
end
#------------------------------------------
# œ ƒŠƒtƒŒƒbƒVƒ…
#------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
for goods_item in @shop_goods
case goods_item[0]
when 0
item = $data_items[goods_item[1]]
when 1
item = $data_weapons[goods_item[1]]
when 2
item = $data_armors[goods_item[1]]
end
if item != nil
@data.push(item)
end
end
# €–ڐ”‚ª 0 ‚łȂ¯‚ê‚΃rƒbƒgƒ}ƒbƒv‚ðì¬‚µA‘S€–Ú‚ð•`‰æ
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
for i in 0...@item_max
draw_item(i)
end
end
end
#------------------------------------------
# œ €–Ú‚Ì•`‰æ
# index : €–ڔԍ†
#------------------------------------------
def draw_item(index)
item = @data[index]
# ƒAƒCƒeƒ€‚ÌŠŽ”‚ðŽæ“¾
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
# ‰¿Ši‚ªŠŽ‹àˆÈ‰ºA‚©‚ÂŠŽ”‚ª 99 ‚łȂ¯‚ê‚Βʏ핶ŽšF‚ɁA
# ‚»‚¤‚łȂ¯‚ê‚Ζ³Œø•¶ŽšF‚ɐݒè
if item.price <= $game_party.gold and number < 99
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
x = 4
y = index * 32
rect = Rect.new(x, y, self.width - 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, 212, 32, item.name, 0)
self.contents.draw_text(x + 240, y, 88, 32, item.price.to_s, 2)
end
#------------------------------------------
# œ ƒwƒ‹ƒvƒeƒLƒXƒgXV
#------------------------------------------
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end
Publicité

Publié dans poubelle

Pour être informé des derniers articles, inscrivez vous :
Commenter cet article