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 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 1..@number window = Window_Base.new(33, 10 + (83-20)*(i-1), 216, 45) window.contents = Bitmap.new(548, 48) @save_game_window_list.push(window) end # Cadre nouvelle sauvegarde @new_save_window = Window_Base.new(33, (16 + 48*@number), 216, 45) @new_save_window.z = 10000 @new_save_window.contents = Bitmap.new(216, 48) set_window(@new_save_window) @new_save_window.contents.font.color = Color.new(160,160,168,255) @new_save_window.contents.draw_text(1,-16,216,48,"NOUVEAU FICHIER") @new_save_window.contents.draw_text(0,-15,216,48,"NOUVEAU FICHIER") @new_save_window.contents.draw_text(1,-15,216,48,"NOUVEAU FICHIER") @new_save_window.contents.font.color = Color.new(80,80,88,255) @new_save_window.contents.draw_text(0,-16,216,48,"NOUVEAU FICHIER") if SAVEBOUNDSLOT @new_save_window.y = 150 end captured = 0 for i in 1..$data_pokedex.length-1 if $data_pokedex[i][1] captured += 1 end end $read_data = [Player.name, Player.id, captured, $map_link] @index = 0 latest_time = Time.at(0) for i in 0..2 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 if SAVEBOUNDSLOT @index = POKEMON_S::_SAVESLOT if @index != @number @new_save_window.visible = false end end end def main refresh_all @spriteset = Spriteset_Map.new @background = Sprite.new @background.bitmap = RPG::Cache.picture("fondsaved_max.png") @background.x = 13 @background.y = 227 @background.z = 9999 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 @spriteset.dispose end def update if SAVEBOUNDSLOT @background.update end if Input.trigger?(Input::DOWN) and not SAVEBOUNDSLOT @index += @index == @number ? 0 : @index == 1 ? 0 : 1 refresh_all end if Input.trigger?(Input::UP) and not SAVEBOUNDSLOT @index -= @index == 0 ? 0 : 1 refresh_all end if Input.trigger?(Input::C) if @index == @number # Nouvelle sauvegarde $game_system.se_play($data_system.save_se) filename = "Save#{@number + 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(3) else decision = draw_choice if decision $game_system.se_play($data_system.save_se) filename = "Save#{@index + 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(3) 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(3) return end end def refresh_all for i in 0..@number-1 @save_game_window_list[i].z = 10000 if i < @index @save_game_window_list[i].opacity = 128 @save_game_window_list[i].y = 229 + 48*i @save_game_window_list[i].height = 48 @save_game_window_list[i].contents = Bitmap.new(548, 48) set_window(@save_game_window_list[i]) @save_game_window_list[i].contents.font.color = Color.new(160,160,168,255) @save_game_window_list[i].contents.draw_text(0, -16+1, 530, 48, "SAUVEGARDER PARTIE "+(i+1).to_s) @save_game_window_list[i].contents.draw_text(0+1, -16, 530, 48, "SAUVEGARDER PARTIE "+(i+1).to_s) @save_game_window_list[i].contents.draw_text(0+1, -16+1, 530, 48, "SAUVEGARDER PARTIE "+(i+1).to_s) @save_game_window_list[i].contents.font.color = Color.new(80, 80, 88, 255) @save_game_window_list[i].contents.draw_text(0, -16, 530, 48, "SAUVEGARDER PARTIE "+(i+1).to_s) if SAVEBOUNDSLOT @save_game_window_list[i].visible = false end elsif i == @index @save_game_window_list[i].opacity = 255 @save_game_window_list[i].y = 229 + 48*i @save_game_window_list[i].height = 103 @save_game_window_list[i].contents = Bitmap.new(548, 131) set_window(@save_game_window_list[i]) if SAVEBOUNDSLOT @save_game_window_list[i].contents.font.color = Color.new(160,160,168,255) @save_game_window_list[i].contents.draw_text(0, -16+1, 530, 48, "SAUVEGARDER PARTIE") @save_game_window_list[i].contents.draw_text(0+1, -16, 530, 48, "SAUVEGARDER PARTIE") @save_game_window_list[i].contents.draw_text(0+1, -16+1, 530, 48, "SAUVEGARDER PARTIE") @save_game_window_list[i].contents.font.color = Color.new(80, 80, 88, 255) @save_game_window_list[i].contents.draw_text(0, -16, 530, 48, "SAUVEGARDER PARTIE") @save_game_window_list[i].y = 229 else @save_game_window_list[i].contents.font.color = Color.new(160,160,168,255) @save_game_window_list[i].contents.draw_text(0, -16+1, 530, 48, "SAUVEGARDER PARTIE "+(i+1).to_s) @save_game_window_list[i].contents.draw_text(0+1, -16, 530, 48, "SAUVEGARDER PARTIE "+(i+1).to_s) @save_game_window_list[i].contents.draw_text(0+1, -16+1, 530, 48, "SAUVEGARDER PARTIE "+(i+1).to_s) @save_game_window_list[i].contents.font.color = Color.new(80, 80, 88, 255) @save_game_window_list[i].contents.draw_text(0, -16, 530, 48, "SAUVEGARDER PARTIE "+(i+1).to_s) end @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 badge = 0.to_s @save_game_window_list[i].contents.font.color = Color.new(160,160,168,255) @save_game_window_list[i].contents.draw_text(9+1, 0, 252, 48, "JOUEUR") @save_game_window_list[i].contents.draw_text(9+1, 0, 167, 48, name, 2) @save_game_window_list[i].contents.draw_text(9+1, 14, 252, 48, "BADGES") @save_game_window_list[i].contents.draw_text(9+1, 14, 167, 48, badge , 2) @save_game_window_list[i].contents.draw_text(9+1, 28, 252, 48, "POKéDEX") @save_game_window_list[i].contents.draw_text(9+1, 28, 167, 48, captured, 2) @save_game_window_list[i].contents.draw_text(9+1, 42, 252, 48, "DUREE DE JEU") @save_game_window_list[i].contents.draw_text(9+1, 42, 167, 48, time, 2) @save_game_window_list[i].contents.draw_text(9, 0+1, 252, 48, "JOUEUR") @save_game_window_list[i].contents.draw_text(9, 0+1, 167, 48, name, 2) @save_game_window_list[i].contents.draw_text(9, 14+1, 252, 48, "BADGES") @save_game_window_list[i].contents.draw_text(9, 14+1, 167, 48, badge , 2) @save_game_window_list[i].contents.draw_text(9, 28+1, 252, 48, "POKéDEX") @save_game_window_list[i].contents.draw_text(9, 28+1, 167, 48, captured, 2) @save_game_window_list[i].contents.draw_text(9, 42+1, 252, 48, "DUREE DE JEU") @save_game_window_list[i].contents.draw_text(9, 42+1, 167, 48, time, 2) @save_game_window_list[i].contents.draw_text(9+1, 0+1, 252, 48, "JOUEUR") @save_game_window_list[i].contents.draw_text(9+1, 0+1, 167, 48, name, 2) @save_game_window_list[i].contents.draw_text(9+1, 14+1, 252, 48, "BADGES") @save_game_window_list[i].contents.draw_text(9+1, 14+1, 167, 48, badge , 2) @save_game_window_list[i].contents.draw_text(9+1, 28+1, 252, 48, "POKéDEX") @save_game_window_list[i].contents.draw_text(9+1, 28+1, 167, 48, captured, 2) @save_game_window_list[i].contents.draw_text(9+1, 42+1, 252, 48, "DUREE DE JEU") @save_game_window_list[i].contents.draw_text(9+1, 42+1, 167, 48, time, 2) @save_game_window_list[i].contents.font.color = Color.new(80, 80, 88, 255) @save_game_window_list[i].contents.draw_text(9, 0, 252, 48, "JOUEUR") @save_game_window_list[i].contents.draw_text(9, 0, 167, 48, name, 2) @save_game_window_list[i].contents.draw_text(9, 14, 252, 48, "BADGES") @save_game_window_list[i].contents.draw_text(9, 14, 167, 48, badge , 2) @save_game_window_list[i].contents.draw_text(9, 28, 252, 48, "POKéDEX") @save_game_window_list[i].contents.draw_text(9, 28, 167, 48, captured, 2) @save_game_window_list[i].contents.draw_text(9, 42, 252, 48, "DUREE DE JEU") @save_game_window_list[i].contents.draw_text(9, 42, 167, 48, time, 2) elsif i > @index @save_game_window_list[i].opacity = 128 @save_game_window_list[i].y = 229 + 48*i + 54 @save_game_window_list[i].height = 48 @save_game_window_list[i].contents = Bitmap.new(548, 48) set_window(@save_game_window_list[i]) @save_game_window_list[i].contents.font.color = Color.new(160,160,168,255) @save_game_window_list[i].contents.draw_text(0, -16+1, 530, 48, "SAUVEGARDER PARTIE "+(i+1).to_s) @save_game_window_list[i].contents.draw_text(0+1, -16, 530, 48, "SAUVEGARDER PARTIE "+(i+1).to_s) @save_game_window_list[i].contents.draw_text(0+1, -16+1, 530, 48, "SAUVEGARDER PARTIE "+(i+1).to_s) @save_game_window_list[i].contents.font.color = Color.new(80, 80, 88, 255) @save_game_window_list[i].contents.draw_text(0, -16, 530, 48, "SAUVEGARDER PARTIE "+(i+1).to_s) if SAVEBOUNDSLOT @save_game_window_list[i].visible = false end end end if @index == @number and @number < 2 @new_save_window.opacity = 255 @new_save_window.y = 229 + 48*@number elsif @number < 2 @new_save_window.opacity = 128 @new_save_window.y = 229 + 51*(@number+1) else @new_save_window.visible = false 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(Player.code, file) #Marshal.dump(Player.id, file) #Marshal.dump(Player.name, file) #Marshal.dump(Player.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) Marshal.dump($SPEED_MSG, file) Marshal.dump($color_menu, file) Marshal.dump($NB_MSG, file) Marshal.dump($MSG, file) Marshal.dump($voir_anim, file) Marshal.dump($choix_battle, file) end def draw_choice @command = Window_Command.new(57, ["OUI", "NON"], $fontsizebig) @command.x = 210 @command.y = 355 @command.z = 10000 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 end end class Interpreter def forcer_sauvegarde if not SAVEBOUNDSLOT return end captured = 0 for i in 1..$data_pokedex.length-1 if $data_pokedex[i][1] captured += 1 end end $read_data = [Player.name, Player.id, captured, $map_link] filename = "Save#{POKEMON_S::_SAVESLOT + 1}.rxdata" file = File.open(filename, "wb") 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 game_system = $game_system.clone game_system.reset_interpreter 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($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) Marshal.dump($SPEED_MSG, file) Marshal.dump($color_menu, file) Marshal.dump($NB_MSG, file) Marshal.dump($MSG, file) Marshal.dump($voir_anim, file) Marshal.dump($choix_battle, file) file.close end end |