Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #===============================================================================
- # RGSS3: Quicksave v1.3.1
- #===============================================================================
- # by Cryranos/Metatron
- #===============================================================================
- # Instructions: Paste In the Materials section. Edit Module if desired.
- #===============================================================================
- # This script allows the player to quickly save and quit the game. Upon
- # reopening the game, the player will be prompted to load the game. If it is
- # loaded or declined, the quicksave file will be deleted.
- #===============================================================================
- # Compatibility: This script will not work with any script that edits
- # Datamanager.first_scene_class.
- #===============================================================================
- $imported = {} if $imported.nil?
- $imported["CRY_Quicksave"] = true
- module Cry
- module Quicksave
- QSFile = "Save.qsav" # Filename for the quicksave.
- QSDcty = "System" # Directory in which the quicksave is found. Enter
- # nil if you want it saved to the game's parent directory.
- MenuOp = true # Add a quicksave command to the menu?
- QSVNam = "Quicksave" # This is what the menu command will show up as.
- # These are the Quicksave help and the Quickload help. Insert the second
- # line with \n.
- QSVMess = "Would you like to save and quit?\nYour save will be deleted upon resuming."
- QSVLoad = "Would you like to load your quicksave?\nPress cancel to close the game."
- # These are for those who wish to bind the quicksave function to a key
- # rather than to the menu.
- UseKey = false
- QSVKey = Input::F5
- end
- end
- module DataManager
- def self.quicksave_file_exists?
- if Cry::Quicksave::QSDcty == nil
- !Dir.glob(Cry::Quicksave::QSFile).empty?
- else
- !Dir.glob(Cry::Quicksave::QSDcty + "/" + Cry::Quicksave::QSFile).empty?
- end
- end
- def self.make_quicksave_filename
- if Cry::Quicksave::QSDcty == nil
- sprintf(Cry::Quicksave::QSFile)
- else
- sprintf(Cry::Quicksave::QSDcty + "/" + Cry::Quicksave::QSFile)
- end
- end
- def self.quicksave_game
- self.quicksave_game_without_rescue
- end
- def self.quicksave_game_without_rescue
- File.open(make_quicksave_filename, "wb") do |file|
- $game_system.on_before_save
- Marshal.dump(make_save_header, file)
- Marshal.dump(make_save_contents, file)
- end
- end
- def self.quickload_game
- self.load_quicksave_without_rescue
- self.dispose_quicksave
- end
- def self.load_quicksave_without_rescue
- File.open(make_quicksave_filename, "rb") do |file|
- Marshal.load(file)
- extract_save_contents(Marshal.load(file))
- reload_map_if_updated
- end
- end
- def self.dispose_quicksave
- File.delete(make_quicksave_filename) rescue nil
- end
- end
- module SceneManager
- def self.first_scene_class
- if $BTEST
- Scene_Battle
- elsif DataManager.quicksave_file_exists?
- Scene_QuickLoadTitle
- else
- Scene_Title
- end
- end
- end
- if Cry::Quicksave::UseKey
- class Game_Player < Game_Character
- alias quicksave_update update
- def update
- quicksave_update
- if Input.trigger?(Cry::Quicksave::QSVKey)
- SceneManager.call(Scene_Quicksave)
- end
- end
- end
- end
- class Window_QuicksaveCommand < Window_Command
- def initialize
- super(0, 0)
- update_placement
- end
- def window_width
- return 160
- end
- def update_placement
- self.x = (Graphics.width - width) / 2
- self.y = (Graphics.height * 1.6 - height) / 2
- end
- def make_command_list
- add_command("Yes", :confirm)
- add_command("No", :decline)
- end
- end
- class Scene_Quicksave < Scene_MenuBase
- def start
- super
- create_command_window
- create_help_window
- end
- def help_window_text
- Cry::Quicksave::QSVMess
- end
- def create_command_window
- @command_window = Window_QuicksaveCommand.new
- @command_window.set_handler(:confirm, method(:command_quicksave))
- @command_window.set_handler(:decline, method(:command_decline))
- @command_window.set_handler(:cancel, method(:return_scene))
- end
- def create_help_window
- @help_window = Window_Help.new(2)
- @help_window.set_text(help_window_text)
- end
- def command_quicksave
- DataManager.quicksave_game
- fadeout_all
- SceneManager.exit
- end
- def command_decline
- SceneManager.return
- end
- def return_scene
- SceneManager.return
- end
- end
- class Scene_QuickLoadTitle < Scene_Title
- def start
- super
- SceneManager.clear
- Graphics.freeze
- create_background
- create_foreground
- create_command_window
- play_title_music
- create_help_window
- end
- def help_window_text
- Cry::Quicksave::QSVLoad
- end
- def create_command_window
- @command_window = Window_QuicksaveCommand.new
- @command_window.set_handler(:confirm, method(:command_quickload))
- @command_window.set_handler(:decline, method(:command_decline))
- @command_window.set_handler(:cancel, method(:return_scene))
- end
- def create_help_window
- @help_window = Window_Help.new(2)
- @help_window.set_text(help_window_text)
- end
- def command_quickload
- close_command_window
- DataManager.quickload_game
- Sound.play_load
- fadeout_all
- $game_system.on_after_load
- SceneManager.goto(Scene_Map)
- end
- def command_decline
- DataManager.dispose_quicksave
- SceneManager.goto(Scene_Title)
- end
- def return_scene
- fadeout_all
- SceneManager.exit
- end
- end
- if Cry::Quicksave::MenuOp
- class Window_MenuCommand
- alias add_qsv_command add_save_command
- def add_save_command
- add_qsv_command
- add_command(Cry::Quicksave::QSVNam, :qsav)
- end
- end
- class Scene_Menu
- alias add_qsv_to_commands create_command_window
- def create_command_window
- add_qsv_to_commands
- @command_window.set_handler(:qsav, method(:command_quicksave))
- end
- def command_quicksave
- SceneManager.call(Scene_Quicksave)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement