Pixel-Composer/scripts/node_feedback_inline/node_feedback_inline.gml

92 lines
2.4 KiB
Plaintext
Raw Normal View History

2023-12-19 14:30:34 +01:00
function Node_Feedback_Inline(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
2023-12-20 14:02:49 +01:00
name = "Feedback";
color = COLORS.node_blend_feedback;
icon = THEME.feedback;
icon_24 = THEME.feedback_24;
2023-12-19 14:30:34 +01:00
2024-01-07 12:18:20 +01:00
w = 0;
h = 0;
2023-12-22 04:15:04 +01:00
is_root = false;
2023-12-19 14:30:34 +01:00
selectable = false;
update_on_frame = true;
attributes.junc_in = [ "", 0 ];
attributes.junc_out = [ "", 0 ];
junc_in = noone;
junc_out = noone;
value_buffer = noone;
static bypassConnection = function() { return CURRENT_FRAME > 0; }
static bypassNextNode = function() { return false; }
static getNextNode = function() { return [] };
2023-12-19 14:30:34 +01:00
static connectJunctions = function(jFrom, jTo) {
junc_in = jFrom.is_dummy? jFrom.dummy_get() : jFrom;
junc_out = jTo;
attributes.junc_in = [ junc_in .node.node_id, junc_in .index ];
attributes.junc_out = [ junc_out.node.node_id, junc_out.index ];
}
static scanJunc = function() {
2023-12-19 14:30:34 +01:00
var node_in = PROJECT.nodeMap[? attributes.junc_in[0]];
var node_out = PROJECT.nodeMap[? attributes.junc_out[0]];
2024-08-08 06:57:51 +02:00
junc_in = node_in? node_in.inputs[attributes.junc_in[1]] : noone;
junc_out = node_out? node_out.outputs[attributes.junc_out[1]] : noone;
2023-12-19 14:30:34 +01:00
if(junc_in) junc_in.value_from_loop = self;
if(junc_out) array_push(junc_out.value_to_loop, self);
}
2023-12-19 14:30:34 +01:00
static updateValue = function() {
2023-12-19 14:30:34 +01:00
var type = junc_out.type;
var val = junc_out.getValue();
switch(type) {
case VALUE_TYPE.surface :
surface_array_free(value_buffer);
value_buffer = surface_array_clone(val);
break;
2023-12-19 14:30:34 +01:00
default :
value_buffer = variable_clone(val);
break;
}
}
2023-12-19 14:30:34 +01:00
static getValue = function(arr) {
2024-04-01 11:10:01 +02:00
INLINE
arr[@ 0] = value_buffer;
arr[@ 1] = junc_out;
}
2023-12-19 14:30:34 +01:00
static drawConnections = function(params = {}) {
2024-03-21 13:57:44 +01:00
if(!active) return noone;
if(!junc_in || !junc_out) return noone;
if(!junc_in.node.active || !junc_out.node.active) return noone;
2023-12-19 14:30:34 +01:00
params.dashed = true;
params.loop = true;
drawJuncConnection(junc_out, junc_in, params);
params.dashed = false;
params.loop = false;
2024-03-21 13:57:44 +01:00
return noone;
}
2023-12-19 14:30:34 +01:00
static drawNode = function(_x, _y, _mx, _my, _s, display_parameter = noone) {}
static pointIn = function(_x, _y, _mx, _my, _s) { return false; }
2024-04-26 14:38:24 +02:00
static postDeserialize = function() { scanJunc(); }
2023-12-19 14:30:34 +01:00
static onDestroy = function() {
2023-12-19 14:30:34 +01:00
if(junc_in) junc_in.value_from_loop = noone;
if(junc_out) array_remove(junc_out.value_to_loop, self);
}
2023-12-19 14:30:34 +01:00
}