Mack Chevalier (niveau 5)
Messages postés : 126 Date d'inscription : 26/06/2013 Jauge LPC :
| Sujet: Zelda Save System Mar 6 Aoû 2013 - 20:31 | |
| Salut ! Auteur : Moi ( Mack ) Utilité : Ce script permet d'avoir un écran titre Zelda-Like. C'est à dire qu'il permet d'avoir trois fichiers, d'en choisir un, et quand le joueur voudra sauvegarder, cela sauvegardera sur le fichier utiliser lors de la création de la partie. La commande : - Code:
-
rapid_save Permet de sauvegarder la partie sur le slot utilisé sans afficher l'image Save_Screen. Sinon, l'onglet sauvegarde du menu permet de sauvegarder en affichant l'image. Script : - Code:
-
=begin Auteur : Mack Aout 2013 Permet d'avoir un écran titre Zelda-Like. La commande : rapid_save
Permet de sauvegarder sans afficher l'image Save_Screen. =end
#============================================================================== # ** Scene_Title #------------------------------------------------------------------------------ # This class performs title screen processing. #==============================================================================
class Scene_Title #-------------------------------------------------------------------------- # * Main Processing #-------------------------------------------------------------------------- def main # If battle test if $BTEST battle_test return end # Load database $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") # Make system object $game_system = Game_System.new @index = 0
# Make title graphic @sprite = Sprite.new @sprite.bitmap = RPG::Cache.title($data_system.title_name) @savefile_windows = [] for i in 0..2 @savefile_windows.push(Window_SaveFile.new(i, make_filename(i))) end # Play title BGM $game_system.bgm_play($data_system.title_bgm) # Stop playing ME and BGS Audio.me_stop Audio.bgs_stop # Execute transition Graphics.transition # Main loop loop do # Update game screen Graphics.update # Update input information Input.update # Frame update update # Abort loop if screen is changed if $scene != self break end end # Prepare for transition Graphics.freeze # Dispose of command window # Dispose of title graphic @sprite.bitmap.dispose @sprite.dispose for i in 0..2 @savefile_windows[i].dispose end end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update for i in 0..2 if i == @index @savefile_windows[i].selected = true else @savefile_windows[i].selected = false end @savefile_windows[i].update end if Input.trigger?(Input::UP) if (@index>0) @index-=1 end elsif Input.trigger?(Input::DOWN) if (@index<2) @index+=1 end end # If C button was pressed if Input.trigger?(Input::C) $game_temp = Game_Temp.new # Branch by command window cursor position if FileTest.exist?("Save#{@index+1}.rxdata") # Remake temporary object read_save_data(@index) $scene = Scene_Map.new else command_new_game end $game_temp.save_index = @index end end def read_save_data(id) filename = make_filename(id) file = File.open(filename, "rb") # Read character data for drawing save file characters = Marshal.load(file) # Read frame count for measuring play time Graphics.frame_count = Marshal.load(file) # Read each type of game object $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 magic number is different from when saving # (if editing was added with editor) if $game_system.magic_number != $data_system.magic_number # Load map $game_map.setup($game_map.map_id) $game_player.center($game_player.x, $game_player.y) end # Refresh party members $game_party.refresh end def make_filename(file_index) return "Save#{file_index + 1}.rxdata" end end #============================================================================== # ** Game_Temp #------------------------------------------------------------------------------ # This class handles temporary data that is not included with save data. # Refer to "$game_temp" for the instance of this class. #==============================================================================
class Game_Temp attr_accessor :save_index end #============================================================================== # ** Window_SaveFile #------------------------------------------------------------------------------ # This window displays save files on the save and load screens. #==============================================================================
class Window_SaveFile < Window_Base #-------------------------------------------------------------------------- # * Public Instance Variables #-------------------------------------------------------------------------- attr_reader :filename # file name attr_reader :selected # selected #-------------------------------------------------------------------------- # * Object Initialization # file_index : save file index (0-3) # filename : file name #-------------------------------------------------------------------------- def initialize(file_index, filename) super(8, (file_index) % 4 * 108 + 102 , 624, 104) self.contents = Bitmap.new(width - 32, height - 32) @file_index = file_index @filename = "Save#{@file_index + 1}.rxdata" @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) @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) @total_sec = @frame_count / Graphics.frame_rate file.close end refresh @selected = false end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh self.contents.clear # Draw file number self.contents.font.color = normal_color # If save file exists if @file_exist name = @game_party.actors[0].name self.contents.draw_text(4, 0, 600, 32, name) @name_width = contents.text_size(name).width # Draw character 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 # Draw play time 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, 588, 32, time_string, 2) # Draw timestamp self.contents.font.color = normal_color time_string = @time_stamp.strftime("%Y/%m/%d %H:%M") self.contents.draw_text(4, 40, 588, 32, time_string, 2) else name = "Vide" self.contents.draw_text(4, 0, 600, 32, name) @name_width = contents.text_size(name).width end end end #============================================================================== # ** Scene_Title #------------------------------------------------------------------------------ # This class performs title screen processing. #==============================================================================
class Scene_Save #-------------------------------------------------------------------------- # * Main Processing #-------------------------------------------------------------------------- def main @sprite = Sprite.new @sprite.bitmap = RPG::Cache.title("Save_Screen") # Execute transition Graphics.transition save_command loop do # Update game screen Graphics.update # Update input information Input.update # Frame update update # Abort loop if screen is changed if $scene != self break end end # Prepare for transition Graphics.freeze # Dispose of title graphic @sprite.bitmap.dispose @sprite.dispose end def update if (Input.trigger?(Input::C)) $scene = Scene_Map.new end end def save_command id = $game_temp.save_index filename = make_filename(id) # Play save SE $game_system.se_play($data_system.save_se) # Write save data file = File.open(filename, "wb") write_save_data(file) end def write_save_data(file) # Make character data for drawing save file characters = [] for i in 0...$game_party.actors.size actor = $game_party.actors[i] characters.push([actor.character_name, actor.character_hue]) end # Write character data for drawing save file Marshal.dump(characters, file) # Wrire frame count for measuring play time Marshal.dump(Graphics.frame_count, file) # Increase save count by 1 $game_system.save_count += 1 # Save magic number # (A random value will be written each time saving with editor) $game_system.magic_number = $data_system.magic_number # Write each type of game object 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) end def make_filename(file_index) return "Save#{file_index + 1}.rxdata" end end
class Interpreter def rapid_save id = $game_temp.save_index filename = "Save#{id + 1}.rxdata" # Play save SE $game_system.se_play($data_system.save_se) # Write save data file = File.open(filename, "wb") # Make character data for drawing save file characters = [] for i in 0...$game_party.actors.size actor = $game_party.actors[i] characters.push([actor.character_name, actor.character_hue]) end # Write character data for drawing save file Marshal.dump(characters, file) # Wrire frame count for measuring play time Marshal.dump(Graphics.frame_count, file) # Increase save count by 1 $game_system.save_count += 1 # Save magic number # (A random value will be written each time saving with editor) $game_system.magic_number = $data_system.magic_number # Write each type of game object 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) end end
Screen : Ressource : Nommé Save_Screen et mis dans le dossier Titles.
Dernière édition par Mack le Jeu 8 Aoû 2013 - 9:56, édité 1 fois |
|
Zexion Administrateur
Messages postés : 6228 Date d'inscription : 04/01/2012 Jauge LPC :
| Sujet: Re: Zelda Save System Mar 6 Aoû 2013 - 20:40 | |
| Une alternative sympathique au système de sauvegarde base. Par contre je me permet de faire remarquer "Fichier sauvegarder" -> "Fichier sauvegardé". En tout cas, je te remercie du partage, je t'ajoute des points. |
|
Mack Chevalier (niveau 5)
Messages postés : 126 Date d'inscription : 26/06/2013 Jauge LPC :
| Sujet: Re: Zelda Save System Jeu 8 Aoû 2013 - 9:52 | |
| Erf xD. J'vais corriger ça, mais d'un autre côté j'espère que personne utilisera cette image, puisque c'était juste pour donner un exemple ^^. ( Parce que bon, coller une fenêtre avec un texte sur le title de base de RM,c'est pas le meilleur design qu'on puisse avoir xD )
Merci ^^. |
|
Elekami Fondateur
Messages postés : 19071 Date d'inscription : 19/07/2008 Jauge LPC :
| Sujet: Re: Zelda Save System Jeu 8 Aoû 2013 - 11:33 | |
| Ça a l'air cool, bravo pour ce script. |
|
Heaven Chevalier Dragon (niveau 1)
Messages postés : 755 Date d'inscription : 01/04/2013 Jauge LPC :
| Sujet: Re: Zelda Save System Jeu 8 Aoû 2013 - 19:08 | |
| Sympas Merci du partage Mack^^ Heav'n |
|
Contenu sponsorisé
| Sujet: Re: Zelda Save System | |
| |
|