#--------------------------------------------------------------------------
# ● ダミーウィンドウの作成
#--------------------------------------------------------------------------
def create_dummy_window
wy = @help_window.y + @help_window.height + 48
wh = Graphics.height - wy
@dummy_window = Window_Base.new(0, wy, Graphics.width, wh)
@dummy_window.viewport = @viewport
end
#--------------------------------------------------------------------------
# ● 個数入力ウィンドウの作成
#--------------------------------------------------------------------------
def create_number_window
wy = @dummy_window.y
wh = @dummy_window.height
@number_window = Window_ItemSynthesisNumber.new(0, wy, wh)
@number_window.viewport = @viewport
@number_window.hide
@number_window.set_handler(:ok, method(:on_number_ok))
@number_window.set_handler(:cancel, method(:on_number_cancel))
end
#--------------------------------------------------------------------------
# ● ステータスウィンドウの作成
#--------------------------------------------------------------------------
def create_status_window
wx = @number_window.width
wy = @dummy_window.y
ww = Graphics.width - wx
wh = @dummy_window.height
@status_window = Window_ShopStatus.new(wx, wy, ww, wh)
@status_window.viewport = @viewport
@status_window.hide
end
#--------------------------------------------------------------------------
# ● 素材ウィンドウの作成
#--------------------------------------------------------------------------
def create_material_window
wx = @number_window.width
wy = @dummy_window.y
ww = Graphics.width - wx
wh = @dummy_window.height
@material_window = Window_ItemSynthesisMaterial.new(wx, wy, ww, wh)
@material_window.viewport = @viewport
@material_window.hide
@number_window.material_window = @material_window
end
#--------------------------------------------------------------------------
# ● 合成アイテムリストウィンドウの作成
#--------------------------------------------------------------------------
def create_list_window
wy = @dummy_window.y
wh = @dummy_window.height
@list_window = Window_ItemSynthesisList.new(0, wy, wh)
@list_window.viewport = @viewport
@list_window.help_window = @help_window
@list_window.status_window = @status_window
@list_window.material_window = @material_window
@list_window.hide
@list_window.set_handler(:ok, method(:on_list_ok))
@list_window.set_handler(:cancel, method(:on_list_cancel))
@list_window.set_handler(:change_window, method(:on_change_window))
end
#--------------------------------------------------------------------------
# ● カテゴリウィンドウの作成
#--------------------------------------------------------------------------
def create_category_window
@category_window = Window_ItemSynthesisCategory.new
@category_window.viewport = @viewport
@category_window.help_window = @help_window
@category_window.y = @help_window.height
@category_window.activate
@category_window.item_window = @list_window
@category_window.set_handler(:ok, method(:on_category_ok))
@category_window.set_handler(:cancel, method(:return_scene))
end
#--------------------------------------------------------------------------
# ● 合成アイテムリストウィンドウのアクティブ化
#--------------------------------------------------------------------------
def activate_list_window
@list_window.money = money
@list_window.show.activate
end
#--------------------------------------------------------------------------
# ● 合成[決定]
#--------------------------------------------------------------------------
def on_list_ok
@item = @list_window.item
@list_window.hide
@number_window.set(@item, max_buy, buying_price, currency_unit)
@number_window.show.activate
end
#--------------------------------------------------------------------------
# ● 合成[キャンセル]
#--------------------------------------------------------------------------
def on_list_cancel
@category_window.activate
@category_window.show
@dummy_window.show
@list_window.hide
@status_window.hide
@status_window.item = nil
@material_window.hide
@material_window.set(nil, nil)
@gold_window.hide
@change_window.hide
@help_window.clear
end
#--------------------------------------------------------------------------
# ● 表示切替
#--------------------------------------------------------------------------
def on_change_window
if @status_window.visible
@status_window.hide
@material_window.show
else
@status_window.show
@material_window.hide
end
end
#--------------------------------------------------------------------------
# ● カテゴリ[決定]
#--------------------------------------------------------------------------
def on_category_ok
activate_list_window
@gold_window.show
@change_window.show
@material_window.show
@category_window.hide
@list_window.select(0)
end
#--------------------------------------------------------------------------
# ● 個数入力[決定]
#--------------------------------------------------------------------------
def on_number_ok
Sound.play_shop
do_syntetic(@number_window.number)
end_number_input
@gold_window.refresh
end
#--------------------------------------------------------------------------
# ● 個数入力[キャンセル]
#--------------------------------------------------------------------------
def on_number_cancel
Sound.play_cancel
end_number_input
end
#--------------------------------------------------------------------------
# ● 合成の実行
#--------------------------------------------------------------------------
def do_syntetic(number)
$game_party.lose_gold(number * buying_price)
$game_party.gain_item(@item, number)
@recipe = @list_window.recipe(@item)
for i in 1...@recipe.size
kind = @recipe[i][0]
id = @recipe[i][1]
num = @recipe[i][2]
if kind == "I"
item = $data_items[id]
elsif kind == "W"
item = $data_weapons[id]
elsif kind == "A"
item = $data_armors[id]
end
$game_party.lose_item(item, num*number)
end
end
#--------------------------------------------------------------------------
# ● 個数入力の終了
#--------------------------------------------------------------------------
def end_number_input
@number_window.hide
activate_list_window
end
#--------------------------------------------------------------------------
# ● 最大購入可能個数の取得
#--------------------------------------------------------------------------
def max_buy
max = $game_party.max_item_number(@item) - $game_party.item_number(@item)
@recipe = @list_window.recipe(@item)
for i in 1...@recipe.size
kind = @recipe[i][0]
id = @recipe[i][1]
num = @recipe[i][2]
if kind == "I"
item = $data_items[id]
elsif kind == "W"
item = $data_weapons[id]
elsif kind == "A"
item = $data_armors[id]
end
if num > 0
max_buf = $game_party.item_number(item)/num
else
max_buf = 999
end
max = [max, max_buf].min
end
buying_price == 0 ? max : [max, money / buying_price].min
end
# ● ダミーウィンドウの作成
#--------------------------------------------------------------------------
def create_dummy_window
wy = @help_window.y + @help_window.height + 48
wh = Graphics.height - wy
@dummy_window = Window_Base.new(0, wy, Graphics.width, wh)
@dummy_window.viewport = @viewport
end
#--------------------------------------------------------------------------
# ● 個数入力ウィンドウの作成
#--------------------------------------------------------------------------
def create_number_window
wy = @dummy_window.y
wh = @dummy_window.height
@number_window = Window_ItemSynthesisNumber.new(0, wy, wh)
@number_window.viewport = @viewport
@number_window.hide
@number_window.set_handler(:ok, method(:on_number_ok))
@number_window.set_handler(:cancel, method(:on_number_cancel))
end
#--------------------------------------------------------------------------
# ● ステータスウィンドウの作成
#--------------------------------------------------------------------------
def create_status_window
wx = @number_window.width
wy = @dummy_window.y
ww = Graphics.width - wx
wh = @dummy_window.height
@status_window = Window_ShopStatus.new(wx, wy, ww, wh)
@status_window.viewport = @viewport
@status_window.hide
end
#--------------------------------------------------------------------------
# ● 素材ウィンドウの作成
#--------------------------------------------------------------------------
def create_material_window
wx = @number_window.width
wy = @dummy_window.y
ww = Graphics.width - wx
wh = @dummy_window.height
@material_window = Window_ItemSynthesisMaterial.new(wx, wy, ww, wh)
@material_window.viewport = @viewport
@material_window.hide
@number_window.material_window = @material_window
end
#--------------------------------------------------------------------------
# ● 合成アイテムリストウィンドウの作成
#--------------------------------------------------------------------------
def create_list_window
wy = @dummy_window.y
wh = @dummy_window.height
@list_window = Window_ItemSynthesisList.new(0, wy, wh)
@list_window.viewport = @viewport
@list_window.help_window = @help_window
@list_window.status_window = @status_window
@list_window.material_window = @material_window
@list_window.hide
@list_window.set_handler(:ok, method(:on_list_ok))
@list_window.set_handler(:cancel, method(:on_list_cancel))
@list_window.set_handler(:change_window, method(:on_change_window))
end
#--------------------------------------------------------------------------
# ● カテゴリウィンドウの作成
#--------------------------------------------------------------------------
def create_category_window
@category_window = Window_ItemSynthesisCategory.new
@category_window.viewport = @viewport
@category_window.help_window = @help_window
@category_window.y = @help_window.height
@category_window.activate
@category_window.item_window = @list_window
@category_window.set_handler(:ok, method(:on_category_ok))
@category_window.set_handler(:cancel, method(:return_scene))
end
#--------------------------------------------------------------------------
# ● 合成アイテムリストウィンドウのアクティブ化
#--------------------------------------------------------------------------
def activate_list_window
@list_window.money = money
@list_window.show.activate
end
#--------------------------------------------------------------------------
# ● 合成[決定]
#--------------------------------------------------------------------------
def on_list_ok
@item = @list_window.item
@list_window.hide
@number_window.set(@item, max_buy, buying_price, currency_unit)
@number_window.show.activate
end
#--------------------------------------------------------------------------
# ● 合成[キャンセル]
#--------------------------------------------------------------------------
def on_list_cancel
@category_window.activate
@category_window.show
@dummy_window.show
@list_window.hide
@status_window.hide
@status_window.item = nil
@material_window.hide
@material_window.set(nil, nil)
@gold_window.hide
@change_window.hide
@help_window.clear
end
#--------------------------------------------------------------------------
# ● 表示切替
#--------------------------------------------------------------------------
def on_change_window
if @status_window.visible
@status_window.hide
@material_window.show
else
@status_window.show
@material_window.hide
end
end
#--------------------------------------------------------------------------
# ● カテゴリ[決定]
#--------------------------------------------------------------------------
def on_category_ok
activate_list_window
@gold_window.show
@change_window.show
@material_window.show
@category_window.hide
@list_window.select(0)
end
#--------------------------------------------------------------------------
# ● 個数入力[決定]
#--------------------------------------------------------------------------
def on_number_ok
Sound.play_shop
do_syntetic(@number_window.number)
end_number_input
@gold_window.refresh
end
#--------------------------------------------------------------------------
# ● 個数入力[キャンセル]
#--------------------------------------------------------------------------
def on_number_cancel
Sound.play_cancel
end_number_input
end
#--------------------------------------------------------------------------
# ● 合成の実行
#--------------------------------------------------------------------------
def do_syntetic(number)
$game_party.lose_gold(number * buying_price)
$game_party.gain_item(@item, number)
@recipe = @list_window.recipe(@item)
for i in 1...@recipe.size
kind = @recipe[i][0]
id = @recipe[i][1]
num = @recipe[i][2]
if kind == "I"
item = $data_items[id]
elsif kind == "W"
item = $data_weapons[id]
elsif kind == "A"
item = $data_armors[id]
end
$game_party.lose_item(item, num*number)
end
end
#--------------------------------------------------------------------------
# ● 個数入力の終了
#--------------------------------------------------------------------------
def end_number_input
@number_window.hide
activate_list_window
end
#--------------------------------------------------------------------------
# ● 最大購入可能個数の取得
#--------------------------------------------------------------------------
def max_buy
max = $game_party.max_item_number(@item) - $game_party.item_number(@item)
@recipe = @list_window.recipe(@item)
for i in 1...@recipe.size
kind = @recipe[i][0]
id = @recipe[i][1]
num = @recipe[i][2]
if kind == "I"
item = $data_items[id]
elsif kind == "W"
item = $data_weapons[id]
elsif kind == "A"
item = $data_armors[id]
end
if num > 0
max_buf = $game_party.item_number(item)/num
else
max_buf = 999
end
max = [max, max_buf].min
end
buying_price == 0 ? max : [max, money / buying_price].min
end