Pixel-Composer/scripts/__initAddon/__initAddon.gml

53 lines
1.1 KiB
Text
Raw Normal View History

2023-05-08 10:50:42 +02:00
function __addonDefault(root) {
if(check_version($"{root}/version")) {
log_message("THEME", "unzipping default addon to DIRECTORY.");
zip_unzip("data/Addons.zip", root);
2023-05-08 10:50:42 +02:00
}
}
2023-05-07 20:55:13 +02:00
function __initAddon() {
2023-04-22 16:23:51 +02:00
var dirPath = DIRECTORY + "Addons";
2023-05-07 20:55:13 +02:00
globalvar ADDONS, ADDONS_ON_START;
2023-04-22 16:23:51 +02:00
ADDONS = [];
2023-05-07 20:55:13 +02:00
ADDONS_ON_START = [];
2023-04-22 16:23:51 +02:00
directory_verify(dirPath);
2023-05-08 10:50:42 +02:00
__addonDefault(dirPath);
var f = file_find_first(dirPath + "/*", fa_directory);
2023-05-07 20:55:13 +02:00
var _f = "";
while(f != "" && f != _f) {
_f = f;
var _path = dirPath + "/" + f;
var _meta = _path + "/meta.json";
2023-05-03 21:42:17 +02:00
2023-12-08 03:50:09 +01:00
if(!file_exists_empty(_meta)) {
2023-05-07 20:55:13 +02:00
f = file_find_next();
continue;
}
2023-05-03 21:42:17 +02:00
var _mSrt = json_load_struct(_meta);
var _str = {
2023-05-03 21:42:17 +02:00
name: f,
path: _path,
meta: struct_try_get(_mSrt, "meta", {}),
2023-05-03 21:42:17 +02:00
open: false
};
array_push(ADDONS, _str);
2023-04-22 16:23:51 +02:00
f = file_find_next();
}
2023-05-07 20:55:13 +02:00
file_find_close();
}
function loadAddon() {
var _path = DIRECTORY + "Addons/__init.json";
2023-12-08 03:50:09 +01:00
if(!file_exists_empty(_path)) return;
2023-05-07 20:55:13 +02:00
ADDONS_ON_START = json_load_struct(_path);
2023-07-25 20:12:40 +02:00
for( var i = 0, n = array_length(ADDONS_ON_START); i < n; i++ )
2023-05-07 20:55:13 +02:00
addonTrigger(ADDONS_ON_START[i], false);
2023-04-22 16:23:51 +02:00
}