Code: |
#------------------------------------------------------------------------------ # ■ Save_Max #------------------------------------------------------------------------------ module ExtraConstants NB_SAVE_SLOTS = 20 #change this to change the number of save slots MODE_SLOTS = 0 # change this to 1 if you prefer the other mode. end # Window_SaveFile #------------------------------------------------------------------------------ # セーブ画面およびロード画面で表示する、セーブファイルのウィンドウです。 #============================================================================== class Window_SaveFile < Window_Base #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_reader :filename # ファイル名 attr_reader :selected # 選択状態 #-------------------------------------------------------------------------- # ● オブジェクト初期化 # file_index : セーブファイルのインデックス (0~3) # filename : ファイル名 #-------------------------------------------------------------------------- def initialize(file_index, filename) super(0, 64 + file_index * 104, 640, 104) self.contents = Bitmap.new(width - 32, height - 32) self.contents.font.name = $fontface self.contents.font.size = $fontsize @file_index = file_index @filename = "Save#{@file_index + 1}.rxdata" @game_party_leader = "" #@time_stamp = Time.at(0) @file_exist = FileTest.exist?(@filename) if @file_exist file = File.open(@filename, "r") # @time_stamp = file.mtime @characters = Marshal.load(file) @frame_count = Marshal.load(file) @total_sec = @frame_count / Graphics.frame_rate @game_party = Marshal.load(file) @game_map_name = Marshal.load(file) @game_party_leader = @game_party.actors[0].name file.close end refresh @selected = false rescue file.close @selected = false @file_exist = false @game_party_leader = "Cette sauvegarde est corrompue - Choisissez une autre sauvegarde." refresh end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh self.contents.clear # ファイル番号を描画 self.contents.font.color = normal_color if @game_party_leader == "" name = "File #{@file_index + 1}" else name = "File #{@file_index + 1} : " + @game_party_leader end self.contents.draw_text(4, 0, 600, 32, name) @name_width = contents.text_size(name).width # セーブファイルが存在する場合 if @file_exist # キャラクターを描画 for i in 0... @characters.size bitmap = RPG::Cache.character(@characters[i][0], @characters[i][1]) cw = bitmap.rect.width / 4 ch = bitmap.rect.height / 4 src_rect = Rect.new(0, 0, cw, ch) x = 300 - @characters.size * 32 + i * 64 - cw / 2 self.contents.blt(x, 68 - ch, bitmap, src_rect) end # プレイ時間を描画 hour = @total_sec / 60 / 60 min = @total_sec / 60 % 60 sec = @total_sec % 60 time_string = sprintf("%02d:%02d:%02d", hour, min, sec) self.contents.font.color = normal_color self.contents.draw_text(4, 8, 600, 32, time_string, 2) # タイムスタンプを描画 self.contents.font.color = normal_color self.contents.draw_text(4, 40, 600, 32, @game_map_name, 2) end end #-------------------------------------------------------------------------- # ● 選択状態の設定 # selected : 新しい選択状態 (true=選択 false=非選択 #-------------------------------------------------------------------------- def selected=(selected) @selected = selected update_cursor_rect end #-------------------------------------------------------------------------- # ● カーソルの矩形更新 #-------------------------------------------------------------------------- def update_cursor_rect if @selected self.cursor_rect.set(0, 0, @name_width + 8, 32) else self.cursor_rect.empty end end end #====================================================#========================== # ■ Scene_Save #------------------------------------------------------------------------------ # セーブ画面の処理を行うクラスです。 #====================================================#========================== class Scene_Save < Scene_File # ----------------------------- def initialize super("Voulez vous sauvegarder la partie ?") @confirm_window = Window_Base.new(120, 188, 400, 64) @confirm_window.contents = Bitmap.new(368, 32) string = "Voulez vous remplacer cette sauvegarde ?" @confirm_window.contents.font.name = "Arial" @confirm_window.contents.font.size = $fontsize @confirm_window.contents.draw_text(4, 0, 368, 32, string) @yes_no_window = Window_Command.new(100, ["Oui", "Non"]) @confirm_window.visible = false @confirm_window.z = 1500 @yes_no_window.visible = false @yes_no_window.active = false @yes_no_window.index = 1 @yes_no_window.x = 270 @yes_no_window.y = 252 @yes_no_window.z = 1500 @mode = 0 end # ----------------------------- def on_decision(filename) if FileTest.exist?(filename) @confirm_window.visible = true @yes_no_window.visible = true @yes_no_window.active = true @mode = 1 else $game_system.se_play($data_system.save_se) file = File.open(filename, "wb") write_save_data(file) file.close if $game_temp.save_calling $game_temp.save_calling = false $scene = Scene_Map.new return end $scene = Scene_Menu.new(4) end end # ----------------------------- def update if @mode == 0 super else @help_window.update @yes_no_window.update if Input.trigger?(Input::C) $game_system.se_play($data_system.decision_se) if @yes_no_window.index == 0 filename = make_filename(@file_index) $game_system.se_play($data_system.save_se) file = File.open(filename, "wb") write_save_data(file) file.close if $game_temp.save_calling $game_temp.save_calling = false $scene = Scene_Map.new else $scene = Scene_Menu.new(4) end else @confirm_window.visible = false @yes_no_window.visible = false @yes_no_window.active = false @yes_no_window.index = 1 @mode = 0 end end if Input.trigger?(Input::B) @confirm_window.visible = false @yes_no_window.visible = false @yes_no_window.active = false @yes_no_window.index = 1 @mode = 0 return end end end # ----------------------------- def on_cancel $game_system.se_play($data_system.cancel_se) if $game_temp.save_calling $game_temp.save_calling = false $scene = Scene_Map.new return end $scene = Scene_Menu.new(4) end # ----------------------------- def write_save_data(file) characters = [] for i in 0...$game_party.actors.size actor = $game_party.actors[i] characters.push([actor.character_name, actor.character_hue]) end Marshal.dump(characters, file) Marshal.dump(Graphics.frame_count, file) $game_system.save_count += 1 $game_system.magic_number = $data_system.magic_number Marshal.dump($game_party, file) Marshal.dump($game_map.name, file) Marshal.dump($game_system, file) Marshal.dump($game_switches, file) Marshal.dump($game_variables, file) Marshal.dump($game_self_switches, file) Marshal.dump($game_screen, file) Marshal.dump($game_actors, file) Marshal.dump($game_map, file) Marshal.dump($game_troop, file) Marshal.dump($game_player, file) end end #============================================================================== # ■ Scene_Load #------------------------------------------------------------------------------ # ロード画面の処理を行うクラスです。 #============================================================================== class Scene_Load < Scene_File #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize # テンポラリオブジェクトを再作成 $game_temp = Game_Temp.new # タイムスタンプが最新のファイルを選択 $game_temp.last_file_index = 0 latest_time = Time.at(0) for i in 0..NB_SAVE_SLOTS-1 filename = make_filename(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 super("Charger quelle partie ?") end #-------------------------------------------------------------------------- # ● 決定時の処理 #-------------------------------------------------------------------------- def on_decision(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") 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 end #-------------------------------------------------------------------------- # ● キャンセル時の処理 #-------------------------------------------------------------------------- def on_cancel # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) # タイトル画面に切り替え $scene = Scene_Title.new end #-------------------------------------------------------------------------- # ● セーブデータの読み込み # file : 読み込み用ファイルオブジェクト (オープン済み #-------------------------------------------------------------------------- def read_save_data(file) characters = Marshal.load(file) Graphics.frame_count = Marshal.load(file) $game_party = Marshal.load(file) @game_map_name = 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_map = Marshal.load(file) $game_troop = 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 end #============================================================================== # ■ Scene_File #------------------------------------------------------------------------------ # セーブ画面およびロード画面のスーパークラスです。 #============================================================================== class Scene_File include ExtraConstants def initialize(help_text) @help_text = help_text @first_window @last_window @top_window @bottom_window end #-------------------------------------------------------------------------- # ● メイン処理 #-------------------------------------------------------------------------- def main # ヘルプウィンドウを作成 @help_window = Window_Help.new @help_window.set_text(@help_text) @top_window = 0 @bottom_window = NB_SAVE_SLOTS-1 @savefile_windows = [] for i in 0..NB_SAVE_SLOTS-1 @savefile_windows.push(Window_SaveFile.new(i, make_filename(i))) if i == 0 then @first_window = i elsif i == 3 then @last_window = i end end # 最後に操作したファイルを選択 @file_index = $game_temp.last_file_index if @file_index > NB_SAVE_SLOTS-1 then @file_index = 0 end @savefile_windows[@file_index].selected = true if @file_index >3 then @last_window = @file_index @first_window = @file_index - 3 for i in 0... @savefile_windows.size @savefile_windows[i].y = @savefile_windows[i].y - (104 * (@file_index- 3) ) if i < @first_window then @savefile_windows[i].visible = false end end end # トランジション実行 Graphics.transition # メインループ loop do # ゲーム画面を更新 Graphics.update # 入力情報を更新 Input.update # フレーム更新 update # 画面が切り替わったらループを中断 if $scene != self break end end # トランジション準備 Graphics.freeze # ウィンドウを解放 @help_window.dispose for i in @savefile_windows i.dispose end if self.is_a?(Scene_Save) @confirm_window.dispose @yes_no_window.dispose end end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update # ウィンドウを更新 @help_window.update for i in @savefile_windows i.update end # C ボタンが押された場合 if Input.trigger?(Input::C) # メソッド on_decision (継承先で定義 を呼ぶ on_decision(make_filename(@file_index)) $game_temp.last_file_index = @file_index return end # B ボタンが押された場合 if Input.trigger?(Input::B) # メソッド on_cancel (継承先で定義 を呼ぶ on_cancel return end if Input.repeat?(Input:: DOWN) or Input.trigger?(Input:: DOWN) # 方向ボタンの下の押下状態がリピートでない場合か、 # またはカーソル位置が 3 より前の場合 ### if @file_index == @last_window and @file_index == @bottom_window if MODE_SLOTS == 1 then $game_system.se_play($data_system.buzzer_se) return elsif NB_SAVE_SLOTS < 5 then @savefile_windows[@file_index].selected = false @file_index = 0 @savefile_windows[@file_index].selected = true $game_system.se_play($data_system.cursor_se) return end @savefile_windows[@top_window].y = @savefile_windows[@bottom_window].y + 104 @top_window = @top_window + 1 @bottom_window = @bottom_window + 1 if @bottom_window == NB_SAVE_SLOTS then @bottom_window = 0 end if @top_window == NB_SAVE_SLOTS then @top_window = 0 end end if @file_index == @last_window for i in @savefile_windows i.y = i.y - 104 end $game_system.se_play($data_system.cursor_se) @savefile_windows[@file_index].selected = false @savefile_windows[@first_window].visible = false @file_index = @file_index + 1 if @file_index == NB_SAVE_SLOTS then @file_index = 0 end @savefile_windows[@file_index].selected = true @savefile_windows[@file_index].visible = true @first_window = @first_window + 1 @last_window = @last_window + 1 if @last_window == NB_SAVE_SLOTS then @last_window = 0 end if @first_window == NB_SAVE_SLOTS then @first_window = 0 end else # カーソル SE を演奏 $game_system.se_play($data_system.cursor_se) # カーソルを下に移動 @savefile_windows[@file_index].selected = false @file_index = @file_index + 1 if @file_index == NB_SAVE_SLOTS then @file_index = 0 end @savefile_windows[@file_index].selected = true @savefile_windows[@file_index].visible = true return end end if Input.repeat?(Input::UP) or Input.trigger?(Input::UP) if @file_index == @first_window and @file_index == @top_window if MODE_SLOTS == 1 then $game_system.se_play($data_system.buzzer_se) return elsif NB_SAVE_SLOTS < 5 then @savefile_windows[@file_index].selected = false @file_index = NB_SAVE_SLOTS - 1 @savefile_windows[@file_index].selected = true $game_system.se_play($data_system.cursor_se) return end @savefile_windows[@bottom_window].y = @savefile_windows[@top_window].y - 104 @top_window = @top_window - 1 @bottom_window = @bottom_window - 1 if @bottom_window == -1 then @bottom_window = NB_SAVE_SLOTS-1 end if @top_window == -1 then @top_window = NB_SAVE_SLOTS-1 end end if @file_index == @first_window for i in @savefile_windows i.y = i.y + 104 end $game_system.se_play($data_system.cursor_se) @savefile_windows[@file_index].selected = false @file_index = @file_index - 1 if @file_index == -1 then @file_index = NB_SAVE_SLOTS-1 end @savefile_windows[@file_index].selected = true @savefile_windows[@file_index].visible = true @first_window = @first_window - 1 @last_window = @last_window - 1 if @last_window == -1 then @last_window = NB_SAVE_SLOTS - 1 end if @first_window == -1 then @first_window = NB_SAVE_SLOTS-1 end else # カーソル SE を演奏 $game_system.se_play($data_system.cursor_se) # カーソルを下に移動 @savefile_windows[@file_index].selected = false @file_index = @file_index - 1 if @file_index == -1 then @file_index = NB_SAVE_SLOTS - 1 end @savefile_windows[@file_index].selected = true @savefile_windows[@file_index].visible = true return end end end #-------------------------------------------------------------------------- # ● ファイル名の作成 # file_index : セーブファイルのインデックス (0~3) #-------------------------------------------------------------------------- def make_filename(file_index) return "Save#{file_index + 1}.rxdata" end end #============================================================================== # Game_Map #============================================================================== class Game_Map #-------------------------------------------------------------------------- def name $map_infos[@map_id] end end #============================================================================== # Scene_Title #============================================================================== class Scene_Title #-------------------------------------------------------------------------- include ExtraConstants def main $map_infos = load_data("Data/MapInfos.rxdata") for key in $map_infos.keys $map_infos[key] = $map_infos[key].name end # 戦闘テストの場合 if $BTEST battle_test return end # データベースをロード $data_actors = load_data("Data/Actors.rxdata") $data_classes = load_data("Data/Classes.rxdata") $data_skills = load_data("Data/Skills.rxdata") $data_items = load_data("Data/Items.rxdata") $data_weapons = load_data("Data/Weapons.rxdata") $data_armors = load_data("Data/Armors.rxdata") $data_enemies = load_data("Data/Enemies.rxdata") $data_troops = load_data("Data/Troops.rxdata") $data_states = load_data("Data/States.rxdata") $data_animations = load_data("Data/Animations.rxdata") $data_tilesets = load_data("Data/Tilesets.rxdata") $data_common_events = load_data("Data/CommonEvents.rxdata") $data_system = load_data("Data/System.rxdata") # システムオブジェクトを作成 $game_system = Game_System.new # タイトルグラフィックを作成 @sprite = Sprite.new @sprite.bitmap = RPG::Cache.title($data_system.title_name) # コマンドウィンドウを作成 s1 = "New Game" s2 = "Continue" s3 = "Shutdown" @command_window = Window_Command.new(192, [s1, s2, s3]) @command_window.back_opacity = 160 @command_window.x = 320 - @command_window.width / 2 @command_window.y = 288 # コンティニュー有効判定 # セーブファイルがひとつでも存在するかどうかを調べる # 有効なら @continue_enabled を true、無効なら false にする @continue_enabled = false for i in 0..NB_SAVE_SLOTS if FileTest.exist?("Save#{i+1}.rxdata") @continue_enabled = true end end # コンティニューが有効な場合、カーソルをコンティニューに合わせる # 無効な場合、コンティニューの文字をグレー表示にする if @continue_enabled @command_window.index = 1 else @command_window.disable_item(1) end # タイトル BGM を演奏 $game_system.bgm_play($data_system.title_bgm) # ME、BGS の演奏を停止 Audio.me_stop Audio.bgs_stop # トランジション実行 Graphics.transition # メインループ loop do # ゲーム画面を更新 Graphics.update # 入力情報を更新 Input.update # フレーム更新 update # 画面が切り替わったらループを中断 if $scene != self break end end # トランジション準備 Graphics.freeze # コマンドウィンドウを解放 @command_window.dispose # タイトルグラフィックを解放 @sprite.bitmap.dispose @sprite.dispose end end |
Code: |
NB_SAVE_SLOTS = 20 |
Code: |
#------------------------------------------------------------------------------ # ■ Save_Max #------------------------------------------------------------------------------ module ExtraConstants NB_SAVE_SLOTS = 20 #change this to change the number of save slots MODE_SLOTS = 0 # change this to 1 if you prefer the other mode. end # Window_SaveFile #------------------------------------------------------------------------------ # セーブ画面およびロード画面で表示する、セーブファイルのウィンドウです。 #============================================================================== class Window_SaveFile < Window_Base #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_reader :filename # ファイル名 attr_reader :selected # 選択状態 #-------------------------------------------------------------------------- # ● オブジェクト初期化 # file_index : セーブファイルのインデックス (0~3) # filename : ファイル名 #-------------------------------------------------------------------------- def initialize(file_index, filename) super(0, 64 + file_index * 104, 640, 104) self.contents = Bitmap.new(width - 32, height - 32) self.contents.font.name = $fontface self.contents.font.size = $fontsize @file_index = file_index @filename = "Save#{@file_index + 1}.rxdata" @game_party_leader = "" #@time_stamp = Time.at(0) @file_exist = FileTest.exist?(@filename) if @file_exist file = File.open(@filename, "r") # @time_stamp = file.mtime @characters = Marshal.load(file) @frame_count = Marshal.load(file) @total_sec = @frame_count / Graphics.frame_rate @game_party = Marshal.load(file) @game_map_name = Marshal.load(file) @game_party_leader = @game_party.actors[0].name file.close end refresh @selected = false rescue file.close @selected = false @file_exist = false @game_party_leader = "Cette sauvegarde est corrompue - Choisissez une autre sauvegarde." refresh end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh self.contents.clear # ファイル番号を描画 self.contents.font.color = normal_color if @game_party_leader == "" name = "File #{@file_index + 1}" else name = "File #{@file_index + 1} : " + @game_party_leader end self.contents.draw_text(4, 0, 600, 32, name) @name_width = contents.text_size(name).width # セーブファイルが存在する場合 if @file_exist # キャラクターを描画 for i in [url=mailto:0...@characters.size]0...@characters.size[/url] bitmap = RPG::Cache.character(@characters[i][0], @characters[i][1]) cw = bitmap.rect.width / 4 ch = bitmap.rect.height / 4 src_rect = Rect.new(0, 0, cw, ch) x = 300 - @characters.size * 32 + i * 64 - cw / 2 self.contents.blt(x, 68 - ch, bitmap, src_rect) end # プレイ時間を描画 hour = @total_sec / 60 / 60 min = @total_sec / 60 % 60 sec = @total_sec % 60 time_string = sprintf("%02d:%02d:%02d", hour, min, sec) self.contents.font.color = normal_color self.contents.draw_text(4, 8, 600, 32, time_string, 2) # タイムスタンプを描画 self.contents.font.color = normal_color self.contents.draw_text(4, 40, 600, 32, @game_map_name, 2) end end #-------------------------------------------------------------------------- # ● 選択状態の設定 # selected : 新しい選択状態 (true=選択 false=非選択 #-------------------------------------------------------------------------- def selected=(selected) @selected = selected update_cursor_rect end #-------------------------------------------------------------------------- # ● カーソルの矩形更新 #-------------------------------------------------------------------------- def update_cursor_rect if @selected self.cursor_rect.set(0, 0, @name_width + 8, 32) else self.cursor_rect.empty end end end #====================================================#========================== # ■ Scene_Save #------------------------------------------------------------------------------ # セーブ画面の処理を行うクラスです。 #====================================================#========================== class Scene_Save < Scene_File # ----------------------------- def initialize super("Voulez vous sauvegarder la partie ?") @confirm_window = Window_Base.new(120, 188, 400, 64) @confirm_window.contents = Bitmap.new(368, 32) string = "Voulez vous remplacer cette sauvegarde ?" @confirm_window.contents.font.name = "Arial" @confirm_window.contents.font.size = $fontsize @confirm_window.contents.draw_text(4, 0, 368, 32, string) @yes_no_window = Window_Command.new(100, ["Oui", "Non"]) @confirm_window.visible = false @confirm_window.z = 1500 @yes_no_window.visible = false @yes_no_window.active = false @yes_no_window.index = 1 @yes_no_window.x = 270 @yes_no_window.y = 252 @yes_no_window.z = 1500 @mode = 0 end # ----------------------------- def on_decision(filename) if FileTest.exist?(filename) @confirm_window.visible = true @yes_no_window.visible = true @yes_no_window.active = true @mode = 1 else $game_system.se_play($data_system.save_se) file = File.open(filename, "wb") write_save_data(file) file.close if $game_temp.save_calling $game_temp.save_calling = false $scene = Scene_Map.new return end $scene = Scene_Menu.new(4) end end # ----------------------------- def update if @mode == 0 super else @help_window.update @yes_no_window.update if Input.trigger?(Input::C) $game_system.se_play($data_system.decision_se) if @yes_no_window.index == 0 filename = make_filename(@file_index) $game_system.se_play($data_system.save_se) file = File.open(filename, "wb") write_save_data(file) file.close if $game_temp.save_calling $game_temp.save_calling = false $scene = Scene_Map.new else $scene = Scene_Menu.new(4) end else @confirm_window.visible = false @yes_no_window.visible = false @yes_no_window.active = false @yes_no_window.index = 1 @mode = 0 end end if Input.trigger?(Input::B) @confirm_window.visible = false @yes_no_window.visible = false @yes_no_window.active = false @yes_no_window.index = 1 @mode = 0 return end end end # ----------------------------- def on_cancel $game_system.se_play($data_system.cancel_se) if $game_temp.save_calling $game_temp.save_calling = false $scene = Scene_Map.new return end $scene = Scene_Menu.new(4) end # ----------------------------- def write_save_data(file) characters = [] for i in 0...$game_party.actors.size actor = $game_party.actors[i] characters.push([actor.character_name, actor.character_hue]) end Marshal.dump(characters, file) Marshal.dump(Graphics.frame_count, file) $game_system.save_count += 1 $game_system.magic_number = $data_system.magic_number Marshal.dump($game_party, file) Marshal.dump($game_map.name, file) Marshal.dump($game_system, file) Marshal.dump($game_switches, file) Marshal.dump($game_variables, file) Marshal.dump($game_self_switches, file) Marshal.dump($game_screen, file) Marshal.dump($game_actors, file) Marshal.dump($game_map, file) Marshal.dump($game_troop, file) Marshal.dump($game_player, file) end end #============================================================================== # ■ Scene_Load #------------------------------------------------------------------------------ # ロード画面の処理を行うクラスです。 #============================================================================== class Scene_Load < Scene_File #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize # テンポラリオブジェクトを再作成 $game_temp = Game_Temp.new # タイムスタンプが最新のファイルを選択 $game_temp.last_file_index = 0 latest_time = Time.at(0) for i in 0..NB_SAVE_SLOTS-1 filename = make_filename(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 super("Charger quelle partie ?") end #-------------------------------------------------------------------------- # ● 決定時の処理 #-------------------------------------------------------------------------- def on_decision(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") 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 end #-------------------------------------------------------------------------- # ● キャンセル時の処理 #-------------------------------------------------------------------------- def on_cancel # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) # タイトル画面に切り替え $scene = Scene_Title.new end #-------------------------------------------------------------------------- # ● セーブデータの読み込み # file : 読み込み用ファイルオブジェクト (オープン済み #-------------------------------------------------------------------------- def read_save_data(file) characters = Marshal.load(file) Graphics.frame_count = Marshal.load(file) $game_party = Marshal.load(file) @game_map_name = 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_map = Marshal.load(file) $game_troop = 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 end #============================================================================== # ■ Scene_File #------------------------------------------------------------------------------ # セーブ画面およびロード画面のスーパークラスです。 #============================================================================== class Scene_File include ExtraConstants def initialize(help_text) @help_text = help_text @first_window @last_window @top_window @bottom_window end #-------------------------------------------------------------------------- # ● メイン処理 #-------------------------------------------------------------------------- def main # ヘルプウィンドウを作成 @help_window = Window_Help.new @help_window.set_text(@help_text) @top_window = 0 @bottom_window = NB_SAVE_SLOTS-1 @savefile_windows = [] for i in 0..NB_SAVE_SLOTS-1 @savefile_windows.push(Window_SaveFile.new(i, make_filename(i))) if i == 0 then @first_window = i elsif i == 3 then @last_window = i end end # 最後に操作したファイルを選択 @file_index = $game_temp.last_file_index if @file_index > NB_SAVE_SLOTS-1 then @file_index = 0 end @savefile_windows[@file_index].selected = true if @file_index >3 then @last_window = @file_index @first_window = @file_index - 3 for i in [url=mailto:0...@savefile_windows.size]0...@savefile_windows.size[/url] @savefile_windows[i].y = @savefile_windows[i].y - (104 * (@file_index- 3) ) if i < @first_window then @savefile_windows[i].visible = false end end end # トランジション実行 Graphics.transition # メインループ loop do # ゲーム画面を更新 Graphics.update # 入力情報を更新 Input.update # フレーム更新 update # 画面が切り替わったらループを中断 if $scene != self break end end # トランジション準備 Graphics.freeze # ウィンドウを解放 @help_window.dispose for i in @savefile_windows i.dispose end if self.is_a?(Scene_Save) @confirm_window.dispose @yes_no_window.dispose end end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update # ウィンドウを更新 @help_window.update for i in @savefile_windows i.update end # C ボタンが押された場合 if Input.trigger?(Input::C) # メソッド on_decision (継承先で定義 を呼ぶ on_decision(make_filename(@file_index)) $game_temp.last_file_index = @file_index return end # B ボタンが押された場合 if Input.trigger?(Input::B) # メソッド on_cancel (継承先で定義 を呼ぶ on_cancel return end if Input.repeat?(Input:: DOWN) or Input.trigger?(Input:: DOWN) # 方向ボタンの下の押下状態がリピートでない場合か、 # またはカーソル位置が 3 より前の場合 ### if @file_index == @last_window and @file_index == @bottom_window if MODE_SLOTS == 1 then $game_system.se_play($data_system.buzzer_se) return elsif NB_SAVE_SLOTS < 5 then @savefile_windows[@file_index].selected = false @file_index = 0 @savefile_windows[@file_index].selected = true $game_system.se_play($data_system.cursor_se) return end @savefile_windows[@top_window].y = @savefile_windows[@bottom_window].y + 104 @top_window = @top_window + 1 @bottom_window = @bottom_window + 1 if @bottom_window == NB_SAVE_SLOTS then @bottom_window = 0 end if @top_window == NB_SAVE_SLOTS then @top_window = 0 end end if @file_index == @last_window for i in @savefile_windows i.y = i.y - 104 end $game_system.se_play($data_system.cursor_se) @savefile_windows[@file_index].selected = false @savefile_windows[@first_window].visible = false @file_index = @file_index + 1 if @file_index == NB_SAVE_SLOTS then @file_index = 0 end @savefile_windows[@file_index].selected = true @savefile_windows[@file_index].visible = true @first_window = @first_window + 1 @last_window = @last_window + 1 if @last_window == NB_SAVE_SLOTS then @last_window = 0 end if @first_window == NB_SAVE_SLOTS then @first_window = 0 end else # カーソル SE を演奏 $game_system.se_play($data_system.cursor_se) # カーソルを下に移動 @savefile_windows[@file_index].selected = false @file_index = @file_index + 1 if @file_index == NB_SAVE_SLOTS then @file_index = 0 end @savefile_windows[@file_index].selected = true @savefile_windows[@file_index].visible = true return end end if Input.repeat?(Input::UP) or Input.trigger?(Input::UP) if @file_index == @first_window and @file_index == @top_window if MODE_SLOTS == 1 then $game_system.se_play($data_system.buzzer_se) return elsif NB_SAVE_SLOTS < 5 then @savefile_windows[@file_index].selected = false @file_index = NB_SAVE_SLOTS - 1 @savefile_windows[@file_index].selected = true $game_system.se_play($data_system.cursor_se) return end @savefile_windows[@bottom_window].y = @savefile_windows[@top_window].y - 104 @top_window = @top_window - 1 @bottom_window = @bottom_window - 1 if @bottom_window == -1 then @bottom_window = NB_SAVE_SLOTS-1 end if @top_window == -1 then @top_window = NB_SAVE_SLOTS-1 end end if @file_index == @first_window for i in @savefile_windows i.y = i.y + 104 end $game_system.se_play($data_system.cursor_se) @savefile_windows[@file_index].selected = false @file_index = @file_index - 1 if @file_index == -1 then @file_index = NB_SAVE_SLOTS-1 end @savefile_windows[@file_index].selected = true @savefile_windows[@file_index].visible = true @first_window = @first_window - 1 @last_window = @last_window - 1 if @last_window == -1 then @last_window = NB_SAVE_SLOTS - 1 end if @first_window == -1 then @first_window = NB_SAVE_SLOTS-1 end else # カーソル SE を演奏 $game_system.se_play($data_system.cursor_se) # カーソルを下に移動 @savefile_windows[@file_index].selected = false @file_index = @file_index - 1 if @file_index == -1 then @file_index = NB_SAVE_SLOTS - 1 end @savefile_windows[@file_index].selected = true @savefile_windows[@file_index].visible = true return end end end #-------------------------------------------------------------------------- # ● ファイル名の作成 # file_index : セーブファイルのインデックス (0~3) #-------------------------------------------------------------------------- def make_filename(file_index) return "Save#{file_index + 1}.rxdata" end end #============================================================================== # Game_Map #============================================================================== class Game_Map #-------------------------------------------------------------------------- def name $map_infos[@map_id] end end #============================================================================== # Scene_Title #============================================================================== class Scene_Title #-------------------------------------------------------------------------- include ExtraConstants def main $map_infos = load_data("Data/MapInfos.rxdata") for key in $map_infos.keys $map_infos[key] = $map_infos[key].name end # 戦闘テストの場合 if $BTEST battle_test return end # データベースをロード $data_actors = load_data("Data/Actors.rxdata") $data_classes = load_data("Data/Classes.rxdata") $data_skills = load_data("Data/Skills.rxdata") $data_items = load_data("Data/Items.rxdata") $data_weapons = load_data("Data/Weapons.rxdata") $data_armors = load_data("Data/Armors.rxdata") $data_enemies = load_data("Data/Enemies.rxdata") $data_troops = load_data("Data/Troops.rxdata") $data_states = load_data("Data/States.rxdata") $data_animations = load_data("Data/Animations.rxdata") $data_tilesets = load_data("Data/Tilesets.rxdata") $data_common_events = load_data("Data/CommonEvents.rxdata") $data_system = load_data("Data/System.rxdata") # システムオブジェクトを作成 $game_system = Game_System.new # タイトルグラフィックを作成 @sprite = Sprite.new @sprite.bitmap = RPG::Cache.title($data_system.title_name) # コマンドウィンドウを作成 s1 = "New Game" s2 = "Continue" s3 = "Shutdown" @command_window = Window_Command.new(192, [s1, s2, s3]) @command_window.back_opacity = 160 @command_window.x = 320 - @command_window.width / 2 @command_window.y = 288 # コンティニュー有効判定 # セーブファイルがひとつでも存在するかどうかを調べる # 有効なら @continue_enabled を true、無効なら false にする @continue_enabled = false for i in 0..NB_SAVE_SLOTS if FileTest.exist?("Save#{i+1}.rxdata") @continue_enabled = true end end # コンティニューが有効な場合、カーソルをコンティニューに合わせる # 無効な場合、コンティニューの文字をグレー表示にする if @continue_enabled @command_window.index = 1 else @command_window.disable_item(1) end # タイトル BGM を演奏 $game_system.bgm_play($data_system.title_bgm) # ME、BGS の演奏を停止 Audio.me_stop Audio.bgs_stop # トランジション実行 Graphics.transition # メインループ loop do # ゲーム画面を更新 Graphics.update # 入力情報を更新 Input.update # フレーム更新 update # 画面が切り替わったらループを中断 if $scene != self break end end # トランジション準備 Graphics.freeze # コマンドウィンドウを解放 @command_window.dispose # タイトルグラフィックを解放 @sprite.bitmap.dispose @sprite.dispose end end |
Code: |
NB_SAVE_SLOTS = 20 |
Citation: |
Le script fonctionne mais pas avec PSP car il n'est pas compatible. |
Code: |
#============================================================================== # ■ Scene_Save (Version Pokémon) # Pokemon Script Project - Krosk # 01/08/07 #------------------------------------------------------------------------------ # Scène à ne pas modifier de préférence #------------------------------------------------------------------------------ module POKEMON_S class Pokemon_Save def initialize Graphics.freeze @background = Plane.new(Viewport.new(0,0,640,480)) @background.bitmap = RPG::Cache.picture("fondsaved.png") @background.z -= 10 number = 0 # Nombre de cadres de sauvegarde à générer for i in 0..2 if FileTest.exist?("Save#{i+1}.rxdata") number = 1 end end @number = number @save_game_window_list = [] for i in [url=mailto:1.. @number]1..@number[/url] window = Window_Base.new(30, 30 + 83*(i-1), 580, 80) window.contents = Bitmap.new(548, 48) @save_game_window_list.push(window) end # Cadre nouvelle sauvegarde @new_save_window = Window_Base.new(30, 30 + [url=mailto:83*@number]83*@number[/url], 580, 80) @new_save_window.contents = Bitmap.new(548, 48) set_window(@new_save_window) @new_save_window.contents.draw_text(9, 3, 548, 48, "NOUVEAU FICHIER") captured = 0 for i in 1..$data_pokedex.length-1 if $data_pokedex[i][1] captured += 1 end end $read_data = [$trainer_name, $trainer_id, captured, $map_link] @index = 0 latest_time = Time.at(0) for i in 0..3 filename = "Save#{i + 1}.rxdata" if FileTest.exist?(filename) file = File.open(filename, "r") if file.mtime > latest_time latest_time = file.mtime @index = i end file.close end end end def main refresh_all Graphics.transition loop do Graphics.update Input.update update if $scene != self break end end Graphics.freeze for window in @save_game_window_list window.dispose end @new_save_window.dispose @background.dispose end def update if Input.trigger?(Input::DOWN) @index += @index == @number ? 0 : @index == 2 ? 0 : 1 refresh_all end if Input.trigger?(Input::UP) @index -= @index == 0 ? 0 : 1 refresh_all end # メニュー画面に切り替え $scene = POKEMON_S::Pokemon_Menu.new(4) else decision = draw_choice if decision $game_system.se_play($data_system.save_se) filename = "[url=mailto:Save#{@index]Save#{@index[/url] + 1}.rxdata" file = File.open(filename, "wb") write_save_data(file) file.close # イベントから呼び出されている場合 if $game_temp.save_calling # セーブ呼び出しフラグをクリア $game_temp.save_calling = false # マップ画面に切り替え $scene = Scene_Map.new return end # メニュー画面に切り替え $scene = POKEMON_S::Pokemon_Menu.new(4) else return end end end if Input.trigger?(Input::B) if $game_temp.save_calling $game_temp.save_calling = false end $scene = POKEMON_S::Pokemon_Menu.new(4) return end end def refresh_all for i in [url=mailto:0..@number-1]0..@number-1[/url] if i < @index @save_game_window_list[i].opacity = 128 @save_game_window_list[i].y = 30 + 83*i @save_game_window_list[i].height = 80 @save_game_window_list[i].contents = Bitmap.new(548, 48) set_window(@save_game_window_list[i]) @save_game_window_list[i].contents.draw_text(9, 3, 530, 48, "SAUVEGARDER PARTIE "+(i+1).to_s) elsif i == @index @save_game_window_list[i].opacity = 255 @save_game_window_list[i].y = 30 + 83*i @save_game_window_list[i].height = 163 @save_game_window_list[i].contents = Bitmap.new(548, 131) set_window(@save_game_window_list[i]) @save_game_window_list[i].contents.draw_text(9, 3, 530, 48, "SAUVEGARDER PARTIE "+(i+1).to_s) @filename = "Save#{i + 1}.rxdata" list = read_preview(@filename) data = list[0] time_sec = list[1] hour = (time_sec / 3600).to_s minute = "00" minute += ((time_sec%3600)/60).to_s minute = minute[minute.size-2, 2] time = hour + ":" + minute name = data[0].to_s id = data[1].to_s captured = data[2].to_s @save_game_window_list[i].contents.draw_text(9, 42, 252, 48, "NOM:") @save_game_window_list[i].contents.draw_text(9, 42, 252, 48, name, 2) @save_game_window_list[i].contents.draw_text(285, 42, 252, 48, "DUREE:") @save_game_window_list[i].contents.draw_text(285, 42, 252, 48, time, 2) @save_game_window_list[i].contents.draw_text(9, 81, 252, 48, "POKéDEX:") @save_game_window_list[i].contents.draw_text(9, 81, 252, 48, captured, 2) elsif i > @index @save_game_window_list[i].opacity = 128 @save_game_window_list[i].y = 30 + 83*i + 83 @save_game_window_list[i].height = 80 @save_game_window_list[i].contents = Bitmap.new(548, 48) set_window(@save_game_window_list[i]) @save_game_window_list[i].contents.draw_text(9, 3, 548, 48, "SAUVEGARDER PARTIE "+(i+1).to_s) end end if @index == @number and @number < 3 @new_save_window.opacity = 255 @save_game_window_list[i].contents.draw_text(9, 42, 252, 48, name, 2) elsif @number < 3 @new_save_window.opacity = 128 @new_save_window.y = 30 + 83*(@number+1) else @new_save_window.visible = true end end def set_window(window) window.contents.font.name = $fontface window.contents.font.size = $fontsizebig window.contents.font.color = window.normal_color end def read_preview(filename) file = File.open(filename, "r") time_stamp = file.mtime characters = Marshal.load(file) frame_count = Marshal.load(file) game_system = Marshal.load(file) game_switches = Marshal.load(file) game_variables = Marshal.load(file) total_sec = frame_count / Graphics.frame_rate # Non utilisé 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) # ------------ read_data = Marshal.load(file) file.close return [read_data, total_sec] end #-------------------------------------------------------------------------- # #-------------------------------------------------------------------------- def write_save_data(file) characters = [] for i in 0...$game_party.actors.size actor = $game_party.actors[i] characters.push([actor.character_name, actor.character_hue]) end Marshal.dump(characters, file) Marshal.dump(Graphics.frame_count, file) $game_system.save_count = 1 $game_system.magic_number = $data_system.magic_number Marshal.dump($game_system, file) Marshal.dump($game_switches, file) Marshal.dump($game_variables, file) Marshal.dump($game_self_switches, file) Marshal.dump($game_screen, file) Marshal.dump($game_actors, file) Marshal.dump($game_party, file) Marshal.dump($game_troop, file) Marshal.dump($game_map, file) Marshal.dump($game_player, file) Marshal.dump($read_data, file) Marshal.dump($trainer_code, file) Marshal.dump($trainer_id, file) Marshal.dump($trainer_name, file) Marshal.dump($trainer_battler , file) Marshal.dump($pokemon_party, file) Marshal.dump($random_encounter, file) Marshal.dump($data_pokedex, file) Marshal.dump($data_storage, file) Marshal.dump($battle_var, file) Marshal.dump($existing_pokemon, file) Marshal.dump($string, file) end def draw_choice @command = Window_Command.new(120, ["OUI", "NON"], $fontsizebig) @command.x = 517 @command.y = 359 loop do Graphics.update Input.update @command.update if Input.trigger?(Input::C) and @command.index == 0 @command.dispose @command = nil Input.update return true end if Input.trigger?(Input::C) and @command.index == 1 @command.dispose @command = nil Input.update return false end end end |
Code: |
#============================================================================== # ■ Scene_Title (Version Pokémon) # Pokemon Script Project - Krosk # 01/08/07 #------------------------------------------------------------------------------ # Scène modifiable #------------------------------------------------------------------------------ # Intègre le menu de chargement #------------------------------------------------------------------------------ class Scene_Title def main # Redéfinition if $BTEST battle_test return end # === Splashscreen --- Ce sont mes crédits, laissez le svp ;) Graphics.freeze @splash = Sprite.new @splash.bitmap = RPG::Cache.title("pkssplash.png") Graphics.transition(10) Graphics.freeze Graphics.transition(50) Graphics.freeze @splash.dispose Graphics.transition(10) Graphics.freeze # === Fin de Splashscreen @splash = Sprite.new @splash.bitmap = RPG::Cache.title("ecrantitre.png") Graphics.transition(10) Graphics.freeze Graphics.transition(50) Graphics.freeze @splash.dispose Graphics.transition(10) Graphics.freeze $data_actors = load_data("Data/Actors.rxdata") $data_classes = load_data("Data/Classes.rxdata") $data_skills = load_data("Data/Skills.rxdata") $data_items = load_data("Data/Items.rxdata") $data_weapons = load_data("Data/Weapons.rxdata") $data_armors = load_data("Data/Armors.rxdata") $data_enemies = load_data("Data/Enemies.rxdata") $data_troops = load_data("Data/Troops.rxdata") $data_states = load_data("Data/States.rxdata") $data_animations = load_data("Data/Animations.rxdata") $data_tilesets = load_data("Data/Tilesets.rxdata") $data_common_events = load_data("Data/CommonEvents.rxdata") $data_system = load_data("Data/System.rxdata") $picture_data = load_data("Data/Library.rxdata") $game_system = Game_System.new @sprite = Sprite.new @sprite.bitmap = RPG::Cache.title($data_system.title_name) number = 0 # Nombre de cadres de sauvegarde à générer for i in 0..2 if FileTest.exist?("Save#{i+1}.rxdata") number = 1 end end @number = number @new_game_window = Window_Base.new(30, 30 + [url=mailto:83*@number]83*@number[/url], 580, 80) @new_game_window.contents = Bitmap.new(548, 48) set_window(@new_game_window) @new_game_window.contents.draw_text(9,3,548,48,"NOUVELLE PARTIE") @save_game_window_list = [] for i in [url=mailto:1..@number]1..@number[/url] window = Window_Base.new(30, 30 + 83*(i-1), 580, 80) window.contents = Bitmap.new(548, 48) @save_game_window_list.push(window) end @index = 0 @background = Plane.new(Viewport.new(0,0,640,480)) @background.bitmap = RPG::Cache.picture("fondsaved.png") @background.z -= 10 $game_system.bgm_play($data_system.title_bgm) Audio.me_stop Audio.bgs_stop refresh_all Graphics.transition loop do Graphics.update Input.update update if $scene != self break end end Graphics.freeze @new_game_window.dispose @background.dispose for window in @save_game_window_list window.dispose end end def update if Input.trigger?(Input::DOWN) @index += @index == @number ? 0 : 1 refresh_all end if Input.trigger?(Input::UP) @index -= @index == 0 ? 0 : 1 refresh_all end if Input.trigger?(Input::C) case @index when @number # Nouveau jeu command_new_game else # Chargement $game_temp = Game_Temp.new on_decision("[url=mailto:Save#{@index]Save#{@index[/url] + 1}.rxdata") end end end def refresh_all for i in [url=mailto:0..@number-1]0..@number-1[/url] if i < @index @save_game_window_list[i].opacity = 128 @save_game_window_list[i].y = 30 + 83*i @save_game_window_list[i].height = 80 @save_game_window_list[i].contents = Bitmap.new(548, 48) set_window(@save_game_window_list[i]) @save_game_window_list[i].contents.draw_text(9, 3, 530, 48, "CONTINUER PARTIE "+(i+1).to_s) elsif i == @index @save_game_window_list[i].opacity = 255 @save_game_window_list[i].y = 30 + 83*i @save_game_window_list[i].height = 163 @save_game_window_list[i].contents = Bitmap.new(548, 131) set_window(@save_game_window_list[i]) @save_game_window_list[i].contents.draw_text(9, 3, 530, 48, "CONTINUER PARTIE "+(i+1).to_s) @filename = "Save#{i + 1}.rxdata" list = read_preview(@filename) data = list[0] time_sec = list[1] hour = (time_sec / 3600).to_s minute = "00" minute += ((time_sec%3600)/60).to_s minute = minute[minute.size-2, 2] time = hour + ":" + minute name = data[0].to_s id = data[1].to_s captured = data[2].to_s @save_game_window_list[i].contents.draw_text(9, 42, 252, 48, "NOM:") @save_game_window_list[i].contents.draw_text(9, 42, 252, 48, name, 2) @save_game_window_list[i].contents.draw_text(285, 42, 252, 48, "DUREE:") @save_game_window_list[i].contents.draw_text(285, 42, 252, 48, time, 2) @save_game_window_list[i].contents.draw_text(9, 81, 252, 48, "POKéDEX:") @save_game_window_list[i].contents.draw_text(9, 81, 252, 48, captured, 2) elsif i > @index @save_game_window_list[i].opacity = 128 @save_game_window_list[i].y = 30 + 83*i + 83 @save_game_window_list[i].height = 80 @save_game_window_list[i].contents = Bitmap.new(548, 48) set_window(@save_game_window_list[i]) @save_game_window_list[i].contents.draw_text(9, 3, 548, 48, "CONTINUER PARTIE "+(i+1).to_s) end end if @index == @number @new_game_window.opacity = 255 @new_game_window.y = 30 + [url=mailto:83*@number]83*@number[/url] else @new_game_window.opacity = 128 @new_game_window.y = 30 + 83*(@number+1) end end def set_window(window) window.contents.font.name = $fontface window.contents.font.size = $fontsizebig window.contents.font.color = window.normal_color end # -------------------------------------------------------- # Chargement # -------------------------------------------------------- def read_preview(filename) file = File.open(filename, "r") time_stamp = file.mtime characters = Marshal.load(file) frame_count = Marshal.load(file) game_system = Marshal.load(file) game_switches = Marshal.load(file) game_variables = Marshal.load(file) total_sec = frame_count / Graphics.frame_rate # Non utilisé 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) # ------------ read_data = Marshal.load(file) file.close return [read_data, total_sec] end def 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) $read_data = Marshal.load(file) $trainer_code = Marshal.load(file) $trainer_id = Marshal.load(file) $trainer_name = Marshal.load(file) $trainer_battler = Marshal.load(file) $pokemon_party = Marshal.load(file) $random_encounter = Marshal.load(file) $data_pokedex = Marshal.load(file) $data_storage = Marshal.load(file) $battle_var = Marshal.load(file) $existing_pokemon = Marshal.load(file) $string = Marshal.load(file) $map_link = $read_data[3] != nil ? $read_data[3] : {} 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 on_decision(filename) unless FileTest.exist?(filename) $game_system.se_play($data_system.buzzer_se) return end $game_system.se_play($data_system.load_se) file = File.open(filename, "rb") read_save_data(file) file.close $game_system.bgm_play($game_system.playing_bgm) $game_system.bgs_play($game_system.playing_bgs) $game_map.update $scene = Scene_Map.new end alias alias_command_new_game command_new_game def command_new_game $map_link = {} alias_command_new_game #----------------------------------------------------- # Variables créées automatiquement au début du jeu # Elles sont absolument nécessaires #----------------------------------------------------- $pokemon_party = POKEMON_S::Pokemon_Party.new $data_storage = [[0]] $pokemon_party.create_box $trainer_code = rand(2**32) $trainer_id = ($trainer_code % (2**16)) $trainer_id = sprintf("%05d", $trainer_id) $trainer_name = $game_actors[1].name $trainer_battler = $game_actors[1].battler_name $random_encounter = Array.new(7) $random_encounter[0] = 0 $battle_var = POKEMON_S::Pokemon_Battle_Variable.new $existing_pokemon = [] $string = [] end end |