Dinasty RPG
Gostaria de reagir a esta mensagem? Crie uma conta em poucos cliques ou inicie sessão para continuar.

Dinasty RPG

Fórum para interessados em Rpgs, Indie Games, RPG Maker e afins
 
InícioPortalProcurarÚltimas imagensRegistrarEntrar

 

 Script de Save avançado

Ir para baixo 
AutorMensagem
Zendion
Cordenador
Cordenador
Zendion


Mensagens : 372
Data de inscrição : 31/07/2011
Idade : 27
Localização : Leme

Script de Save avançado Empty
MensagemAssunto: Script de Save avançado   Script de Save avançado I_icon_minitimeSáb Ago 20, 2011 9:06 pm

Este script modifica o menu de save deixando-o bem mais legal e ainda lhe permite dar um nome ao save ao inves de "jogo 1"

Código:
#-------------------------------------------------------
#                Advanced Save/Load 1.0               
#-------------------------------------------------------
=begin

Criado por GuiRPG - www.guirpg.vai.la

Esse Script Modifica Totalmente o Sistema de Salvar e de Carregar,
tenho certeza que todos irão gostar^^

=end

module Vocab
 
  File  = "Vazio" # O que colocar caso o save esteja vazio
 
  end

module GuiRPG
 
  NUMERO_MAX_DE_SAVES = 15 # Número Máximo de Saves
 
  DIR_SAVES = "Save/" # Diretório dos Arquivos Salvos (Nunca Mude)
 
  Var = 4 #Qual variável vai conter o nome do capítulo?
 
  SaveWidth = 160 #Largura da lista de saves. Não use valores muito altos.
end


class Game_Temp
 attr_accessor :menu_bitmap             
 attr_accessor :sub_menu_bitmap         
 attr_accessor :save_bitmap           
 alias ini initialize
 def initialize
  ini
  @menu_bitmap = Bitmap.new(1, 1)
  @sub_menu_bitmap = Bitmap.new(1, 1)
  @save_bitmap = Bitmap.new(1, 1)
 end
end

 
 
class Window_SaveFile < Window_Base

 attr_reader  :filename               
 attr_reader  :file_exist           

 def initialize(file_index, filename)
  super(176, 59, 304+GuiRPG::SaveWidth-112, 340)
  @file_index = file_index
  @filename = filename
  load_gamedata
  refresh(@file_index)
 end

 def load_gamedata
  @file_exist = FileTest.exist?(GuiRPG::DIR_SAVES + @filename)
  if @file_exist
    file = File.open(GuiRPG::DIR_SAVES + @filename, "r")
    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)
      @total_sec = @frame_count / Graphics.frame_rate
    rescue
      @file_exist = false
    ensure
      file.close
    end
  end
 end

 
 def refresh(index)
  file_index = index
  self.contents.clear
  self.contents.font.color = normal_color
  if @file_exist
    self.contents.fill_rect(0, 0, 272,208+2, Color.new(0,0,64))
    if FileTest.exist?(GuiRPG::DIR_SAVES + @filename.split(/\./)[0] + ".png")
      self.contents.blur
      draw_save_bitmap(0,0)
    else
      self.contents.draw_text(0, 64, 304-32, 24, "inválido", 1)
    end
    draw_party_characters(108, 288-56)
    draw_playtime(0, 288+8-56, contents.width-4, 2)
  else
    self.contents.draw_text(0, 288-56, contents.width-4, 24, "Nenhum Jogo Salvo Aqui", 1)
  end
 end

 
 def file_index=(file_index)
  @file_index = file_index
 end

def draw_party_characters(x, y)
  for i in 0...@characters.size
    name = @characters[i][0]
    index = @characters[i][1]
    draw_character(name, index, x + i * 48, y)
  end
 end

def draw_save_bitmap(x, y)
  bitmap = Bitmap.new(GuiRPG::DIR_SAVES + @filename.split(/\./)[0] + ".png")
  rect = Rect.new(0, 0, 0, 0)
  rect.width = bitmap.width
  rect.height = bitmap.height
  self.contents.blt(x, y, bitmap, rect)
  bitmap.dispose
 end


 
 def draw_playtime(x, y, width, align)
  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(x, y, width, WLH, time_string, 2)
 end
end

class Window_Menu_Command < Window_Selectable

 attr_reader  :commands             


 def initialize(width, commands, column_max = 16, row_max = 0, spacing = 8)
  if row_max == 0
    row_max = (commands.size + column_max - 1) / column_max
  end
  super(0, 416-54, width, row_max * WLH + 32, spacing)
  @commands = commands
  @item_max = commands.size
  @column_max = column_max
  self.index = 0
 end

 def refresh
  self.contents.clear
  for i in 0...@item_max
    draw_item(i)
  end
 end

