2022-01-13 05:24:03 +01:00
|
|
|
function Node(_x, _y) constructor {
|
|
|
|
active = true;
|
2022-01-19 03:05:13 +01:00
|
|
|
node_id = generateUUID();
|
2022-01-13 05:24:03 +01:00
|
|
|
group = -1;
|
|
|
|
color = c_white;
|
|
|
|
icon = noone;
|
2022-11-18 03:20:31 +01:00
|
|
|
bg_spr = THEME.node_bg;
|
|
|
|
bg_sel_spr = THEME.node_active;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
|
|
|
if(!LOADING && !APPENDING) {
|
|
|
|
recordAction(ACTION_TYPE.node_added, self);
|
|
|
|
NODE_MAP[? node_id] = self;
|
|
|
|
group = PANEL_GRAPH.getCurrentContext();
|
|
|
|
}
|
|
|
|
|
|
|
|
name = "";
|
|
|
|
x = _x;
|
|
|
|
y = _y;
|
|
|
|
|
|
|
|
w = 128;
|
|
|
|
h = 128;
|
|
|
|
min_h = 128;
|
|
|
|
auto_height = true;
|
|
|
|
|
|
|
|
input_display_list = -1;
|
2022-09-23 13:28:42 +02:00
|
|
|
inspector_display_list = -1;
|
2022-01-13 05:24:03 +01:00
|
|
|
is_dynamic_output = false;
|
|
|
|
inputs = ds_list_create();
|
|
|
|
outputs = ds_list_create();
|
|
|
|
attributes = ds_map_create();
|
|
|
|
|
|
|
|
show_input_name = false;
|
|
|
|
show_output_name = false;
|
|
|
|
|
|
|
|
always_output = false;
|
|
|
|
inspecting = false;
|
2022-08-30 07:36:37 +02:00
|
|
|
previewing = 0;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
|
|
|
previewable = true;
|
|
|
|
preview_speed = 0;
|
|
|
|
preview_index = 0;
|
2022-01-16 05:17:35 +01:00
|
|
|
preview_channel = 0;
|
2022-01-13 05:24:03 +01:00
|
|
|
preview_x = 0;
|
|
|
|
preview_y = 0;
|
|
|
|
|
|
|
|
rendered = false;
|
|
|
|
auto_update = true;
|
|
|
|
update_on_frame = false;
|
2022-01-16 14:28:57 +01:00
|
|
|
render_time = 0;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
|
|
|
use_cache = false;
|
|
|
|
cached_output = [];
|
|
|
|
|
|
|
|
tools = -1;
|
|
|
|
|
|
|
|
on_dragdrop_file = -1;
|
|
|
|
|
|
|
|
anim_show = true;
|
|
|
|
|
2022-11-03 11:44:49 +01:00
|
|
|
value_validation = array_create(3);
|
2022-09-27 06:37:28 +02:00
|
|
|
MODIFIED = true;
|
|
|
|
|
|
|
|
static getInputJunctionIndex = function(index) {
|
|
|
|
if(input_display_list == -1)
|
|
|
|
return index;
|
|
|
|
|
|
|
|
var jun_list_arr = input_display_list[index];
|
|
|
|
if(is_array(jun_list_arr)) return noone;
|
|
|
|
if(is_struct(jun_list_arr)) return noone;
|
|
|
|
return jun_list_arr;
|
|
|
|
}
|
2022-08-30 07:36:37 +02:00
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
static setHeight = function() {
|
2022-11-03 11:44:49 +01:00
|
|
|
var _hi = ui(32);
|
|
|
|
var _ho = ui(32);
|
2022-01-13 05:24:03 +01:00
|
|
|
for( var i = 0; i < ds_list_size(inputs); i++ ) {
|
|
|
|
if(inputs[| i].isVisible()) _hi += 24;
|
|
|
|
}
|
2022-11-01 03:06:03 +01:00
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
for( var i = 0; i < ds_list_size(outputs); i++ ) {
|
|
|
|
if(outputs[| i].isVisible()) _ho += 24;
|
|
|
|
}
|
|
|
|
|
2022-11-01 03:06:03 +01:00
|
|
|
h = max(min_h, _hi, _ho);
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static move = function(_x, _y) {
|
|
|
|
x = _x;
|
|
|
|
y = _y;
|
2022-09-27 06:37:28 +02:00
|
|
|
MODIFIED = true;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static stepBegin = function() {
|
|
|
|
if(use_cache) {
|
|
|
|
if(array_length(cached_output) != ANIMATOR.frames_total + 1)
|
|
|
|
array_resize(cached_output, ANIMATOR.frames_total + 1);
|
|
|
|
}
|
2022-01-25 04:05:30 +01:00
|
|
|
var stack_push = false;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
|
|
|
if(always_output) {
|
|
|
|
for(var i = 0; i < ds_list_size(outputs); i++) {
|
|
|
|
if(outputs[| i].type == VALUE_TYPE.surface) {
|
|
|
|
var val = outputs[| i].getValue();
|
|
|
|
|
|
|
|
if(is_array(val)) {
|
|
|
|
for(var j = 0; j < array_length(val); j++) {
|
|
|
|
var _surf = val[j];
|
|
|
|
if(!is_surface(_surf) || _surf == DEF_SURFACE) {
|
2022-01-25 04:05:30 +01:00
|
|
|
stack_push = true;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if(!is_surface(val) || val == DEF_SURFACE) {
|
2022-01-25 04:05:30 +01:00
|
|
|
stack_push = true;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(ANIMATOR.is_playing || ANIMATOR.is_scrubing) {
|
|
|
|
if(update_on_frame)
|
|
|
|
doUpdate();
|
|
|
|
for(var i = 0; i < ds_list_size(inputs); i++) {
|
|
|
|
if(inputs[| i].isAnim()) {
|
2022-01-25 04:05:30 +01:00
|
|
|
stack_push = true;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-25 04:05:30 +01:00
|
|
|
if(stack_push) {
|
|
|
|
setRenderStatus(false);
|
|
|
|
UPDATE |= RENDER_TYPE.full;
|
|
|
|
//ds_stack_push(RENDER_STACK, self);
|
|
|
|
}
|
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
if(auto_height)
|
|
|
|
setHeight();
|
|
|
|
}
|
|
|
|
static step = function() {}
|
|
|
|
static focusStep = function() {}
|
|
|
|
|
|
|
|
static doUpdate = function() {
|
2022-01-16 14:28:57 +01:00
|
|
|
var t = get_timer();
|
2022-01-13 05:24:03 +01:00
|
|
|
update();
|
2022-01-23 04:08:16 +01:00
|
|
|
setRenderStatus(true);
|
2022-01-16 14:28:57 +01:00
|
|
|
render_time = get_timer() - t;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static onValueUpdate = function(index) {}
|
|
|
|
|
2022-01-24 02:21:25 +01:00
|
|
|
static isUpdateReady = function() {
|
|
|
|
if(rendered) return false;
|
|
|
|
|
|
|
|
for(var j = 0; j < ds_list_size(inputs); j++) {
|
|
|
|
var _in = inputs[| j];
|
|
|
|
if(_in.value_from) {
|
|
|
|
if (!_in.value_from.node.rendered)
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
static update = function() {}
|
|
|
|
|
|
|
|
static updateValueFrom = function(index) {}
|
|
|
|
|
|
|
|
static updateForward = function() {
|
2022-01-23 04:08:16 +01:00
|
|
|
rendered = false;
|
2022-01-25 04:05:30 +01:00
|
|
|
UPDATE |= RENDER_TYPE.full;
|
|
|
|
//ds_stack_push(RENDER_STACK, self);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
|
|
|
for(var i = 0; i < ds_list_size(outputs); i++) {
|
|
|
|
var jun = outputs[| i];
|
|
|
|
for(var j = 0; j < ds_list_size(jun.value_to); j++) {
|
|
|
|
var _to = jun.value_to[| j];
|
|
|
|
if(_to.value_from == jun && _to.node.auto_update) {
|
|
|
|
_to.node.updateForward();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
doUpdateForward();
|
|
|
|
}
|
|
|
|
|
2022-09-23 13:28:42 +02:00
|
|
|
static onInspect = function() {}
|
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
static doUpdateForward = function() {}
|
|
|
|
|
2022-01-23 04:08:16 +01:00
|
|
|
static setRenderStatus = function(result) {
|
|
|
|
rendered = result;
|
|
|
|
}
|
|
|
|
|
2022-11-01 03:06:03 +01:00
|
|
|
static pointIn = function(_x, _y, _mx, _my, _s) {
|
|
|
|
var xx = x * _s + _x;
|
|
|
|
var yy = y * _s + _y;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-11-01 03:06:03 +01:00
|
|
|
return point_in_rectangle(_mx, _my, xx, yy, xx + w * _s, yy + h * _s);
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
2022-01-16 14:28:57 +01:00
|
|
|
static preDraw = function(_x, _y, _s) {
|
2022-01-26 06:57:34 +01:00
|
|
|
var xx = x * _s + _x;
|
|
|
|
var yy = y * _s + _y;
|
2022-01-16 14:28:57 +01:00
|
|
|
|
2022-09-21 06:09:40 +02:00
|
|
|
var jun;
|
2022-09-23 13:28:42 +02:00
|
|
|
var amo = input_display_list == -1? ds_list_size(inputs) : array_length(input_display_list);
|
2022-11-03 11:44:49 +01:00
|
|
|
var _in = yy + ui(32) * _s;
|
2022-01-16 14:28:57 +01:00
|
|
|
|
|
|
|
for(var i = 0; i < amo; i++) {
|
2022-09-27 06:37:28 +02:00
|
|
|
var idx = getInputJunctionIndex(i);
|
|
|
|
if(idx == noone) continue;
|
2022-01-16 14:28:57 +01:00
|
|
|
|
2022-09-27 06:37:28 +02:00
|
|
|
jun = ds_list_get(inputs, idx, noone);
|
|
|
|
if(jun == noone) continue;
|
2022-01-26 06:57:34 +01:00
|
|
|
jun.x = xx;
|
2022-01-18 05:31:19 +01:00
|
|
|
jun.y = _in;
|
|
|
|
_in += 24 * _s * jun.isVisible();
|
2022-01-16 14:28:57 +01:00
|
|
|
}
|
|
|
|
|
2022-01-26 06:57:34 +01:00
|
|
|
xx = xx + w * _s;
|
2022-11-03 11:44:49 +01:00
|
|
|
_in = yy + ui(32) * _s;
|
2022-01-16 14:28:57 +01:00
|
|
|
for(var i = 0; i < ds_list_size(outputs); i++) {
|
2022-09-21 06:09:40 +02:00
|
|
|
jun = outputs[| i];
|
2022-01-16 14:28:57 +01:00
|
|
|
|
2022-01-26 06:57:34 +01:00
|
|
|
jun.x = xx;
|
2022-01-18 05:31:19 +01:00
|
|
|
jun.y = _in;
|
|
|
|
_in += 24 * _s * jun.isVisible();
|
2022-01-16 14:28:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
static drawNodeBase = function(xx, yy, _s) {
|
|
|
|
draw_sprite_stretched_ext(bg_spr, 0, xx, yy, w * _s, h * _s, color, 0.75);
|
|
|
|
}
|
|
|
|
|
|
|
|
static drawNodeName = function(xx, yy, _s) {
|
|
|
|
if(name == "") return;
|
2022-01-16 05:17:35 +01:00
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
if(_s * w > 48) {
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_sprite_stretched_ext(THEME.node_bg_name, 0, xx, yy, w * _s, ui(20), color, 0.75);
|
|
|
|
draw_set_text(f_p1, fa_left, fa_center, COLORS._main_text);
|
2022-01-16 05:17:35 +01:00
|
|
|
|
2022-11-18 03:20:31 +01:00
|
|
|
if(!auto_update) icon = THEME.refresh_s;
|
2022-01-13 05:24:03 +01:00
|
|
|
if(icon) {
|
2022-11-03 11:44:49 +01:00
|
|
|
draw_sprite_ui_uniform(icon, 0, xx + ui(12), yy + ui(10));
|
|
|
|
draw_text_cut(xx + ui(24), yy + ui(10), name, w * _s - ui(24));
|
2022-01-13 05:24:03 +01:00
|
|
|
} else {
|
2022-11-03 11:44:49 +01:00
|
|
|
draw_text_cut(xx + ui(8), yy + ui(10), name, w * _s - ui(8));
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static drawJunctions = function(_x, _y, _mx, _my, _s) {
|
|
|
|
var hover = noone;
|
2022-09-23 13:28:42 +02:00
|
|
|
var amo = input_display_list == -1? ds_list_size(inputs) : array_length(input_display_list);
|
2022-09-21 06:09:40 +02:00
|
|
|
var jun;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
|
|
|
for(var i = 0; i < amo; i++) {
|
2022-09-27 06:37:28 +02:00
|
|
|
var ind = getInputJunctionIndex(i);
|
|
|
|
if(ind == noone) continue;
|
|
|
|
jun = ds_list_get(inputs, ind, noone);
|
|
|
|
if(jun == noone) continue;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-09-27 06:37:28 +02:00
|
|
|
if(jun.drawJunction(_s, _mx, _my))
|
2022-01-26 06:57:34 +01:00
|
|
|
hover = jun;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
for(var i = 0; i < ds_list_size(outputs); i++) {
|
2022-09-21 06:09:40 +02:00
|
|
|
jun = outputs[| i];
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-09-27 06:37:28 +02:00
|
|
|
if(jun.drawJunction(_s, _mx, _my))
|
2022-01-26 06:57:34 +01:00
|
|
|
hover = jun;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return hover;
|
|
|
|
}
|
|
|
|
|
2022-09-27 06:37:28 +02:00
|
|
|
static drawJunctionNames = function(_x, _y, _mx, _my, _s) {
|
|
|
|
var amo = input_display_list == -1? ds_list_size(inputs) : array_length(input_display_list);
|
|
|
|
var jun;
|
|
|
|
|
|
|
|
var xx = x * _s + _x;
|
|
|
|
var yy = y * _s + _y;
|
|
|
|
|
|
|
|
show_input_name = point_in_rectangle(_mx, _my, xx - 8 * _s, yy + 20 * _s, xx + 8 * _s, yy + h * _s);
|
|
|
|
show_output_name = point_in_rectangle(_mx, _my, xx + (w - 8) * _s, yy + 20 * _s, xx + (w + 8) * _s, yy + h * _s);
|
|
|
|
|
|
|
|
if(show_input_name) {
|
|
|
|
for(var i = 0; i < amo; i++) {
|
|
|
|
var ind = getInputJunctionIndex(i);
|
|
|
|
if(ind == noone) continue;
|
|
|
|
inputs[| ind].drawNameBG(_s);
|
|
|
|
}
|
|
|
|
|
|
|
|
for(var i = 0; i < amo; i++) {
|
|
|
|
var ind = getInputJunctionIndex(i);
|
|
|
|
if(ind == noone) continue;
|
|
|
|
inputs[| ind].drawName(_s, _mx, _my);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(show_output_name) {
|
|
|
|
for(var i = 0; i < ds_list_size(outputs); i++) {
|
|
|
|
outputs[| i].drawNameBG(_s);
|
|
|
|
}
|
|
|
|
|
|
|
|
for(var i = 0; i < ds_list_size(outputs); i++) {
|
|
|
|
outputs[| i].drawName(_s, _mx, _my);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
static drawConnections = function(_x, _y, mx, my, _s) {
|
2022-01-25 04:05:30 +01:00
|
|
|
var hovering = noone;
|
2022-01-13 05:24:03 +01:00
|
|
|
for(var i = 0; i < ds_list_size(inputs); i++) {
|
|
|
|
var jun = inputs[| i];
|
2022-01-26 06:57:34 +01:00
|
|
|
var jx = jun.x;
|
2022-01-13 05:24:03 +01:00
|
|
|
var jy = jun.y;
|
|
|
|
|
|
|
|
if(jun.value_from && jun.isVisible()) {
|
2022-01-26 06:57:34 +01:00
|
|
|
var frx = jun.value_from.x;
|
2022-01-13 05:24:03 +01:00
|
|
|
var fry = jun.value_from.y;
|
|
|
|
|
|
|
|
var c0 = value_color(jun.value_from.type);
|
|
|
|
var c1 = value_color(jun.type);
|
2022-01-25 04:05:30 +01:00
|
|
|
var hover = false;
|
|
|
|
var th = max(1, 2 * _s);
|
|
|
|
|
2022-09-21 06:09:40 +02:00
|
|
|
switch(PREF_MAP[? "curve_connection_line"]) {
|
|
|
|
case 0 :
|
|
|
|
hover = distance_to_line(mx, my, jx, jy, frx, fry) < 6;
|
|
|
|
break;
|
|
|
|
case 1 :
|
|
|
|
hover = distance_to_curve(mx, my, jx, jy, frx, fry) < 6;
|
|
|
|
break;
|
|
|
|
case 2 :
|
|
|
|
var cx = (jx + frx) / 2;
|
|
|
|
hover = distance_to_line(mx, my, jx, jy, cx, jy) < 6;
|
|
|
|
hover |= distance_to_line(mx, my, cx, jy, cx, fry) < 6;
|
|
|
|
hover |= distance_to_line(mx, my, cx, fry, frx, fry) < 6;
|
|
|
|
break;
|
2022-01-25 04:05:30 +01:00
|
|
|
}
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-01-25 04:05:30 +01:00
|
|
|
if(hover)
|
|
|
|
hovering = jun;
|
|
|
|
if(PANEL_GRAPH.junction_hovering == jun)
|
|
|
|
th *= 2;
|
|
|
|
|
2022-01-29 14:25:18 +01:00
|
|
|
var ty = LINE_STYLE.solid;
|
|
|
|
if(jun.type == VALUE_TYPE.node)
|
|
|
|
ty = LINE_STYLE.dashed;
|
2022-09-21 06:09:40 +02:00
|
|
|
|
|
|
|
switch(PREF_MAP[? "curve_connection_line"]) {
|
|
|
|
case 0 :
|
|
|
|
if(ty == LINE_STYLE.solid)
|
|
|
|
draw_line_width_color(jx, jy, frx, fry, th, c0, c1);
|
|
|
|
else
|
|
|
|
draw_line_dashed(jx, jy, frx, fry, th, c0, c1, 12);
|
|
|
|
break;
|
|
|
|
case 1 : draw_line_curve_color(jx, jy, frx, fry, th, c0, c1, ty); break;
|
|
|
|
case 2 : draw_line_elbow_color(jx, jy, frx, fry, th, c0, c1, ty); break;
|
2022-01-25 04:05:30 +01:00
|
|
|
}
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
}
|
2022-01-25 04:05:30 +01:00
|
|
|
|
|
|
|
return hovering;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static drawPreview = function(_node, xx, yy, _s) {
|
2022-01-26 06:57:34 +01:00
|
|
|
if(_node.type != VALUE_TYPE.surface) return;
|
2022-01-13 05:24:03 +01:00
|
|
|
var surf = _node.getValue();
|
|
|
|
if(is_array(surf)) {
|
|
|
|
if(array_length(surf) == 0) return;
|
|
|
|
|
|
|
|
if(preview_speed != 0) {
|
|
|
|
preview_index += preview_speed;
|
|
|
|
if(preview_index <= 0)
|
|
|
|
preview_index = array_length(surf) - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(floor(preview_index) > array_length(surf) - 1) preview_index = 0;
|
2022-01-16 05:17:35 +01:00
|
|
|
surf = surf[preview_index];
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
2022-11-03 11:44:49 +01:00
|
|
|
if(!is_surface(surf)) return;
|
|
|
|
|
|
|
|
var pw = surface_get_width(surf);
|
|
|
|
var ph = surface_get_height(surf);
|
|
|
|
var ps = min((w * _s - 8) / pw, (h * _s - 8) / ph);
|
|
|
|
var px = xx + w * _s / 2 - pw * ps / 2;
|
|
|
|
var py = yy + h * _s / 2 - ph * ps / 2;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-11-03 11:44:49 +01:00
|
|
|
draw_surface_ext_safe(surf, px, py, ps, ps, 0, c_white, 1);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-11-03 11:44:49 +01:00
|
|
|
if(_s * w > 64) {
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_set_text(_s >= 1? f_p1 : f_p2, fa_center, fa_top, COLORS.panel_graph_node_dimension);
|
2022-11-03 11:44:49 +01:00
|
|
|
var tx = xx + w * _s / 2;
|
|
|
|
var ty = yy + (h + 4) * _s;
|
|
|
|
draw_text(round(tx), round(ty), string(pw) + " x " + string(ph) + "px");
|
2022-01-16 14:28:57 +01:00
|
|
|
|
2022-11-03 11:44:49 +01:00
|
|
|
if(PREF_MAP[? "node_show_time"]) {
|
|
|
|
ty += line_height() * 0.8;
|
|
|
|
var rt, unit;
|
|
|
|
if(render_time < 1000) {
|
|
|
|
rt = round(render_time / 10) * 10;
|
|
|
|
unit = "us";
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_set_color(COLORS.speed[2]);
|
2022-11-03 11:44:49 +01:00
|
|
|
} else if(render_time < 1000000) {
|
|
|
|
rt = string_format(render_time / 1000, -1, 2);
|
|
|
|
unit = "ms";
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_set_color(COLORS.speed[1]);
|
2022-11-03 11:44:49 +01:00
|
|
|
} else {
|
|
|
|
rt = string_format(render_time / 1000000, -1, 2);
|
|
|
|
unit = "s";
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_set_color(COLORS.speed[0]);
|
2022-01-16 14:28:57 +01:00
|
|
|
}
|
2022-11-03 11:44:49 +01:00
|
|
|
draw_text(round(tx), round(ty), string(rt) + " " + unit);
|
2022-01-16 05:17:35 +01:00
|
|
|
}
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static drawNode = function(_x, _y, _mx, _my, _s) {
|
|
|
|
if(group != PANEL_GRAPH.getCurrentContext()) return;
|
|
|
|
|
|
|
|
var xx = x * _s + _x;
|
|
|
|
var yy = y * _s + _y;
|
2022-08-30 07:36:37 +02:00
|
|
|
|
2022-11-03 11:44:49 +01:00
|
|
|
if(value_validation[VALIDATION.error])
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_sprite_stretched(THEME.node_error, 0, xx - 9, yy - 9, w * _s + 18, h * _s + 18);
|
2022-08-30 07:36:37 +02:00
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
drawNodeBase(xx, yy, _s);
|
|
|
|
if(previewable && ds_list_size(outputs) > 0)
|
2022-01-17 12:10:30 +01:00
|
|
|
drawPreview(outputs[| preview_channel], xx, yy, _s);
|
2022-01-13 05:24:03 +01:00
|
|
|
drawNodeName(xx, yy, _s);
|
|
|
|
onDrawNode(xx, yy, _mx, _my, _s);
|
2022-08-30 07:36:37 +02:00
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
if(active_draw_index > -1) {
|
2022-11-21 06:38:44 +01:00
|
|
|
draw_sprite_stretched_ext(bg_sel_spr, 0, xx, yy, w * _s, h * _s, active_draw_index > 1? COLORS.node_border_file_drop : COLORS._main_accent, 1);
|
2022-01-13 05:24:03 +01:00
|
|
|
active_draw_index = -1;
|
|
|
|
}
|
|
|
|
|
2022-09-21 06:09:40 +02:00
|
|
|
return drawJunctions(xx, yy, _mx, _my, _s);
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
static onDrawNode = function(xx, yy, _mx, _my, _s) {}
|
|
|
|
|
|
|
|
static drawBadge = function(_x, _y, _s) {
|
|
|
|
var xx = x * _s + _x + w * _s;
|
|
|
|
var yy = y * _s + _y;
|
|
|
|
|
|
|
|
if(previewing) {
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_sprite(THEME.node_state, 0, xx, yy);
|
2022-01-13 05:24:03 +01:00
|
|
|
xx -= max(32 * _s, 16);
|
|
|
|
}
|
|
|
|
if(inspecting) {
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_sprite(THEME.node_state, 1, xx, yy);
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
inspecting = false;
|
2022-08-30 07:36:37 +02:00
|
|
|
previewing = 0;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
active_draw_index = -1;
|
|
|
|
static drawActive = function(_x, _y, _s, ind = 0) {
|
|
|
|
active_draw_index = ind;
|
|
|
|
}
|
|
|
|
|
|
|
|
static drawOverlay = function(_active, _x, _y, _s, _mx, _my) {}
|
|
|
|
|
2022-01-26 06:57:34 +01:00
|
|
|
static destroy = function(_merge = false) {
|
2022-01-13 05:24:03 +01:00
|
|
|
active = false;
|
2022-08-30 07:36:37 +02:00
|
|
|
if(PANEL_GRAPH.node_hover == self) PANEL_GRAPH.node_hover = noone;
|
|
|
|
if(PANEL_GRAPH.node_focus == self) PANEL_GRAPH.node_focus = noone;
|
|
|
|
if(PANEL_PREVIEW.preview_node[0] == self) PANEL_PREVIEW.preview_node[0] = noone;
|
|
|
|
if(PANEL_PREVIEW.preview_node[1] == self) PANEL_PREVIEW.preview_node[1] = noone;
|
|
|
|
if(PANEL_INSPECTOR.inspecting == self) PANEL_INSPECTOR.inspecting = noone;
|
2022-01-13 05:24:03 +01:00
|
|
|
PANEL_ANIMATION.updatePropertyList();
|
|
|
|
|
|
|
|
for(var i = 0; i < ds_list_size(outputs); i++) {
|
|
|
|
var jun = outputs[| i];
|
2022-01-26 06:57:34 +01:00
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
for(var j = 0; j < ds_list_size(jun.value_to); j++) {
|
2022-01-26 06:57:34 +01:00
|
|
|
var _vt = jun.value_to[| j];
|
|
|
|
if(_vt.value_from == noone) return;
|
|
|
|
if(_vt.value_from.node != self) return;
|
|
|
|
|
|
|
|
_vt.removeFrom(false);
|
|
|
|
|
|
|
|
if(_merge) {
|
|
|
|
for( var k = 0; k < ds_list_size(inputs); k++ ) {
|
|
|
|
if(inputs[| k].value_from == noone) continue;
|
|
|
|
if(_vt.setFrom(inputs[| k].value_from)) break;
|
|
|
|
}
|
|
|
|
}
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
2022-01-26 06:57:34 +01:00
|
|
|
|
|
|
|
ds_list_clear(jun.value_to);
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
onDestroy();
|
|
|
|
}
|
2022-08-30 07:36:37 +02:00
|
|
|
static onValidate = function() {
|
2022-11-03 11:44:49 +01:00
|
|
|
value_validation[VALIDATION.pass] = 0;
|
|
|
|
value_validation[VALIDATION.warning] = 0;
|
|
|
|
value_validation[VALIDATION.error] = 0;
|
2022-08-30 07:36:37 +02:00
|
|
|
|
|
|
|
for( var i = 0; i < ds_list_size(inputs); i++ ) {
|
|
|
|
var jun = inputs[| i];
|
|
|
|
if(jun.value_validation)
|
2022-11-03 11:44:49 +01:00
|
|
|
value_validation[jun.value_validation]++;
|
2022-08-30 07:36:37 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
static onDestroy = function() {}
|
|
|
|
|
|
|
|
static cacheCurrentFrame = function(_frame) {
|
|
|
|
if(array_length(cached_output) != ANIMATOR.frames_total + 1)
|
|
|
|
array_resize(cached_output, ANIMATOR.frames_total + 1);
|
|
|
|
if(ANIMATOR.current_frame > ANIMATOR.frames_total) return;
|
|
|
|
|
|
|
|
var _os = cached_output[ANIMATOR.current_frame];
|
|
|
|
if(is_surface(_os))
|
|
|
|
surface_copy_size(_os, _frame);
|
|
|
|
else {
|
|
|
|
_os = surface_clone(_frame);
|
|
|
|
cached_output[ANIMATOR.current_frame] = _os;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
static recoverCache = function() {
|
|
|
|
if(ANIMATOR.current_frame >= array_length(cached_output)) return false;
|
|
|
|
var _s = cached_output[ANIMATOR.current_frame];
|
|
|
|
if(is_surface(_s)) {
|
|
|
|
var _outSurf = outputs[| 0].getValue();
|
|
|
|
if(is_surface(_outSurf))
|
|
|
|
surface_copy_size(_outSurf, _s);
|
|
|
|
else {
|
|
|
|
_outSurf = surface_clone(_s);
|
|
|
|
outputs[| 0].setValue(_outSurf);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
static clearCache = function() {
|
|
|
|
if(array_length(cached_output) != ANIMATOR.frames_total + 1)
|
|
|
|
array_resize(cached_output, ANIMATOR.frames_total + 1);
|
|
|
|
for(var i = 0; i < array_length(cached_output); i++) {
|
|
|
|
var _s = cached_output[i];
|
|
|
|
if(is_surface(_s)) {
|
|
|
|
surface_free(_s);
|
|
|
|
}
|
|
|
|
cached_output[i] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-23 04:08:16 +01:00
|
|
|
static checkConnectGroup = function(_type = "group") {
|
2022-01-13 05:24:03 +01:00
|
|
|
for(var i = 0; i < ds_list_size(inputs); i++) {
|
|
|
|
var _in = inputs[| i];
|
|
|
|
if(_in.value_from && _in.value_from.node.group != group) {
|
2022-09-21 06:09:40 +02:00
|
|
|
var input_node = noone;
|
2022-01-23 04:08:16 +01:00
|
|
|
switch(_type) {
|
|
|
|
case "group" : input_node = new Node_Group_Input(x - w - 64, y, group); break;
|
|
|
|
case "loop" : input_node = new Node_Iterator_Input(x - w - 64, y, group); break;
|
|
|
|
}
|
|
|
|
|
2022-09-21 06:09:40 +02:00
|
|
|
if(input_node == noone) continue;
|
2022-01-13 05:24:03 +01:00
|
|
|
input_node.inputs[| 2].setValue(_in.type);
|
|
|
|
input_node.inputs[| 0].setValue(_in.display_type);
|
|
|
|
|
|
|
|
ds_list_add(group.nodes, input_node);
|
|
|
|
|
2022-01-18 05:31:19 +01:00
|
|
|
input_node.inParent.setFrom(_in.value_from);
|
2022-01-13 05:24:03 +01:00
|
|
|
input_node.onValueUpdate(0);
|
|
|
|
_in.setFrom(input_node.outputs[| 0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for(var i = 0; i < ds_list_size(outputs); i++) {
|
|
|
|
var _ou = outputs[| i];
|
|
|
|
for(var j = 0; j < ds_list_size(_ou.value_to); j++) {
|
|
|
|
var _to = _ou.value_to[| j];
|
2022-01-25 10:58:11 +01:00
|
|
|
if(_to.value_from == _ou && _to.node.active && _to.node.group != group) {
|
2022-09-21 06:09:40 +02:00
|
|
|
var output_node = noone;
|
2022-01-23 04:08:16 +01:00
|
|
|
switch(_type) {
|
|
|
|
case "group" : output_node = new Node_Group_Output(x + w + 64, y, group); break;
|
|
|
|
case "loop" : output_node = new Node_Iterator_Output(x + w + 64, y, group); break;
|
|
|
|
}
|
2022-01-25 10:58:11 +01:00
|
|
|
|
2022-09-21 06:09:40 +02:00
|
|
|
if(output_node == noone) continue;
|
2022-01-13 05:24:03 +01:00
|
|
|
ds_list_add(group.nodes, output_node);
|
|
|
|
|
2022-01-18 05:31:19 +01:00
|
|
|
_to.setFrom(output_node.outParent);
|
2022-01-13 05:24:03 +01:00
|
|
|
output_node.inputs[| 0].setFrom(_ou);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static serialize = function(scale = false) {
|
|
|
|
var _map = ds_map_create();
|
|
|
|
|
|
|
|
_map[? "id"] = node_id;
|
|
|
|
_map[? "name"] = name;
|
|
|
|
_map[? "x"] = x;
|
|
|
|
_map[? "y"] = y;
|
|
|
|
_map[? "type"] = instanceof(self);
|
|
|
|
_map[? "group"] = group == -1? -1 : group.node_id;
|
|
|
|
|
2022-09-23 13:28:42 +02:00
|
|
|
ds_map_add_map(_map, "attri", attributeSerialize());
|
2022-01-13 05:24:03 +01:00
|
|
|
|
|
|
|
var _inputs = ds_list_create();
|
|
|
|
for(var i = 0; i < ds_list_size(inputs); i++) {
|
|
|
|
ds_list_add(_inputs, inputs[| i].serialize(scale));
|
|
|
|
ds_list_mark_as_map(_inputs, i);
|
|
|
|
}
|
|
|
|
ds_map_add_list(_map, "inputs", _inputs);
|
|
|
|
|
|
|
|
doSerialize(_map);
|
|
|
|
return _map;
|
|
|
|
}
|
|
|
|
|
2022-09-23 13:28:42 +02:00
|
|
|
static attributeSerialize = function() {
|
|
|
|
var att = ds_map_create();
|
|
|
|
ds_map_override(att, attributes);
|
|
|
|
return att;
|
|
|
|
}
|
2022-01-13 05:24:03 +01:00
|
|
|
static doSerialize = function(_map) {}
|
|
|
|
|
|
|
|
keyframe_scale = false;
|
2022-01-18 05:31:19 +01:00
|
|
|
load_map = -1;
|
|
|
|
static deserialize = function(scale = false) {
|
2022-01-13 05:24:03 +01:00
|
|
|
keyframe_scale = scale;
|
2022-01-19 03:05:13 +01:00
|
|
|
|
|
|
|
if(APPENDING) {
|
|
|
|
APPEND_MAP[? load_map[? "id"]] = node_id;
|
|
|
|
} else {
|
|
|
|
node_id = load_map[? "id"];
|
|
|
|
}
|
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
NODE_MAP[? node_id] = self;
|
|
|
|
|
2022-01-18 05:31:19 +01:00
|
|
|
name = load_map[? "name"];
|
|
|
|
_group = load_map[? "group"];
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-01-18 05:31:19 +01:00
|
|
|
x = load_map[? "x"];
|
|
|
|
y = load_map[? "y"];
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-01-18 05:31:19 +01:00
|
|
|
if(ds_map_exists(load_map, "attri"))
|
2022-09-23 13:28:42 +02:00
|
|
|
attributeDeserialize(load_map[? "attri"]);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-01-18 05:31:19 +01:00
|
|
|
var _inputs = load_map[? "inputs"];
|
2022-01-13 05:24:03 +01:00
|
|
|
|
|
|
|
if(!ds_list_empty(_inputs) && !ds_list_empty(inputs)) {
|
|
|
|
var _siz = min(ds_list_size(_inputs), ds_list_size(inputs));
|
|
|
|
for(var i = 0; i < _siz; i++) {
|
|
|
|
inputs[| i].deserialize(_inputs[| i], scale);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-23 13:28:42 +02:00
|
|
|
static attributeDeserialize = function(attr) {
|
|
|
|
ds_map_override(attributes, attr);
|
|
|
|
}
|
2022-01-13 05:24:03 +01:00
|
|
|
static postDeserialize = function() {}
|
|
|
|
|
2022-01-18 05:31:19 +01:00
|
|
|
static loadGroup = function() {
|
2022-01-13 05:24:03 +01:00
|
|
|
if(_group == -1) {
|
|
|
|
var c = PANEL_GRAPH.getCurrentContext();
|
|
|
|
if(c != -1) c.add(self);
|
|
|
|
} else {
|
2022-01-19 03:05:13 +01:00
|
|
|
if(APPENDING) _group = GetAppendID(_group);
|
|
|
|
|
|
|
|
if(ds_map_exists(NODE_MAP, _group)) {
|
|
|
|
NODE_MAP[? _group].add(self);
|
|
|
|
} else {
|
|
|
|
var txt = "Group load failed. Can't find node ID " + string(_group);
|
|
|
|
log_warning("LOAD", txt);
|
2022-01-18 05:31:19 +01:00
|
|
|
}
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
2022-01-18 05:31:19 +01:00
|
|
|
}
|
|
|
|
|
2022-09-21 06:09:40 +02:00
|
|
|
static connect = function(log = false) {
|
2022-01-13 05:24:03 +01:00
|
|
|
var connected = true;
|
|
|
|
for(var i = 0; i < ds_list_size(inputs); i++) {
|
2022-09-21 06:09:40 +02:00
|
|
|
connected &= inputs[| i].connect(log);
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
if(!connected) ds_queue_enqueue(CONNECTION_CONFLICT, self);
|
2022-09-21 06:09:40 +02:00
|
|
|
|
|
|
|
return connected;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static preConnect = function() {}
|
2022-01-18 05:31:19 +01:00
|
|
|
static postConnect = function() {}
|
2022-01-19 06:11:17 +01:00
|
|
|
|
|
|
|
static cleanUp = function() {
|
|
|
|
for( var i = 0; i < ds_list_size(inputs); i++ ) {
|
|
|
|
inputs[| i].cleanUp();
|
|
|
|
}
|
|
|
|
for( var i = 0; i < ds_list_size(outputs); i++ ) {
|
|
|
|
outputs[| i].cleanUp();
|
|
|
|
}
|
|
|
|
|
|
|
|
ds_list_destroy(inputs);
|
|
|
|
ds_list_destroy(outputs);
|
|
|
|
ds_map_destroy(attributes);
|
|
|
|
}
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|