AccueilAccueil  PortailPortail  RechercherRechercher  Dernières imagesDernières images  S'enregistrerS'enregistrer  ConnexionConnexion  




Partagez
 

 [VX] Sauvegarde améliorée

Voir le sujet précédent Voir le sujet suivant Aller en bas 
AuteurMessage
MetalRaiden
Poulet trizo Lv.3
Poulet trizo Lv.3
MetalRaiden


Age : 33
Inscrit le : 10/11/2009
Messages : 42

[VX] Sauvegarde améliorée Empty
MessageSujet: [VX] Sauvegarde améliorée   [VX] Sauvegarde améliorée Icon_minitimeDim 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.

Screen :

[VX] Sauvegarde améliorée Menug

Code :

Code:
# ** Advanced Files
#------------------------------------------------------------------------------
#  © Dargor, 2008-2009
#  25/03/09
#  Version 1.3
#  Part of the credits goes to Yeyinde for the Bitmap dump/load methods
#------------------------------------------------------------------------------
#  VERSION HISTORY:
#  - 1.0 (27/06/08), Initial release
#  - 1.1 (05/07/08), Added support for Location Name Picture instead of text
#  - 1.2 (17/02/09), Fixed a bug with wrong actors stats being displayed
#  - 1.3 (25/03/09), Fixed a bug with map preview not being loaded correctly
#------------------------------------------------------------------------------
#  INTRODUCTION:
#    This script let you customize some aspects of save files.
#    You can have as much save files as you want, change the filename,
#    extension and directory of the files and have a confirmation window
#    before loading or overwriting a file.
#------------------------------------------------------------------------------
#  INSTRUCTIONS:
#  - Paste this script above main
#  - Edit the constants in Advanced_Files module
#==============================================================================
 
# 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?'
 
#==============================================================================
# ** Advanced Files Configuration Module
#==============================================================================
 
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
 
#==============================================================================
# ** Bitmap
#==============================================================================
 
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.
#==============================================================================
 
class Window_FileBase < Window_Base
  #--------------------------------------------------------------------------
  # * Load Game Data
  #--------------------------------------------------------------------------
  def load_gamedata(filename)
    @filename = filename
    @time_stamp = Time.at(0)
    @file_exist = FileTest.exist?(@filename)
    if @file_exist
      file = File.open(@filename, "rb")
      @time_stamp = file.mtime
      begin
        @characters    = Marshal.load(file)
        @frame_count    = Marshal.load(file)
        @last_bgm      = Marshal.load(file)
        @last_bgs      = Marshal.load(file)
        @game_system    = Marshal.load(file)
        @game_message  = Marshal.load(file)
        @game_switches  = Marshal.load(file)
        @game_variables = Marshal.load(file)
        @game_self_switches  = 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)
        @actors = Marshal.load(file)
        @total_sec = @frame_count / Graphics.frame_rate
      rescue
        @file_exist = false
      ensure
        file.close
      end
    end
    refresh
  end
end
 
#==============================================================================
# ** 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
Revenir en haut Aller en bas
Edward023
Poulet carnivore Lv.2
Poulet carnivore Lv.2
Edward023


Masculin Age : 33
Inscrit le : 09/12/2009
Messages : 10

[VX] Sauvegarde améliorée Empty
MessageSujet: Re: [VX] Sauvegarde améliorée   [VX] Sauvegarde améliorée Icon_minitimeDim 13 Déc 2009 - 4:04

Salut

j'ai mis ton script et tout et tout, mais sa marche pas, dans les instructions,je ne comprend pas ce bout:
Edit the constants in Advanced_Files module Question