def draw_item(index, enabled = true)
  rect = item_rect(index)
  rect.width -= 8
  self.contents.clear_rect(rect)
  self.contents.font.color = normal_color
  self.contents.font.color.alpha = enabled ? 255 : 128
 end

 def update_help
  text = $data_system.game_title
  if @commands[self.index] != nil
    text += ": " + @commands[self.index]
  end
  @help_window.set_text(text)
 end
end

class Scene_Base

 def create_menu_background
  @menuback_sprite = Sprite.new
  @menuback_sprite.bitmap = $game_temp.background_bitmap
  update_menu_background
 end

 def create_sub_menu_background
  @menuback_sprite = Sprite.new
  @menuback_sprite.bitmap = $game_temp.sub_menu_bitmap
  update_menu_background
 end

 def snapshot_for_save
  d_rect = Rect.new(0, 0, 272, 208)
  s_rect = Rect.new(0, 0, 544, 416)
  save_bitmap = Graphics.snap_to_bitmap
  $game_temp.save_bitmap.dispose
  $game_temp.save_bitmap = Bitmap.new(272, 208)
  $game_temp.save_bitmap.stretch_blt(d_rect, save_bitmap, s_rect)
 end
end

class Scene_Map < Scene_Base

 def terminate
  super
  snapshot_for_save               
  if $scene.is_a?(Scene_Battle)   
    @spriteset.dispose_characters 
  end
  snapshot_for_background         
  snapshot_for_menu               
  @spriteset.dispose
  @message_window.dispose
  if $scene.is_a?(Scene_Battle)   
    perform_battle_transition     
  end
 end

 def snapshot_for_menu
  $game_temp.menu_bitmap.dispose
  $game_temp.menu_bitmap = Graphics.snap_to_bitmap
 end

 def call_menu
  if $game_temp.menu_beep
    Sound.play_decision
    $game_temp.menu_beep = false
  end
  $game_temp.next_scene = nil
  $scene = Scene_Menu.new
 end
end

class Scene_Title < Scene_Base

 def check_continue
  @continue_enabled = (Dir.glob(GuiRPG::DIR_SAVES + 'Save*.rvdata').size > 0)
 end
end

class Scene_Status < Scene_Base

 def start
  super
  create_sub_menu_background
  @actor = $game_party.members[@actor_index]
  @status_window = Window_Status.new(@actor)
  @status_window.openness = 0
 end

 def post_start
  super
  open_status_window
 end

 def pre_terminate
  super
  close_status_window
 end

 def open_status_window
  @status_window.open
  begin
    @status_window.update
    Graphics.update
  end until @status_window.openness == 255
 end

 def close_status_window
  @status_window.close
  begin
    @status_window.update
    Graphics.update
  end until @status_window.openness == 0
 end
end

