Sujet: [VX] Sauvegarde améliorée Dim 13 Déc 2009 - 2:47
Bonjour,
Voici un script permettant d'obtenir un plus joli menu de sauvegarde que celui de base. Ce script avait déjà été posté sur le forum, mais il y avait un bug qui selon moi avait son importance : l'affichage correspondait uniquement a la database et non aux données in game d'un projet. Ce script est originellement crée par Dargor. Ce script permet d'afficher les options suivantes pour une sauvegarde :
- Confirmation de sauvegarde et de chargement - Aperçu de la carte ou se trouve le joueur - Stats et niveaux des persos affichés - Affichage du nom de la carte - Affichage de l'argent possédé et du temps de jeu.
Instructions : Créer un nouveau script au dessus de main, et insérez y ce code. Aucune ressource ni dll n'est nécessaire au fonctionnement de ce script.
# Vocabulary Vocab::SaveMessage = "Save to which file?" Vocab::LoadMessage = "Load which file?" Vocab::File = 'File' Vocab::NoFile = 'Empty' Vocab::FileConfirm = 'Are you sure you want to %s this file?'
module Advanced_Files # Maximum number of files Max_Files = 10 # Filename Name = 'Save' # File extension Extension = 'rvdata' # File directory (Automatically creates the directory) Directory = 'Save' # Use file confirmation Confirmation = true # Smooth Scroll Smooth_Scroll = true # Scroll Speed (The higher the faster) Scroll_Speed = 30 # Use a picture for location name instead of text Location_Name_Picture = false end
#============================================================================== # ** Font #==============================================================================
class Font def marshal_dump;end def marshal_load(obj);end end
class Bitmap # Win32API RtlMoveMemory_pi = Win32API.new('kernel32', 'RtlMoveMemory', 'pii', 'i') RtlMoveMemory_ip = Win32API.new('kernel32', 'RtlMoveMemory', 'ipi', 'i') #-------------------------------------------------------------------------- # * Dump #-------------------------------------------------------------------------- def _dump(limit) data = "rgba" * width * height RtlMoveMemory_pi.call(data, address, data.length) [width, height, Zlib::Deflate.deflate(data)].pack("LLa*") end #-------------------------------------------------------------------------- # * Load #-------------------------------------------------------------------------- def self._load(str) w, h, zdata = str.unpack("LLa*"); b = new(w, h) RtlMoveMemory_ip.call(b.address, Zlib::Inflate.inflate(zdata), w * h * 4); b end #-------------------------------------------------------------------------- # * Address #-------------------------------------------------------------------------- def address buffer, ad = "xxxx", object_id * 2 + 16 RtlMoveMemory_pi.call(buffer, ad, 4); ad = buffer.unpack("L")[0] + 8 RtlMoveMemory_pi.call(buffer, ad, 4); ad = buffer.unpack("L")[0] + 16 RtlMoveMemory_pi.call(buffer, ad, 4); return buffer.unpack("L")[0] end end
#============================================================================== # ** Game_System #------------------------------------------------------------------------------ # This class handles system-related data. Also manages vehicles and BGM, etc. # The instance of this class is referenced by $game_system. #==============================================================================
class Game_System #-------------------------------------------------------------------------- # * Public Instance Variables #-------------------------------------------------------------------------- attr_accessor :background_bitmap attr_accessor :map_name #-------------------------------------------------------------------------- # * Alias Listing #-------------------------------------------------------------------------- alias dargor_advanced_files_system_initialize initialize #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize dargor_advanced_files_system_initialize @background_bitmap = nil @map_name = '' end end
#============================================================================== # ** Game_Map #------------------------------------------------------------------------------ # This class handles maps. It includes scrolling and passage determination # functions. The instance of this class is referenced by $game_map. #==============================================================================
class Game_Map #-------------------------------------------------------------------------- # * Get Map ID #-------------------------------------------------------------------------- def name map_infos = load_data("Data/MapInfos.rvdata") name = map_infos[@map_id].name return name end end
#============================================================================== # ** Window_FileBase #------------------------------------------------------------------------------ # This is a superclass of all file windows in the game. #==============================================================================
#============================================================================== # ** Window_MapPreview #------------------------------------------------------------------------------ # This window displays a map preview in the File screen. #==============================================================================
class Window_MapPreview < Window_FileBase #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize super(272, 212,264,196) self.visible = false end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh self.contents.clear return unless @file_exist name = @game_system.map_name if Advanced_Files::Location_Name_Picture bitmap = Cache.picture(name) self.contents.blt(4,4,bitmap,bitmap.rect) else self.contents.draw_text(4,4,272,WLH,name) end bitmap = @game_system.background_bitmap bitmap = Bitmap.new(32,32) if bitmap.nil? self.contents.blt(4,32,bitmap,Rect.new(160,128,224,128)) end end
#============================================================================== # ** Window_FileDetail #------------------------------------------------------------------------------ # This window displays file details in the File screen. #==============================================================================
class Window_FileDetail < Window_FileBase #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize super(0,202,544,214) self.visible = false end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh self.contents.clear return unless @file_exist if @game_system.instance_variables.include?('@difficulty_id') y = 24 self.contents.font.color = system_color self.contents.draw_text(4,0, 240, WLH, 'Difficulty:') self.contents.font.color = normal_color difficulty = Difficulty::Names[@game_system.difficulty_id] self.contents.draw_text(96,0, 240, WLH, difficulty) else y = 0 end for actor in @actors i = @actors.index(actor) draw_actor_name(actor,4,y + i * WLH) draw_actor_hp(actor,96,y + i * WLH) end end end
#============================================================================== # ** Window_FileGold #------------------------------------------------------------------------------ # This window displays the amount of gold in the File screen. #==============================================================================
class Window_FileGold < Window_FileBase #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize super(108, 352, 160, WLH + 32) self.visible = false end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh self.contents.clear draw_currency_value(@game_party.gold, 4, 0, 120) end end
#============================================================================== # ** Window_SaveFile #------------------------------------------------------------------------------ # This window displays save files on the save and load screens. #==============================================================================
class Window_SaveFile < Window_Base MAX_FILES = Advanced_Files::Max_Files #-------------------------------------------------------------------------- # * Public Instance Variables #-------------------------------------------------------------------------- attr_reader :file_index #-------------------------------------------------------------------------- # * Alias Listing #-------------------------------------------------------------------------- alias dargor_vx_advanced_files_window_refresh refresh #-------------------------------------------------------------------------- # * Object Initialization # file_index : save file index (0-3) # filename : filename #-------------------------------------------------------------------------- def initialize(file_index, filename) super(0, file_index % MAX_FILES * 90, 544, 90) @file_index = file_index @filename = filename load_gamedata refresh @selected = false end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh dargor_vx_advanced_files_window_refresh unless @file_exist y = (self.height / 2)-(WLH / 2) self.contents.draw_text(0,y,508,WLH,Vocab::NoFile,2) end end end
#============================================================================== # ** Scene_Title #------------------------------------------------------------------------------ # This class performs the title screen processing. #==============================================================================
class Scene_Title < Scene_Base #-------------------------------------------------------------------------- # * Determine if Continue is Enabled #-------------------------------------------------------------------------- def check_continue name = Advanced_Files::Name extension = Advanced_Files::Extension directory = Advanced_Files::Directory unless FileTest.directory?(directory) Dir.mkdir(directory) end @continue_enabled = (Dir.glob("#{directory}/#{name}*.#{extension}").size > 0) end end
#============================================================================== # ** Scene_File #------------------------------------------------------------------------------ # This class performs the save and load screen processing. #==============================================================================
class Scene_File < Scene_Base MAX_FILES = Advanced_Files::Max_Files #-------------------------------------------------------------------------- # * Alias Listing #-------------------------------------------------------------------------- alias dargor_vx_advanced_files_scene_file_start start alias dargor_vx_advanced_files_scene_file_terminate terminate alias dargor_vx_advanced_files_scene_file_update update alias dargor_vx_advanced_files_scene_file_update_savefile_windows update_savefile_windows alias dargor_vx_advanced_files_scene_file_write_save_data write_save_data alias dargor_vx_advanced_files_scene_file_read_save_data read_save_data #-------------------------------------------------------------------------- # * Create Save File Window #-------------------------------------------------------------------------- def create_savefile_windows @savefile_windows = [] @file_viewport = Viewport.new(0,56,544,416) @file_viewport.z = 500 @old_top_row = 0 @speed = 0 for i in 0...MAX_FILES @savefile_windows.push(Window_SaveFile.new(i, make_filename(i))) @savefile_windows[i].viewport = @file_viewport end @item_max = MAX_FILES end #-------------------------------------------------------------------------- # * Start Processing #-------------------------------------------------------------------------- def start dargor_vx_advanced_files_scene_file_start create_command_window @detail_window = Window_FileDetail.new @map_window = Window_MapPreview.new @gold_window = Window_FileGold.new end #-------------------------------------------------------------------------- # * Terminate Processing #-------------------------------------------------------------------------- def terminate dargor_vx_advanced_files_scene_file_terminate @command_window.dispose @detail_window.dispose @map_window.dispose @gold_window.dispose end #-------------------------------------------------------------------------- # * Create Command Window #-------------------------------------------------------------------------- def create_command_window @command_window = Window_Command.new(544,['Yes','No'],2) @command_window.active = false @command_window.visible = false @command_window.y = 56 @command_window.z = 501 end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update @command_window.update @detail_window.update @map_window.update @gold_window.update @detail_window.visible = @command_window.visible @map_window.visible = @command_window.visible @gold_window.visible = @command_window.visible if @command_window.active update_command_window return end dargor_vx_advanced_files_scene_file_update end #-------------------------------------------------------------------------- # * Frame Update (Command Window) #-------------------------------------------------------------------------- def update_command_window unless $game_map.nil? @spriteset.update unless @spriteset.nil? end if Input.trigger?(Input::B) Sound.play_cancel close_confirmation_window end if Input.trigger?(Input::C) case @command_window.index when 0 if @saving Sound.play_save do_save else Sound.play_load do_load end when 1 Sound.play_cancel close_confirmation_window end end end #-------------------------------------------------------------------------- # * Open Confirmation Window #-------------------------------------------------------------------------- def open_confirmation_window window_to_top for window in @savefile_windows window.visible = false unless window.file_index == @index end mode = @saving ? 'overwrite' : 'load' text = sprintf(Vocab::FileConfirm, mode) @help_window.set_text(text) @detail_window.load_gamedata(@savefile_windows[@index].filename) @map_window.load_gamedata(@savefile_windows[@index].filename) @gold_window.load_gamedata(@savefile_windows[@index].filename) @command_window.visible = true @command_window.active = true end #-------------------------------------------------------------------------- # * Close Confirmation Window #-------------------------------------------------------------------------- def close_confirmation_window self.top_row = @old_top_row for window in @savefile_windows window.visible = true end if @saving text = Vocab::SaveMessage else text = Vocab::LoadMessage end @help_window.set_text(text) @command_window.visible = false @command_window.active = false end #-------------------------------------------------------------------------- # * Get Top Row #-------------------------------------------------------------------------- def top_row return @file_viewport.oy / 90 end #-------------------------------------------------------------------------- # * Get Top Row #-------------------------------------------------------------------------- def top_row=(index) @file_viewport.oy = index * 90 end #-------------------------------------------------------------------------- # * Get Bottom Row #-------------------------------------------------------------------------- def bottom_row return top_row + 3 end #-------------------------------------------------------------------------- # * Get Top Row #-------------------------------------------------------------------------- def window_to_top @file_viewport.oy = @index * 90 @file_viewport.oy -= 56 end #-------------------------------------------------------------------------- # * Confirm Save File #-------------------------------------------------------------------------- def determine_savefile if @saving if @savefile_windows[@index].file_exist if Advanced_Files::Confirmation Sound.play_decision open_confirmation_window else Sound.play_save do_save end else Sound.play_save do_save end else if @savefile_windows[@index].file_exist if Advanced_Files::Confirmation Sound.play_decision open_confirmation_window else Sound.play_load do_load end else Sound.play_buzzer return end end $game_temp.last_file_index = @index end #-------------------------------------------------------------------------- # * Update Save File Window #-------------------------------------------------------------------------- def update_savefile_windows dargor_vx_advanced_files_scene_file_update_savefile_windows # Update file viewport if @index < top_row if Advanced_Files::Smooth_Scroll loop do Graphics.update Input.update if Graphics.frame_count % 30 == 0 @speed = [[@speed + 1, 6].min, 0].max end dist = 5 * (Advanced_Files::Scroll_Speed + @speed) @file_viewport.oy = [[@file_viewport.oy - dist, MAX_FILES * 90].min, @index * 90].max break if @file_viewport.oy == @index * 90 end else @file_viewport.oy = @index * 90 end elsif @index > bottom_row if Advanced_Files::Smooth_Scroll loop do Graphics.update Input.update if Graphics.frame_count % 30 == 0 @speed = [[@speed + 1, 6].min, 0].max end dist = 5 * (Advanced_Files::Scroll_Speed + @speed) @file_viewport.oy = [[@file_viewport.oy + dist, 0].max, (@index - 3) * 90].min break if @file_viewport.oy == (@index - 3) * 90 end else @file_viewport.oy = (@index - 3) * 90 end else @speed = [[@speed - 1, 0].max, 6].min end end #-------------------------------------------------------------------------- # * Create Filename # file_index : save file index (0-3) #-------------------------------------------------------------------------- def make_filename(file_index) name = Advanced_Files::Name extension = Advanced_Files::Extension directory = Advanced_Files::Directory unless FileTest.directory?(directory) Dir.mkdir(directory) end return "#{directory}/#{name}#{file_index + 1}.#{extension}" end #-------------------------------------------------------------------------- # * Write Save Data # file : write file object (opened) #-------------------------------------------------------------------------- def write_save_data(file) dargor_vx_advanced_files_scene_file_write_save_data(file) actors = [] for actor in $game_party.members actors.push(actor) end Marshal.dump(actors, file) end #-------------------------------------------------------------------------- # * Read Save Data # file : read file object (opened) #-------------------------------------------------------------------------- def read_save_data(file) dargor_vx_advanced_files_scene_file_read_save_data(file) @actors = Marshal.load(file) end end
#============================================================================== # ** Scene_Map #------------------------------------------------------------------------------ # This class performs the map screen processing. #==============================================================================
class Scene_Map #-------------------------------------------------------------------------- # * Alias Listing #-------------------------------------------------------------------------- alias dargor_vx_advanced_files_map_call_menu call_menu alias dargor_vx_advanced_files_map_call_save call_save #-------------------------------------------------------------------------- # * Switch to Menu Screen #-------------------------------------------------------------------------- def call_menu $game_system.background_bitmap = Graphics.snap_to_bitmap $game_system.map_name = $game_map.name dargor_vx_advanced_files_map_call_menu end #-------------------------------------------------------------------------- # * Switch to Menu Screen #-------------------------------------------------------------------------- def call_save $game_system.background_bitmap = Graphics.snap_to_bitmap $game_system.map_name = $game_map.name dargor_vx_advanced_files_map_call_save end end
Dernière édition par MetalRaiden le Dim 13 Déc 2009 - 10:12, édité 2 fois
Oui ce serait bien que tu donnes les "trucs" à faire pour que ça fonctionne. Et d'ailleurs il ne faut pas un machin à mettre dans le fichier du jeu pour prendre le screen?
Edit: Excuse moi je l'ai testé en en fait, quand on prendre la sauvegarde on voit pas les données, et lorsque on la charge, on voit tout ! Merci à toi car l'ancien script de sauvegarde custome n'était pas compatible avec un de mes scripts
Dernière édition par Diblo le Dim 13 Déc 2009 - 12:05, édité 1 fois
Edward023 => Les constantes que tu peux modifier ou éditer, sont les suivants : le nombre max de slots souhaités (ligne 38), et la vitesse d'apparition (ligne 50, mais personnellement je te conseille de ne pas y toucher)
Ensuite, qu'est-ce que tu veux dire par :
Citation :
mais il est toujours comme au début.
? Tu veux dire que même en installant ce script tu n'as toujours que le menu de sauvegarde de base ?
Diblo =>
Citation :
quand on prendre la sauvegarder on voit pas les données, et lorsque on la charge, on voit tout
Exactement, remercions Blockade d'avoir corrigé le bug^^ Il marche à merveille maintenant.
D'ailleurs n'oubliez pas de le citer ainsi que Dargor, l'auteur, dans vos crédits de jeu.
Ah attention, je n'ai pas corrigé le bug, pas du tout ! J'ai juste été voir le forum anglophone rmxp.org, j'ai cherché le sujet "Avanced files" et pris la dernière version en date xD
Merci de l'avoir posté en tout cas j'te met 2 points à la vie du forum pour ta présentation claire.
J'ai vérifier plusieur foix pour savoir ce qui n'allait pas dans le code pourquoi sa me disait tout le temps que sa ne fonctionnait pas. Mais j'ai rien du tout trouver.
Pour le moment sa me dit que j'ai un problème à la ligne 250. Qui es la suivante: for actor in @actors
Donc j'aimerais savoir pourquoi sa ne veux pas fonctionner. Même si je l'ai correctement tout pris.
Dans la petit fenètre qui me dit que j'ai une erreur voici ce qui est dit:
Script module_Sauvegarde' Line 250 : No methodError Occured. Undefined method`each'for # (Game_Fatigue : 0x172e4a0)
Merci de votre réponse.
Matsuo Kaito
Age : 33 Inscrit le : 27/06/2008 Messages : 10881
Sujet: Re: [VX] Sauvegarde améliorée Mar 5 Jan 2010 - 9:10
Pourquoi prendre ce script tout vieux et au rendu si moche ? ( et qui buggue en plus ? ) Woratana est votre ami
Code:
#=============================================================== # ● [VX] ◦ Neo Save System III ◦ □ #-------------------------------------------------------------- # ◦ by Woratana [woratana@hotmail.com] # ◦ Thaiware RPG Maker Community # ◦ Released on: 15/02/2009 # ◦ Version: 3.0 #-------------------------------------------------------------- # ◦ Log III: # - Change back to draw tilemap as screenshot. Don't need any image. # - For drawing tilemap, the characters won't show on the tilemap. #-------------------------------------------------------------- # ◦ Log II: # - Screenshot DLL is not work with Vista Aero, so I remove it # and use image for each map instead of screenshot. # - Actor's level in last version (V.1) is incorrect. #-------------------------------------------------------------- # ◦ Features: # - Unlimited save slots, you can choose max save slot # - You can use image for scene's background # - Choose your save file's name, and folder to store save files # - Choose to show only information you want # - Editable text for information's title # - Draw tilemap for map that player is currently in. # - Remove text you don't want from map's name (e.g. tags for special script) # - Choose map that you don't want to show its name # - Include save confirmation window before overwrite old save #=================================================================
module Wora_NSS #========================================================================== # * START NEO SAVE SYSTEM - SETUP #-------------------------------------------------------------------------- NSS_WINDOW_OPACITY = 255 # All windows' opacity (Lowest 0 - 255 Highest) # You can change this to 0 in case you want to use image for background NSS_IMAGE_BG = '' # Background image file name, it must be in folder Picture. # use '' for no background NSS_IMAGE_BG_OPACITY = 255 # Opacity for background image
MAX_SAVE_SLOT = 20 # Max save slots no. SLOT_NAME = 'SLOT {id}' # Name of the slot (show in save slots list), use {id} for slot ID SAVE_FILE_NAME = 'Saveslot{id}.rvdata' # Save file name, you can also change its file type from .rvdata to other # use {id} for save slot ID SAVE_PATH = '' # Path to store save file, e.g. 'Save/' or '' (for game folder)
SAVED_SLOT_ICON = 2319 # Icon Index for saved slot EMPTY_SLOT_ICON = 2318 # Icon Index for empty slot
EMPTY_SLOT_TEXT = '-Pas de Sauvegarde-' # Text to show for empty slot's data
MAP_NAME_TEXT_SUB = %w{} # Text that you want to remove from map name, # e.g. %w{[LN] [DA]} will remove text '[LN]' and '[DA]' from map name MAP_NO_NAME_LIST = [] # ID of Map that will not show map name, e.g. [1,2,3] MAP_NO_NAME_NAME = '??????????' # What you will use to call map in no name list
MAP_BORDER = Color.new(0,0,0,200) # Map image border color (R,G,B,Opacity) FACE_BORDER = Color.new(0,0,0,200) # Face border color
## SAVE CONFIRMATION WINDOW ## SFC_Text_Confirm = 'Confirmer la sauvegarde' # Text to confirm to save file SFC_Text_Cancel = 'Annuler' # Text to cancel to save SFC_Window_Width = 200 # Width of Confirmation Window SFC_Window_X_Offset = 0 # Move Confirmation Window horizontally SFC_Window_Y_Offset = 0 # Move Confirmation Window vertically #---------------------------------------------------------------------- # END NEO SAVE SYSTEM - SETUP #========================================================================= end
def make_filename(file_index) return SAVE_PATH + SAVE_FILE_NAME.gsub(/\{ID\}/i) { (file_index).to_s } end
def file_exist?(slot_id) return @exist_list[slot_id] if !@exist_list[slot_id].nil? @exist_list[slot_id] = FileTest.exist?(make_filename(slot_id)) return @exist_list[slot_id] end
def get_mapname(map_id) if @map_data.nil? @map_data = load_data("Data/MapInfos.rvdata") end if @map_name[map_id].nil? if MAP_NO_NAME_LIST.include?(map_id) @map_name[map_id] = MAP_NO_NAME_NAME else @map_name[map_id] = @map_data[map_id].name MAP_NAME_TEXT_SUB.each_index do |i| @map_name[map_id].sub!(MAP_NAME_TEXT_SUB[i], '') end end end return @map_name[map_id] end
def dispose_tilemap unless @tilemap.nil? @tilemap.dispose @tilemap = nil end end end
class Scene_Title < Scene_Base def check_continue file_name = Wora_NSS::SAVE_PATH + Wora_NSS::SAVE_FILE_NAME.gsub(/\{ID\}/i) { '*' } @continue_enabled = (Dir.glob(file_name).size > 0) end end #====================================================================== # END - NEO SAVE SYSTEM by Woratana #======================================================================
gallant
Poulet carnivore Lv.2
Inscrit le : 13/01/2009 Messages : 12
Sujet: Re: [VX] Sauvegarde améliorée Mar 5 Jan 2010 - 12:58
Merci, je l'ai changer pour le tient et il marche maintenant. Merci beaucoup.
shaxx
Poulet trizo Lv.3
Age : 34 Avertissements : 2Inscrit le : 21/03/2010 Messages : 46
Sujet: Re: [VX] Sauvegarde améliorée Dim 28 Mar 2010 - 11:09
Merci pour ce partage, sa marche vraiment tres bien =)
Matsuo Kaito
Age : 33 Inscrit le : 27/06/2008 Messages : 10881
Sujet: Re: [VX] Sauvegarde améliorée Dim 28 Mar 2010 - 12:02
Nécropost inutile spotted. +1 averto, merci d'aller relire le règlement.