J'ai copié ton script en dessous de main et je l'ai appliqué, mais il est toujours comme au début. (Je suis qu'un minable débutant dans le script, Mad )

Merci de me répondre
Revenir en haut Aller en bas
Diblo
Illusionniste Lv.12
Illusionniste Lv.12
Diblo


Masculin Age : 114
Inscrit le : 07/08/2009
Messages : 774

[VX] Sauvegarde améliorée Empty
MessageSujet: Re: [VX] Sauvegarde améliorée   [VX] Sauvegarde améliorée Icon_minitimeDim 13 Déc 2009 - 8:36

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 Very Happy


Dernière édition par Diblo le Dim 13 Déc 2009 - 12:05, édité 1 fois
Revenir en haut Aller en bas
MetalRaiden
Poulet trizo Lv.3
Poulet trizo Lv.3
MetalRaiden


Age : 33
Inscrit le : 10/11/2009
Messages : 42

[VX] Sauvegarde améliorée Empty
MessageSujet: Re: [VX] Sauvegarde améliorée   [VX] Sauvegarde améliorée Icon_minitimeDim 13 Déc 2009 - 10:11

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.
Revenir en haut Aller en bas
Blockade
Ex-Admin Cruelle
Ex-Admin Cruelle
Blockade


Féminin Age : 32
Inscrit le : 03/07/2008
Messages : 2441

[VX] Sauvegarde améliorée Empty
MessageSujet: Re: [VX] Sauvegarde améliorée   [VX] Sauvegarde améliorée Icon_minitimeDim 13 Déc 2009 - 11:17

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.
Revenir en haut Aller en bas
MetalRaiden
Poulet trizo Lv.3
Poulet trizo Lv.3
MetalRaiden


Age : 33
Inscrit le : 10/11/2009
Messages : 42

[VX] Sauvegarde améliorée Empty
MessageSujet: Re: [VX] Sauvegarde améliorée   [VX] Sauvegarde améliorée Icon_minitimeDim 13 Déc 2009 - 22:52

Ah d'accord xD ben reste que tu as pris le temps de chercher^^

Merci =)
Revenir en haut Aller en bas
gallant
Poulet carnivore Lv.2
Poulet carnivore Lv.2
avatar


Inscrit le : 13/01/2009
Messages : 12

[VX] Sauvegarde améliorée Empty
MessageSujet: Re: [VX] Sauvegarde améliorée   [VX] Sauvegarde améliorée Icon_minitimeLun 4 Jan 2010 - 22:35

Bonjour,

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.
Revenir en haut Aller en bas
Matsuo Kaito
+ Heir Øf Ŧime +
+ Heir Øf Ŧime +
Matsuo Kaito


Masculin Age : 32
Inscrit le : 27/06/2008
Messages : 10881

[VX] Sauvegarde améliorée Empty
MessageSujet: Re: [VX] Sauvegarde améliorée   [VX] Sauvegarde améliorée Icon_minitimeMar 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 Rolling Eyes

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
 
  DRAW_GOLD = true # Draw Gold
  DRAW_PLAYTIME = true # Draw Playtime
  DRAW_LOCATION = true # Draw location
  DRAW_FACE = true # Draw Actor's face
  DRAW_LEVEL = true # Draw Actor's level
  DRAW_NAME = true # Draw Actor's name
 
  PLAYTIME_TEXT = 'Tps de Jeu : '
  GOLD_TEXT = 'Argent : '
  LOCATION_TEXT = 'Lieu : '
  LV_TEXT = 'Lvl '
 
  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
 
