#==============================================================================
# ■ Scene_Shop
#------------------------------------------------------------------------------
# 处理商店画面的类。
#==============================================================================
class Scene_Shop < Scene_Base
#--------------------------------------------------------------------------
# ● 开始处理
#--------------------------------------------------------------------------
def start
super
create_menu_background
create_command_window
@help_window = Window_Help.new
@gold_window = Window_Gold.new(384, 56)
@gold_window.y = 0
@dummy_window = Window_Base.new(0, 56, 608, 424)
@buy_window = Window_ShopBuy.new(0, 56)
@buy_window.active = false
@buy_window.visible = false
@buy_window.help_window = @help_window
@sell_window = NaturalBlue_Window_ItemList.new
@sell_window.active = false
@sell_window.visible = false
@sell_window.help_window = @help_window
@number_window = Window_ShopNumber.new(0, 56)
@number_window.active = false
@number_window.visible = false
@status_window = Window_ShopStatus.new(304, 112)
@status_window.y = 56
@status_window.visible = false
@itemcommand_window = NaturalBlue_Window_ItemCommand.new
@itemcommand_window.y = 56
@itemcommand_window.height = 360
@itemcommand_window.back_opacity = 200
@itemcommand_window.help_window = @help_window
@itemcommand_window.active = false
@itemcommand_window.visible = false
@command_index = @itemcommand_window.index
@sell_window.set_item_sell(@itemcommand_window.commands[@command_index])
end
#--------------------------------------------------------------------------
# ● 结束处理
#--------------------------------------------------------------------------
def terminate
super
dispose_menu_background
dispose_command_window
@help_window.dispose
@gold_window.dispose
@dummy_window.dispose
@buy_window.dispose
@sell_window.dispose
@number_window.dispose
@status_window.dispose
end
#--------------------------------------------------------------------------
# ● 更新画面
#--------------------------------------------------------------------------
def update
super
update_menu_background
@help_window.update
@command_window.update
@gold_window.update
@dummy_window.update
@buy_window.update
@sell_window.update
@number_window.update
@status_window.update
@itemcommand_window.update
@itemcommand_window.refresh
if @command_index != @itemcommand_window.index
@sell_window.index = 0
@command_index = @itemcommand_window.index
@sell_window.set_item_sell(@itemcommand_window.commands[@command_index])
end
@itemcommand_window.update_help
if @command_window.active
update_command_selection
elsif @buy_window.active
update_buy_selection
elsif @itemcommand_window.active
update_itemcommand
elsif @sell_window.active
update_sell_selection
elsif @number_window.active
@help_window.visible = false #我加
update_number_input
end
end
#--------------------------------------------------------------------------
# ● 生成命令窗口
#--------------------------------------------------------------------------
def create_command_window
s1 = Vocab::ShopBuy
s2 = Vocab::ShopSell
s3 = Vocab::ShopCancel
@command_window = Window_Command.new(384, [s1, s2, s3], 3)
@command_window.x = 0 #<--- 新增
@command_window.y = 0
if $game_temp.shop_purchase_only
@command_window.draw_item(1, false)
end
end
#--------------------------------------------------------------------------
# ● 释放命令窗口
#--------------------------------------------------------------------------
def dispose_command_window
@command_window.dispose
end
#--------------------------------------------------------------------------
# ● 更新命令窗口
#--------------------------------------------------------------------------
def update_command_selection
if Input.trigger?(Input::B)
Sound.play_cancel
$scene = Scene_Map.new
elsif Input.trigger?(Input::C)
case @command_window.index
when 0 # 买入
Sound.play_decision
@command_window.active = false
@dummy_window.visible = false
@buy_window.active = true
@buy_window.visible = true
@buy_window.refresh
@status_window.visible = true
when 1 # 卖出
if $game_temp.shop_purchase_only
Sound.play_buzzer
else
Sound.play_decision
@command_window.active = false
@dummy_window.visible = false
@sell_window.active = false
@sell_window.visible = true
@itemcommand_window.active = true
@itemcommand_window.visible = true
@itemcommand_window.refresh
end
when 2 # 离开
Sound.play_decision
$scene = Scene_Map.new
end
end
end
#--------------------------------------------------------------------------
# ● 更新买入选择
#--------------------------------------------------------------------------
def update_buy_selection
@status_window.item = @buy_window.item
@help_window.visible = true
if Input.trigger?(Input::B)
Sound.play_cancel
@command_window.active = true
@dummy_window.visible = true
@buy_window.active = false
@buy_window.visible = false
@status_window.visible = false
@status_window.item = nil
@help_window.visible = false
return
end
if Input.trigger?(Input::C)
@item = @buy_window.item
number = $game_party.item_number(@item)
if @item == nil or @item.price > $game_party.gold or number == 9999
Sound.play_buzzer
else
Sound.play_decision
max = @item.price == 0 ? 9999 : $game_party.gold / @item.price
max = [max, 9999 - number].min
@buy_window.active = false
@buy_window.visible = false
@number_window.set(@item, max, @item.price)
@number_window.active = true
@number_window.visible = true
end
end
end
#--------------------------------------------------------------------------
# ● 更新卖出选择
#--------------------------------------------------------------------------
def update_sell_selection
@help_window.visible = true
if Input.trigger?(Input::B)
Sound.play_cancel
@itemcommand_window.active = true
@sell_window.active = false
@status_window.item = nil
@help_window.visible = false
elsif Input.trigger?(Input::C)
@item = @sell_window.item
@status_window.item = @item
if @item == nil or @item.price == 0
Sound.play_buzzer
else
Sound.play_decision
max = $game_party.item_number(@item)
@sell_window.active = false
@sell_window.visible = false
@itemcommand_window.visible = false
@number_window.set(@item, max, @item.price / 4)
@number_window.active = true
@number_window.visible = true
@status_window.visible = true
end
end
end
#--------------------------------------------------------------------------
# ● 更新数值输入
#--------------------------------------------------------------------------
def update_number_input
if Input.trigger?(Input::B)
cancel_number_input
elsif Input.trigger?(Input::C)
decide_number_input
end
end
#--------------------------------------------------------------------------
# ● 取消数值输入
#--------------------------------------------------------------------------
def cancel_number_input
Sound.play_cancel
@number_window.active = false
@number_window.visible = false
case @command_window.index
when 0 # 买入
@buy_window.active = true
@buy_window.visible = true
when 1 # 卖出
@sell_window.active = true
@sell_window.visible = true
@itemcommand_window.visible = true
@status_window.visible = false
end
end
#--------------------------------------------------------------------------
# ● 确认数值输入,注意,在随机属性里面有再定义
#--------------------------------------------------------------------------
=begin
def decide_number_input
Sound.play_shop
@number_window.active = false
@number_window.visible = false
case @command_window.index
when 0 # 买入
$game_party.lose_gold(@number_window.number * @item.price)
$game_party.gain_item(@item, @number_window.number)
@gold_window.refresh
@buy_window.refresh
@status_window.refresh
@buy_window.active = true
@buy_window.visible = true
when 1 # 卖出
$game_party.gain_gold(@number_window.number * (@item.price / 4))
$game_party.lose_reini(@item, @number_window.number)
@gold_window.refresh
@sell_window.set_item_sell(@itemcommand_window.commands[@command_index])
@status_window.refresh
@sell_window.active = true
@sell_window.visible = true
@status_window.visible = false
@itemcommand_window.visible = true
end
end
=end
#--------------------------------------------------------------------------
# ● 更新物品类型菜单
#--------------------------------------------------------------------------
def update_itemcommand
if Input.trigger?(Input::B)
Sound.play_cancel
@command_window.active = true
@itemcommand_window.active = false
@itemcommand_window.visible = false
@sell_window.visible = false
@dummy_window.visible = true
return
end
if Input.trigger?(Input::C)
if @sell_window.item_number == 0
Sound.play_buzzer
return
end
Sound.play_decision
@itemcommand_window.active = false
@sell_window.index = 0
@sell_window.active = true
return
end
end
end