class CAO::Dummy_ItemList < Window_ItemList
#--------------------------------------------------------------------------
# ● メソッド定義の取り消し
#--------------------------------------------------------------------------
# undef_method *self.superclass.instance_methods(false)
# def include?(item); super; end
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize
@category = :none
end
#--------------------------------------------------------------------------
# ● カテゴリのアイテム所持数を取得
#--------------------------------------------------------------------------
def count(category)
@category = category
return $game_party.all_items.count {|item| include?(item) }
end
end
class Game_Party
#--------------------------------------------------------------------------
# ● カテゴリのアイテム所持数を取得
#--------------------------------------------------------------------------
def item_count(category)
return CAO::Dummy_ItemList.new.count(category)
end
end
class Game_Interpreter
#--------------------------------------------------------------------------
# ○ ショップの処理
#--------------------------------------------------------------------------
alias _cao_itemchoice_command_302 command_302
def command_302
if $game_message.item_choice_from_goods
goods = [@params]
while next_event_code == 605 @Index += 1
goods.push(@list[@index].parameters)
end
$game_message.item_choice_goods = []
goods.each do |param|
case param[0]
when 0; item = $data_items[param[1]]
when 1; item = $data_weapons[param[1]]
when 2; item = $data_armors[param[1]]
end
$game_message.item_choice_goods.push(item) if item
end
else
_cao_itemchoice_command_302
end
end
end
class Window_ItemList
#--------------------------------------------------------------------------
# ○ アイテムをリストに含めるかどうか
#--------------------------------------------------------------------------
alias _cao_itemchoice_include? include?
def include?(item)
case @category
when String
return item && item.note.include?("<#{@category}>")
when :all
return item != nil
when :all_item
return item.kind_of?(RPG::Item)
when :equip
return item.kind_of?(RPG::Weapon) || item.kind_of?(RPG::Armor)
when :sell
return false if item == nil
return false if item.respond_to?(:key_item?) && item.key_item?
return false if item.price == 0
return true
else
return _cao_itemchoice_include?(item)
end
end
end
class Window_KeyItem
#--------------------------------------------------------------------------
# ◎ オブジェクト解放
#--------------------------------------------------------------------------
def dispose
@help_window.dispose if @help_window
super
end
#--------------------------------------------------------------------------
# ◎ ウィンドウを開く
#--------------------------------------------------------------------------
def open
@help_window.open if @help_window
super
end
#--------------------------------------------------------------------------
# ◎ ウィンドウを閉じる
#--------------------------------------------------------------------------
def close
@help_window.close if @help_window
super
end
#--------------------------------------------------------------------------
# ◎ アイテムリストの作成
#--------------------------------------------------------------------------
alias _cao_itemchoice_make_item_list make_item_list unless $!
def make_item_list
if $game_message.item_choice_show_nothing
if $game_message.item_choice_from_goods
@data = $game_message.item_choice_goods
else
items = $data_items + $data_weapons + $data_armors
@data = items.select {|item| include?(item) }
end
else
if $game_message.item_choice_from_goods
@data = $game_party.all_items & $game_message.item_choice_goods
else
# super
_cao_itemchoice_make_item_list
end
end
create_help_window
end
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def create_help_window
$game_message.item_choice_line ||= CAO::ItemChoice::ITEM_LINE
$game_message.item_choice_help_line ||= CAO::ItemChoice::HELP_LINE
@help_window.dispose if @help_window
if $game_message.item_choice_help_line != 0
self.help_window = Window_Help.new($game_message.item_choice_help_line)
@help_window.openness = 0
@help_window.open
end
self.height = fitting_height($game_message.item_choice_line)
update_placement
end
#--------------------------------------------------------------------------
# ○ アイテムを許可状態で表示するかどうか
#--------------------------------------------------------------------------
def enable?(item)
return true
end
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def variable=(value)
$game_variables[$game_message.item_choice_variable_id] = value
end
#--------------------------------------------------------------------------
# ○ 決定時の処理
#--------------------------------------------------------------------------
def on_ok
if self.item == nil
self.variable = 0
elsif CAO::ItemChoice::PLUS_ID > 0
self.variable = self.item.id
case self.item
when RPG::Weapon
self.variable += CAO::ItemChoice::PLUS_ID
when RPG::Armor
self.variable += CAO::ItemChoice::PLUS_ID * 2
end
else
self.variable = self.item
end
close
end
#--------------------------------------------------------------------------
# ○ キャンセル処理の有効状態を取得
#--------------------------------------------------------------------------
def cancel_enabled?
return false
end
#--------------------------------------------------------------------------
# ◎ フレーム更新
#--------------------------------------------------------------------------
alias _cao_itemchoice_update update unless $!
def update
# super
_cao_itemchoice_update
@help_window.update if @help_window
if open? && self.active && Input.trigger?(:B)
Input.update
if $game_message.item_choice_cancel_disabled
Sound.play_buzzer
else
Sound.play_cancel
deactivate
on_cancel
end
end
end
#--------------------------------------------------------------------------
# ○ ウィンドウ位置の更新
#--------------------------------------------------------------------------
def update_placement
if $game_message.item_choice_help_line == 0
help_height = 0
else
help_height = @help_window.height
end
if CAO::ItemChoice::POS_TOP
if @message_window.close?
self.y = help_height
elsif self.height + help_height < @message_window.y
self.y = help_height
else
self.y = @message_window.y + @message_window.height + help_height
end
else
mbh = Graphics.height - (@message_window.y + @message_window.height)
if @message_window.close?
self.y = Graphics.height - self.height
elsif self.height + help_height < mbh
self.y = Graphics.height - self.height
else
self.y = @message_window.y - self.height
end
end
if $game_message.item_choice_help_line != 0
@help_window.y = self.y - @help_window.height
end
end
#--------------------------------------------------------------------------
# ○ アイテムの個数を描画
#--------------------------------------------------------------------------
alias _cao_itemchoice_draw_item_number draw_item_number
def draw_item_number(rect, item)
return if $game_message.item_choice_hide_number
_cao_itemchoice_draw_item_number(rect, item)
end
end
class Window_Message
#--------------------------------------------------------------------------
# ○ アイテムの選択処理
#--------------------------------------------------------------------------
def input_item
@item_window.start
@item_window.category = ($game_message.item_choice_category || :key_item)
Fiber.yield while @item_window.active
$game_message.clear_item_choice
end
end
[/pre]