class Scene_File < Scene_Base
  include Wora_NSS
  attr_reader :window_slotdetail
  #--------------------------------------------------------------------------
  # * Start processing
  #--------------------------------------------------------------------------
  def start
    super
    create_menu_background
    if NSS_IMAGE_BG != ''
      @bg = Sprite.new
      @bg.bitmap = Cache.picture(NSS_IMAGE_BG)
      @bg.opacity = NSS_IMAGE_BG_OPACITY
    end
    @help_window = Window_Help.new
    command = []
    (1..MAX_SAVE_SLOT).each do |i|
      command << SLOT_NAME.clone.gsub!(/\{ID\}/i) { i.to_s }
    end
    @window_slotdetail = Window_NSS_SlotDetail.new
    @window_slotlist = Window_SlotList.new(160, command)
    @window_slotlist.y = @help_window.height
    @window_slotlist.height = Graphics.height - @help_window.height
    @help_window.opacity = NSS_WINDOW_OPACITY
    @window_slotdetail.opacity = @window_slotlist.opacity = NSS_WINDOW_OPACITY
   
  # Create Folder for Save file
  if SAVE_PATH != ''
    Dir.mkdir(SAVE_PATH) if !FileTest.directory?(SAVE_PATH)
  end
    if @saving
      @index = $game_temp.last_file_index
      @help_window.set_text(Vocab::SaveMessage)
    else
      @index = self.latest_file_index
      @help_window.set_text(Vocab::LoadMessage)
      (1..MAX_SAVE_SLOT).each do |i|
        @window_slotlist.draw_item(i-1, false) if !@window_slotdetail.file_exist?(i)
      end
    end
    @window_slotlist.index = @index
    # Draw Information
    @last_slot_index = @window_slotlist.index
    @window_slotdetail.draw_data(@last_slot_index + 1)
  end
  #--------------------------------------------------------------------------
  # * Termination Processing
  #--------------------------------------------------------------------------
  def terminate
    super
    dispose_menu_background
    unless @bg.nil?
      @bg.bitmap.dispose
      @bg.dispose
    end
    @window_slotlist.dispose
    @window_slotdetail.dispose
    @help_window.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    if !@confirm_window.nil?
      @confirm_window.update
      if Input.trigger?(Input::C)
        if @confirm_window.index == 0
          determine_savefile
          @confirm_window.dispose
          @confirm_window = nil
        else
          Sound.play_cancel
          @confirm_window.dispose
          @confirm_window = nil
        end
      elsif Input.trigger?(Input::B)
      Sound.play_cancel
      @confirm_window.dispose
      @confirm_window = nil
      end
    else
      update_menu_background
      @window_slotlist.update
      if @window_slotlist.index != @last_slot_index
        @last_slot_index = @window_slotlist.index
        @window_slotdetail.draw_data(@last_slot_index + 1)
      end
      @help_window.update
      update_savefile_selection
    end
  end
  #--------------------------------------------------------------------------
  # * Update Save File Selection
  #--------------------------------------------------------------------------
  def update_savefile_selection
    if Input.trigger?(Input::C)
      if @saving and @window_slotdetail.file_exist?(@last_slot_index + 1)
        Sound.play_decision
        text1 = SFC_Text_Confirm
        text2 = SFC_Text_Cancel
        @confirm_window = Window_Command.new(SFC_Window_Width,[text1,text2])
        @confirm_window.x = ((544 - @confirm_window.width) / 2) + SFC_Window_X_Offset
        @confirm_window.y = ((416 - @confirm_window.height) / 2) + SFC_Window_Y_Offset
      else
        determine_savefile
      end
    elsif Input.trigger?(Input::B)
      Sound.play_cancel
      return_scene
    end
  end
  #--------------------------------------------------------------------------
  # * Execute Save
  #--------------------------------------------------------------------------
  def do_save
    file = File.open(make_filename(@last_slot_index), "wb")
    write_save_data(file)
    file.close
    $scene = Scene_Map.new
  end
  #--------------------------------------------------------------------------
  # * Execute Load
  #--------------------------------------------------------------------------
  def do_load
    file = File.open(make_filename(@last_slot_index), "rb")
    read_save_data(file)
    file.close
    $scene = Scene_Map.new
    RPG::BGM.fade(1500)
    Graphics.fadeout(60)
    Graphics.wait(40)
    @last_bgm.play
    @last_bgs.play
  end
  #--------------------------------------------------------------------------
  # * Confirm Save File
  #--------------------------------------------------------------------------
  def determine_savefile
    if @saving
      Sound.play_save
      do_save
    else
      if @window_slotdetail.file_exist?(@last_slot_index + 1)
        Sound.play_load
        do_load
      else
        Sound.play_buzzer
        return
      end
    end
    $game_temp.last_file_index = @last_slot_index
  end
  #--------------------------------------------------------------------------
  # * Create Filename
  #    file_index : save file index (0-3)
  #--------------------------------------------------------------------------
  def make_filename(file_index)
    return SAVE_PATH + SAVE_FILE_NAME.gsub(/\{ID\}/i) { (file_index + 1).to_s }
  end
  #--------------------------------------------------------------------------
  # * Select File With Newest Timestamp
  #--------------------------------------------------------------------------
  def latest_file_index
    latest_index = 0
    latest_time = Time.at(0)
    (1..MAX_SAVE_SLOT).each do |i|
      file_name = make_filename(i - 1)
      next if !@window_slotdetail.file_exist?(i)
      file_time = File.mtime(file_name)
      if file_time > latest_time
        latest_time = file_time
        latest_index = i - 1
      end
    end
    return latest_index
  end
