2023-05-03 21:42:17 +02:00
|
|
|
/// @description
|
|
|
|
event_inherited();
|
|
|
|
|
|
|
|
#region init
|
2023-06-17 14:30:49 +02:00
|
|
|
alarm[0] = 1;
|
|
|
|
|
2023-05-07 20:55:13 +02:00
|
|
|
function init(directory, _openDialog = true) {
|
2023-05-03 21:42:17 +02:00
|
|
|
ID = UUID_generate();
|
|
|
|
global.ADDON_ID[? ID] = self;
|
|
|
|
ready = false;
|
|
|
|
name = filename_name_only(directory);
|
|
|
|
|
|
|
|
thread = lua_create();
|
|
|
|
__addon_lua_setup(thread, self);
|
|
|
|
|
|
|
|
self.directory = directory;
|
|
|
|
|
|
|
|
var propPath = directory + "\\meta.json";
|
|
|
|
context_menus = {};
|
|
|
|
panels = {};
|
|
|
|
|
|
|
|
if(file_exists(propPath)) {
|
|
|
|
var meta = json_load_struct(propPath);
|
|
|
|
if(struct_has(meta, "panels")) {
|
|
|
|
panels = meta.panels;
|
|
|
|
|
2023-05-07 20:55:13 +02:00
|
|
|
if(_openDialog) {
|
|
|
|
var arr = variable_struct_get_names(panels);
|
2023-07-25 20:12:40 +02:00
|
|
|
for( var i = 0, n = array_length(arr); i < n; i++ ) {
|
2023-05-07 20:55:13 +02:00
|
|
|
var _key = arr[i];
|
|
|
|
var pane = panels[$ _key];
|
2023-05-03 21:42:17 +02:00
|
|
|
|
2023-05-07 20:55:13 +02:00
|
|
|
if(struct_has(pane, "main") && pane.main)
|
|
|
|
dialogPanelCall(new addonPanel(self, pane));
|
2023-05-03 21:42:17 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(struct_has(meta, "context_menu_callbacks")) {
|
|
|
|
context_menus = meta.context_menu_callbacks;
|
|
|
|
|
|
|
|
var arr = variable_struct_get_names(context_menus);
|
2023-07-25 20:12:40 +02:00
|
|
|
for( var i = 0, n = array_length(arr); i < n; i++ ) {
|
2023-05-03 21:42:17 +02:00
|
|
|
var _call = ds_map_try_get(CONTEXT_MENU_CALLBACK, arr[i], []);
|
|
|
|
var _fnk = context_menus[$ arr[i]];
|
|
|
|
var _generator = new addonContextGenerator(self, _fnk);
|
|
|
|
array_push(_call, _generator);
|
|
|
|
|
|
|
|
CONTEXT_MENU_CALLBACK[? arr[i]] = _call;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
scriptPath = directory + "\\script.lua";
|
|
|
|
if(!file_exists(scriptPath)) {
|
|
|
|
noti_warning(title + " Addon error: script.lua not found.");
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
lua_add_file(thread, scriptPath);
|
|
|
|
var runResult = lua_call(thread, "init");
|
|
|
|
|
|
|
|
array_push(ANIMATION_PRE, animationPreStep);
|
|
|
|
array_push(ANIMATION_POST, animationPostStep);
|
|
|
|
}
|
|
|
|
|
|
|
|
function animationPreStep() {
|
|
|
|
if(!ready) return;
|
|
|
|
var runResult = lua_call(thread, "animationPreStep");
|
|
|
|
}
|
|
|
|
|
|
|
|
function animationPostStep() {
|
|
|
|
if(!ready) return;
|
|
|
|
var runResult = lua_call(thread, "animationPostStep");
|
|
|
|
}
|
|
|
|
|
|
|
|
function callFunctions(fn) {
|
|
|
|
lua_call(thread, fn);
|
|
|
|
}
|
|
|
|
#endregion
|