class Window_Selectable
alias initialize_old initialize
def initialize(x, y, width, height)
initialize_old(x, y, width, height)
@column_max = 1
end
end
class Window_Help < Window_Base
def initialize
super(0, 0, 640, 64)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
end
end
class Window_Item < Window_Selectable
def initialize
if !$game_temp.in_battle
super(320, 64, 320, 416)
@column_max = 1
refresh
self.index = 0
else
super(0, 64, 640, 416)
@column_max = 2
refresh
self.index = 0
self.y = 64
self.height = 256
self.back_opacity = 160
end
end
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
if !$game_temp.in_battle
x = 4
y = index * 32
else
x = 4 + index % 2 * (288 + 32)
y = index / 2 * 32
end
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
if !$game_temp.in_battle
self.contents.blt(x+256, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x, y, 212, 32, item.name, 0)
self.contents.draw_text(x + 240, y, 16, 32, "|", 1)
else
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, 16, 32, ":", 1)
self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
end
end
end
class Window_Target < Window_Selectable
def initialize
super(0, 0, 336, 480)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
self.z += 10
@item_max = $game_party.actors.size
refresh
end
def refresh
self.contents.clear
for i in 0...$game_party.actors.size
x = 4
y = i * 116
actor = $game_party.actors[i]
draw_actor_name(actor, x, y)
draw_actor_class(actor, x + 144, y)
draw_actor_level(actor, x + 8, y + 32)
draw_actor_state(actor, x + 8, y + 64)
draw_actor_hp(actor, x + 152, y + 32)
draw_actor_sp(actor, x + 152, y + 64)
draw_actor_graphic(actor, x + 80, y + 55)
end
end
end
class Window_Stock < Window_Base
def initialize
super(0, 355,320, 125)
self.contents = Bitmap.new(width - 32, height - 32)
end
def update_stock(item)
self.contents.clear
self.contents.font.name = $fontface
number = $game_party.item_number(item.id)
if item == nil
@price = 0
else
@price = item.price / 2
end
self.contents.draw_text(0,0,168,32, "Stock :", 0)
self.contents.draw_text(200, 0, 24, 32, number.to_s, 2)
self.contents.draw_text(0,40, 320, 32, "Sell Price:",0)
self.contents.draw_text(176, 40, 48, 32, @price.to_s, 2)
end
end
class Scene_Item
def main
@spriteset = Spriteset_Map.new
@help_window = Window_Help.new
@item_window = Window_Item.new
if !$game_temp.in_battle
@stock_window = Window_Stock.new
end
@item_window.help_window = @help_window
@target_window = Window_Target.new
@target_window.visible = false
@target_window.active = false
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
if !$game_temp.in_battle
@stock_window.dispose
end
@spriteset.dispose
@help_window.dispose
@item_window.dispose
@target_window.dispose
end
alias update_old update_item
def update_item
@item = @item_window.item
if !$game_temp.in_battle
@stock_window.update_stock(@item)
end
update_old
end
end