Pixel-Composer/scripts/node_registry/node_registry.gml

673 lines
18 KiB
Text
Raw Normal View History

2025-01-03 11:53:34 +01:00
#region globalvar
2025-01-11 04:31:00 +01:00
globalvar ALL_NODES, NODE_PB_CATEGORY, NODE_PCX_CATEGORY;
globalvar NODE_CATEGORY, NODE_CATEGORY_MAP;
2025-01-03 11:53:34 +01:00
globalvar SUPPORTER_NODES, NEW_NODES;
2025-01-10 03:04:53 +01:00
globalvar CUSTOM_NODES, CUSTOM_NODES_POSITION;
2025-01-03 11:53:34 +01:00
2025-01-11 04:31:00 +01:00
globalvar NODE_PAGE_DEFAULT, NODE_PAGE_LAST;
2025-01-09 08:28:19 +01:00
globalvar NODE_ACTION_LIST;
2025-01-03 11:53:34 +01:00
2025-01-09 05:28:30 +01:00
global.PATREON_NODES = [
Node_Brush_Linear,
Node_Ambient_Occlusion,
Node_RM_Cloud,
Node_Perlin_Extra,
Node_Voronoi_Extra,
Node_Gabor_Noise,
Node_Shard_Noise,
Node_Wavelet_Noise,
Node_Caustic,
Node_Noise_Bubble,
Node_Flow_Noise,
Node_Noise_Cristal,
Node_Honeycomb_Noise,
Node_Grid_Pentagonal,
Node_Pytagorean_Tile,
Node_Herringbone_Tile,
Node_Random_Tile,
Node_MK_Fracture,
Node_MK_Sparkle,
];
2025-01-03 11:53:34 +01:00
#endregion
2025-01-11 04:31:00 +01:00
function NodeObject(_name, _node, _tooltip = "") constructor {
2022-01-13 05:24:03 +01:00
name = _name;
2022-12-16 09:18:09 +01:00
node = _node;
2025-01-11 04:31:00 +01:00
spr = s_node_icon;
2024-02-12 10:25:23 +01:00
icon = noone;
2025-01-10 03:04:53 +01:00
nodekey = "";
2024-02-12 10:25:23 +01:00
2025-01-03 06:41:04 +01:00
nodeName = script_get_name(node);
createFn = noone;
createParam = noone;
2022-01-13 05:24:03 +01:00
2025-01-09 10:33:38 +01:00
sourceDir = "";
2025-01-03 06:41:04 +01:00
tags = [];
tooltip = _tooltip;
2025-01-09 10:33:38 +01:00
tooltip_spr = undefined;
2024-02-12 13:59:43 +01:00
2025-01-09 08:28:19 +01:00
pxc_version = 0;
2024-09-10 11:48:51 +02:00
new_node = false;
deprecated = false;
2022-12-27 04:00:50 +01:00
show_in_recent = true;
2023-12-18 13:54:33 +01:00
show_in_global = true;
2025-01-09 05:28:30 +01:00
patreon = array_exists(global.PATREON_NODES, node);
2025-01-10 03:04:53 +01:00
if(patreon) array_push(SUPPORTER_NODES, self);
2025-01-09 05:28:30 +01:00
testable = true;
2025-01-09 05:28:30 +01:00
ioArray = [];
2025-01-05 01:48:23 +01:00
input_type_mask = 0b0;
output_type_mask = 0b0;
2025-01-11 04:31:00 +01:00
author = "";
license = "";
2025-01-09 10:33:38 +01:00
_fn = registerFunctionLite("New node", name, function(n) /*=>*/ { PANEL_GRAPH.createNodeHotkey(n); }, [ nodeName ]);
_fn.spr = spr;
2025-01-09 05:28:30 +01:00
static init = function() {
2025-01-09 10:33:38 +01:00
if(IS_CMD) return;
2025-01-09 05:28:30 +01:00
2025-01-09 10:33:38 +01:00
if(struct_has(global.NODE_GUIDE, node)) {
var _n = global.NODE_GUIDE[$ node];
name = _n.name;
if(_n.tooltip != "")
tooltip = _n.tooltip;
2024-02-12 13:59:43 +01:00
}
2025-01-09 05:28:30 +01:00
} init();
2025-01-09 10:33:38 +01:00
static setTags = function(_tags) { tags = _tags; return self; }
static setSpr = function(_spr) { spr = _spr; return self; }
static setTooltip = function(_tool) { tooltip = _tool; return self; }
static setBuild = function(_fn) { createFn = _fn; return self; }
2025-01-03 06:41:04 +01:00
static setParam = function(_par) { createParam = _par; return self; }
2025-01-09 05:28:30 +01:00
static setIO = function(t) {
for(var i = 0; i < argument_count; i++) {
input_type_mask |= value_bit(argument[i]);
output_type_mask |= value_bit(argument[i]);
array_push(ioArray, value_type_to_string(argument[i]));
}
return self;
}
2025-01-05 01:48:23 +01:00
2024-07-08 04:37:36 +02:00
static setVersion = function(version) {
INLINE
2024-02-15 14:23:26 +01:00
if(IS_CMD) return self;
2024-02-12 13:59:43 +01:00
2025-01-09 08:28:19 +01:00
pxc_version = version;
new_node = version >= LATEST_VERSION;
2023-11-20 13:21:50 +01:00
2022-12-27 04:00:50 +01:00
return self;
2024-07-08 04:37:36 +02:00
}
2022-12-27 04:00:50 +01:00
2024-09-09 03:04:54 +02:00
static setIcon = function(_icon) {
2024-02-12 10:25:23 +01:00
INLINE
2024-02-15 14:23:26 +01:00
if(IS_CMD) return self;
2024-02-12 13:59:43 +01:00
2024-09-09 03:04:54 +02:00
icon = _icon;
2024-02-12 10:25:23 +01:00
return self;
2024-07-08 04:37:36 +02:00
}
2024-02-12 10:25:23 +01:00
2024-07-08 04:37:36 +02:00
static isDeprecated = function() {
INLINE
2024-02-15 14:23:26 +01:00
if(IS_CMD) return self;
2024-02-12 13:59:43 +01:00
deprecated = true;
return self;
2024-07-08 04:37:36 +02:00
}
2024-07-08 04:37:36 +02:00
static hideRecent = function() {
INLINE
2024-02-15 14:23:26 +01:00
if(IS_CMD) return self;
2024-02-12 13:59:43 +01:00
show_in_recent = false;
testable = false;
2024-09-14 05:36:18 +02:00
variable_struct_remove(FUNCTIONS, _fn.fnName);
return self;
2024-07-08 04:37:36 +02:00
}
static notTest = function() { testable = false; return self; }
2024-07-08 04:37:36 +02:00
static hideGlobal = function() {
2023-12-18 13:54:33 +01:00
INLINE
2024-02-15 14:23:26 +01:00
if(IS_CMD) return self;
2024-02-12 13:59:43 +01:00
2023-12-18 13:54:33 +01:00
show_in_global = false;
return self;
2024-07-08 04:37:36 +02:00
}
2023-12-18 13:54:33 +01:00
static getName = function() { return __txt_node_name(node, name); }
static getTooltip = function() { return __txt_node_tooltip(node, tooltip); }
2025-01-09 10:33:38 +01:00
static getTooltipSpr = function() {
if(tooltip_spr != undefined) return tooltip_spr;
tooltip_spr = noone;
var pth = $"{sourceDir}/tooltip_spr.png";
if(file_exists_empty(pth))
tooltip_spr = sprite_add(pth, 0, false, false, 0, 0);
return tooltip_spr;
}
2023-06-05 18:27:53 +02:00
2024-07-08 04:37:36 +02:00
static build = function(_x = 0, _y = 0, _group = PANEL_GRAPH.getCurrentContext(), _param = {}) {
2024-03-31 05:36:11 +02:00
INLINE
2025-01-10 03:04:53 +01:00
if(createParam != noone) {
struct_append(_param, createParam);
_param.sourceDir = sourceDir;
_param.iname = nodekey;
}
var _node = createFn == noone? new node(_x, _y, _group, _param) : createFn(_x, _y, _group, _param);
_node.name = name;
2025-01-11 04:31:00 +01:00
_node.postBuild();
2025-01-10 03:04:53 +01:00
2022-01-13 05:24:03 +01:00
return _node;
2024-07-08 04:37:36 +02:00
}
2024-07-08 04:37:36 +02:00
static drawGrid = function(_x, _y, _mx, _my, grid_size, _param = {}) {
var spr_x = _x + grid_size / 2;
var spr_y = _y + grid_size / 2;
2023-12-01 05:49:44 +01:00
var _spw = sprite_get_width(spr);
var _sph = sprite_get_height(spr);
2025-01-11 04:31:00 +01:00
var _ss = grid_size / max(_spw, _sph) * 0.85;
2023-12-01 05:49:44 +01:00
gpu_set_tex_filter(true);
draw_sprite_uniform(spr, 0, spr_x, spr_y, _ss);
2023-12-01 05:49:44 +01:00
gpu_set_tex_filter(false);
if(new_node) {
draw_sprite_ui_uniform(THEME.node_new_badge, 0, _x + grid_size - ui(12), _y + ui(6),, COLORS._main_accent);
draw_sprite_ui_uniform(THEME.node_new_badge, 1, _x + grid_size - ui(12), _y + ui(6));
}
if(deprecated) {
draw_sprite_ui_uniform(THEME.node_deprecated_badge, 0, _x + grid_size - ui(12), _y + ui(6),, COLORS._main_value_negative);
draw_sprite_ui_uniform(THEME.node_deprecated_badge, 1, _x + grid_size - ui(12), _y + ui(6));
}
2025-01-06 05:32:21 +01:00
var fav = struct_exists(global.FAV_NODES, nodeName);
if(fav) {
gpu_set_tex_filter(true);
draw_sprite_ui_uniform(THEME.star, 0, _x + grid_size - ui(10), _y + grid_size - ui(10), .8, COLORS._main_accent, 1.);
gpu_set_tex_filter(false);
}
2024-05-22 04:46:29 +02:00
2024-02-12 10:25:23 +01:00
var spr_x = _x + grid_size - 4;
var spr_y = _y + 4;
2025-01-05 01:48:23 +01:00
if(IS_PATREON && patreon) {
BLEND_SUBTRACT
gpu_set_colorwriteenable(0, 0, 0, 1);
draw_sprite_ext(THEME.patreon_supporter, 0, spr_x, spr_y, 1, 1, 0, c_white, 1);
gpu_set_colorwriteenable(1, 1, 1, 1);
BLEND_NORMAL
draw_sprite_ext(THEME.patreon_supporter, 1, spr_x, spr_y, 1, 1, 0, COLORS._main_accent, 1);
if(point_in_circle(_mx, _my, spr_x, spr_y, 10)) TOOLTIP = __txt("Supporter exclusive");
}
2024-02-12 10:25:23 +01:00
if(icon) draw_sprite_ext(icon, 0, spr_x, spr_y, 1, 1, 0, c_white, 1);
2024-07-08 04:37:36 +02:00
}
static drawList = function(_x, _y, _mx, _my, _h, _w, _param = {}) {
2025-01-06 05:32:21 +01:00
var fav = struct_exists(global.FAV_NODES, nodeName);
if(fav) {
gpu_set_tex_filter(true);
draw_sprite_ui_uniform(THEME.star, 0, _x + ui(16), _y + _h / 2, .8, COLORS._main_accent, 1.);
gpu_set_tex_filter(false);
}
var spr_x = _x + ui(32) + _h / 2;
var spr_y = _y + _h / 2;
var ss = (_h - ui(8)) / max(sprite_get_width(spr), sprite_get_height(spr));
2023-12-01 05:49:44 +01:00
gpu_set_tex_filter(true);
draw_sprite_ext(spr, 0, spr_x, spr_y, ss, ss, 0, c_white, 1);
2023-12-01 05:49:44 +01:00
gpu_set_tex_filter(false);
var tx = spr_x + _h / 2 + ui(4);
var ty = _y + _h / 2;
if(new_node) {
var _nx = _w - ui(6 + 18);
draw_sprite_ui_uniform(THEME.node_new_badge, 0, _nx, _y + _h / 2,, COLORS._main_accent);
draw_sprite_ui_uniform(THEME.node_new_badge, 1, _nx, _y + _h / 2);
}
if(deprecated) {
var _nx = _w - ui(6 + 18);
draw_sprite_ui_uniform(THEME.node_deprecated_badge, 0, _nx, _y + _h / 2,, COLORS._main_value_negative);
draw_sprite_ui_uniform(THEME.node_deprecated_badge, 1, _nx, _y + _h / 2);
}
var _txt = getName();
var _query = struct_try_get(_param, "query", "");
var _range = struct_try_get(_param, "range", 0);
if(_query != "") {
2024-02-16 07:44:36 +01:00
draw_set_text(f_p2, fa_left, fa_center, COLORS._main_text_sub);
draw_text_add(tx, ty, _txt);
tx += string_width(_txt);
draw_sprite_ext(THEME.arrow, 0, tx + ui(12), ty, 1, 1, 0, COLORS._main_icon, 1);
tx += ui(24);
2024-02-16 07:44:36 +01:00
_query = string_title(_query);
draw_set_text(f_p2, fa_left, fa_center, COLORS._main_text);
if(_range == 0) draw_text_add(tx, ty, _query);
else draw_text_match_range(tx, ty, _query, _range);
2024-02-16 07:44:36 +01:00
tx += string_width(_query);
} else {
draw_set_text(f_p2, fa_left, fa_center, COLORS._main_text);
if(_range == 0) draw_text_add(tx, ty, _txt);
else draw_text_match_range(tx, ty, _txt, _range);
2024-02-16 07:44:36 +01:00
tx += string_width(_txt);
}
2025-01-05 01:48:23 +01:00
if(IS_PATREON && patreon) {
var spr_x = tx + ui(4);
var spr_y = _y + _h / 2 - ui(6);
gpu_set_colorwriteenable(0, 0, 0, 1); BLEND_SUBTRACT
draw_sprite_ext(THEME.patreon_supporter, 0, spr_x, spr_y, 1, 1, 0, c_white, 1);
gpu_set_colorwriteenable(1, 1, 1, 1); BLEND_NORMAL
draw_sprite_ext(THEME.patreon_supporter, 1, spr_x, spr_y, 1, 1, 0, COLORS._main_accent, 1);
if(point_in_circle(_mx, _my, spr_x, spr_y, ui(10))) TOOLTIP = __txt("Supporter exclusive");
2024-12-29 10:12:24 +01:00
2024-12-30 11:05:35 +01:00
tx += ui(12);
}
return tx;
2024-07-08 04:37:36 +02:00
}
2025-01-09 10:33:38 +01:00
2025-01-09 05:28:30 +01:00
static serialize = function() {
var _str = {
name,
2025-01-09 08:28:19 +01:00
spr: sprite_get_name(spr),
2025-01-09 05:28:30 +01:00
baseNode: nodeName,
io: ioArray,
}
2025-01-09 08:28:19 +01:00
if(tooltip != "") _str.tooltip = tooltip;
if(createFn != noone) _str.build = script_get_name(createFn);
if(deprecated) _str.deprecated = true;
if(pxc_version) _str.pxc_version = pxc_version;
if(!show_in_recent) _str.show_in_recent = show_in_recent;
if(!array_empty(tags)) _str.alias = tags;
2025-01-09 05:28:30 +01:00
return _str;
}
2025-01-09 10:33:38 +01:00
static deserialize = function(_data, _dir) {
sourceDir = _dir;
2025-01-09 08:28:19 +01:00
if(struct_has(_data, "tooltip")) setTooltip(_data.tooltip);
2025-01-09 05:28:30 +01:00
2025-01-11 04:31:00 +01:00
if(struct_has(_data, "spr")) {
2025-01-12 04:53:32 +01:00
var _ispr = _data[$ "spr"];
_spr = asset_get_index(_ispr);
2025-01-11 04:31:00 +01:00
2025-01-16 04:39:54 +01:00
if(sprite_exists(_spr)) spr = _spr;
else print($"Node icon not found {_ispr}");
2025-01-12 04:53:32 +01:00
2025-01-11 04:31:00 +01:00
} else {
var pth = $"{sourceDir}/icon.png";
2025-01-16 04:39:54 +01:00
2025-01-11 04:31:00 +01:00
if(file_exists_empty(pth)) {
spr = sprite_add(pth, 0, false, false, 0, 0);
sprite_set_offset(spr, sprite_get_width(spr) / 2, sprite_get_height(spr) / 2);
2025-01-16 04:39:54 +01:00
} else {
var _spr = asset_get_index($"s_{string_lower(nodeName)}");
if(sprite_exists(_spr)) spr = _spr;
2025-01-11 04:31:00 +01:00
}
}
2025-01-09 05:28:30 +01:00
if(struct_has(_data, "io")) {
var _io = _data.io;
for( var i = 0, n = array_length(_io); i < n; i++ )
2025-01-09 08:28:19 +01:00
setIO(value_type_from_string(_io[i]));
2025-01-09 05:28:30 +01:00
}
if(struct_has(_data, "build")) {
var _bfn = asset_get_index(_data.build);
2025-01-09 08:28:19 +01:00
if(_bfn != -1) setBuild(_bfn);
2025-01-09 05:28:30 +01:00
}
if(struct_has(_data, "deprecated"))
isDeprecated();
if(struct_has(_data, "alias"))
setTags(_data.alias);
2025-01-09 08:28:19 +01:00
if(struct_has(_data, "show_in_recent"))
show_in_recent = _data.show_in_recent;
if(struct_has(_data, "pxc_version"))
setVersion(_data.pxc_version);
2025-01-09 05:28:30 +01:00
2025-01-10 03:04:53 +01:00
if(struct_has(_data, "params"))
setParam(_data.params);
2025-01-11 04:31:00 +01:00
if(struct_has(_data, "author"))
author = _data.author;
if(struct_has(_data, "license"))
license = _data.license;
2025-01-10 03:04:53 +01:00
if(struct_has(_data, "position")) {
for( var i = 0, n = array_length(_data.position); i < n; i++ ) {
var pos = _data.position[i];
if(struct_has(CUSTOM_NODES_POSITION, pos))
array_push(CUSTOM_NODES_POSITION[$ pos], self);
else
CUSTOM_NODES_POSITION[$ pos] = [ self ];
}
}
2025-01-09 05:28:30 +01:00
return self;
}
2024-07-08 04:37:36 +02:00
}
2022-01-13 05:24:03 +01:00
function nodeBuild(_name, _x, _y, _group = PANEL_GRAPH.getCurrentContext()) {
2024-03-31 05:36:11 +02:00
INLINE
2025-01-09 08:28:19 +01:00
if(!struct_has(ALL_NODES, _name)) {
2023-12-05 09:51:24 +01:00
log_warning("LOAD", $"Node type {_name} not found");
return noone;
}
2025-01-09 08:28:19 +01:00
var _node = ALL_NODES[$ _name];
var _bnode = _node.build(_x, _y, _group);
2022-01-13 05:24:03 +01:00
return _bnode;
}
2025-01-09 05:28:30 +01:00
////- Nodes
2025-01-09 05:28:30 +01:00
function __read_node_directory(dir) {
if(!directory_exists(dir)) return;
__read_node_folder(dir);
var _dirs = [];
2025-01-09 08:28:19 +01:00
var _f = file_find_first(dir + "/*", fa_directory);
2025-01-09 05:28:30 +01:00
var f, p;
while(_f != "") {
f = _f;
2025-01-09 08:28:19 +01:00
p = dir + "/" + f;
2025-01-09 05:28:30 +01:00
_f = file_find_next();
if(!directory_exists(p)) continue;
array_push(_dirs, p);
}
file_find_close();
array_foreach(_dirs, function(d) /*=>*/ {return __read_node_directory(d)});
}
2025-01-11 04:31:00 +01:00
function __read_node_folder(dir) {
var _info = dir + "/info.json";
2025-01-09 05:28:30 +01:00
if(!file_exists(_info)) return;
var _data = json_load_struct(_info);
var _name = _data[$ "name"];
2025-01-09 05:28:30 +01:00
var _base = _data[$ "baseNode"];
var _inme = _data[$ "iname"] ?? _base;
2025-01-10 03:04:53 +01:00
var _custom = _data[$ "custom"] ?? false;
2025-01-09 05:28:30 +01:00
if(is_undefined(_base)) {
print($"NODE ERROR: baseNode not found in {_info}.");
return;
}
2025-01-09 08:28:19 +01:00
if(struct_has(ALL_NODES, _inme))
2025-01-09 08:55:34 +01:00
print($"NODE WARNING: Duplicate node iname {_inme} | {dir}.");
2025-01-09 05:28:30 +01:00
var _node = asset_get_index(_base);
2025-01-11 04:31:00 +01:00
var _n = new NodeObject(_name, _node);
2025-01-09 05:28:30 +01:00
2025-01-10 03:04:53 +01:00
_n.nodekey = _inme;
2025-01-09 10:33:38 +01:00
_n.deserialize(_data, dir);
2025-01-09 08:28:19 +01:00
ALL_NODES[$ _inme] = _n;
2025-01-10 03:04:53 +01:00
if(_custom) array_push(CUSTOM_NODES, _n);
2025-01-09 05:28:30 +01:00
return _n;
}
2025-01-11 04:31:00 +01:00
function __read_node_display(_list) {
var _currLab = "";
2025-01-09 08:28:19 +01:00
for( var i = 0, n = array_length(_list); i < n; i++ ) {
var _dl = _list[i];
var _name = _dl.name;
2025-01-10 03:04:53 +01:00
var _iname = _dl[$ "iname"] ?? _name;
2025-01-11 04:31:00 +01:00
var _filter = _dl[$ "context"] ?? undefined;
var _ctx = _dl[$ "globalContext"] ?? "";
var _color = struct_has(_dl, "color")? COLORS[$ _dl.color] : undefined;
2025-01-09 08:28:19 +01:00
2025-01-11 04:31:00 +01:00
var _kname = _iname;
2025-01-10 03:04:53 +01:00
var _nodes = _dl.nodes;
var _head = "";
var _lab = "";
2025-01-11 04:31:00 +01:00
if(struct_has(NODE_CATEGORY_MAP, _iname)) {
_lobj = NODE_CATEGORY_MAP[$ _iname];
_l = _lobj.list;
} else {
var _l = [];
var _lobj = {
name : _name,
list : _l,
filter : _filter,
color : _color,
};
NODE_CATEGORY_MAP[$ _iname] = _lobj;
}
switch(_ctx) {
case "pb" : array_push(NODE_PB_CATEGORY, _lobj); break;
case "pcx" : array_push(NODE_PCX_CATEGORY, _lobj); break;
default : array_insert(NODE_CATEGORY, NODE_PAGE_LAST++, _lobj); break;
}
2025-01-09 08:28:19 +01:00
for( var j = 0, m = array_length(_nodes); j < m; j++ ) {
var _n = _nodes[j];
2025-01-14 02:25:51 +01:00
if(is_string(_n)) {
if(struct_has(ALL_NODES, _n)) {
var _node = ALL_NODES[$ _n];
if(_node.new_node) {
if(_currLab != _head)
array_push(NEW_NODES, _head);
_currLab = _head;
array_push(NEW_NODES, _node);
}
array_push(_l, _node);
} else {
var _txt = $"Missing node data [{_n}]: Check if node folder exists in {DIRECTORY}Nodes\Internal";
// print(_txt);
noti_warning(_txt);
2025-01-11 04:31:00 +01:00
}
}
2025-01-10 03:04:53 +01:00
if(is_struct(_n) && struct_has(_n, "label")) {
var _k = _kname; if(_head != "") _k += "/" + _head; if(_lab != "") _k += "/" + _lab;
array_append(_l, CUSTOM_NODES_POSITION[$ _k]);
if(!string_starts_with(_n.label, "/")) _head = _n.label;
else _lab = string_trim_start(_n.label, ["/"]);
array_push(_l, _n.label);
2025-01-09 08:28:19 +01:00
}
}
2025-01-10 03:04:53 +01:00
var _k = _kname; if(_head != "") _k += "/" + _head; if(_lab != "") _k += "/" + _lab;
array_append(_l, CUSTOM_NODES_POSITION[$ _k]);
2025-01-09 08:28:19 +01:00
}
}
2025-01-11 04:31:00 +01:00
function __read_node_display_folder(dir) {
if(!directory_exists(dir)) return;
2023-12-05 09:51:24 +01:00
2025-01-11 04:31:00 +01:00
var _dirs = [];
var _f = file_find_first(dir + "/*", fa_directory);
while(_f != "") {
array_push(_dirs, dir + "/" + _f);
_f = file_find_next();
}
file_find_close();
var _f = file_find_first(dir + "/*", 0);
while(_f != "") {
if(_f == "display_data.json") {
var _data = json_load_struct(dir + "/" + _f);
__read_node_display(_data);
}
_f = file_find_next();
}
file_find_close();
array_foreach(_dirs, function(d) /*=>*/ {return __read_node_display_folder(d)});
}
function __initNodes(unzip = true) {
2025-01-10 03:04:53 +01:00
CUSTOM_NODES_POSITION = {};
2025-01-11 04:31:00 +01:00
ALL_NODES = {};
NODE_CATEGORY_MAP = {};
NODE_CATEGORY = [];
NODE_PB_CATEGORY = [];
NODE_PCX_CATEGORY = [];
SUPPORTER_NODES = [];
NEW_NODES = [];
CUSTOM_NODES = [];
CUSTOM_NODES_POSITION = {};
global.FAV_NODES = {};
2025-01-09 10:33:38 +01:00
NODE_PAGE_DEFAULT = 0;
ADD_NODE_PAGE = 0;
2025-01-11 04:31:00 +01:00
NODE_PAGE_LAST = 0;
2025-01-09 08:28:19 +01:00
////- DATA
2025-01-11 04:31:00 +01:00
if(unzip) {
directory_verify($"{DIRECTORY}Nodes");
if(check_version($"{DIRECTORY}Nodes/version"))
zip_unzip("data/Nodes/Internal.zip", $"{DIRECTORY}Nodes");
}
2025-01-10 03:04:53 +01:00
__read_node_directory($"{DIRECTORY}Nodes");
2025-01-09 10:33:38 +01:00
if(IS_CMD) return;
2023-12-20 14:02:49 +01:00
2025-01-09 08:28:19 +01:00
////- DISPLAY
2023-12-05 13:49:18 +01:00
2025-01-11 04:31:00 +01:00
if(unzip) {
var _relFrom = $"data/Nodes/display_data.json";
var _relTo = $"{DIRECTORY}Nodes/display_data.json";
file_copy_override(_relFrom, _relTo);
}
2023-12-05 09:51:24 +01:00
2025-01-11 04:31:00 +01:00
__read_node_display_folder($"{DIRECTORY}Nodes");
2023-12-05 09:51:24 +01:00
2025-01-11 04:31:00 +01:00
__initNodeActions(); array_push(NODE_CATEGORY, { name : "Action", list : NODE_ACTION_LIST });
if(IS_PATREON) array_push(NODE_CATEGORY, { name : "Extra", list : SUPPORTER_NODES });
if(!array_empty(CUSTOM_NODES)) array_push(NODE_CATEGORY, { name : "Custom", list : CUSTOM_NODES });
2025-01-09 10:33:38 +01:00
////- FAV
var favPath = $"{DIRECTORY}Nodes/fav.json";
if(file_exists_empty(favPath)) {
var favs = json_load_struct(favPath);
for (var i = 0, n = array_length(favs); i < n; i++)
global.FAV_NODES[$ favs[i]] = 1;
}
var recPath = $"{DIRECTORY}Nodes/recent.json";
global.RECENT_NODES = file_exists_empty(recPath)? json_load_struct(recPath) : [];
if(!is_array(global.RECENT_NODES)) global.RECENT_NODES = [];
2025-01-09 08:28:19 +01:00
}
function __generateNodeData() {
var _dir = "D:/Project/MakhamDev/LTS-PixelComposer/PixelComposer/datafiles/data/Nodes/Internal"
2023-12-05 09:51:24 +01:00
2025-01-10 03:04:53 +01:00
for( var i = 0, n = array_length(NODE_CATEGORY); i < n; i++ ) {
var _cat = NODE_CATEGORY[i];
2024-12-29 10:12:24 +01:00
2025-01-09 08:28:19 +01:00
var _lnme = _cat.name;
var _list = _cat.list;
directory_verify($"{_dir}/{_lnme}");
2024-06-17 13:12:33 +02:00
2025-01-10 03:04:53 +01:00
for( var j = 0, m = array_length(_list); j < m; j++ ) {
var _node = _list[j];
2025-01-09 08:28:19 +01:00
if(!is(_node, NodeObject)) continue;
2023-12-05 09:51:24 +01:00
2025-01-09 08:28:19 +01:00
var _nme = _node.nodeName;
var _vnme = filename_name_validate(_nme);
2023-12-05 09:51:24 +01:00
2025-01-09 08:28:19 +01:00
var _str = _node.serialize();
directory_verify($"{_dir}/{_lnme}/{_vnme}");
json_save_struct($"{_dir}/{_lnme}/{_vnme}/info.json", _str, true);
2023-03-05 07:16:44 +01:00
}
2025-01-09 08:28:19 +01:00
}
2022-01-13 05:24:03 +01:00
2025-01-10 03:04:53 +01:00
for( var i = 0, n = array_length(NODE_PB_CATEGORY); i < n; i++ ) {
var _cat = NODE_PB_CATEGORY[i];
2023-12-09 09:00:35 +01:00
2025-01-09 08:28:19 +01:00
var _lnme = _cat.name;
var _list = _cat.list;
directory_verify($"{_dir}/{_lnme}");
2024-01-22 10:26:25 +01:00
2025-01-10 03:04:53 +01:00
for( var j = 0, m = array_length(_list); j < m; j++ ) {
var _node = _list[j];
2025-01-09 08:28:19 +01:00
if(!is(_node, NodeObject)) continue;
2023-12-05 09:51:24 +01:00
2025-01-09 08:28:19 +01:00
var _nme = _node.nodeName;
var _vnme = filename_name_validate(_nme);
2023-12-05 09:51:24 +01:00
2025-01-09 08:28:19 +01:00
var _str = _node.serialize();
directory_verify($"{_dir}/pb_{_lnme}/{_vnme}");
json_save_struct($"{_dir}/pb_{_lnme}/{_vnme}/info.json", _str, true);
}
2025-01-09 08:28:19 +01:00
}
2025-01-09 05:28:30 +01:00
2025-01-10 03:04:53 +01:00
for( var i = 0, n = array_length(NODE_PCX_CATEGORY); i < n; i++ ) {
var _cat = NODE_PCX_CATEGORY[i];
2025-01-09 05:28:30 +01:00
var _lnme = _cat.name;
var _list = _cat.list;
directory_verify($"{_dir}/{_lnme}");
2025-01-10 03:04:53 +01:00
for( var j = 0, m = array_length(_list); j < m; j++ ) {
var _node = _list[j];
2025-01-09 05:28:30 +01:00
if(!is(_node, NodeObject)) continue;
2025-01-09 08:28:19 +01:00
var _nme = _node.nodeName;
2025-01-09 05:28:30 +01:00
var _vnme = filename_name_validate(_nme);
var _str = _node.serialize();
2025-01-09 08:28:19 +01:00
directory_verify($"{_dir}/pcx_{_lnme}/{_vnme}");
json_save_struct($"{_dir}/pcx_{_lnme}/{_vnme}/info.json", _str, true);
2025-01-09 05:28:30 +01:00
}
}
}