Pixel-Composer/scripts/preset_data/preset_data.gml

36 lines
938 B
Text
Raw Permalink Normal View History

global.PRESETS_MAP = ds_map_create();
function __initPresets() {
ds_map_clear(global.PRESETS_MAP);
2022-12-10 05:06:01 +01:00
var _preset_path = "data/Preset.zip";
var root = DIRECTORY + "Presets";
directory_verify(root);
if(check_version($"{root}/version") && file_exists_empty(_preset_path))
zip_unzip(_preset_path, root);
2025-01-11 04:31:00 +01:00
global.PRESETS = new DirectoryObject(root);
global.PRESETS.scan([".json"]);
2023-02-14 02:51:14 +01:00
for( var i = 0; i < ds_list_size(global.PRESETS.subDir); i++ ) {
var l = [];
var grp = global.PRESETS.subDir[| i];
global.PRESETS_MAP[? grp.name] = l;
2022-12-10 05:06:01 +01:00
for( var j = 0; j < ds_list_size(grp.content); j++ ) {
var pth = grp.content[| j].path;
2025-01-11 04:31:00 +01:00
var f = new FileObject(pth);
array_push(l, f);
2022-12-10 05:06:01 +01:00
}
}
}
function loadPreset(preset) {
INLINE
if(preset.content == -1) {
preset.content = json_load_struct(preset.path);
preset.thumbnail_data = struct_try_get(preset.content, "thumbnail", -1);
}
return preset.content;
}