Pixel-Composer/scripts/node_group_output/node_group_output.gml

146 lines
4.1 KiB
Plaintext
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";
2023-02-14 05:32:32 +01:00
destroy_when_upgroup = true;
2022-12-10 05:06:01 +01:00
color = COLORS.node_blend_collection;
2022-01-13 05:24:03 +01:00
previewable = false;
2023-10-20 12:32:43 +02:00
attributes.input_priority = group == noone? 0 : group.getOutputFreeOrder();
2023-09-11 16:08:58 +02:00
2022-01-13 05:24:03 +01:00
w = 96;
h = 32 + 24;
min_h = h;
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-08-06 16:00:59 +02:00
attributes.inherit_name = !LOADING && !APPENDING;
2022-01-18 05:31:19 +01:00
outParent = undefined;
output_index = -1;
2023-06-13 14:42:06 +02:00
_onSetDisplayName = function() {
attributes.inherit_name = false;
}
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 [];
2023-03-29 15:02:03 +02:00
//group.setRenderStatus(true);
2023-05-22 20:31:55 +02:00
//printIf(global.FLAG.render, "Value to amount " + string(ds_list_size(outParent.value_to)));
2022-12-16 09:18:09 +01:00
LOG_BLOCK_START();
2023-03-28 06:58:28 +02:00
var nodes = [];
2022-12-16 09:18:09 +01:00
for(var j = 0; j < ds_list_size(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-18 14:58:55 +02:00
static createOutput = function(override_order = true) { #region
2023-03-28 06:58:28 +02:00
if(group == noone) return;
if(!is_struct(group)) return;
2023-09-11 16:08:58 +02:00
if(override_order)
attributes.input_priority = ds_list_size(group.outputs);
2022-01-18 05:31:19 +01:00
2023-03-28 06:58:28 +02:00
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);
group.setHeight();
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-06-13 14:42:06 +02:00
onSetDisplayName = _onSetDisplayName;
if(attributes.inherit_name && inputs[| 0].value_from != noone) {
if(display_name != inputs[| 0].value_from.name) {
onSetDisplayName = noone;
setDisplayName(inputs[| 0].value_from.name);
}
}
2023-10-18 14:58:55 +02:00
} #endregion
2022-12-10 05:06:01 +01:00
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-02-14 05:32:32 +01:00
if(PROJECT.version < 11520) attributes.input_priority = getInputData(1);
2023-02-14 05:32:32 +01:00
group.sortIO();
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
if(CLONING) attributes.input_priority = group.getOutputFreeOrder();
} #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_delete(group.outputs, ds_list_find_index(group.outputs, outParent));
2023-10-18 14:58:55 +02:00
} #endregion
2023-02-14 05:32:32 +01:00
2023-10-18 14:58:55 +02:00
static ungroup = function() { #region
2023-02-14 05:32:32 +01:00
var fr = inputs[| 0].value_from;
for( var i = 0; i < ds_list_size(outParent.value_to); i++ ) {
var to = outParent.value_to[| i];
if(to.value_from != outParent) continue;
to.setFrom(fr);
}
2023-10-18 14:58:55 +02:00
} #endregion
static onLoadGroup = function() { #region
if(group == noone) nodeDelete(self);
} #endregion
2022-01-13 05:24:03 +01:00
}