#==============================================================================
# ■ 道具操作选项
#------------------------------------------------------------------------------
#
# 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
#
# 作者:protosssonny
#
#==============================================================================
#==============================================================================
# ■ Scene_Item
#------------------------------------------------------------------------------
# 处理物品画面的类。
#==============================================================================
class Scene_Item < Scene_Base
#--------------------------------------------------------------------------
# ● 开始处理
#--------------------------------------------------------------------------
def start
super
create_menu_background
@viewport = Viewport.new(0, 0, 544, 416)
@help_window = Window_Help.new
@help_window.viewport = @viewport
@item_window = Window_Item.new(0, 56, 544, 360)
@item_window.viewport = @viewport
@item_window.help_window = @help_window
@item_window.active = false
@target_window = Window_MenuStatus.new(0, 0)
@item_command_window = Window_Command.new(160, ["使用","丢弃","取消"])
@item_command_window.y = 56
@item_command_window.active = false
@item_command_window.visible = false
hide_target_window
end
#--------------------------------------------------------------------------
# ● 结束处理
#--------------------------------------------------------------------------
def terminate
super
dispose_menu_background
@viewport.dispose
@help_window.dispose
@item_window.dispose
@target_window.dispose
@item_command_window.dispose
end
#--------------------------------------------------------------------------
# ● 回到原画面
#--------------------------------------------------------------------------
def return_scene
$scene = Scene_Menu.new(0)
end
#--------------------------------------------------------------------------
# ● 更新画面
#--------------------------------------------------------------------------
def update
super
update_menu_background
@help_window.update
@item_window.update
@target_window.update
@item_command_window.update
if @item_window.active
update_item_selection
elsif @target_window.active
update_target_selection
elsif @item_command_window.active
update_item_command_selection
end
end
#--------------------------------------------------------------------------
# ● 更新物品选择
#--------------------------------------------------------------------------
def update_item_selection
if Input.trigger?(Input::B)
Sound.play_cancel
return_scene
elsif Input.trigger?(Input::C)
Sound.play_decision
@item_window.active = false
@item_command_window.active = true
@item_command_window.visible = true
end
end
#--------------------------------------------------------------------------
# ● 更新物品选择
#--------------------------------------------------------------------------
def update_item_command_selection
if Input.trigger?(Input::B)
@item_command_window.active = false
@item_command_window.visible = false
@item_window.active = true
Sound.play_cancel
elsif Input.trigger?(Input::C)
case @item_command_window.index
when 0 # 使用
@item = @item_window.item
if @item != nil
$game_party.last_item_id = @item.id
end
if $game_party.item_can_use?(@item)
Sound.play_decision
determine_item
else
Sound.play_buzzer
end
when 1 # 丢弃
@item = @item_window.item
if @item == nil or @item.price == 0
Sound.play_buzzer
else
$game_party.lose_item(@item, 1)
Sound.play_decision
@item_window.refresh
end
when 2 # 取消
@item_command_window.active = false
@item_command_window.visible = false
@item_window.active = true
Sound.play_cancel
end
end
end
#--------------------------------------------------------------------------
# ● 显示目标窗口
# right : 靠又对齐标签(为false时则靠左)
#--------------------------------------------------------------------------
def show_target_window(right)
@item_command_window.active = false
width_remain = 544 - @target_window.width
@target_window.x = right ? width_remain : 0
@target_window.visible = true
@target_window.active = true
if right
@viewport.rect.set(0, 0, width_remain, 416)
@viewport.ox = 0
else
@viewport.rect.set(@target_window.width, 0, width_remain, 416)
@viewport.ox = @target_window.width
end
end
#--------------------------------------------------------------------------
# ● 隐藏目标窗口
#--------------------------------------------------------------------------
def hide_target_window
if @item_command_window.visible
@item_command_window.active = true
else
@item_window.active = true
@item_command_window.index = 0
end
@target_window.visible = false
@target_window.active = false
@viewport.rect.set(0, 0, 544, 416)
@viewport.ox = 0
end
end