#============================================================================== # ■ VXAce-RGSS3-31 和風レイアウト by Claimh #------------------------------------------------------------------------------ # スキル画面変更 #============================================================================== #============================================================================== # ■ Window_SkillCommand #------------------------------------------------------------------------------ #  スキル画面で、コマンド(特技や魔法など)を選択するウィンドウです。 #============================================================================== class Window_J_SkillCommand < Window_J_Command #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_reader :skill_window #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(x, y) super(x, y) @actor = nil end #-------------------------------------------------------------------------- # ● ウィンドウ幅の取得 #-------------------------------------------------------------------------- def window_width fitting_width(visible_line_number) end #-------------------------------------------------------------------------- # ● ウィンドウ幅の取得 #-------------------------------------------------------------------------- def window_height return 120 end #-------------------------------------------------------------------------- # ● アクターの設定 #-------------------------------------------------------------------------- def actor=(actor) return if @actor == actor @actor = actor refresh select_last end #-------------------------------------------------------------------------- # ● 表示行数の取得 #-------------------------------------------------------------------------- def visible_line_number return 4 end #-------------------------------------------------------------------------- # ● コマンドリストの作成 #-------------------------------------------------------------------------- def make_command_list return unless @actor @actor.added_skill_types.sort.each do |stype_id| name = $data_system.skill_types[stype_id] add_command(name, :skill, true, stype_id) end end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update super @skill_window.stype_id = current_ext if @skill_window end #-------------------------------------------------------------------------- # ● スキルウィンドウの設定 #-------------------------------------------------------------------------- def skill_window=(skill_window) @skill_window = skill_window update end #-------------------------------------------------------------------------- # ● 前回の選択位置を復帰 #-------------------------------------------------------------------------- def select_last skill = @actor.last_skill.object if skill select_ext(skill.stype_id) else select(0) end end end #============================================================================== # ■ Window_SkillStatus #------------------------------------------------------------------------------ #  スキル画面で、スキル使用者のステータスを表示するウィンドウです。 #============================================================================== class Window_SkillStatus < Window_Base #-------------------------------------------------------------------------- # ● ウィンドウ幅の取得 #-------------------------------------------------------------------------- def window_width Graphics.width - fitting_height(2) - 120 end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh contents.clear return unless @actor draw_actor_face(@actor, 0, 0) draw_actor_simple_status(@actor, 108, line_height / 2, 90) end end #============================================================================== # ■ Window_J_SkillList #------------------------------------------------------------------------------ #  スキル画面で、使用できるスキルの一覧を表示するウィンドウです。 #============================================================================== class Window_J_SkillList < Window_J_Selectable #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(x, y, width, height) super @actor = nil @stype_id = 0 @data = [] end #-------------------------------------------------------------------------- # ● アクターの設定 #-------------------------------------------------------------------------- def actor=(actor) return if @actor == actor @actor = actor refresh self.oy = 0 end #-------------------------------------------------------------------------- # ● スキルタイプ ID の設定 #-------------------------------------------------------------------------- def stype_id=(stype_id) return if @stype_id == stype_id @stype_id = stype_id refresh self.oy = 0 end #-------------------------------------------------------------------------- # ● 桁数の取得 #-------------------------------------------------------------------------- def col_max return 1 end #-------------------------------------------------------------------------- # ● 項目数の取得 #-------------------------------------------------------------------------- def item_max @data ? @data.size : 1 end #-------------------------------------------------------------------------- # ● スキルの取得 #-------------------------------------------------------------------------- def item @data && index >= 0 ? @data[index] : nil end #-------------------------------------------------------------------------- # ● 選択項目の有効状態を取得 #-------------------------------------------------------------------------- def current_item_enabled? enable?(@data[index]) end #-------------------------------------------------------------------------- # ● スキルをリストに含めるかどうか #-------------------------------------------------------------------------- def include?(item) item && item.stype_id == @stype_id end #-------------------------------------------------------------------------- # ● スキルを許可状態で表示するかどうか #-------------------------------------------------------------------------- def enable?(item) @actor && @actor.usable?(item) end #-------------------------------------------------------------------------- # ● スキルリストの作成 #-------------------------------------------------------------------------- def make_item_list @data = @actor ? @actor.skills.select {|skill| include?(skill) } : [] end #-------------------------------------------------------------------------- # ● 前回の選択位置を復帰 #-------------------------------------------------------------------------- def select_last select(@data.index(@actor.last_skill.object) || 0) end #-------------------------------------------------------------------------- # ● 項目の描画 #-------------------------------------------------------------------------- def draw_item(index) skill = @data[index] if skill rect = item_rect(index) rect.width -= 4 draw_item_name(skill, rect.x, rect.y, enable?(skill)) draw_skill_cost(rect, skill) end end #-------------------------------------------------------------------------- # ● スキルの使用コストを描画 #-------------------------------------------------------------------------- def draw_skill_cost(rect, skill) rect.y = rect.height - line_width rect.height = line_width if @actor.skill_tp_cost(skill) > 0 change_color(tp_cost_color, enable?(skill)) contents.draw_text(rect, @actor.skill_tp_cost(skill), 2) elsif @actor.skill_mp_cost(skill) > 0 change_color(mp_cost_color, enable?(skill)) contents.draw_text(rect, @actor.skill_mp_cost(skill), 2) end end #-------------------------------------------------------------------------- # ● ヘルプテキスト更新 #-------------------------------------------------------------------------- def update_help @help_window.set_item(item) end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh make_item_list create_contents draw_all_items end end #============================================================================== # ■ Scene_Skill #------------------------------------------------------------------------------ #  スキル画面の処理を行うクラスです。処理共通化の便宜上、スキルも「アイテム」 # として扱っています。 #============================================================================== class Scene_Skill < Scene_ItemBase #-------------------------------------------------------------------------- # ● カーソルが左列にあるかの判定 #-------------------------------------------------------------------------- def cursor_left? #~ @item_window.index % 2 == 0 true end #-------------------------------------------------------------------------- # ● ヘルプウィンドウの作成 #-------------------------------------------------------------------------- def create_help_window @help_window = Window_J_Help.new @help_window.viewport = @viewport end #-------------------------------------------------------------------------- # ● コマンドウィンドウの作成 #-------------------------------------------------------------------------- def create_command_window @command_window = Window_J_SkillCommand.new(0, 0) @command_window.x = Graphics.width - @command_window.width @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 @status_window = Window_SkillStatus.new(@help_window.width, 0) @status_window.viewport = @viewport @status_window.actor = @actor end #-------------------------------------------------------------------------- # ● アイテムウィンドウの作成 #-------------------------------------------------------------------------- def create_item_window wx = @help_window.width wy = @status_window.height ww = Graphics.width - wx wh = Graphics.height - wy @item_window = Window_J_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 end