Skip to content

Commit

Permalink
Merge pull request #2 from stoozey/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
stoozey authored Jul 10, 2023
2 parents 5e2f146 + a250829 commit 69efc00
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 15 deletions.
18 changes: 8 additions & 10 deletions objects/obj_ssave_demo_manager/Create_0.gml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#region example ConfigFile

ssave_get(ConfigFile)
.set("subtitles", false)
.save();

.set("subtitles", false);

#endregion

#region example SaveFile - multiple of the same SSave
Expand All @@ -26,15 +25,14 @@ ssave_get(SaveFile, "3")
#region example of SSAVE_PROTECTION

ssave_get(SaveFile, "1")
.set_protection(SSAVE_PROTECTION.NONE)
.save();
.set_protection(SSAVE_PROTECTION.NONE);

ssave_get(SaveFile, "2")
.set_protection(SSAVE_PROTECTION.ENCODE)
.save();
.set_protection(SSAVE_PROTECTION.ENCODE);

ssave_get(SaveFile, "3")
.set_protection(SSAVE_PROTECTION.ENCRYPT)
.save();
.set_protection(SSAVE_PROTECTION.ENCRYPT);

#endregion
#endregion

ssave_save_all();
2 changes: 1 addition & 1 deletion scripts/__scr_ssave_macros/__scr_ssave_macros.gml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ enum SSAVE_PROTECTION
}

#macro __SSAVE_FILE_EXTENSION "ssave"
#macro __SSAVE_VERSION "1.3.0"
#macro __SSAVE_VERSION "1.3.1"
9 changes: 5 additions & 4 deletions scripts/scr_ssave/scr_ssave.gml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function SSave(_name = "data", _protection = SSAVE_PROTECTION_DEFAULT) construct
///@desc Saves the ssave
static save = function()
{
var _filename = __get_filename(__filePrefix);
var _filename = __get_filename();
return __save_to_file(_filename);
}

Expand All @@ -52,7 +52,7 @@ function SSave(_name = "data", _protection = SSAVE_PROTECTION_DEFAULT) construct
if (_filePrefix != undefined)
set_file_prefix(_filePrefix);

var _filename = __get_filename(__filePrefix);
var _filename = __get_filename();
return __load_from_file(_filename);
}

Expand Down Expand Up @@ -82,7 +82,7 @@ function SSave(_name = "data", _protection = SSAVE_PROTECTION_DEFAULT) construct

///@desc Gets the current file prefix
///@returns {string} The file prefix
static get_file_prefix = function(_filePrefix)
static get_file_prefix = function()
{
return __filePrefix;
}
Expand Down Expand Up @@ -163,6 +163,7 @@ function SSave(_name = "data", _protection = SSAVE_PROTECTION_DEFAULT) construct
switch (_header.get_version())
{
default:
case "1.3.1":
case "1.3.0":
case "1.2.0":
case "1.1.1":
Expand Down Expand Up @@ -235,7 +236,7 @@ function SSave(_name = "data", _protection = SSAVE_PROTECTION_DEFAULT) construct
return __values[$ _name];
}

static __get_filename = function(_prefix = "")
static __get_filename = function()
{
return (__ssave_get_save_directory() + get_full_name() + "." + __SSAVE_FILE_EXTENSION);
}
Expand Down
26 changes: 26 additions & 0 deletions scripts/scr_ssave_manager/scr_ssave_manager.gml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ if (SSAVE_USE_MANAGER)
global.__ssave_manager = new SSaveManager();

///@desc Wrapper for SSaveManager.get
///@param {SSave} ssaveConstructor The constructor for the ssave file
///@param {string|undefined} filePrefix The file prefix (SSAVE_FILE_PREFIX_DEFAULT if undefined)
///@returns {SSave}
function ssave_get(_ssaveConstructor, _filePrefix = undefined)
{
Expand All @@ -12,6 +14,8 @@ function ssave_get(_ssaveConstructor, _filePrefix = undefined)
}

///@desc Wrapper for SSaveManager.remove
///@param {SSave} ssaveConstructor The constructor for the ssave file
///@param {string|undefined} filePrefix The file prefix (SSAVE_FILE_PREFIX_DEFAULT if undefined)
function ssave_remove(_ssaveConstructor, _filePrefix = undefined)
{
if (!SSAVE_USE_MANAGER)
Expand All @@ -20,6 +24,28 @@ function ssave_remove(_ssaveConstructor, _filePrefix = undefined)
return global.__ssave_manager.remove(_ssaveConstructor, _filePrefix);
}

///@desc Calls ssave.save() on all SSaveManager ssaves
function ssave_save_all()
{
with (global.__ssave_manager)
{
var i = 0;
var _ssaveConstructors = variable_struct_get_names(__ssaves);
repeat (array_length(_ssaveConstructors))
{
var _ssaveConstructor = _ssaveConstructors[i++];
var _ssaves = __ssaves[$ _ssaveConstructor];

var j = 0;
repeat (ds_list_size(_ssaves))
{
var _ssave = _ssaves[| j++];
_ssave.save();
}
}
}
}

function SSaveManager() constructor
{
///@desc Gets an ssave, creating it if it doesnt exist already
Expand Down

0 comments on commit 69efc00

Please sign in to comment.