Pixel-Composer/scripts/node_group_output/node_group_output.gml

145 lines
3.8 KiB
Text
Raw Normal View History

2023-02-28 09:43:01 +01:00
function Node_Group_Output(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
2023-02-19 13:49:20 +01:00
name = "Group Output";
2022-12-10 05:06:01 +01:00
color = COLORS.node_blend_collection;
2023-12-05 13:49:18 +01:00
is_group_io = true;
2022-01-13 05:24:03 +01:00
destroy_when_upgroup = true;
2024-03-28 14:18:02 +01:00
setDimension(96, 32 + 24);
2022-01-13 05:24:03 +01:00
2023-02-14 05:32:32 +01:00
inputs[| 0] = nodeValue("Value", self, JUNCTION_CONNECT.input, VALUE_TYPE.any, -1)
2023-07-25 20:12:40 +02:00
.uncache()
2022-01-19 06:11:17 +01:00
.setVisible(true, true);
2022-01-13 05:24:03 +01:00
2023-12-03 05:02:04 +01:00
attributes.inherit_name = true;
outParent = undefined;
2022-01-18 05:31:19 +01:00
output_index = -1;
2023-12-03 05:02:04 +01:00
onSetDisplayName = function() { attributes.inherit_name = false; }
inputs[| 0].onSetFrom = function(juncFrom) {
2024-04-03 09:40:37 +02:00
if(attributes.inherit_name && !LOADING && !APPENDING)
2023-12-03 05:02:04 +01:00
setDisplayName(juncFrom.name);
}
2023-06-13 14:42:06 +02:00
2023-10-18 14:58:55 +02:00
static setRenderStatus = function(result) { #region
2023-10-08 08:02:38 +02:00
if(rendered == result) return;
LOG_LINE_IF(global.FLAG.render == 1, $"Set render status for {INAME} : {result}");
2023-04-04 09:49:33 +02:00
rendered = result;
if(group) group.setRenderStatus(result);
2023-10-18 14:58:55 +02:00
} #endregion
2023-04-04 09:49:33 +02:00
2023-10-18 14:58:55 +02:00
static onValueUpdate = function(index = 0) { #region
2022-01-18 05:31:19 +01:00
if(is_undefined(outParent)) return;
2023-10-18 14:58:55 +02:00
} #endregion
2022-01-18 05:31:19 +01:00
2023-10-18 14:58:55 +02:00
static getNextNodes = function() { #region
2023-03-28 06:58:28 +02:00
if(is_undefined(outParent)) return [];
2022-12-16 09:18:09 +01:00
LOG_BLOCK_START();
2023-03-28 06:58:28 +02:00
var nodes = [];
2023-12-19 14:30:34 +01:00
for(var j = 0; j < array_length(outParent.value_to); j++) {
var _to = outParent.value_to[j];
2023-06-17 14:30:49 +02:00
if(!_to.node.isRenderActive()) continue;
2023-05-22 20:31:55 +02:00
//printIf(global.FLAG.render, "Value to " + _to.name);
2022-12-16 09:18:09 +01:00
if(!_to.node.active || _to.value_from == noone) {
2023-05-22 20:31:55 +02:00
//printIf(global.FLAG.render, "no value from");
2022-12-16 09:18:09 +01:00
continue;
}
if(_to.value_from.node != group) {
2023-05-22 20:31:55 +02:00
//printIf(global.FLAG.render, "value from not equal group");
2022-12-16 09:18:09 +01:00
continue;
}
2023-05-22 20:31:55 +02:00
//printIf(global.FLAG.render, "Group output ready " + string(_to.node.isRenderable()));
2022-12-16 09:18:09 +01:00
2023-03-29 15:02:03 +02:00
array_push(nodes, _to.node);
LOG_IF(global.FLAG.render == 1, $"Check complete, push {_to.node.internalName} to queue.");
2022-12-16 09:18:09 +01:00
}
LOG_BLOCK_END();
2023-03-28 06:58:28 +02:00
return nodes;
2023-10-18 14:58:55 +02:00
} #endregion
2022-12-16 09:18:09 +01:00
2023-10-28 04:07:43 +02:00
static createOutput = function() { #region
2023-03-28 06:58:28 +02:00
if(group == noone) return;
if(!is_struct(group)) return;
if(!is_undefined(outParent))
ds_list_remove(group.outputs, outParent);
2023-02-14 05:32:32 +01:00
2023-03-28 06:58:28 +02:00
outParent = nodeValue("Value", group, JUNCTION_CONNECT.output, VALUE_TYPE.any, -1)
2023-07-25 20:12:40 +02:00
.uncache()
2023-03-28 06:58:28 +02:00
.setVisible(true, true);
outParent.from = self;
2022-01-19 03:05:13 +01:00
2023-03-28 06:58:28 +02:00
ds_list_add(group.outputs, outParent);
if(!LOADING && !APPENDING) {
group.refreshNodeDisplay();
group.sortIO();
}
2022-01-13 05:24:03 +01:00
2023-03-28 06:58:28 +02:00
outParent.setFrom(inputs[| 0]);
2023-10-18 14:58:55 +02:00
} if(!LOADING && !APPENDING) createOutput(); #endregion
2022-01-13 05:24:03 +01:00
2023-10-18 14:58:55 +02:00
static step = function() { #region
2022-01-18 05:31:19 +01:00
if(is_undefined(outParent)) return;
2023-02-14 05:32:32 +01:00
outParent.name = display_name;
2022-01-25 10:58:11 +01:00
2023-10-07 16:23:40 +02:00
inputs[| 0].setType(VALUE_TYPE.any);
2022-12-10 05:06:01 +01:00
if(inputs[| 0].value_from != noone) {
2023-10-07 16:23:40 +02:00
inputs[| 0].setType(inputs[| 0].value_from.type);
2022-12-10 05:06:01 +01:00
inputs[| 0].display_type = inputs[| 0].value_from.display_type;
}
2023-10-07 16:23:40 +02:00
outParent.setType(inputs[| 0].type);
2022-12-10 05:06:01 +01:00
outParent.display_type = inputs[| 0].display_type;
2023-10-18 14:58:55 +02:00
} #endregion
2022-12-10 05:06:01 +01:00
2024-04-02 14:33:25 +02:00
static getGraphPreviewSurface = function() { #region
return inputs[| 0].getValue();
} #endregion
2023-10-18 14:58:55 +02:00
static postDeserialize = function() { #region
if(group == noone) return;
2022-01-18 05:31:19 +01:00
createOutput(false);
2023-10-18 14:58:55 +02:00
} #endregion
2022-01-13 05:24:03 +01:00
2023-10-20 12:32:43 +02:00
static doApplyDeserialize = function() { #region
2024-03-27 11:51:14 +01:00
2023-10-20 12:32:43 +02:00
} #endregion
2023-10-18 14:58:55 +02:00
static onDestroy = function() { #region
2022-01-18 05:31:19 +01:00
if(is_undefined(outParent)) return;
ds_list_remove(group.outputs, outParent);
group.sortIO();
group.refreshNodes();
2024-07-03 05:16:46 +02:00
var _tos = outParent.getJunctionTo();
for (var i = 0, n = array_length(_tos); i < n; i++)
_tos[i].removeFrom();
2023-10-18 14:58:55 +02:00
} #endregion
2023-02-14 05:32:32 +01:00
2024-05-22 12:13:46 +02:00
static onUngroup = function() { #region
2023-02-14 05:32:32 +01:00
var fr = inputs[| 0].value_from;
2023-12-19 14:30:34 +01:00
for( var i = 0; i < array_length(outParent.value_to); i++ ) {
var to = outParent.value_to[i];
2023-02-14 05:32:32 +01:00
if(to.value_from != outParent) continue;
to.setFrom(fr);
}
2023-10-18 14:58:55 +02:00
} #endregion
static onLoadGroup = function() { #region
2024-04-08 07:13:46 +02:00
if(group == noone) destroy();
2023-10-18 14:58:55 +02:00
} #endregion
2022-01-13 05:24:03 +01:00
}