2023-05-08 10:50:42 +02:00
|
|
|
function __addonDefault(root) {
|
2023-11-18 03:47:11 +01:00
|
|
|
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
|
|
|
|
2023-11-18 03:47:11 +01:00
|
|
|
directory_verify(dirPath);
|
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);
|
2023-11-13 12:11:54 +01:00
|
|
|
var _str = {
|
2023-05-03 21:42:17 +02:00
|
|
|
name: f,
|
|
|
|
path: _path,
|
2023-11-13 12:11:54 +01:00
|
|
|
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";
|
|
|
|
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
|
|
|
}
|