end

class Window_SlotList < Window_Command
  #--------------------------------------------------------------------------
  # * Draw Item
  #--------------------------------------------------------------------------
  def draw_item(index, enabled = true)
    rect = item_rect(index)
    rect.x += 4
    rect.width -= 8
    icon_index = 0
    self.contents.clear_rect(rect)
    if $scene.window_slotdetail.file_exist?(index + 1)
      icon_index = Wora_NSS::SAVED_SLOT_ICON
    else
      icon_index = Wora_NSS::EMPTY_SLOT_ICON
    end
    if !icon_index.nil?
      rect.x -= 4
      draw_icon(icon_index, rect.x, rect.y, enabled) # Draw Icon
      rect.x += 26
      rect.width -= 20
    end
    self.contents.clear_rect(rect)
    self.contents.font.color = normal_color
    self.contents.font.color.alpha = enabled ? 255 : 128
    self.contents.draw_text(rect, @commands[index])
  end
 
  def cursor_down(wrap = false)
    if @index < @item_max - 1 or wrap
      @index = (@index + 1) % @item_max
    end
  end

  def cursor_up(wrap = false)
    if @index > 0 or wrap
      @index = (@index - 1 + @item_max) % @item_max
    end
  end
end

class Window_NSS_SlotDetail < Window_Base
  include Wora_NSS
  def initialize
    super(160, 56, 384, 360)
    @data = []
    @exist_list = []
    @bitmap_list = {}
    @map_name = []
  end
 
  def dispose
    dispose_tilemap
    super
  end

  def draw_data(slot_id)
    contents.clear # 352, 328
    dispose_tilemap
    load_save_data(slot_id) if @data[slot_id].nil?
    if @exist_list[slot_id]
      save_data = @data[slot_id]
      # DRAW SCREENSHOT~
      contents.fill_rect(0,30,352,160, MAP_BORDER)
      create_tilemap(save_data['gamemap'].data, save_data['gamemap'].display_x,
    save_data['gamemap'].display_y)
      if DRAW_GOLD
        # DRAW GOLD
        gold_textsize = contents.text_size(save_data['gamepar'].gold).width
        goldt_textsize = contents.text_size(GOLD_TEXT).width
        contents.font.color = system_color
        contents.draw_text(0, 0, goldt_textsize, WLH, GOLD_TEXT)
        contents.draw_text(goldt_textsize + gold_textsize,0,200,WLH, Vocab::gold)
        contents.font.color = normal_color
        contents.draw_text(goldt_textsize, 0, gold_textsize, WLH, save_data['gamepar'].gold)
      end
      if DRAW_PLAYTIME
        # DRAW PLAYTIME
        hour = save_data['total_sec'] / 60 / 60
        min = save_data['total_sec'] / 60 % 60
        sec = save_data['total_sec'] % 60
        time_string = sprintf("%02d:%02d:%02d", hour, min, sec)
        pt_textsize = contents.text_size(PLAYTIME_TEXT).width
        ts_textsize = contents.text_size(time_string).width
        contents.font.color = system_color
        contents.draw_text(contents.width - ts_textsize - pt_textsize, 0,
        pt_textsize, WLH, PLAYTIME_TEXT)
        contents.font.color = normal_color
        contents.draw_text(0, 0, contents.width, WLH, time_string, 2)
      end
      if DRAW_LOCATION
        # DRAW LOCATION
        lc_textsize = contents.text_size(LOCATION_TEXT).width
        mn_textsize = contents.text_size(save_data['map_name']).width
        contents.font.color = system_color
        contents.draw_text(0, 190, contents.width,
        WLH, LOCATION_TEXT)
        contents.font.color = normal_color
        contents.draw_text(lc_textsize, 190, contents.width, WLH,
        save_data['map_name'])
      end
        # DRAW FACE & Level & Name
        save_data['gamepar'].members.each_index do |i|
          actor = save_data['gameactor'][save_data['gamepar'].members[i].id]
          face_x_base = (i*80) + (i*8)
          face_y_base = 216
          lvn_y_plus = 10
          lv_textsize = contents.text_size(actor.level).width
          lvt_textsize = contents.text_size(LV_TEXT).width
        if DRAW_FACE
          # Draw Face
          contents.fill_rect(face_x_base, face_y_base, 84, 84, FACE_BORDER)
          draw_face(actor.face_name, actor.face_index, face_x_base + 2,
          face_y_base + 2, 80)
        end
        if DRAW_LEVEL
          # Draw Level
          contents.font.color = system_color
          contents.draw_text(face_x_base + 2 + 80 - lv_textsize - lvt_textsize,
          face_y_base + 2 + 80 - WLH + lvn_y_plus, lvt_textsize, WLH, LV_TEXT)
          contents.font.color = normal_color
          contents.draw_text(face_x_base + 2 + 80 - lv_textsize,
          face_y_base + 2 + 80 - WLH + lvn_y_plus, lv_textsize, WLH, actor.level)
        end
        if DRAW_NAME
          # Draw Name
          contents.draw_text(face_x_base, face_y_base + 2 + 80 + lvn_y_plus - 6, 84,
          WLH, actor.name, 1)
        end
      end
    else
      contents.draw_text(0,0, contents.width, contents.height - WLH, EMPTY_SLOT_TEXT, 1)
    end
  end
 
  def load_save_data(slot_id)
    file_name = make_filename(slot_id)
    if file_exist?(slot_id) or FileTest.exist?(file_name)
      @exist_list[slot_id] = true
      @data[slot_id] = {}
      # Start load data
      file = File.open(file_name, "r")
      @data[slot_id]['time'] = file.mtime
      @data[slot_id]['char'] = Marshal.load(file)
      @data[slot_id]['frame'] = Marshal.load(file)
      @data[slot_id]['last_bgm'] = Marshal.load(file)
      @data[slot_id]['last_bgs'] = Marshal.load(file)
      @data[slot_id]['gamesys'] = Marshal.load(file)
      @data[slot_id]['gamemes'] = Marshal.load(file)
      @data[slot_id]['gameswi'] = Marshal.load(file)
      @data[slot_id]['gamevar'] = Marshal.load(file)
      @data[slot_id]['gameselfvar'] = Marshal.load(file)
      @data[slot_id]['gameactor'] = Marshal.load(file)
      @data[slot_id]['gamepar'] = Marshal.load(file)
      @data[slot_id]['gametro'] = Marshal.load(file)
      @data[slot_id]['gamemap'] = Marshal.load(file)
      @data[slot_id]['total_sec'] = @data[slot_id]['frame'] / Graphics.frame_rate
      @data[slot_id]['map_name'] = get_mapname(@data[slot_id]['gamemap'].map_id)
      file.close
    else
      @exist_list[slot_id] = false
      @data[slot_id] = -1
    end
  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 create_tilemap(map_data, ox, oy)
    @viewport = Viewport.new(self.x + 2 + 16, self.y + 32 + 16, 348,156)
    @viewport.z = self.z
    @tilemap = Tilemap.new(@viewport)
    @tilemap.bitmaps[0] = Cache.system("TileA1")
    @tilemap.bitmaps[1] = Cache.system("TileA2")
    @tilemap.bitmaps[2] = Cache.system("TileA3")
    @tilemap.bitmaps[3] = Cache.system("TileA4")
    @tilemap.bitmaps[4] = Cache.system("TileA5")
    @tilemap.bitmaps[5] = Cache.system("TileB")
    @tilemap.bitmaps[6] = Cache.system("TileC")
    @tilemap.bitmaps[7] = Cache.system("TileD")
    @tilemap.bitmaps[8] = Cache.system("TileE")
    @tilemap.map_data = map_data
    @tilemap.ox = ox / 8 + 99
    @tilemap.oy = oy / 8 + 90
  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
