Single Save File System

Discussion in 'RGSS3 Scripts (RMVX Ace)' started by MeowFace, Dec 17, 2015.

  1. MeowFace

    MeowFace Meow Veteran

    Messages:
    1,034
    Likes Received:
    178
    Location:
    La La Land
    First Language:
    Meowish
    Made a script that required one save file system in the request board awhile back
    and found an urge to make the whole one save file script.
    So here it is! Single Save File System!
     
    [​IMG]
     
    Features:
    [1] Able to change the default save file name to whatever you want.
    [2] Save/Load without the need to enter save/load menu.
    [3] Display Saving Message and Icon on save
    [4] Hide Load Command in Title Scene when there is no save file
    [5] Confirmation on Restarting a new game if save file exist.
    [6] Auto delete save file when restarting a new game.
    [7] Able to change all text message/command text in the script's Settings.
    [8] Opening Save Menu using Eventing will directly save the game.
     
    How to Use:
    [1] Paste this script in your script editor below Material and above Main.
    [2] Set up your preferences in the script's SETTINGS AREA
     
    Note:
    Event's Open Save Menu will directly save the game. Please use that if you wish to force save the game.
     
    Compatibility:
    This script overwrites how the save/load is handled in game as well as some of the GUI in Title Scene.
    If you have custom script overwriting the methods this script uses, there's a chance of conflict.
     
    Terms of Use:
    Free for both commercial and non-commercial.
     
    Script:

    Code:
    #==============================================================================# ■ Meow Face Single Save File System#------------------------------------------------------------------------------# Change the game save/load system to work on one save file only.#==============================================================================# How to Use:# [1] Paste this below Material and above Main# [2] Set your preferences save file name in the script's SETTINGS AREA#==============================================================================module MeowSaveFileManager #DO NOT REMOVE!!#==============================================================================# Settings Area#==============================================================================  #---------------#  # Save File Name  #  #---------------#  FILE_NAME = "meow.dat" #save file name and extension  #--------------#  # Saving a Game #  #--------------#  SAVE_MESSAGE = "Now Saving..." #save message to display  SAVE_ICON = 286 #(icon id) set which icon to be displayed with the save message  #----------------------#  # Restarting A New Game  #  #----------------------#  CONFIRM_MESSAGE = "Are you sure to restart a new game?" #Confirmation message  OVERWRITE_WARNING = "Warning!! You will lost your current progress!" #Warning Message  YES = "I'm Sure!"  NO = "No Way!"#==============================================================================# End of Settings Area# Edit anything past this line at your own risk!#==============================================================================endmodule DataManager  def self.save_file_exists? #overwrite    !Dir.glob(MeowSaveFileManager::FILE_NAME).empty?  end  def self.savefile_max #overwrite    return 1  end  def self.make_filename(index) #overwrite    sprintf(MeowSaveFileManager::FILE_NAME, index + 1)  endendclass Game_Map  attr_accessor :sm_show  alias meow_setup_sm setup  def setup(map_id) #alias    meow_setup_sm(map_id)    @sm_show = false  end  def show_sm    SceneManager.scene.show_save_message    @sm_show = false  end  alias meow_update_sm update  def update(main = false) #alias    meow_update_sm(main)     show_sm if @sm_show  endendclass Game_Interpreter  def command_352 #overwrite    return if $game_party.in_battle    if DataManager.save_game(0)      Sound.play_save      $game_map.sm_show = true    else      Sound.play_buzzer    end  endendclass Window_SaveMessage < Window_Base  def initialize    super(Graphics.width - window_width, Graphics.height - fitting_height(1), window_width, fitting_height(1))    self.opacity = 0    self.contents_opacity = 0    @show_count = 0    refresh  end  def window_width    return 240  end  def update    super    if @show_count > 0 && $game_map.name_display      update_fadein      @show_count -= 1    else      update_fadeout    end  end  def update_fadein    self.contents_opacity += 16  end  def update_fadeout    self.contents_opacity -= 16  end  def open    refresh    @show_count = 150    self.contents_opacity = 0    self  end  def close    @show_count = 0    self  end  def refresh    contents.clear    draw_background(contents.rect)    draw_icon(MeowSaveFileManager::SAVE_ICON, contents.rect.width-24, 0)    draw_icon(MeowSaveFileManager::SAVE_ICON, contents.rect.x, 0)    draw_text(contents.rect.x,contents.rect.y,contents.rect.width, fitting_height(0), MeowSaveFileManager::SAVE_MESSAGE, 1)  end  def draw_background(rect)    temp_rect = rect.clone    temp_rect.width /= 2    contents.gradient_fill_rect(temp_rect, back_color2, back_color1)    temp_rect.x = temp_rect.width    contents.gradient_fill_rect(temp_rect, back_color1, back_color2)  end  def back_color1    Color.new(0, 0, 0, 192)  end  def back_color2    Color.new(0, 0, 0, 0)  endendclass Window_TitleCommand < Window_Command  def make_command_list #overwrite    add_command(Vocab::new_game, :new_game)    add_command(Vocab::continue, :continue, continue_enabled) if DataManager.save_file_exists?    add_command(Vocab::shutdown, :shutdown)  endendclass Window_StartNewAsk < Window_Base  def initialize    super((Graphics.width - window_width)/2, (Graphics.height - fitting_height(5))/2, window_width, fitting_height(5))    create_message  end  def window_width    return Graphics.width - 40  end  def create_message    draw_text(contents.rect.x,contents.rect.y,contents.rect.width, fitting_height(0), MeowSaveFileManager::CONFIRM_MESSAGE, 1)    draw_text(contents.rect.x,contents.rect.y+fitting_height(0),contents.rect.width, fitting_height(0), MeowSaveFileManager::OVERWRITE_WARNING, 1)    draw_text(contents.rect.x,contents.rect.y+fitting_height(2),contents.rect.width, fitting_height(0), "/", 1)  endendclass Window_StartNewConfirm < Window_HorzCommand  def initialize    super(0, 0)    update_placement    self.opacity = 0  end  def window_width    return 240  end  def col_max    return 2  end  def spacing    return 12  end  def update_placement    self.x = (Graphics.width - window_width) / 2  end  def make_command_list    add_command(MeowSaveFileManager::YES, :ok)    add_command(MeowSaveFileManager::NO,   :cancel)  endendclass Scene_Title < Scene_Base  alias meow_st_start_sm start  def start    meow_st_start_sm    create_ask_window    create_confirm_window  end  def mf_start_new_game    DataManager.setup_new_game    close_command_window    fadeout_all    $game_map.autoplay    SceneManager.goto(Scene_Map)  end  def create_ask_window    @ask_window = Window_StartNewAsk.new    @ask_window.hide  end  def create_confirm_window    @confirm_select_window = Window_StartNewConfirm.new    @confirm_select_window.y = @ask_window.y + (24*3)    @confirm_select_window.set_handler(:ok,     method(:on_confirm_ok))    @confirm_select_window.set_handler(:cancel, method(:on_confirm_cancel))    @confirm_select_window.hide.deactivate  end  def on_confirm_ok    @ask_window.close    @confirm_select_window.close    DataManager.delete_save_file(0)    mf_start_new_game  end  def on_confirm_cancel    @ask_window.hide    @confirm_select_window.hide.deactivate    @command_window.show.activate  end  def command_new_game #overwrite    if DataManager.save_file_exists?      @command_window.hide.deactivate      @ask_window.show      @confirm_select_window.show.activate    else      mf_start_new_game    end  end  def command_continue #overwrite    close_command_window    if DataManager.load_game(0)      Sound.play_load      fadeout_all      $game_system.on_after_load      SceneManager.goto(Scene_Map)    else      Sound.play_buzzer    end  endendclass Scene_Map < Scene_Base  def create_save_message_window    @sm_window = Window_SaveMessage.new  end  def show_save_message    @sm_window.open  end  alias meow_sm_caw_sm create_all_windows  def create_all_windows #alias    meow_sm_caw_sm    create_save_message_window  endendclass Scene_Menu < Scene_MenuBase  def command_save #overwrite    if DataManager.save_game(0)      Sound.play_save      $game_map.sm_show = true      return_scene    else      Sound.play_buzzer    end  endend
     
    Last edited by a moderator: Dec 17, 2015
    #1
  2. Crimson Dragon Inc.

    Crimson Dragon Inc. Crimson Dragon Veteran

    Messages:
    925
    Likes Received:
    133
    Location:
    Sheboygan wisconsin
    First Language:
    english
    Primarily Uses:
    RMMV
    gah not a plug in D:
     
    #2
  3. MeowFace

    MeowFace Meow Veteran

    Messages:
    1,034
    Likes Received:
    178
    Location:
    La La Land
    First Language:
    Meowish
    Nope, this is RGSS3
     
    #3
  4. Crimson Dragon Inc.

    Crimson Dragon Inc. Crimson Dragon Veteran

    Messages:
    925
    Likes Received:
    133
    Location:
    Sheboygan wisconsin
    First Language:
    english
    Primarily Uses:
    RMMV
    but i want D:
     
    #4
  5. MeowFace

    MeowFace Meow Veteran

    Messages:
    1,034
    Likes Received:
    178
    Location:
    La La Land
    First Language:
    Meowish
    Sorry, i am not planning to support MV nor am i planning to get one in the future, unless they solve the RTP system for MV. Else i don't see the point of using MV over Unity. Unity is more powerful and suits my requirement for now. ;)
     
    #5
  6. MeowFace

    MeowFace Meow Veteran

    Messages:
    1,034
    Likes Received:
    178
    Location:
    La La Land
    First Language:
    Meowish
    The script is the top post is messed up due to the recent V3 to V4 forum migration.


    Please use this alternative version until the web staff is able to fix the top post.

    Code:
    #==============================================================================
    # ■ Meow Face Single Save File System
    #------------------------------------------------------------------------------
    # Change the game save/load system to work on one save file only.
    #==============================================================================
    # How to Use:
    # [1] Paste this below Material and above Main
    # [2] Set your preferences save file name in the script's SETTINGS AREA
    #==============================================================================
    module MeowSaveFileManager #DO NOT REMOVE!!
    #==============================================================================
    # Settings Area
    #==============================================================================
      #---------------#
      # Save File Name  #
      #---------------#
      FILE_NAME = "meow.dat" #save file name and extension
      #--------------#
      # Saving a Game #
      #--------------#
      SAVE_MESSAGE = "Now Saving..." #save message to display
      SAVE_ICON = 286 #(icon id) set which icon to be displayed with the save message
      #----------------------#
      # Restarting A New Game  #
      #----------------------#
      CONFIRM_MESSAGE = "Are you sure to restart a new game?" #Confirmation message
      OVERWRITE_WARNING = "Warning!! You will lost your current progress!" #Warning Message
      YES = "I'm Sure!"
      NO = "No Way!"
    #==============================================================================
    # End of Settings Area
    # Edit anything past this line at your own risk!
    #==============================================================================
    end
    module DataManager
      def self.save_file_exists? #overwrite
        !Dir.glob(MeowSaveFileManager::FILE_NAME).empty?
      end
      def self.savefile_max #overwrite
        return 1
      end
      def self.make_filename(index) #overwrite
        sprintf(MeowSaveFileManager::FILE_NAME, index + 1)
      end
    end
    class Game_Map
      attr_accessor :sm_show
      alias meow_setup_sm setup
      def setup(map_id) #alias
        meow_setup_sm(map_id)
        @sm_show = false
      end
      def show_sm
        SceneManager.scene.show_save_message
        @sm_show = false
      end
      alias meow_update_sm update
      def update(main = false) #alias
        meow_update_sm(main) 
        show_sm if @sm_show
      end
    end
    class Game_Interpreter
      def command_352 #overwrite
        return if $game_party.in_battle
        if DataManager.save_game(0)
          Sound.play_save
          $game_map.sm_show = true
        else
          Sound.play_buzzer
        end
      end
    end
    class Window_SaveMessage < Window_Base
      def initialize
        super(Graphics.width - window_width, Graphics.height - fitting_height(1), window_width, fitting_height(1))
        self.opacity = 0
        self.contents_opacity = 0
        @show_count = 0
        refresh
      end
      def window_width
        return 240
      end
      def update
        super
        if @show_count > 0 && $game_map.name_display
          update_fadein
          @show_count -= 1
        else
          update_fadeout
        end
      end
      def update_fadein
        self.contents_opacity += 16
      end
      def update_fadeout
        self.contents_opacity -= 16
      end
      def open
        refresh
        @show_count = 150
        self.contents_opacity = 0
        self
      end
      def close
        @show_count = 0
        self
      end
      def refresh
        contents.clear
        draw_background(contents.rect)
        draw_icon(MeowSaveFileManager::SAVE_ICON, contents.rect.width-24, 0)
        draw_icon(MeowSaveFileManager::SAVE_ICON, contents.rect.x, 0)
        draw_text(contents.rect.x,contents.rect.y,contents.rect.width, fitting_height(0), MeowSaveFileManager::SAVE_MESSAGE, 1)
      end
      def draw_background(rect)
        temp_rect = rect.clone
        temp_rect.width /= 2
        contents.gradient_fill_rect(temp_rect, back_color2, back_color1)
        temp_rect.x = temp_rect.width
        contents.gradient_fill_rect(temp_rect, back_color1, back_color2)
      end
      def back_color1
        Color.new(0, 0, 0, 192)
      end
      def back_color2
        Color.new(0, 0, 0, 0)
      end
    end
    class Window_TitleCommand < Window_Command
      def make_command_list #overwrite
        add_command(Vocab::new_game, :new_game)
        add_command(Vocab::continue, :continue, continue_enabled) if DataManager.save_file_exists?
        add_command(Vocab::shutdown, :shutdown)
      end
    end
    class Window_StartNewAsk < Window_Base
      def initialize
        super((Graphics.width - window_width)/2, (Graphics.height - fitting_height(5))/2, window_width, fitting_height(5))
        create_message
      end
      def window_width
        return Graphics.width - 40
      end
      def create_message
        draw_text(contents.rect.x,contents.rect.y,contents.rect.width, fitting_height(0), MeowSaveFileManager::CONFIRM_MESSAGE, 1)
        draw_text(contents.rect.x,contents.rect.y+fitting_height(0),contents.rect.width, fitting_height(0), MeowSaveFileManager::OVERWRITE_WARNING, 1)
        draw_text(contents.rect.x,contents.rect.y+fitting_height(2),contents.rect.width, fitting_height(0), "/", 1)
      end
    end
    class Window_StartNewConfirm < Window_HorzCommand
      def initialize
        super(0, 0)
        update_placement
        self.opacity = 0
      end
      def window_width
        return 240
      end
      def col_max
        return 2
      end
      def spacing
        return 12
      end
      def update_placement
        self.x = (Graphics.width - window_width) / 2
      end
      def make_command_list
        add_command(MeowSaveFileManager::YES, :ok)
        add_command(MeowSaveFileManager::NO,   :cancel)
      end
    end
    class Scene_Title < Scene_Base
      alias meow_st_start_sm start
      def start
        meow_st_start_sm
        create_ask_window
        create_confirm_window
      end
      def mf_start_new_game
        DataManager.setup_new_game
        close_command_window
        fadeout_all
        $game_map.autoplay
        SceneManager.goto(Scene_Map)
      end
      def create_ask_window
        @ask_window = Window_StartNewAsk.new
        @ask_window.hide
      end
      def create_confirm_window
        @confirm_select_window = Window_StartNewConfirm.new
        @confirm_select_window.y = @ask_window.y + (24*3)
        @confirm_select_window.set_handler(:ok,     method(:on_confirm_ok))
        @confirm_select_window.set_handler(:cancel, method(:on_confirm_cancel))
        @confirm_select_window.hide.deactivate
      end
      def on_confirm_ok
        @ask_window.close
        @confirm_select_window.close
        DataManager.delete_save_file(0)
        mf_start_new_game
      end
      def on_confirm_cancel
        @ask_window.hide
        @confirm_select_window.hide.deactivate
        @command_window.show.activate
      end
      def command_new_game #overwrite
        if DataManager.save_file_exists?
          @command_window.hide.deactivate
          @ask_window.show
          @confirm_select_window.show.activate
        else
          mf_start_new_game
        end
      end
      def command_continue #overwrite
        close_command_window
        if DataManager.load_game(0)
          Sound.play_load
          fadeout_all
          $game_system.on_after_load
          SceneManager.goto(Scene_Map)
        else
          Sound.play_buzzer
        end
      end
    end
    class Scene_Map < Scene_Base
      def create_save_message_window
        @sm_window = Window_SaveMessage.new
      end
      def show_save_message
        @sm_window.open
      end
      alias meow_sm_caw_sm create_all_windows
      def create_all_windows #alias
        meow_sm_caw_sm
        create_save_message_window
      end
    end
    class Scene_Menu < Scene_MenuBase
      def command_save #overwrite
        if DataManager.save_game(0)
          Sound.play_save
          $game_map.sm_show = true
          return_scene
        else
          Sound.play_buzzer
        end
      end
    end
     
    #6
    Romanticist and Ploy_V like this.

Share This Page