Pixel-Composer/scripts/__initAddon/__initAddon.gml

62 lines
1.3 KiB
Text
Raw Normal View History

2023-05-08 10:50:42 +02:00
function __addonDefault(root) {
var _l = root + "/version";
if(file_exists(_l)) {
var res = json_load_struct(_l);
if(res.version == BUILD_NUMBER) return;
}
json_save_struct(_l, { version: BUILD_NUMBER });
log_message("THEME", "unzipping default addon to DIRECTORY.");
zip_unzip("data/Addons.zip", root);
}
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
if(!directory_exists(dirPath)) {
directory_create(dirPath);
return;
}
2023-05-08 10:50:42 +02:00
__addonDefault(dirPath);
2023-04-22 16:23:51 +02:00
var f = file_find_first(dirPath + "\\*", fa_directory);
2023-05-07 20:55:13 +02:00
var _f = "";
while(f != "" && f != _f) {
_f = f;
2023-05-03 21:42:17 +02:00
var _path = dirPath + "\\" + f;
var _meta = _path + "\\meta.json";
2023-05-07 20:55:13 +02:00
if(!file_exists(_meta)) {
f = file_find_next();
continue;
}
2023-05-03 21:42:17 +02:00
var _mSrt = json_load_struct(_meta);
var _str = {
name: f,
path: _path,
meta: _mSrt.meta,
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";
if(!file_exists(_path)) return;
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
}