#======================================================================
Revenir en haut Aller en bas
gallant
Poulet carnivore Lv.2
Poulet carnivore Lv.2
avatar


Inscrit le : 13/01/2009
Messages : 12

[VX] Sauvegarde améliorée Empty
MessageSujet: Re: [VX] Sauvegarde améliorée   [VX] Sauvegarde améliorée Icon_minitimeMar 5 Jan 2010 - 12:58

Merci, je l'ai changer pour le tient et il marche maintenant. Merci beaucoup.
Revenir en haut Aller en bas
shaxx
Poulet trizo Lv.3
Poulet trizo Lv.3
shaxx


Masculin Age : 33
Avertissements : 2
Inscrit le : 21/03/2010
Messages : 46

[VX] Sauvegarde améliorée Empty
MessageSujet: Re: [VX] Sauvegarde améliorée   [VX] Sauvegarde améliorée Icon_minitimeDim 28 Mar 2010 - 11:09

Merci pour ce partage, sa marche vraiment tres bien =)
Revenir en haut Aller en bas
Matsuo Kaito
+ Heir Øf Ŧime +
+ Heir Øf Ŧime +
Matsuo Kaito


Masculin Age : 32
Inscrit le : 27/06/2008
Messages : 10881

[VX] Sauvegarde améliorée Empty
MessageSujet: Re: [VX] Sauvegarde améliorée   [VX] Sauvegarde améliorée Icon_minitimeDim 28 Mar 2010 - 12:02

