2022-12-10 05:06:01 +01:00
|
|
|
#region loading
|
|
|
|
global.PRESETS_MAP = ds_map_create();
|
|
|
|
|
|
|
|
function __initPresets() {
|
|
|
|
ds_map_clear(global.PRESETS_MAP);
|
|
|
|
|
|
|
|
var root = DIRECTORY + "Presets";
|
|
|
|
if(!directory_exists(root))
|
|
|
|
directory_create(root);
|
|
|
|
|
2023-03-08 12:14:01 +01:00
|
|
|
var _l = root + "/version";
|
2023-02-14 02:51:14 +01:00
|
|
|
if(file_exists(_l)) {
|
|
|
|
var res = json_load_struct(_l);
|
2023-03-05 07:16:44 +01:00
|
|
|
if(!is_struct(res) || !struct_has(res, "version") || res.version < VERSION)
|
2023-02-14 02:51:14 +01:00
|
|
|
zip_unzip("data/Preset.zip", root);
|
|
|
|
} else
|
|
|
|
zip_unzip("data/Preset.zip", root);
|
|
|
|
json_save_struct(_l, { version: VERSION });
|
|
|
|
|
2022-12-10 05:06:01 +01:00
|
|
|
global.PRESETS = new DirectoryObject("Presets", root);
|
|
|
|
global.PRESETS.scan([".json"]);
|
|
|
|
|
|
|
|
for( var i = 0; i < ds_list_size(global.PRESETS.subDir); i++ ) {
|
|
|
|
var l = [];
|
|
|
|
var grp = global.PRESETS.subDir[| i];
|
|
|
|
for( var j = 0; j < ds_list_size(grp.content); j++ ) {
|
|
|
|
var pth = grp.content[| j].path;
|
|
|
|
var f = new FileObject(grp.content[| j].name, pth);
|
|
|
|
f.content = json_load(pth);
|
|
|
|
array_push(l, f);
|
|
|
|
}
|
|
|
|
global.PRESETS_MAP[? grp.name] = l;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|