2022-01-24 02:21:25 +01:00
|
|
|
enum COLLECTION_TAG {
|
|
|
|
group = 1,
|
|
|
|
loop = 2
|
|
|
|
}
|
|
|
|
|
2023-10-10 07:12:42 +02:00
|
|
|
function groupNodes(nodeArray, _group = noone, record = true, check_connect = true) { #region
|
2024-01-26 14:38:50 +01:00
|
|
|
#region check inline
|
|
|
|
var _ctx_nodes = [];
|
2023-12-18 08:27:31 +01:00
|
|
|
|
2024-01-26 14:38:50 +01:00
|
|
|
for(var i = 0; i < array_length(nodeArray); i++) {
|
|
|
|
var node = nodeArray[i];
|
|
|
|
var ctx = node.inline_context;
|
2023-12-18 08:27:31 +01:00
|
|
|
|
2024-01-26 14:38:50 +01:00
|
|
|
if(ctx == noone) continue;
|
|
|
|
array_push_unique(_ctx_nodes, ctx);
|
2023-12-18 08:27:31 +01:00
|
|
|
|
2024-01-26 14:38:50 +01:00
|
|
|
for( var k = 0, n = array_length(ctx.members); k < n; k++ ) {
|
|
|
|
if(array_exists(nodeArray, ctx.members[k])) continue;
|
|
|
|
noti_warning("Grouping incomplete inline group is not allowed.");
|
|
|
|
return;
|
2023-12-18 08:27:31 +01:00
|
|
|
}
|
2024-01-26 14:38:50 +01:00
|
|
|
}
|
|
|
|
#endregion
|
2023-12-18 08:27:31 +01:00
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
UNDO_HOLDING = true;
|
|
|
|
|
|
|
|
if(_group == noone) {
|
|
|
|
var cx = 0;
|
|
|
|
var cy = 0;
|
|
|
|
for(var i = 0; i < array_length(nodeArray); i++) {
|
|
|
|
var _node = nodeArray[i];
|
|
|
|
cx += _node.x;
|
|
|
|
cy += _node.y;
|
|
|
|
}
|
2024-01-26 14:38:50 +01:00
|
|
|
|
|
|
|
cx = value_snap(cx / array_length(nodeArray), 32);
|
|
|
|
cy = value_snap(cy / array_length(nodeArray), 32);
|
2023-02-14 05:32:32 +01:00
|
|
|
|
|
|
|
_group = new Node_Group(cx, cy, PANEL_GRAPH.getCurrentContext());
|
|
|
|
}
|
|
|
|
|
|
|
|
var _content = [];
|
2023-12-18 08:27:31 +01:00
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
for(var i = 0; i < array_length(nodeArray); i++) {
|
|
|
|
_group.add(nodeArray[i]);
|
|
|
|
_content[i] = nodeArray[i];
|
|
|
|
}
|
2023-12-18 08:27:31 +01:00
|
|
|
|
|
|
|
for( var i = 0, n = array_length(_ctx_nodes); i < n; i++ ) {
|
|
|
|
_group.add(_ctx_nodes[i]);
|
|
|
|
_content[i] = _ctx_nodes[i];
|
|
|
|
}
|
|
|
|
|
2024-01-26 14:38:50 +01:00
|
|
|
var _io = { inputs: {}, outputs: {}, map: {} };
|
|
|
|
|
|
|
|
if(check_connect) { #region IO creation
|
|
|
|
for(var i = 0; i < array_length(nodeArray); i++)
|
|
|
|
nodeArray[i].checkConnectGroup(_io);
|
|
|
|
|
|
|
|
var _in = _io.inputs;
|
|
|
|
var _inKey = struct_get_names(_in);
|
|
|
|
var _x, _y, m;
|
2023-02-14 05:32:32 +01:00
|
|
|
|
2024-01-26 14:38:50 +01:00
|
|
|
for( var i = 0, n = array_length(_inKey); i < n; i++ ) {
|
|
|
|
var _frm = _io.map[$ _inKey[i]];
|
|
|
|
var _tos = _in[$ _inKey[i]];
|
|
|
|
|
|
|
|
_x = 0
|
|
|
|
_y = 0;
|
|
|
|
m = array_length(_tos);
|
|
|
|
|
|
|
|
for( var j = 0; j < m; j++ ) {
|
|
|
|
var _to = _tos[j];
|
|
|
|
|
|
|
|
_x = min(_x, _to.node.x);
|
|
|
|
_y += _to.node.y;
|
|
|
|
}
|
|
|
|
|
|
|
|
_x = value_snap(_x - 64 - 128, 32);
|
|
|
|
_y = value_snap(_y / m, 32);
|
|
|
|
|
|
|
|
var _n = new Node_Group_Input(_x, _y, _group);
|
|
|
|
_n.inputs[| 2].setValue(_frm.type);
|
|
|
|
_n.onValueUpdate(0);
|
|
|
|
_n.inParent.setFrom(_frm);
|
|
|
|
|
|
|
|
for( var j = 0; j < m; j++ ) {
|
|
|
|
var _to = _tos[j];
|
|
|
|
_to.setFrom(_n.outputs[| 0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var _ot = _io.outputs;
|
|
|
|
var _otKey = struct_get_names(_ot);
|
|
|
|
|
|
|
|
for( var i = 0, n = array_length(_otKey); i < n; i++ ) {
|
|
|
|
var _frm = _io.map[$ _otKey[i]];
|
|
|
|
var _tos = _ot[$ _otKey[i]];
|
|
|
|
|
|
|
|
_x = value_snap(_frm.node.x + _frm.node.w + 64, 32);
|
|
|
|
_y = value_snap(_frm.node.y, 32);
|
|
|
|
m = array_length(_tos);
|
|
|
|
|
|
|
|
var _n = new Node_Group_Output(_x, _y, _group);
|
|
|
|
_n.inputs[| 0].setFrom(_frm);
|
|
|
|
|
|
|
|
for( var j = 0; j < m; j++ ) {
|
|
|
|
var _to = _tos[j];
|
|
|
|
_to.setFrom(_n.outParent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} #endregion
|
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
UNDO_HOLDING = false;
|
2024-01-26 14:38:50 +01:00
|
|
|
if(record) recordAction(ACTION_TYPE.group, _group, { content: _content });
|
2023-02-14 05:32:32 +01:00
|
|
|
|
|
|
|
return _group;
|
2023-10-10 07:12:42 +02:00
|
|
|
} #endregion
|
2023-02-14 05:32:32 +01:00
|
|
|
|
2023-10-10 07:12:42 +02:00
|
|
|
function upgroupNode(collection, record = true) { #region
|
2023-02-14 05:32:32 +01:00
|
|
|
UNDO_HOLDING = true;
|
|
|
|
var _content = [];
|
2023-02-28 09:43:01 +01:00
|
|
|
var node_list = collection.getNodeList();
|
2024-01-26 14:38:50 +01:00
|
|
|
|
2023-02-28 09:43:01 +01:00
|
|
|
while(!ds_list_empty(node_list)) {
|
|
|
|
var remNode = node_list[| 0];
|
2024-01-26 14:38:50 +01:00
|
|
|
if(!remNode.destroy_when_upgroup)
|
2023-02-14 05:32:32 +01:00
|
|
|
array_push(_content, remNode);
|
|
|
|
|
|
|
|
collection.remove(remNode);
|
|
|
|
}
|
|
|
|
|
2024-04-08 07:13:46 +02:00
|
|
|
collection.destroy();
|
2023-02-14 05:32:32 +01:00
|
|
|
UNDO_HOLDING = false;
|
|
|
|
|
2024-01-26 14:38:50 +01:00
|
|
|
if(record) recordAction(ACTION_TYPE.ungroup, collection, { content: _content });
|
2023-10-10 07:12:42 +02:00
|
|
|
} #endregion
|
2023-02-14 05:32:32 +01:00
|
|
|
|
2023-10-10 07:12:42 +02:00
|
|
|
function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
2024-04-01 06:34:02 +02:00
|
|
|
nodes = ds_list_create();
|
|
|
|
node_length = ds_list_size(nodes);
|
|
|
|
|
2023-07-17 19:58:33 +02:00
|
|
|
ungroupable = true;
|
|
|
|
auto_render_time = false;
|
2023-02-19 13:49:20 +01:00
|
|
|
combine_render_time = true;
|
2023-11-08 08:38:04 +01:00
|
|
|
previewable = true;
|
|
|
|
|
2023-06-01 10:32:21 +02:00
|
|
|
reset_all_child = false;
|
2023-07-17 19:58:33 +02:00
|
|
|
isInstancer = false;
|
|
|
|
instanceBase = noone;
|
2023-02-28 09:43:01 +01:00
|
|
|
|
2023-10-07 09:09:18 +02:00
|
|
|
input_display_list_def = [];
|
2023-11-02 14:37:13 +01:00
|
|
|
custom_input_index = 0;
|
|
|
|
custom_output_index = 0;
|
2022-01-23 04:08:16 +01:00
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
metadata = new MetaDataManager();
|
|
|
|
|
2024-03-27 11:51:14 +01:00
|
|
|
attributes.input_display_list = [];
|
|
|
|
attributes.output_display_list = [];
|
2023-03-08 07:35:51 +01:00
|
|
|
|
2023-11-02 14:37:13 +01:00
|
|
|
managedRenderOrder = false;
|
|
|
|
|
2023-10-07 09:09:18 +02:00
|
|
|
input_dummy = nodeValue("Add to group", self, JUNCTION_CONNECT.input, VALUE_TYPE.any, 0);
|
|
|
|
draw_dummy = false;
|
|
|
|
|
2023-11-19 14:28:50 +01:00
|
|
|
input_dummy.onSetFrom = function(juncFrom) { #region
|
2023-12-19 14:30:34 +01:00
|
|
|
array_remove(juncFrom.value_to, input_dummy);
|
2023-10-07 09:09:18 +02:00
|
|
|
input_dummy.value_from = noone;
|
|
|
|
|
|
|
|
var input = nodeBuild("Node_Group_Input", 0, 0, self);
|
|
|
|
var _type = juncFrom.type;
|
|
|
|
var _tind = array_find(input.data_type_map, juncFrom.type);
|
|
|
|
|
|
|
|
input.attributes.inherit_type = false;
|
|
|
|
if(_tind != -1)
|
|
|
|
input.inputs[| 2].setValue(_tind);
|
|
|
|
|
|
|
|
input.inParent.setFrom(juncFrom);
|
2023-10-08 04:14:35 +02:00
|
|
|
|
|
|
|
if(onNewInputFromGraph != noone) onNewInputFromGraph(juncFrom);
|
2023-11-19 14:28:50 +01:00
|
|
|
} #endregion
|
2023-10-07 09:09:18 +02:00
|
|
|
|
2023-10-08 04:14:35 +02:00
|
|
|
onNewInputFromGraph = noone;
|
|
|
|
|
2023-07-17 19:58:33 +02:00
|
|
|
tool_node = noone;
|
2023-09-11 16:08:58 +02:00
|
|
|
draw_input_overlay = true;
|
2023-07-17 19:58:33 +02:00
|
|
|
|
2024-03-27 11:51:14 +01:00
|
|
|
array_push(attributeEditors, ["Edit Input Display", function() { return 0; },
|
|
|
|
button(function() { dialogCall(o_dialog_group_input_order).setNode(self, JUNCTION_CONNECT.input); }) ]);
|
2023-10-20 12:32:43 +02:00
|
|
|
|
2024-03-27 11:51:14 +01:00
|
|
|
array_push(attributeEditors, ["Edit Output Display", function() { return 0; },
|
|
|
|
button(function() { dialogCall(o_dialog_group_input_order).setNode(self, JUNCTION_CONNECT.output); }) ]);
|
2023-03-19 09:17:39 +01:00
|
|
|
|
2024-04-01 06:34:02 +02:00
|
|
|
hasInsp1 = false;
|
2023-06-04 18:28:29 +02:00
|
|
|
insp1UpdateTooltip = __txtx("panel_inspector_execute", "Execute node contents");
|
2023-03-28 06:58:28 +02:00
|
|
|
insp1UpdateIcon = [ THEME.sequence_control, 1, COLORS._main_value_positive ];
|
2023-03-02 07:59:14 +01:00
|
|
|
|
2024-04-01 06:34:02 +02:00
|
|
|
hasInsp2 = false;
|
2023-11-18 11:49:25 +01:00
|
|
|
insp2UpdateTooltip = "Clear cache";
|
|
|
|
insp2UpdateIcon = [ THEME.cache, 0, COLORS._main_icon ];
|
|
|
|
|
2024-04-01 06:34:02 +02:00
|
|
|
static inspector1Update = function() { onInspector1Update(); }
|
2024-04-16 10:34:05 +02:00
|
|
|
static onInspector1Update = function() { RenderList(nodes); }
|
2024-04-01 06:34:02 +02:00
|
|
|
static hasInspector1Update = function() { INLINE return hasInsp1; }
|
2023-03-02 07:59:14 +01:00
|
|
|
|
2024-04-01 06:34:02 +02:00
|
|
|
static inspector2Update = function() { onInspector2Update(); }
|
|
|
|
static onInspector2Update = function() { #region
|
|
|
|
var i = 0;
|
|
|
|
|
2024-04-02 09:49:26 +02:00
|
|
|
repeat(ds_list_size(nodes)) {
|
2023-11-18 11:49:25 +01:00
|
|
|
if(nodes[| i].hasInspector2Update())
|
|
|
|
nodes[| i].inspector2Update();
|
2024-04-01 06:34:02 +02:00
|
|
|
i++;
|
2023-11-18 11:49:25 +01:00
|
|
|
}
|
|
|
|
} #endregion
|
2024-04-01 06:34:02 +02:00
|
|
|
static hasInspector2Update = function() { INLINE return hasInsp2; }
|
|
|
|
|
|
|
|
will_refresh = false;
|
|
|
|
static refreshNodes = function() { #region
|
|
|
|
will_refresh = false;
|
2023-11-18 11:49:25 +01:00
|
|
|
|
2024-04-01 06:34:02 +02:00
|
|
|
hasInsp1 = false;
|
|
|
|
hasInsp2 = false;
|
|
|
|
|
2024-04-02 09:49:26 +02:00
|
|
|
node_length = ds_list_size(nodes);
|
|
|
|
|
2024-04-01 06:34:02 +02:00
|
|
|
var i = 0;
|
|
|
|
repeat(node_length) {
|
|
|
|
hasInsp1 |= nodes[| i].hasInspector1Update();
|
|
|
|
hasInsp2 |= nodes[| i].hasInspector2Update();
|
|
|
|
|
|
|
|
i++;
|
|
|
|
}
|
2024-04-02 09:49:26 +02:00
|
|
|
|
2023-11-18 11:49:25 +01:00
|
|
|
} #endregion
|
|
|
|
|
2023-09-13 16:24:01 +02:00
|
|
|
static getNodeBase = function() { #region
|
2023-02-28 09:43:01 +01:00
|
|
|
if(instanceBase == noone) return self;
|
|
|
|
return instanceBase.getNodeBase();
|
2023-09-13 16:24:01 +02:00
|
|
|
} #endregion
|
2023-02-28 09:43:01 +01:00
|
|
|
|
2023-09-13 16:24:01 +02:00
|
|
|
static getNodeList = function() { #region
|
2023-11-08 08:38:04 +01:00
|
|
|
INLINE
|
2023-02-28 09:43:01 +01:00
|
|
|
if(instanceBase == noone) return nodes;
|
|
|
|
return instanceBase.getNodeList();
|
2023-09-13 16:24:01 +02:00
|
|
|
} #endregion
|
2023-02-28 09:43:01 +01:00
|
|
|
|
2024-03-14 14:35:19 +01:00
|
|
|
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { #region
|
2023-09-11 16:08:58 +02:00
|
|
|
if(!draw_input_overlay) return;
|
2023-10-09 16:07:33 +02:00
|
|
|
|
2023-01-01 02:06:02 +01:00
|
|
|
for(var i = custom_input_index; i < ds_list_size(inputs); i++) {
|
2023-03-11 01:40:17 +01:00
|
|
|
var _in = inputs[| i];
|
2023-10-02 08:57:44 +02:00
|
|
|
var _show = _in.from.getInputData(6);
|
2023-01-01 02:06:02 +01:00
|
|
|
|
|
|
|
if(!_show) continue;
|
2024-03-14 14:35:19 +01:00
|
|
|
var _hov = _in.drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny);
|
2023-10-09 16:07:33 +02:00
|
|
|
if(_hov != undefined) active &= !_hov;
|
2023-01-01 02:06:02 +01:00
|
|
|
}
|
2023-09-13 16:24:01 +02:00
|
|
|
} #endregion
|
2023-01-01 02:06:02 +01:00
|
|
|
|
2023-09-13 16:24:01 +02:00
|
|
|
static getOutputNodes = function() { #region
|
2024-04-01 06:34:02 +02:00
|
|
|
var _nodes = [];
|
2023-06-13 14:42:06 +02:00
|
|
|
for( var i = custom_output_index; i < ds_list_size(outputs); i++ ) {
|
|
|
|
var _junc = outputs[| i];
|
|
|
|
|
2023-12-19 14:30:34 +01:00
|
|
|
for( var j = 0; j < array_length(_junc.value_to); j++ ) {
|
|
|
|
var _to = _junc.value_to[j];
|
2023-06-13 14:42:06 +02:00
|
|
|
if(_to.value_from != _junc) continue;
|
2024-04-01 06:34:02 +02:00
|
|
|
array_push_unique(_nodes, _to.node);
|
2023-06-13 14:42:06 +02:00
|
|
|
}
|
|
|
|
}
|
2024-04-01 06:34:02 +02:00
|
|
|
return _nodes;
|
2023-09-13 16:24:01 +02:00
|
|
|
} #endregion
|
2023-06-13 14:42:06 +02:00
|
|
|
|
2023-10-07 09:09:18 +02:00
|
|
|
static getInput = function(junc = noone) { #region
|
|
|
|
return input_dummy;
|
|
|
|
} #endregion
|
|
|
|
|
2023-10-10 07:12:42 +02:00
|
|
|
static getNextNodes = function() { return getNextNodesInternal(); }
|
|
|
|
|
|
|
|
static getNextNodesInternal = function() { #region //get node inside the group
|
2023-04-03 11:55:45 +02:00
|
|
|
LOG_BLOCK_START();
|
2023-11-30 08:55:33 +01:00
|
|
|
LOG_IF(global.FLAG.render == 1, $"→→→→→ Call get next node from group: {INAME}");
|
2023-06-01 10:32:21 +02:00
|
|
|
|
2024-04-01 06:34:02 +02:00
|
|
|
var _nodes = [];
|
2023-06-17 14:30:49 +02:00
|
|
|
if(isRenderActive()) {
|
2023-06-13 14:42:06 +02:00
|
|
|
var allReady = true;
|
|
|
|
for(var i = custom_input_index; i < ds_list_size(inputs); i++) {
|
|
|
|
var _in = inputs[| i].from;
|
2023-06-17 14:30:49 +02:00
|
|
|
if(!_in.isRenderActive()) continue;
|
2022-12-16 09:18:09 +01:00
|
|
|
|
2023-06-13 14:42:06 +02:00
|
|
|
if(!_in.isRenderable()) {
|
2023-10-05 06:29:20 +02:00
|
|
|
LOG_IF(global.FLAG.render == 1, $"Node {_in.internalName} not ready, loop skip.");
|
2023-06-13 14:42:06 +02:00
|
|
|
LOG_BLOCK_END();
|
|
|
|
return [];
|
|
|
|
}
|
2023-06-01 10:32:21 +02:00
|
|
|
}
|
2023-06-13 14:42:06 +02:00
|
|
|
|
2024-04-01 06:34:02 +02:00
|
|
|
_nodes = __nodeLeafList(getNodeList());
|
2022-12-16 09:18:09 +01:00
|
|
|
}
|
2023-03-28 06:58:28 +02:00
|
|
|
|
2023-04-03 11:55:45 +02:00
|
|
|
LOG_BLOCK_END();
|
2024-04-01 06:34:02 +02:00
|
|
|
return _nodes;
|
2023-09-13 16:24:01 +02:00
|
|
|
} #endregion
|
2022-12-16 09:18:09 +01:00
|
|
|
|
2023-09-13 16:24:01 +02:00
|
|
|
static getNextNodesExternal = function() { #region //get node connected to the parent object
|
2023-10-05 06:29:20 +02:00
|
|
|
LOG_IF(global.FLAG.render == 1, $"Checking next node external for {INAME}");
|
2023-07-28 19:41:57 +02:00
|
|
|
LOG_BLOCK_START();
|
|
|
|
|
2024-04-01 06:34:02 +02:00
|
|
|
var nextNodes = [];
|
2023-06-01 10:32:21 +02:00
|
|
|
for( var i = 0; i < ds_list_size(outputs); i++ ) {
|
|
|
|
var _ot = outputs[| i];
|
2023-10-19 11:34:29 +02:00
|
|
|
if(!_ot.forward) continue;
|
|
|
|
if(_ot.type == VALUE_TYPE.node) continue;
|
|
|
|
|
2023-07-28 19:41:57 +02:00
|
|
|
var _tos = _ot.getJunctionTo();
|
|
|
|
for( var j = 0, n = array_length(_tos); j < n; j++ ) {
|
|
|
|
var _to = _tos[j];
|
2023-06-01 10:32:21 +02:00
|
|
|
var _node = _to.node;
|
|
|
|
|
2023-10-05 06:29:20 +02:00
|
|
|
LOG_IF(global.FLAG.render == 1, $"Checking node {_node.internalName} : {_node.isRenderable()}");
|
2023-10-10 07:12:42 +02:00
|
|
|
if(!_node.isRenderable()) continue;
|
2023-06-01 10:32:21 +02:00
|
|
|
|
2024-04-01 06:34:02 +02:00
|
|
|
array_push(nextNodes, _to.node);
|
2023-06-01 10:32:21 +02:00
|
|
|
}
|
|
|
|
}
|
2023-07-28 19:41:57 +02:00
|
|
|
LOG_BLOCK_END();
|
2023-06-01 10:32:21 +02:00
|
|
|
|
2024-04-01 06:34:02 +02:00
|
|
|
return nextNodes;
|
2023-09-13 16:24:01 +02:00
|
|
|
} #endregion
|
2023-06-01 10:32:21 +02:00
|
|
|
|
2024-04-03 09:40:37 +02:00
|
|
|
static clearTopoSorted = function() { INLINE topoSorted = false; for( var i = 0, n = ds_list_size(nodes); i < n; i++ ) { nodes[| i].clearTopoSorted(); } }
|
|
|
|
|
2023-09-13 16:24:01 +02:00
|
|
|
static setRenderStatus = function(result) { #region
|
2023-04-03 11:55:45 +02:00
|
|
|
LOG_BLOCK_START();
|
2023-10-05 06:29:20 +02:00
|
|
|
LOG_IF(global.FLAG.render == 1, $"Set render status for {INAME} : {result}");
|
2022-12-12 09:08:03 +01:00
|
|
|
rendered = result;
|
2024-04-02 09:49:26 +02:00
|
|
|
if(rendered == result) return;
|
2022-12-12 09:08:03 +01:00
|
|
|
|
2023-07-28 19:41:57 +02:00
|
|
|
if(result)
|
|
|
|
for( var i = custom_output_index, n = ds_list_size(outputs); i < n; i++ ) {
|
|
|
|
var _o = outputs[| i];
|
|
|
|
if(_o.from.rendered) continue;
|
2022-12-16 09:18:09 +01:00
|
|
|
|
2023-10-05 06:29:20 +02:00
|
|
|
LOG_IF(global.FLAG.render == 1, $"Set fail because {_o.from.internalName} is not rendered.");
|
2023-07-28 19:41:57 +02:00
|
|
|
rendered = false;
|
|
|
|
break;
|
2022-12-12 09:08:03 +01:00
|
|
|
}
|
2023-04-09 21:24:16 +02:00
|
|
|
|
2023-10-08 08:02:38 +02:00
|
|
|
if(rendered) exitGroup();
|
2023-04-09 21:24:16 +02:00
|
|
|
|
2023-02-28 09:43:01 +01:00
|
|
|
if(!result && group != noone)
|
2022-12-12 09:08:03 +01:00
|
|
|
group.setRenderStatus(result);
|
2023-07-28 19:41:57 +02:00
|
|
|
LOG_BLOCK_END();
|
2023-09-13 16:24:01 +02:00
|
|
|
} #endregion
|
2022-12-12 09:08:03 +01:00
|
|
|
|
2023-11-19 14:28:50 +01:00
|
|
|
static isActiveDynamic = function(frame = CURRENT_FRAME) { #region
|
|
|
|
if(update_on_frame) return true;
|
2024-04-02 09:49:26 +02:00
|
|
|
if(!rendered) return true;
|
2023-11-19 14:28:50 +01:00
|
|
|
|
2023-11-26 13:16:38 +01:00
|
|
|
for( var i = custom_input_index, n = ds_list_size(inputs); i < n; i++ )
|
2023-11-19 14:28:50 +01:00
|
|
|
if(inputs[| i].isActiveDynamic(frame) || !inputs[| i].from.rendered) return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
} #endregion
|
|
|
|
|
2023-04-09 21:24:16 +02:00
|
|
|
static exitGroup = function() {}
|
|
|
|
|
2023-09-13 16:24:01 +02:00
|
|
|
static add = function(_node) { #region
|
2023-02-28 09:43:01 +01:00
|
|
|
ds_list_add(getNodeList(), _node);
|
|
|
|
var list = _node.group == noone? PANEL_GRAPH.nodes_list : _node.group.getNodeList();
|
2023-11-08 08:38:04 +01:00
|
|
|
ds_list_remove(list, _node);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
|
|
|
recordAction(ACTION_TYPE.group_added, self, _node);
|
|
|
|
_node.group = self;
|
2024-04-01 06:34:02 +02:00
|
|
|
|
|
|
|
will_refresh = true;
|
2024-04-02 09:49:26 +02:00
|
|
|
node_length = ds_list_size(nodes);
|
2023-09-13 16:24:01 +02:00
|
|
|
} #endregion
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-09-13 16:24:01 +02:00
|
|
|
static remove = function(_node) { #region
|
2023-02-28 09:43:01 +01:00
|
|
|
var node_list = getNodeList();
|
|
|
|
var _pos = ds_list_find_index(node_list, _node);
|
|
|
|
ds_list_delete(node_list, _pos);
|
|
|
|
var list = group == noone? PANEL_GRAPH.nodes_list : group.getNodeList();
|
2022-01-13 05:24:03 +01:00
|
|
|
ds_list_add(list, _node);
|
|
|
|
|
|
|
|
recordAction(ACTION_TYPE.group_removed, self, _node);
|
2022-01-29 14:25:18 +01:00
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
if(struct_has(_node, "ungroup"))
|
|
|
|
_node.ungroup();
|
|
|
|
|
|
|
|
if(_node.destroy_when_upgroup)
|
2024-04-08 07:13:46 +02:00
|
|
|
_node.destroy();
|
2023-02-14 05:32:32 +01:00
|
|
|
else
|
|
|
|
_node.group = group;
|
2024-04-01 06:34:02 +02:00
|
|
|
|
|
|
|
will_refresh = true;
|
2024-04-02 09:49:26 +02:00
|
|
|
node_length = ds_list_size(nodes);
|
2023-09-13 16:24:01 +02:00
|
|
|
} #endregion
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-09-13 16:24:01 +02:00
|
|
|
static clearCache = function() { #region
|
2023-02-28 09:43:01 +01:00
|
|
|
var node_list = getNodeList();
|
|
|
|
for(var i = 0; i < ds_list_size(node_list); i++) {
|
|
|
|
node_list[| i].clearCache();
|
2022-12-10 05:06:01 +01:00
|
|
|
}
|
2023-09-13 16:24:01 +02:00
|
|
|
} #endregion
|
2022-12-10 05:06:01 +01:00
|
|
|
|
2024-04-02 09:49:26 +02:00
|
|
|
static stepBegin = function() { #region
|
2024-04-01 06:34:02 +02:00
|
|
|
if(will_refresh) refreshNodes();
|
|
|
|
doStepBegin();
|
2024-04-02 09:49:26 +02:00
|
|
|
} #endregion
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-09-13 16:24:01 +02:00
|
|
|
static step = function() { #region
|
2023-11-08 08:38:04 +01:00
|
|
|
if(combine_render_time) {
|
|
|
|
render_time = 0;
|
|
|
|
var node_list = getNodeList();
|
|
|
|
for(var i = 0; i < ds_list_size(node_list); i++)
|
2023-02-28 09:43:01 +01:00
|
|
|
render_time += node_list[| i].render_time;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
2022-12-16 09:18:09 +01:00
|
|
|
onStep();
|
2023-09-13 16:24:01 +02:00
|
|
|
} #endregion
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-12-16 09:18:09 +01:00
|
|
|
static onStep = function() {}
|
|
|
|
|
2023-10-07 09:09:18 +02:00
|
|
|
static onPreDraw = function(_x, _y, _s, _iny, _outy) { #region
|
|
|
|
var xx = x * _s + _x;
|
|
|
|
var yy = y * _s + _y;
|
|
|
|
|
|
|
|
input_dummy.x = xx;
|
|
|
|
input_dummy.y = _iny;
|
|
|
|
} #endregion
|
|
|
|
|
2023-09-13 16:24:01 +02:00
|
|
|
static preConnect = function() { #region
|
2022-01-18 05:31:19 +01:00
|
|
|
sortIO();
|
2022-12-12 09:08:03 +01:00
|
|
|
deserialize(load_map, load_scale);
|
2023-09-13 16:24:01 +02:00
|
|
|
} #endregion
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-10-07 09:09:18 +02:00
|
|
|
static onDrawJunctions = function(_x, _y, _mx, _my, _s) { #region
|
|
|
|
input_dummy.visible = false;
|
2023-03-08 07:35:51 +01:00
|
|
|
|
2023-10-07 09:09:18 +02:00
|
|
|
if(draw_dummy) {
|
|
|
|
input_dummy.visible = true;
|
|
|
|
input_dummy.drawJunction(_s, _mx, _my);
|
|
|
|
}
|
|
|
|
|
|
|
|
draw_dummy = false;
|
|
|
|
} #endregion
|
|
|
|
|
|
|
|
static sortIO = function() { #region
|
2024-04-02 09:49:26 +02:00
|
|
|
var _ilen = ds_list_size(inputs);
|
|
|
|
var _iarr = attributes.input_display_list;
|
|
|
|
|
|
|
|
for( var i = 0; i < _ilen; i++ )
|
|
|
|
array_push_unique(_iarr, i);
|
|
|
|
for( var i = array_length(_iarr) - 1; i >= 0; i-- ) {
|
2024-04-02 14:33:25 +02:00
|
|
|
if(is_array(_iarr[i])) continue;
|
2024-04-02 09:49:26 +02:00
|
|
|
if(_iarr[i] >= _ilen) array_delete(_iarr, i, 1);
|
|
|
|
}
|
|
|
|
|
2024-03-27 11:51:14 +01:00
|
|
|
input_display_list = attributes.input_display_list;
|
2023-03-08 07:35:51 +01:00
|
|
|
|
2024-04-02 09:49:26 +02:00
|
|
|
///////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
var _olen = ds_list_size(outputs);
|
|
|
|
var _oarr = attributes.output_display_list;
|
|
|
|
|
|
|
|
for( var i = 0; i < _olen; i++ )
|
|
|
|
array_push_unique(_oarr, i);
|
|
|
|
for( var i = array_length(_oarr) - 1; i >= 0; i-- ) {
|
2024-04-03 09:40:37 +02:00
|
|
|
if(is_array(_oarr[i])) continue;
|
2024-04-02 14:33:25 +02:00
|
|
|
if(_oarr[i] >= _olen) array_delete(_oarr, i, 1);
|
2024-04-02 09:49:26 +02:00
|
|
|
}
|
2024-03-27 11:51:14 +01:00
|
|
|
output_display_list = attributes.output_display_list;
|
2023-11-08 08:38:04 +01:00
|
|
|
|
2024-04-02 09:49:26 +02:00
|
|
|
///////////////////////////////////////////////////////////////////
|
|
|
|
|
2024-03-31 11:10:14 +02:00
|
|
|
refreshNodeDisplay();
|
2023-09-13 16:24:01 +02:00
|
|
|
} #endregion
|
2022-01-19 03:51:53 +01:00
|
|
|
|
2023-10-10 07:12:42 +02:00
|
|
|
static getTool = function() { #region
|
2024-04-02 09:49:26 +02:00
|
|
|
for(var i = 0, n = ds_list_size(nodes); i < n; i++) {
|
2023-07-17 19:58:33 +02:00
|
|
|
var _node = nodes[| i];
|
2024-04-01 11:10:01 +02:00
|
|
|
if(!_node.active) continue;
|
2023-07-17 19:58:33 +02:00
|
|
|
if(_node.isTool) return _node.getTool();
|
|
|
|
}
|
|
|
|
|
|
|
|
return self;
|
2023-09-13 16:24:01 +02:00
|
|
|
} #endregion
|
2023-07-17 19:58:33 +02:00
|
|
|
|
2023-09-13 16:24:01 +02:00
|
|
|
static onClone = function(_newNode, target = PANEL_GRAPH.getCurrentContext()) { #region
|
2023-02-28 09:43:01 +01:00
|
|
|
if(instanceBase != noone) {
|
|
|
|
_newNode.instanceBase = instanceBase;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
var dups = ds_list_create();
|
|
|
|
|
2024-04-02 09:49:26 +02:00
|
|
|
for(var i = 0, n = ds_list_size(nodes); i < n; i++) {
|
2023-02-14 05:32:32 +01:00
|
|
|
var _node = nodes[| i];
|
|
|
|
var _cnode = _node.clone(target);
|
|
|
|
ds_list_add(dups, _cnode);
|
|
|
|
|
|
|
|
APPEND_MAP[? _node.node_id] = _cnode.node_id;
|
2022-01-19 03:51:53 +01:00
|
|
|
}
|
2023-02-14 05:32:32 +01:00
|
|
|
|
|
|
|
APPENDING = true;
|
|
|
|
for(var i = 0; i < ds_list_size(dups); i++) {
|
|
|
|
var _node = dups[| i];
|
|
|
|
_node.connect();
|
|
|
|
}
|
|
|
|
APPENDING = false;
|
|
|
|
|
|
|
|
ds_list_destroy(dups);
|
2023-09-13 16:24:01 +02:00
|
|
|
} #endregion
|
2023-02-14 05:32:32 +01:00
|
|
|
|
2023-09-13 16:24:01 +02:00
|
|
|
static enable = function() { #region
|
2023-02-14 05:32:32 +01:00
|
|
|
active = true;
|
2023-02-28 09:43:01 +01:00
|
|
|
var node_list = getNodeList();
|
|
|
|
for( var i = 0; i < ds_list_size(node_list); i++ )
|
|
|
|
node_list[| i].enable();
|
2023-09-13 16:24:01 +02:00
|
|
|
} #endregion
|
2023-02-14 05:32:32 +01:00
|
|
|
|
2023-09-13 16:24:01 +02:00
|
|
|
static disable = function() { #region
|
2023-02-14 05:32:32 +01:00
|
|
|
active = false;
|
2023-02-28 09:43:01 +01:00
|
|
|
var node_list = getNodeList();
|
|
|
|
for( var i = 0; i < ds_list_size(node_list); i++ )
|
|
|
|
node_list[| i].disable();
|
2023-09-13 16:24:01 +02:00
|
|
|
} #endregion
|
2022-01-25 04:05:30 +01:00
|
|
|
|
2023-10-08 08:02:38 +02:00
|
|
|
static resetRender = function(_clearCache = false) { #region
|
2024-04-02 09:49:26 +02:00
|
|
|
LOG_LINE_IF(global.FLAG.render == 1, $"Reset Render for group {INAME}");
|
2023-04-03 11:55:45 +02:00
|
|
|
|
2023-06-01 10:32:21 +02:00
|
|
|
setRenderStatus(false);
|
2023-10-08 08:02:38 +02:00
|
|
|
if(_clearCache) clearInputCache();
|
2023-04-03 11:55:45 +02:00
|
|
|
|
2024-04-02 09:49:26 +02:00
|
|
|
if(reset_all_child)
|
|
|
|
for(var i = 0, n = ds_list_size(nodes); i < n; i++)
|
2023-10-08 08:02:38 +02:00
|
|
|
nodes[| i].resetRender(_clearCache);
|
2023-09-13 16:24:01 +02:00
|
|
|
} #endregion
|
2022-12-21 02:30:23 +01:00
|
|
|
|
2023-09-13 16:24:01 +02:00
|
|
|
static setInstance = function(node) { #region
|
2023-02-28 09:43:01 +01:00
|
|
|
instanceBase = node;
|
2023-09-13 16:24:01 +02:00
|
|
|
} #endregion
|
2023-02-28 09:43:01 +01:00
|
|
|
|
2023-09-13 16:24:01 +02:00
|
|
|
static resetInstance = function() { #region
|
2023-02-28 09:43:01 +01:00
|
|
|
instanceBase = noone;
|
2023-09-13 16:24:01 +02:00
|
|
|
} #endregion
|
2023-02-28 09:43:01 +01:00
|
|
|
|
2023-09-13 16:24:01 +02:00
|
|
|
static onDoubleClick = function(panel) { #region
|
2024-04-03 09:40:37 +02:00
|
|
|
if(PREFERENCES.panel_graph_group_require_shift && !key_mod_press(SHIFT)) return false;
|
|
|
|
|
2023-11-10 11:32:46 +01:00
|
|
|
__temp_panel = panel;
|
|
|
|
|
|
|
|
if(PREFERENCES.graph_open_group_in_tab)
|
|
|
|
run_in(1, function() { __temp_panel.openGroupTab(self) });
|
|
|
|
else
|
|
|
|
panel.addContext(self);
|
|
|
|
|
2023-10-09 16:07:33 +02:00
|
|
|
if(ononDoubleClick != noone)
|
|
|
|
ononDoubleClick(panel);
|
2024-04-03 09:40:37 +02:00
|
|
|
|
|
|
|
return true;
|
2023-09-13 16:24:01 +02:00
|
|
|
} #endregion
|
2023-07-15 20:01:29 +02:00
|
|
|
|
2023-10-09 16:07:33 +02:00
|
|
|
static ononDoubleClick = noone;
|
|
|
|
|
2023-10-06 11:51:11 +02:00
|
|
|
static getGraphPreviewSurface = function() { #region
|
|
|
|
var _output_junc = outputs[| preview_channel];
|
2023-11-23 02:32:26 +01:00
|
|
|
|
2024-04-02 09:49:26 +02:00
|
|
|
for( var i = 0, n = ds_list_size(nodes); i < n; i++ ) {
|
2023-10-06 11:51:11 +02:00
|
|
|
if(!nodes[| i].active) continue;
|
|
|
|
if(is_instanceof(nodes[| i], Node_Group_Thumbnail))
|
|
|
|
_output_junc = nodes[| i].inputs[| 0];
|
|
|
|
}
|
|
|
|
|
2023-10-07 09:09:18 +02:00
|
|
|
if(!is_instanceof(_output_junc, NodeValue)) return noone;
|
|
|
|
|
2023-10-06 11:51:11 +02:00
|
|
|
switch(_output_junc.type) {
|
|
|
|
case VALUE_TYPE.surface :
|
|
|
|
case VALUE_TYPE.dynaSurface :
|
|
|
|
return _output_junc.getValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
return noone;
|
|
|
|
} #endregion
|
|
|
|
|
2023-11-15 14:42:53 +01:00
|
|
|
static enable = function() { #region
|
|
|
|
active = true; timeline_item.active = true;
|
2024-04-02 09:49:26 +02:00
|
|
|
for( var i = 0, n = ds_list_size(nodes); i < n; i++ ) nodes[| i].enable();
|
2023-11-15 14:42:53 +01:00
|
|
|
} #endregion
|
|
|
|
|
|
|
|
static disable = function() { #region
|
|
|
|
active = false; timeline_item.active = false;
|
2024-04-02 09:49:26 +02:00
|
|
|
for( var i = 0, n = ds_list_size(nodes); i < n; i++ ) nodes[| i].disable();
|
|
|
|
} #endregion
|
|
|
|
|
|
|
|
static attributeSerialize = function() { #region
|
|
|
|
sortIO();
|
|
|
|
|
|
|
|
var _attr = variable_clone(attributes);
|
|
|
|
|
|
|
|
_attr.custom_input_list = [];
|
|
|
|
for( var i = custom_input_index, n = ds_list_size(inputs); i < n; i++ ) {
|
|
|
|
if(struct_has(inputs[| i], "from"))
|
|
|
|
array_push(_attr.custom_input_list, inputs[| i].from.node_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
_attr.custom_output_list = [];
|
|
|
|
for( var i = custom_output_index, n = ds_list_size(outputs); i < n; i++ ) {
|
|
|
|
if(struct_has(outputs[| i], "from"))
|
|
|
|
array_push(_attr.custom_output_list , outputs[| i].from.node_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
return _attr;
|
|
|
|
} #endregion
|
|
|
|
|
2024-04-02 14:33:25 +02:00
|
|
|
static preApplyDeserialize = function() { #region
|
2024-04-02 09:49:26 +02:00
|
|
|
var attr = attributes;
|
|
|
|
|
2024-04-02 14:33:25 +02:00
|
|
|
if(LOADING_VERSION < 11690) { #region
|
|
|
|
var pr = ds_priority_create();
|
|
|
|
|
|
|
|
for( var i = ds_list_size(inputs) - 1; i >= custom_input_index; i-- ) {
|
|
|
|
if(!struct_has(inputs[| i].attributes, "input_priority")) continue;
|
|
|
|
|
|
|
|
var _pri = inputs[| i].attributes.input_priority;
|
|
|
|
ds_priority_add(pr, inputs[| i], _pri);
|
|
|
|
ds_list_delete(inputs, i);
|
|
|
|
}
|
|
|
|
|
|
|
|
repeat(ds_priority_size(pr)) ds_list_add(inputs, ds_priority_delete_min(pr));
|
|
|
|
|
|
|
|
for( var i = ds_list_size(outputs) - 1; i >= custom_output_index; i-- ) {
|
|
|
|
if(!struct_has(outputs[| i].attributes, "output_priority")) continue;
|
|
|
|
|
|
|
|
var _pri = outputs[| i].attributes.output_priority;
|
|
|
|
ds_priority_add(pr, outputs[| i], _pri);
|
|
|
|
ds_list_delete(outputs, i);
|
|
|
|
}
|
|
|
|
|
|
|
|
repeat(ds_priority_size(pr)) ds_list_add(outputs, ds_priority_delete_min(pr));
|
|
|
|
|
|
|
|
ds_priority_destroy(pr);
|
|
|
|
return;
|
|
|
|
} #endregion
|
|
|
|
|
2024-04-02 09:49:26 +02:00
|
|
|
if(struct_has(attr, "custom_input_list")) {
|
|
|
|
var _ilist = attr.custom_input_list;
|
|
|
|
var _inarr = {};
|
2024-04-02 14:33:25 +02:00
|
|
|
var _dilst = [];
|
|
|
|
|
|
|
|
if(APPENDING)
|
|
|
|
for( var i = 0, n = array_length(_ilist); i < n; i++ )
|
|
|
|
_ilist[i] = ds_map_try_get(APPEND_MAP, _ilist[i], _ilist[i]);
|
2024-04-02 09:49:26 +02:00
|
|
|
|
|
|
|
for( var i = ds_list_size(inputs) - 1; i >= custom_input_index; i-- ) {
|
|
|
|
if(!struct_has(inputs[| i], "from")) continue;
|
|
|
|
|
|
|
|
var _frNode = inputs[| i].from.node_id;
|
|
|
|
if(array_exists(_ilist, _frNode)) {
|
|
|
|
_inarr[$ _frNode] = inputs[| i];
|
|
|
|
ds_list_delete(inputs, i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for( var i = 0, n = array_length(_ilist); i < n; i++ ) {
|
|
|
|
if(!struct_has(_inarr, _ilist[i])) continue;
|
|
|
|
|
|
|
|
ds_list_add(inputs, _inarr[$ _ilist[i]]);
|
|
|
|
}
|
2024-04-02 14:33:25 +02:00
|
|
|
|
2024-04-02 09:49:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(struct_has(attr, "custom_output_list")) {
|
|
|
|
var _ilist = attr.custom_output_list;
|
|
|
|
var _inarr = {};
|
|
|
|
|
2024-04-02 14:33:25 +02:00
|
|
|
if(APPENDING)
|
|
|
|
for( var i = 0, n = array_length(_ilist); i < n; i++ )
|
|
|
|
_ilist[i] = ds_map_try_get(APPEND_MAP, _ilist[i], _ilist[i]);
|
|
|
|
|
2024-04-02 09:49:26 +02:00
|
|
|
for( var i = ds_list_size(outputs) - 1; i >= custom_output_index; i-- ) {
|
|
|
|
if(!struct_has(outputs[| i], "from")) continue;
|
|
|
|
|
|
|
|
var _frNode = outputs[| i].from.node_id;
|
|
|
|
if(array_exists(_ilist, _frNode)) {
|
|
|
|
_inarr[$ _frNode] = outputs[| i];
|
|
|
|
ds_list_delete(outputs, i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for( var i = 0, n = array_length(_ilist); i < n; i++ ) {
|
|
|
|
if(!struct_has(_inarr, _ilist[i])) continue;
|
|
|
|
|
|
|
|
ds_list_add(outputs, _inarr[$ _ilist[i]]);
|
|
|
|
}
|
2024-04-03 09:40:37 +02:00
|
|
|
|
2024-04-02 09:49:26 +02:00
|
|
|
}
|
|
|
|
|
2023-11-15 14:42:53 +01:00
|
|
|
} #endregion
|
|
|
|
|
2023-09-13 16:24:01 +02:00
|
|
|
static processSerialize = function(_map) { #region
|
2024-04-02 05:24:55 +02:00
|
|
|
_map.instance_base = instanceBase? instanceBase.node_id : noone;
|
2023-09-13 16:24:01 +02:00
|
|
|
} #endregion
|
2023-02-28 09:43:01 +01:00
|
|
|
|
2023-09-13 16:24:01 +02:00
|
|
|
static preConnect = function() { #region
|
2023-06-13 14:42:06 +02:00
|
|
|
instanceBase = GetAppendID(struct_try_get(load_map, "instance_base", noone));
|
2023-02-28 09:43:01 +01:00
|
|
|
|
2022-12-21 02:30:23 +01:00
|
|
|
sortIO();
|
2023-01-17 08:11:55 +01:00
|
|
|
applyDeserialize();
|
2023-09-13 16:24:01 +02:00
|
|
|
} #endregion
|
2023-03-08 07:35:51 +01:00
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|