Nécropost inutile spotted. +1 averto, merci d'aller relire le règlement.

Lock.
Revenir en haut Aller en bas
narusaku
Poulet carnivore Lv.2
Poulet carnivore Lv.2
narusaku


Masculin Age : 29
Inscrit le : 09/08/2011
Messages : 20

[VX] Sauvegarde améliorée Empty
MessageSujet: Re: [VX] Sauvegarde améliorée   [VX] Sauvegarde améliorée Icon_minitimeJeu 1 Aoû 2013 - 16:47

COOL SA MARCHE:lol!: 
Revenir en haut Aller en bas
Biward
Gardien des Scripts
Gardien des Scripts
Biward


Féminin Age : 27
Inscrit le : 30/12/2009
Messages : 1067

[VX] Sauvegarde améliorée Empty
MessageSujet: Re: [VX] Sauvegarde améliorée   [VX] Sauvegarde améliorée Icon_minitimeDim 4 Aoû 2013 - 12:01

Encore heureux, il serait pas ici sinon. Mais essaie de faire attention au necroposts, surtout si c'est pour ne rien dire de bien construit ^^'
Revenir en haut Aller en bas
http://vx-fan.1fr1.net
Contenu sponsorisé




[VX] Sauvegarde améliorée Empty
MessageSujet: Re: [VX] Sauvegarde améliorée   [VX] Sauvegarde améliorée Icon_minitime

Revenir en haut Aller en bas
 

[VX] Sauvegarde améliorée

Voir le sujet précédent Voir le sujet suivant Revenir en haut 
Page 1 sur 1

 Sujets similaires

-
» Problème avec le script Menu Sauvegarde améliorée de Samarium
» [ADD-ON SBS] : Ambidextrie Améliorée
» Demande aide pour script météo améliorée
» Système de sauvegarde
» Effacer une sauvegarde

Permission de ce forum:Vous ne pouvez pas répondre aux sujets dans ce forum
RPG Maker VX :: Entraide :: Scripts :: Scripts VX - RGSS2 :: Sauvegarde-
Créer un forum | ©phpBB | Forum gratuit d'entraide | Signaler un abus | Forum gratuit