rebf-gaiden/Scripts/Scene_Skill.rb
2025-04-26 17:06:34 -05:00

108 lines
4.5 KiB
Ruby

#==============================================================================
# ■ Scene_Skill
#------------------------------------------------------------------------------
#  スキル画面の処理を行うクラスです。処理共通化の便宜上、スキルも「アイテム」
# として扱っています。
#==============================================================================
class Scene_Skill < Scene_ItemBase
#--------------------------------------------------------------------------
# ● 開始処理
#--------------------------------------------------------------------------
def start
super
create_help_window
create_command_window
create_status_window
create_item_window
end
#--------------------------------------------------------------------------
# ● コマンドウィンドウの作成
#--------------------------------------------------------------------------
def create_command_window
wy = @help_window.height
@command_window = Window_SkillCommand.new(0, wy)
@command_window.viewport = @viewport
@command_window.help_window = @help_window
@command_window.actor = @actor
@command_window.set_handler(:skill, method(:command_skill))
@command_window.set_handler(:cancel, method(:return_scene))
@command_window.set_handler(:pagedown, method(:next_actor))
@command_window.set_handler(:pageup, method(:prev_actor))
end
#--------------------------------------------------------------------------
# ● ステータスウィンドウの作成
#--------------------------------------------------------------------------
def create_status_window
y = @help_window.height
@status_window = Window_SkillStatus.new(@command_window.width, y)
@status_window.viewport = @viewport
@status_window.actor = @actor
end
#--------------------------------------------------------------------------
# ● アイテムウィンドウの作成
#--------------------------------------------------------------------------
def create_item_window
wx = 0
wy = @status_window.y + @status_window.height
ww = Graphics.width
wh = Graphics.height - wy
@item_window = Window_SkillList.new(wx, wy, ww, wh)
@item_window.actor = @actor
@item_window.viewport = @viewport
@item_window.help_window = @help_window
@item_window.set_handler(:ok, method(:on_item_ok))
@item_window.set_handler(:cancel, method(:on_item_cancel))
@command_window.skill_window = @item_window
end
#--------------------------------------------------------------------------
# ● スキルの使用者を取得
#--------------------------------------------------------------------------
def user
@actor
end
#--------------------------------------------------------------------------
# ● コマンド[スキル]
#--------------------------------------------------------------------------
def command_skill
@item_window.activate
@item_window.select_last
end
#--------------------------------------------------------------------------
# ● アイテム[決定]
#--------------------------------------------------------------------------
def on_item_ok
@actor.last_skill.object = item
determine_item
end
#--------------------------------------------------------------------------
# ● アイテム[キャンセル]
#--------------------------------------------------------------------------
def on_item_cancel
@item_window.unselect
@command_window.activate
end
#--------------------------------------------------------------------------
# ● アイテム使用時の SE 演奏
#--------------------------------------------------------------------------
def play_se_for_item
Sound.play_use_skill
end
#--------------------------------------------------------------------------
# ● アイテムの使用
#--------------------------------------------------------------------------
def use_item
super
@status_window.refresh
@item_window.refresh
end
#--------------------------------------------------------------------------
# ● アクターの切り替え
#--------------------------------------------------------------------------
def on_actor_change
@command_window.actor = @actor
@status_window.actor = @actor
@item_window.actor = @actor
@command_window.activate
end
end