=begin RGSS3 ★ セーブ&ロード確認 ★ セーブまたはロードを行う際に確認を行います。 ver1.00 Last Update : 2011/12/17 12/17 : RGSS2からの移植 ろかん   http://kaisou-ryouiki.sakura.ne.jp/ =end #=========================================== # 設定箇所 #=========================================== module Rokan module File_Confirm # セーブを行う際、ヘルプに表示される確認メッセージ SAVE_CONFIRM = "このファイルへセーブします。よろしいですか?" # ロードを行う際、ヘルプに表示される確認メッセージ LORD_CONFIRM = "このファイルをロードします。よろしいですか?" end end #=========================================== # ここまで #=========================================== $rsi ||= {} $rsi["セーブ&ロード確認"] = true class YesNo_Window < Window_Command #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(0, 0) update_placement select_symbol(:cancel) self.openness = 0 self.active = false end #-------------------------------------------------------------------------- # ● ウィンドウ幅の取得 #-------------------------------------------------------------------------- def window_width return 160 end #-------------------------------------------------------------------------- # ● ウィンドウ位置の更新 #-------------------------------------------------------------------------- def update_placement self.x = (Graphics.width - width) / 2 self.y = (Graphics.height - height) / 2 end #-------------------------------------------------------------------------- # ● コマンドリストの作成 #-------------------------------------------------------------------------- def make_command_list add_command("はい", :ok) add_command("いいえ", :cancel) end #-------------------------------------------------------------------------- # ● 決定ボタンが押されたときの処理 #-------------------------------------------------------------------------- def process_ok if current_item_enabled? Input.update deactivate call_ok_handler else Sound.play_buzzer end end #-------------------------------------------------------------------------- # ● ウィンドウのアクティブ化 #-------------------------------------------------------------------------- def activate open super end #-------------------------------------------------------------------------- # ● ウィンドウの非アクティブ化 #-------------------------------------------------------------------------- def deactivate close super end end class Scene_File < Scene_MenuBase #-------------------------------------------------------------------------- # ● 開始処理 #-------------------------------------------------------------------------- alias file_confirm_start start def start file_confirm_start create_command_window end #-------------------------------------------------------------------------- # ● 終了処理 #-------------------------------------------------------------------------- alias file_confirm_terminate terminate def terminate file_confirm_terminate @command_window.dispose end #-------------------------------------------------------------------------- # ● 確認コマンドウィンドウの作成 #-------------------------------------------------------------------------- def create_command_window @command_window = YesNo_Window.new @command_window.set_handler(:ok, method(:on_savefile_ok)) @command_window.set_handler(:cancel, method(:end_fileconfirm_command_selection)) end #-------------------------------------------------------------------------- # ● セーブファイル選択の更新 ※再定義 #-------------------------------------------------------------------------- def update_savefile_selection unless @command_window.active if Input.trigger?(:C) start_fileconfirm_command_selection elsif Input.trigger?(:B) on_savefile_cancel else update_cursor end end end #-------------------------------------------------------------------------- # ● ファイル確認コマンド選択の開始 #-------------------------------------------------------------------------- def start_fileconfirm_command_selection if enable_file? Sound.play_ok update_help_window(true) @command_window.activate else Sound.play_buzzer end end #-------------------------------------------------------------------------- # ● ファイル確認コマンド選択の終了 #-------------------------------------------------------------------------- def end_fileconfirm_command_selection Sound.play_cancel update_help_window @command_window.deactivate @command_window.index = 1 end end class Scene_Save < Scene_File #-------------------------------------------------------------------------- # ● インクルード Rokan::File_Confirm #-------------------------------------------------------------------------- include Rokan::File_Confirm #-------------------------------------------------------------------------- # ● ヘルプウィンドウを更新 #-------------------------------------------------------------------------- def update_help_window(confirm = false) @help_window.set_text(confirm ? SAVE_CONFIRM : help_window_text) end #-------------------------------------------------------------------------- # ● ファイル操作の有効判定 #-------------------------------------------------------------------------- def enable_file? true end end class Scene_Load < Scene_File #-------------------------------------------------------------------------- # ● インクルード Rokan::File_Confirm #-------------------------------------------------------------------------- include Rokan::File_Confirm #-------------------------------------------------------------------------- # ● ヘルプウィンドウを更新 #-------------------------------------------------------------------------- def update_help_window(confirm = false) @help_window.set_text(confirm ? LORD_CONFIRM : help_window_text) end #-------------------------------------------------------------------------- # ● ファイル操作の有効判定 #-------------------------------------------------------------------------- def enable_file? File.exist?(DataManager.make_filename(@index)) end end