class Scene_File < Scene_Base


 def initialize(saving, from_title, from_event)
  @saving = saving
  @from_title = from_title
  @from_event = from_event
 end

 def start
  super
  @help_window = Window_Help.new
  unless $game_temp.sub_menu_bitmap.width == 1
    @help_window.opacity = 0
    create_sub_menu_background
  else
    create_title_graphic
  end
  create_command_window
  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)
  end
  @refresh_index = @command_window.index = @index
  @item_max = GuiRPG::NUMERO_MAX_DE_SAVES
  create_savefile_window
  @savefile_window.openness = 0
 end

 def terminate
  super
  dispose_menu_background
  @help_window.dispose
  dispose_item_windows
 end

 def return_scene
  if @from_title
    $scene = Scene_Title.new
  elsif @from_event
    $scene = Scene_Map.new
  else
    $scene = Scene_Menu.new(4)
  end
 end

 def update
  super
  update_menu_background
  @help_window.update
  update_savefile_windows
  update_savefile_selection
 end

 def post_start
  super
  open_savefile_window
 end

 def pre_terminate
  super
  close_savefile_window
 end

 def create_title_graphic
  @menuback_sprite = Sprite.new
  @menuback_sprite.bitmap = Cache.system("Title")
 end

 def create_command_window
  file_names = []
  for i in 0...GuiRPG::NUMERO_MAX_DE_SAVES
    id = (i+1).to_s
    @filename = Vocab::File+id+'.rvdata'
    file_names.push(load_gamedata)
  end
  @command_window = Window_Command.new(GuiRPG::SaveWidth, file_names)
  @command_window.height = 340
  @command_window.x = 176 - @command_window.width
  @command_window.y = 59
  @command_window.openness = 0
 end

 def load_gamedata
  filename = GuiRPG::DIR_SAVES+@filename.gsub!(Vocab::File,'Save')
  @file_exist = FileTest.exist?(filename)
  if @file_exist
    file = File.open(filename, "r")
    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)
      @total_sec = @frame_count / Graphics.frame_rate
      returned = @game_variables[GuiRPG::Var].to_s#@characters[0][0]
    rescue
      @file_exist = false
    ensure
      file.close
    end
    return returned
  else
    return Vocab::File
  end
 end
 
 def create_savefile_window
  @savefile_window = Window_SaveFile.new(@command_window.index, make_filename(@command_window.index))
 end

 def dispose_item_windows
  @command_window.dispose
  @savefile_window.dispose
 end

 def open_savefile_window
  @command_window.open
  @savefile_window.open
  begin
    @command_window.update
    @savefile_window.update
    Graphics.update
  end until @savefile_window.openness == 255
 end

 def close_savefile_window
  @command_window.close
  @savefile_window.close
  begin
    @command_window.update
    @savefile_window.update
    Graphics.update
  end until @savefile_window.openness == 0
 end

 def update_savefile_windows
  @command_window.update
  @savefile_window.update
 end

 def update_savefile_selection
  if Input.trigger?(Input::C)
    determine_savefile
  end
  if Input.trigger?(Input::B)
    Sound.play_cancel
    return_scene
  end
  if @refresh_index != @command_window.index
    @refresh_index = @command_window.index
    @savefile_window.dispose
    create_savefile_window
    end
 end

 def determine_savefile
  if @saving
    Sound.play_save
    do_save
  else
    if @savefile_window.file_exist
      Sound.play_load
      do_load
    else
      Sound.play_buzzer
      return
    end
  end
  $game_temp.last_file_index = @index
 end

 
 def make_filename(file_index)
  return "Save#{file_index + 1}.rvdata"
 end

 def latest_file_index
  index = 0
  latest_time = Time.at(0)
  for i in 0...GuiRPG::NUMERO_MAX_DE_SAVES
    file_name = make_filename(i)
    if FileTest.exist?(GuiRPG::DIR_SAVES + file_name)
      file = File.open(GuiRPG::DIR_SAVES + file_name, "r")
      if file.mtime > latest_time
        latest_time = file.mtime
        index = i
      end
    end
  end
  return index
 end

 def do_save
  file_name = make_filename(@command_window.index)
  $game_temp.save_bitmap.make_png(file_name.split(/\./)[0], GuiRPG::DIR_SAVES)
  file = File.open(GuiRPG::DIR_SAVES + file_name, "wb")
  write_save_data(file)
  file.close
  return_scene
 end

 def do_load
  file_name = make_filename(@command_window.index)
  file = File.open("Save/" + file_name, "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
end

module Zlib
 class Png_File < GzipWriter

  def make_png(bitmap_Fx)
    @bitmap_Fx = bitmap_Fx
    self.write(make_header)
    self.write(make_ihdr)
    self.write(make_idat)
    self.write(make_iend)
  end
 
 
 
  def make_header
    return [0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a].pack("C*")
  end
 
 
 
  def make_ihdr
    ih_size = [13].pack("N")
    ih_sign = "IHDR"
    ih_width = [@bitmap_Fx.width].pack("N")
    ih_height = [@bitmap_Fx.height].pack("N")
    ih_bit_depth = [8].pack("C")
    ih_color_type = [6].pack("C")
    ih_compression_method = [0].pack("C")
    ih_filter_method = [0].pack("C")
    ih_interlace_method = [0].pack("C")
    string = ih_sign + ih_width + ih_height + ih_bit_depth + ih_color_type +
              ih_compression_method + ih_filter_method + ih_interlace_method
    ih_crc = [Zlib.crc32(string)].pack("N")
    return ih_size + string + ih_crc
  end
 
 
 
  def make_idat
    header = "\x49\x44\x41\x54"
    data = make_bitmap_data
    data = Zlib::Deflate.deflate(data, 8)
    crc = [Zlib.crc32(header + data)].pack("N")
    size = [data.length].pack("N")
    return size + header + data + crc
  end
 
 
 
  def make_bitmap_data
    gz = Zlib::GzipWriter.open('hoge.gz')
    t_Fx = 0
    w = @bitmap_Fx.width
    h = @bitmap_Fx.height
    data = []
    for y in 0...h
      data.push(0)
      for x in 0...w
        t_Fx += 1
        if t_Fx % 10000 == 0
          Graphics.update
        end
        if t_Fx % 100000 == 0
          s = data.pack("C*")
          gz.write(s)
          data.clear
        end
        color = @bitmap_Fx.get_pixel(x, y)
        red = color.red
        green = color.green
        blue = color.blue
        alpha = color.alpha
        data.push(red)
        data.push(green)
        data.push(blue)
        data.push(alpha)
      end
    end
    s = data.pack("C*")
    gz.write(s)
    gz.close   
    data.clear
    gz = Zlib::GzipReader.open('hoge.gz')
    data = gz.read
    gz.close
    File.delete('hoge.gz')
    return data
  end
 
 
 
  def make_iend
    ie_size = [0].pack("N")
    ie_sign = "IEND"
    ie_crc = [Zlib.crc32(ie_sign)].pack("N")
    return ie_size + ie_sign + ie_crc
  end
 end
end
class Bitmap

 def make_png(name="Gui_Img_Save", path="",mode=0)
  make_dir(path) if path != ""
  Zlib::Png_File.open("temp.gz") {|gz|
    gz.make_png(self)
  }
  Zlib::GzipReader.open("temp.gz") {|gz|
    $read = gz.read
  }
  f = File.open(path + name + ".png","wb")
  f.write($read)
  f.close
  File.delete('temp.gz')
  end

 def make_dir(path)
  dir = path.split("/")
  for i in 0...dir.size
    unless dir == "."
      add_dir = dir[0..i].join("/")
      begin
        Dir.mkdir(add_dir)
      rescue
      end
    end
  end
 end
end

e este

Código:
class Window_Savelist < Window_Selectable
  #--------------------------------------------------------------------------
  # Variáveis públicas
  #--------------------------------------------------------------------------
  attr_reader  :commands                # Comandos
  #--------------------------------------------------------------------------
  # Inicialização do objeto
  #    width      : largura da janela
  #    commands  : array de comandos
  #    column_max : número de colunas (2 ou mais)
  #    row_max    : número de linhas (0: número de comandos)
  #    spacing    : espaçamento entre items localizados próximos
  #--------------------------------------------------------------------------
  def initialize(width, commands, column_max = 1, row_max = 0, spacing = 32)
    if row_max == 0
      row_max = (commands.size + column_max - 1) / column_max
    end
    super(0, 0, width, 11 * WLH + 32, spacing)
    @commands = commands
    @item_max = commands.size
    @column_max = column_max
    refresh
    self.index = 0
  end
  #--------------------------------------------------------------------------
  # Atualização
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    for i in 0...@item_max
      draw_item(i)
    end
  end
  #--------------------------------------------------------------------------
  # Desenho do item
  #    index  : número (ID) do item
  #    enabled : espaço ativo. Quando translúcido significa falso
  #--------------------------------------------------------------------------
  def draw_item(index, enabled = true)
    rect = item_rect(index)
    rect.x += 4
    rect.width -= 8
    self.contents.clear_rect(rect)
    self.contents.font.color = normal_color
    enabled = !(@commands[index] == Vocab::File)
    self.contents.font.color.alpha = enabled ? 255 : 128
    self.contents.draw_text(rect, @commands[index])
  end
 
  def item_rect(index)
    rect = Rect.new(0, 0, 0, 0)
    rect.width = (contents.width + @spacing) / @column_max - @spacing
    rect.height = 32
    rect.x = index % @column_max * (rect.width + @spacing)
    rect.y = index *(contents.height / @item_max)#/ @column_max * WLH
    return rect
  end
end

e para dar o nome desejado ao save, quando for salvar(tem que ser por check point) use o chamar script na aba 3 de eventos e digite

Código:
nm = 'Teste'
$game_variables[GuiRPG::Var] = nm

onde está escrito "teste" vc coloka o nome desejado

creditos a Gui RPG
Espero ter sido util
FUI Jimbabua
Ir para o topo Ir para baixo
https://www.youtube.com/user/Zendionx
 
Script de Save avançado
Ir para o topo 
Página 1 de 1
 Tópicos semelhantes
-
» Script FF7
» Script de vídeo VX e XP
» Castlevania HUD
» Pokémon Script Project DS(raro)
» Omegas7's Quest System Script 3.0 editado

Permissões neste sub-fórumNão podes responder a tópicos
Dinasty RPG  :: Scripts (RGSS/RGSS2) :: Scripts (RGSS2)-
Ir para: