#============================================================================== # ■ XP-RGSS-8-load TitleCustom【ロード】 by Claimh #------------------------------------------------------------------------------ # USE_LOADが有効のときに使用します。 #------------------------------------------------------------------------------ # ロード画面から戻る際にロゴ等を表示されないようにできます。 # 基本的にScene_Loadの処理をそのままコピー #============================================================================== module Title_Custom # ウィンドウ背景の透明度 LOAD_WIN_OP = 128 end class Scene_Title TXT_LOAD = "どのファイルをロードしますか?" #-------------------------------------------------------------------------- # ● ロードフェーズ:総合フレーム更新 #-------------------------------------------------------------------------- def update_phase_load case @local_phase when 0; load_phase_initialize # 準備 when 1; load_phase_update # 操作フレーム更新 when 2; load_phase_terminate # 終了 end title_phase_update_titleback end #-------------------------------------------------------------------------- # ● ロードフェーズ:準備 #-------------------------------------------------------------------------- def load_phase_initialize # Load.initialize # テンポラリオブジェクトを再作成 $game_temp = Game_Temp.new # タイムスタンプが最新のファイルを選択 $game_temp.last_file_index = 0 latest_time = Time.at(0) for i in 0...Title_Custom::SAVE_FILE_MAX filename = save_file(i) if FileTest.exist?(filename) file = File.open(filename, "r") if file.mtime > latest_time latest_time = file.mtime $game_temp.last_file_index = i end file.close end end # initilize # ヘルプウィンドウを作成 @help_window = Window_Help.new @help_window.back_opacity = Title_Custom::LOAD_WIN_OP @help_window.set_text(TXT_LOAD) # セーブファイルウィンドウを作成 @savefile_windows = [] for i in 0..3 @savefile_windows.push(Window_SaveFile.new(i, save_file(i))) @savefile_windows[i].back_opacity = Title_Custom::LOAD_WIN_OP end # 最後に操作したファイルを選択 @file_index = $game_temp.last_file_index @savefile_windows[@file_index].selected = true @local_phase = 1 end #-------------------------------------------------------------------------- # ● ロードフェーズ:操作フレーム更新 #-------------------------------------------------------------------------- def load_phase_update # ウィンドウを更新 @help_window.update for i in @savefile_windows i.update end # C ボタンが押された場合 if Input.trigger?(Input::C) # メソッド on_decision (継承先で定義) を呼ぶ load_phase_on_decision_load(save_file(@file_index)) $game_temp.last_file_index = @file_index return end # B ボタンが押された場合 if Input.trigger?(Input::B) # メソッド on_cancel (継承先で定義) を呼ぶ load_phase_on_cancel return end # 方向ボタンの下が押された場合 if Input.repeat?(Input::DOWN) # 方向ボタンの下の押下状態がリピートでない場合か、 # またはカーソル位置が 3 より前の場合 if Input.trigger?(Input::DOWN) or @file_index < 3 # カーソル SE を演奏 $game_system.se_play($data_system.cursor_se) # カーソルを下に移動 @savefile_windows[@file_index].selected = false @file_index = (@file_index + 1) % 4 @savefile_windows[@file_index].selected = true return end end # 方向ボタンの上が押された場合 if Input.repeat?(Input::UP) # 方向ボタンの上の押下状態がリピートでない場合か、 # またはカーソル位置が 0 より後ろの場合 if Input.trigger?(Input::UP) or @file_index > 0 # カーソル SE を演奏 $game_system.se_play($data_system.cursor_se) # カーソルを上に移動 @savefile_windows[@file_index].selected = false @file_index = (@file_index + 3) % 4 @savefile_windows[@file_index].selected = true return end end end #-------------------------------------------------------------------------- # ● 決定時の処理 [Load] #-------------------------------------------------------------------------- def load_phase_on_decision_load(filename) # ファイルが存在しない場合 unless FileTest.exist?(filename) # ブザー SE を演奏 $game_system.se_play($data_system.buzzer_se) return end # ロード SE を演奏 $game_system.se_play($data_system.load_se) # セーブデータの書き込み file = File.open(filename, "rb") load_phase_read_save_data(file) file.close # BGM、BGS を復帰 $game_system.bgm_play($game_system.playing_bgm) $game_system.bgs_play($game_system.playing_bgs) # マップを更新 (並列イベント実行) $game_map.update # マップ画面に切り替え $scene = Scene_Map.new # 終了 @phase = 0 load_phase_exit end #-------------------------------------------------------------------------- # ● セーブデータの読み込み # file : 読み込み用ファイルオブジェクト (オープン済み) #-------------------------------------------------------------------------- def load_phase_read_save_data(file) # セーブファイル描画用のキャラクターデータを読み込む characters = Marshal.load(file) # プレイ時間計測用のフレームカウントを読み込む Graphics.frame_count = Marshal.load(file) # 各種ゲームオブジェクトを読み込む $game_system = Marshal.load(file) $game_switches = Marshal.load(file) $game_variables = Marshal.load(file) $game_self_switches = Marshal.load(file) $game_screen = Marshal.load(file) $game_actors = Marshal.load(file) $game_party = Marshal.load(file) $game_troop = Marshal.load(file) $game_map = Marshal.load(file) $game_player = Marshal.load(file) # マジックナンバーがセーブ時と異なる場合 # (エディタで編集が加えられている場合) if $game_system.magic_number != $data_system.magic_number # マップをリロード $game_map.setup($game_map.map_id) $game_player.center($game_player.x, $game_player.y) end # パーティメンバーをリフレッシュ $game_party.refresh end #-------------------------------------------------------------------------- # ● ロードフェーズ:キャンセル #-------------------------------------------------------------------------- def load_phase_on_cancel $game_system.se_play($data_system.cancel_se) @phase = PHASE_TITLE load_phase_exit end #-------------------------------------------------------------------------- # ● ロードフェーズ:終了 #-------------------------------------------------------------------------- def load_phase_exit @local_phase = 0 # ウィンドウを解放 @help_window.dispose for i in @savefile_windows i.dispose end end end