mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-07 21:24:59 +00:00
Rewrote load game screen inc. supporting multiple save files, allowed \PN and \v[42] in map names and Town Map point names
This commit is contained in:
@@ -6,6 +6,8 @@
|
||||
# @see SaveData.register_conversion
|
||||
#===============================================================================
|
||||
module SaveData
|
||||
DIRECTORY = (File.directory?(System.data_directory)) ? System.data_directory : "./"
|
||||
FILENAME_REGEX = /Game(\d*)\.rxdata$/
|
||||
# Contains the file path of the save file.
|
||||
FILE_PATH = if File.directory?(System.data_directory)
|
||||
System.data_directory + "/Game.rxdata"
|
||||
@@ -18,6 +20,19 @@ module SaveData
|
||||
return File.file?(FILE_PATH)
|
||||
end
|
||||
|
||||
# @return[Array] array of filenames in the save folder that are save files
|
||||
def self.all_save_files
|
||||
files = Dir.get(DIRECTORY, "*", false)
|
||||
ret = []
|
||||
files.each do |file|
|
||||
next if !file[FILENAME_REGEX]
|
||||
ret.push([$~[1].to_i, file])
|
||||
end
|
||||
ret.sort! { |a, b| a[0] <=> b[0] }
|
||||
ret.map! { |val| val[1] }
|
||||
return ret
|
||||
end
|
||||
|
||||
# Fetches the save data from the given file.
|
||||
# Returns an Array in the case of a pre-v19 save file.
|
||||
# @param file_path [String] path of the file to load from
|
||||
@@ -64,9 +79,9 @@ module SaveData
|
||||
|
||||
# Deletes the save file (and a possible .bak backup file if one exists)
|
||||
# @raise [Error::ENOENT]
|
||||
def self.delete_file
|
||||
File.delete(FILE_PATH)
|
||||
File.delete(FILE_PATH + ".bak") if File.file?(FILE_PATH + ".bak")
|
||||
def self.delete_file(filename)
|
||||
File.delete(DIRECTORY + filename)
|
||||
File.delete(DIRECTORY + filename + ".bak") if File.file?(DIRECTORY + filename + ".bak")
|
||||
end
|
||||
|
||||
# Converts the pre-v19 format data to the new format.
|
||||
|
||||
@@ -259,9 +259,9 @@ module SaveData
|
||||
# been set to be loaded during bootup. Done when a save file exists.
|
||||
# @param save_data [Hash] save data to load
|
||||
# @raise [InvalidValueError] if an invalid value is being loaded
|
||||
def self.load_bootup_values(save_data)
|
||||
def self.load_bootup_values(save_data, reload = false)
|
||||
validate save_data => Hash
|
||||
load_values(save_data) { |value| !value.loaded? && value.load_in_bootup? }
|
||||
load_values(save_data) { |value| (reload || !value.loaded?) && value.load_in_bootup? }
|
||||
end
|
||||
|
||||
# Goes through each value with {Value#load_in_bootup} enabled and loads their
|
||||
|
||||
@@ -10,16 +10,17 @@ SaveData.register(:player) do
|
||||
end
|
||||
|
||||
SaveData.register(:game_system) do
|
||||
load_in_bootup
|
||||
# TODO: Am I sure this doesn't need to be loaded in bootup?
|
||||
# load_in_bootup
|
||||
ensure_class :Game_System
|
||||
save_value { $game_system }
|
||||
load_value { |value| $game_system = value }
|
||||
new_game_value { Game_System.new }
|
||||
reset_on_new_game
|
||||
# reset_on_new_game
|
||||
end
|
||||
|
||||
SaveData.register(:pokemon_system) do
|
||||
load_in_bootup
|
||||
load_in_bootup # Because this contains values for the Options screen
|
||||
ensure_class :PokemonSystem
|
||||
save_value { $PokemonSystem }
|
||||
load_value { |value| $PokemonSystem = value }
|
||||
@@ -96,7 +97,6 @@ SaveData.register(:storage_system) do
|
||||
end
|
||||
|
||||
SaveData.register(:essentials_version) do
|
||||
load_in_bootup
|
||||
ensure_class :String
|
||||
save_value { Essentials::VERSION }
|
||||
load_value { |value| $save_engine_version = value }
|
||||
@@ -104,7 +104,6 @@ SaveData.register(:essentials_version) do
|
||||
end
|
||||
|
||||
SaveData.register(:game_version) do
|
||||
load_in_bootup
|
||||
ensure_class :String
|
||||
save_value { Settings::GAME_VERSION }
|
||||
load_value { |value| $save_game_version = value }
|
||||
@@ -112,10 +111,8 @@ SaveData.register(:game_version) do
|
||||
end
|
||||
|
||||
SaveData.register(:stats) do
|
||||
load_in_bootup
|
||||
ensure_class :GameStats
|
||||
save_value { $stats }
|
||||
load_value { |value| $stats = value }
|
||||
new_game_value { GameStats.new }
|
||||
reset_on_new_game
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user