Pixel-Composer/scripts/node_group_output/node_group_output.gml

145 lines
3.8 KiB
Text
Raw Normal View History

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