2023-02-14 13:44:46 +01:00
|
|
|
global.loop_nodes = [ "Node_Iterate", "Node_Iterate_Each" ];
|
|
|
|
|
2023-03-07 14:29:47 +01:00
|
|
|
function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x, _y) constructor {
|
2022-01-13 05:24:03 +01:00
|
|
|
active = true;
|
2023-02-19 13:49:20 +01:00
|
|
|
renderActive = true;
|
2023-03-24 09:32:08 +01:00
|
|
|
|
2022-01-19 03:05:13 +01:00
|
|
|
node_id = generateUUID();
|
2022-12-13 09:20:36 +01:00
|
|
|
group = _group;
|
2023-02-14 02:51:14 +01:00
|
|
|
destroy_when_upgroup = false;
|
2022-12-13 09:20:36 +01:00
|
|
|
ds_list_add(PANEL_GRAPH.getNodeList(_group), self);
|
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
color = c_white;
|
|
|
|
icon = noone;
|
2022-11-18 03:20:31 +01:00
|
|
|
bg_spr = THEME.node_bg;
|
2023-03-24 09:32:08 +01:00
|
|
|
bg_sel_spr = THEME.node_active;
|
2022-12-12 09:08:03 +01:00
|
|
|
anim_priority = ds_map_size(NODE_MAP);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
|
|
|
if(!LOADING && !APPENDING) {
|
|
|
|
recordAction(ACTION_TYPE.node_added, self);
|
|
|
|
NODE_MAP[? node_id] = self;
|
2023-02-23 07:02:19 +01:00
|
|
|
MODIFIED = true;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
name = "";
|
2023-02-14 02:51:14 +01:00
|
|
|
display_name = "";
|
2023-03-05 07:16:44 +01:00
|
|
|
tooltip = "";
|
2022-01-13 05:24:03 +01:00
|
|
|
x = _x;
|
|
|
|
y = _y;
|
|
|
|
|
|
|
|
w = 128;
|
|
|
|
h = 128;
|
2023-01-17 08:11:55 +01:00
|
|
|
min_h = 0;
|
2023-03-07 14:29:47 +01:00
|
|
|
draw_padding = 8;
|
|
|
|
auto_height = true;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-01-04 02:30:04 +01:00
|
|
|
draw_name = true;
|
2023-03-05 07:16:44 +01:00
|
|
|
draggable = true;
|
2023-01-04 02:30:04 +01:00
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
inputs = ds_list_create();
|
|
|
|
outputs = ds_list_create();
|
2023-03-28 06:58:28 +02:00
|
|
|
|
|
|
|
input_display_list = -1;
|
|
|
|
output_display_list = -1;
|
|
|
|
inspector_display_list = -1;
|
|
|
|
is_dynamic_output = false;
|
|
|
|
|
2023-03-19 09:17:39 +01:00
|
|
|
attributes = ds_map_create();
|
|
|
|
attributeEditors = [];
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-03-28 06:58:28 +02:00
|
|
|
inspectInput1 = nodeValue("Toggle execution", self, JUNCTION_CONNECT.input, VALUE_TYPE.action, false).setVisible(true, true);
|
|
|
|
inspectInput2 = nodeValue("Toggle execution", self, JUNCTION_CONNECT.input, VALUE_TYPE.action, false).setVisible(true, true);
|
|
|
|
|
|
|
|
show_input_name = false;
|
2022-01-13 05:24:03 +01:00
|
|
|
show_output_name = false;
|
|
|
|
|
|
|
|
always_output = false;
|
2023-03-28 06:58:28 +02:00
|
|
|
inspecting = false;
|
|
|
|
previewing = 0;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-03-28 06:58:28 +02:00
|
|
|
preview_surface = noone;
|
2023-01-25 06:49:00 +01:00
|
|
|
preview_amount = 0;
|
2023-03-28 06:58:28 +02:00
|
|
|
previewable = true;
|
|
|
|
preview_speed = 0;
|
|
|
|
preview_index = 0;
|
2022-01-16 05:17:35 +01:00
|
|
|
preview_channel = 0;
|
2023-03-28 06:58:28 +02:00
|
|
|
preview_alpha = 1;
|
|
|
|
preview_x = 0;
|
|
|
|
preview_y = 0;
|
2023-03-26 07:13:36 +02:00
|
|
|
|
|
|
|
preview_surface_prev = noone;
|
|
|
|
preview_trans = 1;
|
|
|
|
preview_drop_x = 0;
|
|
|
|
preview_drop_y = 0;
|
|
|
|
|
|
|
|
preview_mx = 0;
|
|
|
|
preview_my = 0;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
|
|
|
rendered = false;
|
|
|
|
update_on_frame = false;
|
2022-01-16 14:28:57 +01:00
|
|
|
render_time = 0;
|
2023-02-19 13:49:20 +01:00
|
|
|
auto_render_time = true;
|
2023-02-28 09:43:01 +01:00
|
|
|
updated = false;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
|
|
|
use_cache = false;
|
|
|
|
cached_output = [];
|
2022-12-10 05:06:01 +01:00
|
|
|
cache_result = [];
|
2023-02-23 07:02:19 +01:00
|
|
|
temp_surface = [];
|
2022-01-13 05:24:03 +01:00
|
|
|
|
|
|
|
tools = -1;
|
|
|
|
|
|
|
|
on_dragdrop_file = -1;
|
|
|
|
|
|
|
|
anim_show = true;
|
2023-03-05 07:16:44 +01:00
|
|
|
dopesheet_y = 0;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-11-03 11:44:49 +01:00
|
|
|
value_validation = array_create(3);
|
2023-02-14 02:51:14 +01:00
|
|
|
|
2023-03-24 05:55:34 +01:00
|
|
|
error_noti_update = noone;
|
2023-02-14 02:51:14 +01:00
|
|
|
error_update_enabled = false;
|
2023-03-24 05:55:34 +01:00
|
|
|
manual_updated = false;
|
|
|
|
manual_deletable = true;
|
2023-02-14 02:51:14 +01:00
|
|
|
|
2023-03-11 01:40:17 +01:00
|
|
|
tool_settings = [];
|
|
|
|
tool_attribute = {};
|
|
|
|
|
2023-03-05 07:16:44 +01:00
|
|
|
static initTooltip = function() {
|
|
|
|
if(!struct_has(global.NODE_GUIDE, instanceof(self))) return;
|
|
|
|
|
|
|
|
var _n = global.NODE_GUIDE[$ instanceof(self)];
|
|
|
|
var _ins = _n.inputs;
|
|
|
|
var _ots = _n.outputs;
|
|
|
|
|
|
|
|
var amo = min(ds_list_size(inputs), array_length(_ins));
|
|
|
|
for( var i = 0; i < amo; i++ ) {
|
|
|
|
inputs[| i].name = _ins[i].name;
|
|
|
|
inputs[| i].tooltip = _ins[i].tooltip;
|
|
|
|
}
|
|
|
|
|
|
|
|
var amo = min(ds_list_size(outputs), array_length(_ots));
|
|
|
|
for( var i = 0; i < amo; i++ ) {
|
|
|
|
outputs[| i].name = _ots[i].name;
|
|
|
|
outputs[| i].tooltip = _ots[i].tooltip;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
run_in(1, initTooltip);
|
|
|
|
|
2023-02-14 02:51:14 +01:00
|
|
|
static resetDefault = function() {
|
|
|
|
var folder = instanceof(self);
|
|
|
|
if(!ds_map_exists(global.PRESETS_MAP, folder)) return;
|
|
|
|
|
|
|
|
var pres = global.PRESETS_MAP[? folder];
|
|
|
|
for( var i = 0; i < array_length(pres); i++ ) {
|
|
|
|
var preset = pres[i];
|
|
|
|
if(preset.name != "_default") continue;
|
|
|
|
|
|
|
|
deserialize(preset.content, true, true);
|
|
|
|
applyDeserialize(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
doUpdate();
|
|
|
|
}
|
|
|
|
run_in(1, method(self, resetDefault));
|
2022-09-27 06:37:28 +02:00
|
|
|
|
|
|
|
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-12-13 09:20:36 +01:00
|
|
|
static getOutputJunctionIndex = function(index) {
|
|
|
|
if(output_display_list == -1)
|
|
|
|
return index;
|
|
|
|
return output_display_list[index];
|
|
|
|
}
|
|
|
|
|
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);
|
2023-01-25 06:49:00 +01:00
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2023-02-14 02:51:14 +01:00
|
|
|
h = max(min_h, (preview_surface && previewable)? 128 : 0, _hi, _ho);
|
|
|
|
}
|
|
|
|
|
|
|
|
static getOutput = function(junc = noone) {
|
|
|
|
for( var i = 0; i < ds_list_size(outputs); i++ ) {
|
|
|
|
if(!outputs[| i].visible) continue;
|
|
|
|
if(junc != noone && !junc.isConnectable(outputs[| i], true)) continue;
|
|
|
|
|
|
|
|
return outputs[| i];
|
|
|
|
}
|
|
|
|
return noone;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
2023-01-25 06:49:00 +01:00
|
|
|
static getInput = function(junc = noone) {
|
|
|
|
for( var i = 0; i < ds_list_size(inputs); i++ ) {
|
|
|
|
if(!inputs[| i].visible) continue;
|
|
|
|
if(inputs[| i].value_from != noone) continue;
|
|
|
|
if(junc != noone && !inputs[| i].isConnectable(junc, true)) continue;
|
|
|
|
|
|
|
|
return inputs[| i];
|
|
|
|
}
|
|
|
|
return noone;
|
|
|
|
}
|
|
|
|
|
2023-02-14 02:51:14 +01:00
|
|
|
static getFullName = function() {
|
|
|
|
return display_name == ""? name : "[" + name + "] " + display_name;
|
|
|
|
}
|
|
|
|
|
2023-01-25 06:49:00 +01:00
|
|
|
static addInput = function(junctionFrom) {
|
|
|
|
var targ = getInput(junctionFrom);
|
|
|
|
if(targ == noone) return;
|
|
|
|
|
|
|
|
targ.setFrom(junctionFrom);
|
|
|
|
}
|
|
|
|
|
|
|
|
static isAnimated = function() {
|
|
|
|
for(var i = 0; i < ds_list_size(inputs); i++) {
|
|
|
|
if(inputs[| i].isAnimated())
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2023-02-14 13:44:46 +01:00
|
|
|
static isInLoop = function() {
|
|
|
|
return array_exists(global.loop_nodes, instanceof(group));
|
|
|
|
}
|
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
static move = function(_x, _y) {
|
2023-02-23 07:02:19 +01:00
|
|
|
if(x == _x && y == _y) return;
|
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
x = _x;
|
|
|
|
y = _y;
|
2023-02-23 07:02:19 +01:00
|
|
|
if(!LOADING) MODIFIED = true;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
2023-03-28 06:58:28 +02:00
|
|
|
insp1UpdateTooltip = get_text("panel_inspector_execute", "Execute node");
|
|
|
|
insp1UpdateIcon = [ THEME.sequence_control, 1, COLORS._main_value_positive ];
|
2023-02-14 02:51:14 +01:00
|
|
|
|
2023-03-28 06:58:28 +02:00
|
|
|
static inspector1Update = function() {
|
2023-02-14 02:51:14 +01:00
|
|
|
if(error_update_enabled && error_noti_update != noone)
|
|
|
|
noti_remove(error_noti_update);
|
|
|
|
error_noti_update = noone;
|
|
|
|
|
2023-03-28 06:58:28 +02:00
|
|
|
onInspector1Update();
|
2023-02-14 02:51:14 +01:00
|
|
|
}
|
2023-03-28 06:58:28 +02:00
|
|
|
static onInspector1Update = noone;
|
|
|
|
static hasInspector1Update = function() { return onInspector1Update != noone; }
|
2023-02-14 02:51:14 +01:00
|
|
|
|
|
|
|
insp2UpdateTooltip = get_text("panel_inspector_execute", "Execute node");
|
|
|
|
insp2UpdateIcon = [ THEME.sequence_control, 1, COLORS._main_value_positive ];
|
|
|
|
|
2023-02-23 07:02:19 +01:00
|
|
|
static inspector2Update = function() { onInspector2Update(); }
|
2023-02-14 02:51:14 +01:00
|
|
|
static onInspector2Update = noone;
|
|
|
|
static hasInspector2Update = function() { return onInspector2Update != noone; }
|
2022-12-23 04:45:52 +01:00
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
static stepBegin = function() {
|
2023-03-28 06:58:28 +02:00
|
|
|
if(use_cache) cacheArrayCheck();
|
2022-12-23 04:45:52 +01:00
|
|
|
var willUpdate = false;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
|
|
|
if(always_output) {
|
|
|
|
for(var i = 0; i < ds_list_size(outputs); i++) {
|
2022-12-16 09:18:09 +01:00
|
|
|
if(outputs[| i].type != VALUE_TYPE.surface)
|
|
|
|
continue;
|
|
|
|
var val = outputs[| i].getValue();
|
2023-01-01 02:06:02 +01:00
|
|
|
|
2022-12-16 09:18:09 +01:00
|
|
|
if(is_array(val)) {
|
|
|
|
for(var j = 0; j < array_length(val); j++) {
|
|
|
|
var _surf = val[j];
|
|
|
|
if(is_surface(_surf) && _surf != DEF_SURFACE)
|
|
|
|
continue;
|
2022-12-23 04:45:52 +01:00
|
|
|
willUpdate = true;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
2023-01-01 02:06:02 +01:00
|
|
|
} else if(!is_surface(val) || val == DEF_SURFACE)
|
2022-12-23 04:45:52 +01:00
|
|
|
willUpdate = true;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-10 05:06:01 +01:00
|
|
|
if(ANIMATOR.frame_progress) {
|
2022-01-13 05:24:03 +01:00
|
|
|
if(update_on_frame)
|
2023-01-04 02:30:04 +01:00
|
|
|
willUpdate = true;
|
|
|
|
|
2023-01-25 06:49:00 +01:00
|
|
|
if(isAnimated())
|
|
|
|
willUpdate = true;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
2022-12-23 04:45:52 +01:00
|
|
|
if(willUpdate) {
|
2022-01-25 04:05:30 +01:00
|
|
|
setRenderStatus(false);
|
2022-12-12 09:08:03 +01:00
|
|
|
UPDATE |= RENDER_TYPE.partial;
|
2022-01-25 04:05:30 +01:00
|
|
|
}
|
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
if(auto_height)
|
|
|
|
setHeight();
|
2022-12-16 09:18:09 +01:00
|
|
|
|
|
|
|
doStepBegin();
|
2023-03-28 06:58:28 +02:00
|
|
|
|
|
|
|
if(hasInspector1Update()) inspectInput1.name = insp1UpdateTooltip;
|
|
|
|
if(hasInspector2Update()) inspectInput2.name = insp2UpdateTooltip;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
2022-12-16 09:18:09 +01:00
|
|
|
static doStepBegin = function() {}
|
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
static step = function() {}
|
|
|
|
static focusStep = function() {}
|
|
|
|
|
2023-02-14 02:51:14 +01:00
|
|
|
static doUpdate = function() {
|
|
|
|
if(SAFE_MODE) return;
|
|
|
|
var sBase = surface_get_target();
|
|
|
|
|
2023-03-28 06:58:28 +02:00
|
|
|
for( var i = 0; i < ds_list_size(inputs); i++ ) {
|
|
|
|
if(inputs[| i].type != VALUE_TYPE.trigger) continue;
|
|
|
|
if(inputs[| i].editWidget == noone) continue;
|
|
|
|
|
|
|
|
var trg = inputs[| i].getValue();
|
|
|
|
if(trg) inputs[| i].editWidget.onClick();
|
|
|
|
}
|
|
|
|
|
2023-02-14 02:51:14 +01:00
|
|
|
try {
|
2022-12-21 02:30:23 +01:00
|
|
|
var t = get_timer();
|
|
|
|
update();
|
|
|
|
setRenderStatus(true);
|
2023-02-19 13:49:20 +01:00
|
|
|
if(auto_render_time)
|
|
|
|
render_time = get_timer() - t;
|
2023-02-14 02:51:14 +01:00
|
|
|
} catch(exception) {
|
|
|
|
var sCurr = surface_get_target();
|
|
|
|
while(surface_get_target() != sBase)
|
|
|
|
surface_reset_target();
|
|
|
|
|
2023-02-19 02:13:19 +01:00
|
|
|
log_warning("RENDER", exception_print(exception), self);
|
2023-02-14 02:51:14 +01:00
|
|
|
}
|
2023-03-28 06:58:28 +02:00
|
|
|
|
|
|
|
if(hasInspector1Update()) {
|
|
|
|
var trigger = inspectInput1.getValue();
|
|
|
|
if(trigger) onInspector1Update();
|
|
|
|
}
|
|
|
|
|
|
|
|
if(hasInspector2Update()) {
|
|
|
|
var trigger = inspectInput2.getValue();
|
|
|
|
if(trigger) onInspector2Update();
|
|
|
|
}
|
2023-02-14 02:51:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static valueUpdate = function(index) {
|
|
|
|
if(error_update_enabled && error_noti_update == noone)
|
|
|
|
error_noti_update = noti_error(getFullName() + " node require manual execution.",, self);
|
|
|
|
|
|
|
|
onValueUpdate(index);
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
2023-02-14 02:51:14 +01:00
|
|
|
static onValueUpdate = function(index = 0) {}
|
2023-01-09 03:14:20 +01:00
|
|
|
static onValueFromUpdate = function(index) {}
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-03-26 07:13:36 +02:00
|
|
|
static triggerRender = function() {
|
2023-03-28 06:58:28 +02:00
|
|
|
printIf(global.RENDER_LOG, " -> Trigger render for " + name + " (" + display_name + ")");
|
|
|
|
|
2023-03-26 07:13:36 +02:00
|
|
|
setRenderStatus(false);
|
|
|
|
UPDATE |= RENDER_TYPE.partial;
|
|
|
|
|
2023-03-28 06:58:28 +02:00
|
|
|
var nodes = getNextNodes();
|
|
|
|
for(var i = 0; i < array_length(nodes); i++)
|
|
|
|
nodes[i].triggerRender();
|
2023-03-26 07:13:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static isRenderable = function() { //Check if every input is ready (updated)
|
|
|
|
if(!active) return false;
|
|
|
|
if(!renderActive) return false;
|
2022-01-24 02:21:25 +01:00
|
|
|
|
2023-03-26 07:13:36 +02:00
|
|
|
var _startNode = true;
|
2022-01-24 02:21:25 +01:00
|
|
|
for(var j = 0; j < ds_list_size(inputs); j++) {
|
|
|
|
var _in = inputs[| j];
|
2023-03-26 07:13:36 +02:00
|
|
|
if( _in.type == VALUE_TYPE.node) continue;
|
|
|
|
|
2023-02-19 13:49:20 +01:00
|
|
|
var val_from = _in.value_from;
|
2023-03-26 07:13:36 +02:00
|
|
|
if( val_from == noone) continue;
|
2023-02-19 13:49:20 +01:00
|
|
|
if(!val_from.node.active) continue;
|
|
|
|
if(!val_from.node.renderActive) continue;
|
2023-03-26 07:13:36 +02:00
|
|
|
if(!val_from.node.rendered)
|
2022-12-23 04:45:52 +01:00
|
|
|
return false;
|
2022-01-24 02:21:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2023-03-26 07:13:36 +02:00
|
|
|
static getNextNodes = function() {
|
2023-03-28 06:58:28 +02:00
|
|
|
var nodes = [];
|
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
for(var i = 0; i < ds_list_size(outputs); i++) {
|
2023-03-26 07:13:36 +02:00
|
|
|
var _ot = outputs[| i];
|
|
|
|
|
|
|
|
for(var j = 0; j < ds_list_size(_ot.value_to); j++) {
|
|
|
|
var _to = _ot.value_to[| j];
|
|
|
|
if(!_to.node.active || _to.value_from == noone) continue;
|
2022-12-12 09:08:03 +01:00
|
|
|
|
2023-03-28 06:58:28 +02:00
|
|
|
printIf(global.RENDER_LOG, " -> Check render " + _to.node.name + " from " + _to.value_from.node.name);
|
|
|
|
if(_to.value_from.node != self) continue;
|
2023-03-26 07:13:36 +02:00
|
|
|
|
2023-03-28 06:58:28 +02:00
|
|
|
printIf(global.RENDER_LOG, " --> Check complete, push " + _to.node.name + " to stack.");
|
|
|
|
array_push(nodes, _to.node);
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
2023-03-26 07:13:36 +02:00
|
|
|
}
|
2023-03-28 06:58:28 +02:00
|
|
|
|
|
|
|
return nodes;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
2022-09-23 13:28:42 +02:00
|
|
|
static onInspect = function() {}
|
|
|
|
|
2022-01-23 04:08:16 +01:00
|
|
|
static setRenderStatus = function(result) {
|
|
|
|
rendered = result;
|
2022-12-12 09:08:03 +01:00
|
|
|
|
2023-02-28 09:43:01 +01:00
|
|
|
if(!result && group != noone)
|
2022-12-12 09:08:03 +01:00
|
|
|
group.setRenderStatus(result);
|
2022-01-23 04:08:16 +01:00
|
|
|
}
|
|
|
|
|
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-09-21 06:09:40 +02:00
|
|
|
var jun;
|
2022-12-13 09:20:36 +01:00
|
|
|
|
2023-03-28 06:58:28 +02:00
|
|
|
var inspCount = hasInspector1Update() + hasInspector2Update();
|
|
|
|
var ind = 1;
|
|
|
|
if(hasInspector1Update()) {
|
|
|
|
inspectInput1.x = xx + w * _s * ind / (inspCount + 1);
|
|
|
|
inspectInput1.y = yy;
|
|
|
|
ind++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(hasInspector2Update()) {
|
|
|
|
inspectInput2.x = xx + w * _s * ind / (inspCount + 1);
|
|
|
|
inspectInput2.y = yy;
|
|
|
|
ind++;
|
|
|
|
}
|
|
|
|
|
2022-12-13 09:20:36 +01:00
|
|
|
var inamo = 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
|
|
|
|
2022-12-13 09:20:36 +01:00
|
|
|
for(var i = 0; i < inamo; 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);
|
2023-02-14 02:51:14 +01:00
|
|
|
if(jun == noone || is_undefined(jun)) 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-12-13 09:20:36 +01:00
|
|
|
var outamo = output_display_list == -1? ds_list_size(outputs) : array_length(output_display_list);
|
|
|
|
|
2023-03-28 06:58:28 +02:00
|
|
|
xx = xx + w * _s;
|
2022-11-03 11:44:49 +01:00
|
|
|
_in = yy + ui(32) * _s;
|
2022-12-13 09:20:36 +01:00
|
|
|
for(var i = 0; i < outamo; i++) {
|
|
|
|
var idx = getOutputJunctionIndex(i);
|
|
|
|
jun = outputs[| idx];
|
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) {
|
2023-02-14 02:51:14 +01:00
|
|
|
if(!active) return;
|
2023-02-19 13:49:20 +01:00
|
|
|
var aa = 0.25 + 0.5 * renderActive;
|
|
|
|
draw_sprite_stretched_ext(bg_spr, 0, xx, yy, w * _s, h * _s, color, aa);
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
2023-01-04 02:30:04 +01:00
|
|
|
static drawGetBbox = function(xx, yy, _s) {
|
2023-03-07 14:29:47 +01:00
|
|
|
var x0 = xx + draw_padding * _s;
|
|
|
|
var x1 = xx + (w - draw_padding) * _s;
|
|
|
|
var y0 = yy + 20 * draw_name + draw_padding * _s;
|
|
|
|
var y1 = yy + (h - draw_padding) * _s;
|
2023-01-04 02:30:04 +01:00
|
|
|
|
2023-03-24 10:12:44 +01:00
|
|
|
return { x0 : x0,
|
2023-01-04 02:30:04 +01:00
|
|
|
x1 : x1,
|
2023-03-24 10:12:44 +01:00
|
|
|
y0 : y0,
|
2023-01-04 02:30:04 +01:00
|
|
|
y1 : y1,
|
2023-03-24 10:12:44 +01:00
|
|
|
xc : (x0 + x1) / 2,
|
|
|
|
yc : (y0 + y1) / 2,
|
|
|
|
w : x1 - x0,
|
|
|
|
h : y1 - y0
|
2023-01-04 02:30:04 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
static drawNodeName = function(xx, yy, _s) {
|
2023-02-14 02:51:14 +01:00
|
|
|
if(!active) return;
|
2023-02-19 13:49:20 +01:00
|
|
|
|
2023-01-04 02:30:04 +01:00
|
|
|
draw_name = false;
|
2023-02-14 02:51:14 +01:00
|
|
|
var _name = display_name == ""? name : display_name;
|
|
|
|
if(_name == "") return;
|
2023-01-25 06:49:00 +01:00
|
|
|
if(_s < 0.75) return;
|
2023-01-04 02:30:04 +01:00
|
|
|
draw_name = true;
|
2022-12-10 05:06:01 +01:00
|
|
|
|
2023-02-19 13:49:20 +01:00
|
|
|
var aa = 0.25 + 0.5 * renderActive;
|
|
|
|
draw_sprite_stretched_ext(THEME.node_bg_name, 0, xx, yy, w * _s, ui(20), color, aa);
|
2022-12-10 05:06:01 +01:00
|
|
|
|
|
|
|
var cc = COLORS._main_text;
|
2022-12-12 09:08:03 +01:00
|
|
|
if(PREF_MAP[? "node_show_render_status"] && !rendered)
|
2023-03-26 07:13:36 +02:00
|
|
|
cc = isRenderable()? COLORS._main_value_positive : COLORS._main_value_negative;
|
2022-12-12 09:08:03 +01:00
|
|
|
|
2022-12-10 05:06:01 +01:00
|
|
|
draw_set_text(f_p1, fa_left, fa_center, cc);
|
|
|
|
|
2023-03-28 06:58:28 +02:00
|
|
|
if(hasInspector1Update()) icon = THEME.refresh_s;
|
2022-12-12 09:08:03 +01:00
|
|
|
var ts = clamp(power(_s, 0.5), 0.5, 1);
|
2023-01-04 02:30:04 +01:00
|
|
|
|
2023-02-19 13:49:20 +01:00
|
|
|
var aa = 0.5 + 0.5 * renderActive;
|
|
|
|
draw_set_alpha(aa);
|
|
|
|
|
2023-01-04 02:30:04 +01:00
|
|
|
if(icon && _s > 0.75) {
|
2023-02-19 13:49:20 +01:00
|
|
|
draw_sprite_ui_uniform(icon, 0, xx + ui(12), yy + ui(10),,, aa);
|
2023-02-14 02:51:14 +01:00
|
|
|
draw_text_cut(xx + ui(24), yy + ui(10), _name, w * _s - ui(24), ts);
|
2023-01-04 02:30:04 +01:00
|
|
|
} else
|
2023-02-14 02:51:14 +01:00
|
|
|
draw_text_cut(xx + ui(8), yy + ui(10), _name, w * _s - ui(8), ts);
|
2023-02-19 13:49:20 +01:00
|
|
|
|
|
|
|
draw_set_alpha(1);
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static drawJunctions = function(_x, _y, _mx, _my, _s) {
|
2023-02-14 02:51:14 +01:00
|
|
|
if(!active) return;
|
2022-01-13 05:24:03 +01:00
|
|
|
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);
|
2023-02-14 02:51:14 +01:00
|
|
|
if(jun == noone || is_undefined(jun)) 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
|
|
|
}
|
|
|
|
|
2023-03-28 06:58:28 +02:00
|
|
|
if(hasInspector1Update() && inspectInput1.drawJunction(_s, _mx, _my))
|
|
|
|
hover = inspectInput1;
|
|
|
|
|
|
|
|
if(hasInspector2Update() && inspectInput2.drawJunction(_s, _mx, _my))
|
|
|
|
hover = inspectInput2;
|
|
|
|
|
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) {
|
2023-02-14 02:51:14 +01:00
|
|
|
if(!active) return;
|
2022-09-27 06:37:28 +02:00
|
|
|
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;
|
|
|
|
|
2023-02-23 07:02:19 +01:00
|
|
|
show_input_name = PANEL_GRAPH.pHOVER && point_in_rectangle(_mx, _my, xx - 8 * _s, yy + 20 * _s, xx + 8 * _s, yy + h * _s);
|
|
|
|
show_output_name = PANEL_GRAPH.pHOVER && point_in_rectangle(_mx, _my, xx + (w - 8) * _s, yy + 20 * _s, xx + (w + 8) * _s, yy + h * _s);
|
2022-09-27 06:37:28 +02:00
|
|
|
|
|
|
|
if(show_input_name) {
|
|
|
|
for(var i = 0; i < amo; i++) {
|
|
|
|
var ind = getInputJunctionIndex(i);
|
|
|
|
if(ind == noone) continue;
|
2023-03-07 14:29:47 +01:00
|
|
|
if(!inputs[| ind]) continue;
|
|
|
|
|
2022-09-27 06:37:28 +02:00
|
|
|
inputs[| ind].drawNameBG(_s);
|
|
|
|
}
|
|
|
|
|
|
|
|
for(var i = 0; i < amo; i++) {
|
|
|
|
var ind = getInputJunctionIndex(i);
|
|
|
|
if(ind == noone) continue;
|
2023-03-07 14:29:47 +01:00
|
|
|
if(!inputs[| ind]) continue;
|
|
|
|
|
2022-09-27 06:37:28 +02:00
|
|
|
inputs[| ind].drawName(_s, _mx, _my);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(show_output_name) {
|
2023-02-23 07:02:19 +01:00
|
|
|
for(var i = 0; i < ds_list_size(outputs); i++)
|
2022-09-27 06:37:28 +02:00
|
|
|
outputs[| i].drawNameBG(_s);
|
|
|
|
|
2023-02-23 07:02:19 +01:00
|
|
|
for(var i = 0; i < ds_list_size(outputs); i++)
|
2022-09-27 06:37:28 +02:00
|
|
|
outputs[| i].drawName(_s, _mx, _my);
|
|
|
|
}
|
2023-03-28 06:58:28 +02:00
|
|
|
|
|
|
|
if(hasInspector1Update() && PANEL_GRAPH.pHOVER && point_in_circle(_mx, _my, inspectInput1.x, inspectInput1.y, 10)) {
|
|
|
|
inspectInput1.drawNameBG(_s);
|
|
|
|
inspectInput1.drawName(_s, _mx, _my);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(hasInspector2Update() && PANEL_GRAPH.pHOVER && point_in_circle(_mx, _my, inspectInput2.x, inspectInput2.y, 10)) {
|
|
|
|
inspectInput2.drawNameBG(_s);
|
|
|
|
inspectInput2.drawName(_s, _mx, _my);
|
|
|
|
}
|
2022-09-27 06:37:28 +02:00
|
|
|
}
|
|
|
|
|
2023-03-05 07:16:44 +01:00
|
|
|
static drawConnections = function(_x, _y, _s, mx, my, _active, aa = 1) {
|
2023-02-14 02:51:14 +01:00
|
|
|
if(!active) return;
|
|
|
|
|
2022-01-25 04:05:30 +01:00
|
|
|
var hovering = noone;
|
2023-03-05 07:16:44 +01:00
|
|
|
var drawLineIndex = 1;
|
|
|
|
|
|
|
|
for(var i = 0; i < ds_list_size(outputs); i++) {
|
|
|
|
var jun = outputs[| i];
|
|
|
|
var connected = false;
|
|
|
|
|
|
|
|
for( var j = 0; j < ds_list_size(jun.value_to); j++ ) {
|
|
|
|
if(jun.value_to[| j].value_from == jun)
|
|
|
|
connected = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(connected) {
|
|
|
|
jun.drawLineIndex = drawLineIndex;
|
|
|
|
drawLineIndex += 0.5;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-28 06:58:28 +02:00
|
|
|
var st = 0;
|
|
|
|
if(hasInspector1Update()) st = -1;
|
|
|
|
if(hasInspector2Update()) st = -2;
|
|
|
|
|
2023-03-05 07:16:44 +01:00
|
|
|
var drawLineIndex = 1;
|
2023-03-28 06:58:28 +02:00
|
|
|
for(var i = st; i < ds_list_size(inputs); i++) {
|
|
|
|
var jun;
|
|
|
|
if(i == -1) jun = inspectInput1;
|
|
|
|
else if(i == -2) jun = inspectInput2;
|
|
|
|
else jun = inputs[| i];
|
|
|
|
|
|
|
|
var jx = jun.x;
|
|
|
|
var jy = jun.y;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-02-14 02:51:14 +01:00
|
|
|
if(jun.value_from == noone) continue;
|
|
|
|
if(!jun.value_from.node.active) continue;
|
|
|
|
if(!jun.isVisible()) continue;
|
2023-03-05 07:16:44 +01:00
|
|
|
jun.drawLineIndex = drawLineIndex;
|
2023-02-14 02:51:14 +01:00
|
|
|
|
|
|
|
var frx = jun.value_from.x;
|
|
|
|
var fry = jun.value_from.y;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-03-02 07:59:14 +01:00
|
|
|
var c0 = value_color(jun.value_from.type);
|
|
|
|
var c1 = value_color(jun.type);
|
|
|
|
|
|
|
|
var shx = jun.draw_line_shift_x * _s;
|
|
|
|
var shy = jun.draw_line_shift_y * _s;
|
|
|
|
|
|
|
|
var cx = round((frx + jx) / 2 + shx);
|
|
|
|
var cy = round((fry + jy) / 2 + shy);
|
|
|
|
|
2023-02-14 02:51:14 +01:00
|
|
|
var hover = false;
|
|
|
|
var th = max(1, PREF_MAP[? "connection_line_width"] * _s);
|
2023-03-05 07:16:44 +01:00
|
|
|
jun.draw_line_shift_hover = false;
|
2023-02-23 07:02:19 +01:00
|
|
|
|
2023-03-28 06:58:28 +02:00
|
|
|
var drawCorner = jun.type == VALUE_TYPE.action || jun.value_from.type == VALUE_TYPE.action;
|
|
|
|
|
2023-02-23 07:02:19 +01:00
|
|
|
if(PANEL_GRAPH.pHOVER)
|
2023-02-14 02:51:14 +01:00
|
|
|
switch(PREF_MAP[? "curve_connection_line"]) {
|
|
|
|
case 0 :
|
2023-03-02 07:59:14 +01:00
|
|
|
hover = distance_to_line(mx, my, jx, jy, frx, fry) < max(th * 2, 6);
|
2023-02-14 02:51:14 +01:00
|
|
|
break;
|
|
|
|
case 1 :
|
2023-03-28 06:58:28 +02:00
|
|
|
if(drawCorner)
|
|
|
|
hover = distance_to_curve_corner(mx, my, jx, jy, frx, fry, _s) < max(th * 2, 6);
|
|
|
|
else
|
|
|
|
hover = distance_to_curve(mx, my, jx, jy, frx, fry, cx, cy, _s) < max(th * 2, 6);
|
|
|
|
|
2023-03-05 07:16:44 +01:00
|
|
|
if(PANEL_GRAPH._junction_hovering == noone)
|
|
|
|
jun.draw_line_shift_hover = hover;
|
2023-02-14 02:51:14 +01:00
|
|
|
break;
|
|
|
|
case 2 :
|
2023-03-28 06:58:28 +02:00
|
|
|
if(drawCorner)
|
|
|
|
hover = distance_to_elbow_corner(mx, my, frx, fry, jx, jy) < max(th * 2, 6);
|
|
|
|
else
|
|
|
|
hover = distance_to_elbow(mx, my, frx, fry, jx, jy, cx, cy, _s, jun.value_from.drawLineIndex, jun.drawLineIndex) < max(th * 2, 6);
|
2023-03-02 07:59:14 +01:00
|
|
|
|
2023-03-05 07:16:44 +01:00
|
|
|
if(PANEL_GRAPH._junction_hovering == noone)
|
2023-03-12 02:28:21 +01:00
|
|
|
jun.draw_line_shift_hover = hover;
|
2023-03-05 07:16:44 +01:00
|
|
|
break;
|
|
|
|
case 3 :
|
2023-03-28 06:58:28 +02:00
|
|
|
if(drawCorner)
|
|
|
|
hover = distance_to_elbow_diag_corner(mx, my, frx, fry, jx, jy) < max(th * 2, 6);
|
|
|
|
else
|
|
|
|
hover = distance_to_elbow_diag(mx, my, frx, fry, jx, jy, cx, cy, _s, jun.value_from.drawLineIndex, jun.drawLineIndex) < max(th * 2, 6);
|
2023-03-02 07:59:14 +01:00
|
|
|
|
2023-03-05 07:16:44 +01:00
|
|
|
if(PANEL_GRAPH._junction_hovering == noone)
|
|
|
|
jun.draw_line_shift_hover = hover;
|
2023-02-14 02:51:14 +01:00
|
|
|
break;
|
|
|
|
}
|
2023-03-05 07:16:44 +01:00
|
|
|
|
2023-02-14 02:51:14 +01:00
|
|
|
if(_active && hover)
|
|
|
|
hovering = jun;
|
2023-03-05 07:16:44 +01:00
|
|
|
|
|
|
|
var thicken = false;
|
|
|
|
thicken |= PANEL_GRAPH.nodes_junction_d == jun;
|
|
|
|
thicken |= _active && PANEL_GRAPH.junction_hovering == jun && PANEL_GRAPH._junction_hovering == noone;
|
|
|
|
thicken |= instance_exists(o_dialog_add_node) && o_dialog_add_node.junction_hovering == jun;
|
|
|
|
|
2023-03-28 06:58:28 +02:00
|
|
|
if(PREF_MAP[? "connection_line_transition"]) {
|
|
|
|
jun.draw_line_thick.set(thicken? 2 : 1);
|
|
|
|
th *= jun.draw_line_thick.get();
|
|
|
|
} else
|
|
|
|
th *= thicken? 2 : 1;
|
2023-03-05 07:16:44 +01:00
|
|
|
|
|
|
|
var corner = PREF_MAP[? "connection_line_corner"] * _s;
|
2023-02-14 02:51:14 +01:00
|
|
|
var ty = LINE_STYLE.solid;
|
|
|
|
if(jun.type == VALUE_TYPE.node)
|
|
|
|
ty = LINE_STYLE.dashed;
|
2023-03-05 07:16:44 +01:00
|
|
|
|
2023-03-26 07:13:36 +02:00
|
|
|
var ss = _s * aa;
|
2023-03-05 07:16:44 +01:00
|
|
|
jx *= aa;
|
|
|
|
jy *= aa;
|
|
|
|
frx *= aa;
|
|
|
|
fry *= aa;
|
|
|
|
th *= aa;
|
|
|
|
cx *= aa;
|
|
|
|
cy *= aa;
|
|
|
|
corner *= aa;
|
|
|
|
|
2023-02-14 02:51:14 +01:00
|
|
|
switch(PREF_MAP[? "curve_connection_line"]) {
|
|
|
|
case 0 :
|
|
|
|
if(ty == LINE_STYLE.solid)
|
|
|
|
draw_line_width_color(jx, jy, frx, fry, th, c1, c0);
|
|
|
|
else
|
2023-03-05 07:16:44 +01:00
|
|
|
draw_line_dashed_color(jx, jy, frx, fry, th, c1, c0, 12 * ss);
|
2023-02-14 02:51:14 +01:00
|
|
|
break;
|
2023-03-28 06:58:28 +02:00
|
|
|
case 1 :
|
|
|
|
if(drawCorner)
|
|
|
|
draw_line_curve_corner(jx, jy, frx, fry, ss, th, c0, c1);
|
|
|
|
else
|
|
|
|
draw_line_curve_color(jx, jy, frx, fry, cx, cy, ss, th, c0, c1, ty);
|
|
|
|
break;
|
|
|
|
case 2 :
|
|
|
|
if(drawCorner)
|
|
|
|
draw_line_elbow_corner(frx, fry, jx, jy, ss, th, c0, c1, corner, jun.value_from.drawLineIndex, jun.drawLineIndex, ty);
|
|
|
|
else
|
|
|
|
draw_line_elbow_color(frx, fry, jx, jy, cx, cy, ss, th, c0, c1, corner, jun.value_from.drawLineIndex, jun.drawLineIndex, ty);
|
|
|
|
break;
|
|
|
|
case 3 :
|
|
|
|
if(drawCorner)
|
|
|
|
draw_line_elbow_diag_corner(frx, fry, jx, jy, ss, th, c0, c1, corner, jun.value_from.drawLineIndex, jun.drawLineIndex, ty);
|
|
|
|
else
|
|
|
|
draw_line_elbow_diag_color(frx, fry, jx, jy, cx, cy, ss, th, c0, c1, corner, jun.value_from.drawLineIndex, jun.drawLineIndex, ty);
|
|
|
|
break;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
2023-03-05 07:16:44 +01:00
|
|
|
|
|
|
|
drawLineIndex += 0.5;
|
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
|
|
|
}
|
|
|
|
|
2023-01-25 06:49:00 +01:00
|
|
|
static drawPreview = function(xx, yy, _s) {
|
2023-02-14 02:51:14 +01:00
|
|
|
if(!active) return;
|
2023-02-20 10:16:31 +01:00
|
|
|
|
2023-01-25 06:49:00 +01:00
|
|
|
var _node = outputs[| preview_channel];
|
2022-01-26 06:57:34 +01:00
|
|
|
if(_node.type != VALUE_TYPE.surface) return;
|
2023-02-20 10:16:31 +01:00
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
var surf = _node.getValue();
|
2023-01-25 06:49:00 +01:00
|
|
|
preview_amount = 0;
|
2022-01-13 05:24:03 +01:00
|
|
|
if(is_array(surf)) {
|
|
|
|
if(array_length(surf) == 0) return;
|
2023-01-25 06:49:00 +01:00
|
|
|
preview_amount = array_length(surf);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2023-02-14 02:51:14 +01:00
|
|
|
preview_surface = is_surface(surf)? surf : noone;
|
2023-03-26 07:13:36 +02:00
|
|
|
if(preview_surface == noone) return;
|
2022-11-03 11:44:49 +01:00
|
|
|
|
2023-03-26 07:13:36 +02:00
|
|
|
var pw = surface_get_width(preview_surface);
|
|
|
|
var ph = surface_get_height(preview_surface);
|
2022-11-03 11:44:49 +01:00
|
|
|
var ps = min((w * _s - 8) / pw, (h * _s - 8) / ph);
|
2023-03-26 07:13:36 +02:00
|
|
|
var px = xx + w * _s / 2 - pw * ps / 2;
|
|
|
|
var py = yy + h * _s / 2 - ph * ps / 2;
|
|
|
|
var aa = 0.5 + 0.5 * renderActive;
|
|
|
|
|
|
|
|
if(preview_trans == 1) {
|
|
|
|
draw_surface_ext_safe(preview_surface, px, py, ps, ps, 0, c_white, aa);
|
|
|
|
return;
|
2023-03-11 01:40:17 +01:00
|
|
|
}
|
2023-02-19 13:49:20 +01:00
|
|
|
|
2023-03-26 07:13:36 +02:00
|
|
|
if(preview_trans < 1 && is_surface(preview_surface_prev)) {
|
|
|
|
preview_trans = lerp_float(preview_trans, 1, 8);
|
|
|
|
var _pw = surface_get_width(preview_surface_prev);
|
|
|
|
var _ph = surface_get_height(preview_surface_prev);
|
|
|
|
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;
|
|
|
|
|
|
|
|
draw_surface_ext_safe(preview_surface_prev, _px, _py, _ps, _ps, 0, c_white, aa);
|
|
|
|
|
|
|
|
shader_set(sh_trans_node_prev_drop);
|
|
|
|
shader_set_f("dimension", _pw, _ph);
|
|
|
|
shader_set_f("position", (preview_drop_x - px) / (_pw * _ps), (preview_drop_y - py) / (_ph * _ps));
|
|
|
|
shader_set_f("prog", preview_trans);
|
|
|
|
draw_surface_ext_safe(preview_surface, px, py, ps, ps, 0, c_white, aa);
|
|
|
|
shader_reset();
|
|
|
|
} else if(is_surface(preview_surface_prev))
|
|
|
|
surface_free(preview_surface_prev);
|
|
|
|
}
|
|
|
|
|
|
|
|
static previewDropAnimation = function() {
|
|
|
|
preview_surface_prev = surface_clone(preview_surface);
|
|
|
|
preview_trans = 0;
|
|
|
|
preview_drop_x = preview_mx;
|
|
|
|
preview_drop_y = preview_my;
|
2023-01-25 06:49:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static getNodeDimension = function() {
|
|
|
|
if(!is_surface(preview_surface)) {
|
|
|
|
if(ds_list_size(outputs))
|
2023-03-19 09:17:39 +01:00
|
|
|
return "[" + array_shape(outputs[| 0].getValue()) + "]";
|
2023-01-25 06:49:00 +01:00
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
var pw = surface_get_width(preview_surface);
|
|
|
|
var ph = surface_get_height(preview_surface);
|
2023-03-19 09:17:39 +01:00
|
|
|
var format = surface_get_format(preview_surface);
|
|
|
|
|
|
|
|
var txt = "[" + string(pw) + " x " + string(ph) + " ";
|
|
|
|
if(preview_amount) txt = string(preview_amount) + " x " + txt;
|
|
|
|
|
|
|
|
switch(format) {
|
|
|
|
case surface_rgba4unorm : txt += "4RGBA"; break;
|
|
|
|
case surface_rgba8unorm : txt += "8RGBA"; break;
|
|
|
|
case surface_rgba16float : txt += "16RGBA"; break;
|
|
|
|
case surface_rgba32float : txt += "32RGBA"; break;
|
|
|
|
case surface_r8unorm : txt += "8BW"; break;
|
|
|
|
case surface_r16float : txt += "16BW"; break;
|
|
|
|
case surface_r32float : txt += "32BW"; break;
|
|
|
|
}
|
|
|
|
txt += "]";
|
2023-01-25 06:49:00 +01:00
|
|
|
|
|
|
|
return txt;
|
|
|
|
}
|
|
|
|
|
|
|
|
static drawDimension = function(xx, yy, _s) {
|
2023-02-14 02:51:14 +01:00
|
|
|
if(!active) return;
|
2023-01-25 06:49:00 +01:00
|
|
|
if(_s * w < 64) return;
|
|
|
|
|
|
|
|
draw_set_text(_s >= 1? f_p1 : f_p2, fa_center, fa_top, COLORS.panel_graph_node_dimension);
|
|
|
|
var tx = xx + w * _s / 2;
|
|
|
|
var ty = yy + (h + 4) * _s;
|
|
|
|
|
|
|
|
if(PANEL_GRAPH.show_dimension) {
|
2023-03-19 09:17:39 +01:00
|
|
|
var txt = string(getNodeDimension());
|
2023-01-25 06:49:00 +01:00
|
|
|
draw_text(round(tx), round(ty), txt);
|
2023-03-19 09:17:39 +01:00
|
|
|
ty += string_height(txt) - 4 * _s;
|
2023-01-25 06:49:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if(PANEL_GRAPH.show_compute) {
|
|
|
|
var rt, unit;
|
|
|
|
if(render_time < 1000) {
|
|
|
|
rt = round(render_time / 10) * 10;
|
|
|
|
unit = "us";
|
|
|
|
draw_set_color(COLORS.speed[2]);
|
|
|
|
} else if(render_time < 1000000) {
|
|
|
|
rt = string_format(render_time / 1000, -1, 2);
|
|
|
|
unit = "ms";
|
|
|
|
draw_set_color(COLORS.speed[1]);
|
|
|
|
} else {
|
|
|
|
rt = string_format(render_time / 1000000, -1, 2);
|
|
|
|
unit = "s";
|
|
|
|
draw_set_color(COLORS.speed[0]);
|
2022-01-16 05:17:35 +01:00
|
|
|
}
|
2023-01-25 06:49:00 +01:00
|
|
|
draw_text(round(tx), round(ty), string(rt) + " " + unit);
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static drawNode = function(_x, _y, _mx, _my, _s) {
|
2023-02-14 02:51:14 +01:00
|
|
|
if(!active) return;
|
2023-03-13 10:45:56 +01:00
|
|
|
//if(group != PANEL_GRAPH.getCurrentContext()) return;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
|
|
|
var xx = x * _s + _x;
|
|
|
|
var yy = y * _s + _y;
|
2022-08-30 07:36:37 +02:00
|
|
|
|
2023-03-26 07:13:36 +02:00
|
|
|
preview_mx = _mx;
|
|
|
|
preview_my = _my;
|
|
|
|
|
2023-02-14 02:51:14 +01:00
|
|
|
if(value_validation[VALIDATION.error] || error_noti_update != noone)
|
2023-01-01 02:06:02 +01:00
|
|
|
draw_sprite_stretched_ext(THEME.node_glow, 0, xx - 9, yy - 9, w * _s + 18, h * _s + 18, COLORS._main_value_negative, 1);
|
2022-08-30 07:36:37 +02:00
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
drawNodeBase(xx, yy, _s);
|
2023-01-01 02:06:02 +01:00
|
|
|
if(previewable && ds_list_size(outputs) > 0) {
|
|
|
|
if(preview_channel >= ds_list_size(outputs))
|
|
|
|
preview_channel = 0;
|
2023-01-25 06:49:00 +01:00
|
|
|
drawPreview(xx, yy, _s);
|
2023-02-14 02:51:14 +01:00
|
|
|
}
|
2023-01-25 06:49:00 +01:00
|
|
|
drawDimension(xx, yy, _s);
|
2023-01-01 02:06:02 +01:00
|
|
|
|
2023-03-05 07:16:44 +01:00
|
|
|
onDrawNode(xx, yy, _mx, _my, _s, PANEL_GRAPH.node_hovering == self, PANEL_GRAPH.node_focus == self);
|
2022-12-16 09:18:09 +01:00
|
|
|
drawNodeName(xx, yy, _s);
|
2023-03-05 07:16:44 +01:00
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
if(active_draw_index > -1) {
|
2023-01-25 06:49:00 +01:00
|
|
|
draw_sprite_stretched_ext(bg_sel_spr, 0, xx, yy, round(w * _s), round(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;
|
|
|
|
}
|
|
|
|
|
2023-03-26 07:13:36 +02:00
|
|
|
if(draw_droppable)
|
|
|
|
draw_sprite_stretched_ext(THEME.ui_panel_active, 0, xx, yy, w * _s, h * _s, COLORS._main_value_positive, 1);
|
|
|
|
draw_droppable = false;
|
|
|
|
|
2022-09-21 06:09:40 +02:00
|
|
|
return drawJunctions(xx, yy, _mx, _my, _s);
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
2023-03-28 06:58:28 +02:00
|
|
|
|
2023-01-25 06:49:00 +01:00
|
|
|
static onDrawNodeBehind = function(_x, _y, _mx, _my, _s) {}
|
2023-03-28 06:58:28 +02:00
|
|
|
|
2023-03-05 07:16:44 +01:00
|
|
|
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover = false, _focus = false) {}
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-03-28 06:58:28 +02:00
|
|
|
badgePreview = 0;
|
|
|
|
badgeInspect = 0;
|
2022-01-13 05:24:03 +01:00
|
|
|
static drawBadge = function(_x, _y, _s) {
|
2023-02-14 02:51:14 +01:00
|
|
|
if(!active) return;
|
2022-01-13 05:24:03 +01:00
|
|
|
var xx = x * _s + _x + w * _s;
|
|
|
|
var yy = y * _s + _y;
|
|
|
|
|
2023-03-28 06:58:28 +02:00
|
|
|
badgePreview = lerp_float(badgePreview, !!previewing, 2);
|
|
|
|
badgeInspect = lerp_float(badgeInspect, inspecting, 2);
|
|
|
|
|
|
|
|
if(badgePreview > 0) {
|
|
|
|
draw_sprite_ext(THEME.node_state, 0, xx, yy, badgePreview, badgePreview, 0, c_white, 1);
|
|
|
|
xx -= 28 * badgePreview;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
2023-03-28 06:58:28 +02:00
|
|
|
|
|
|
|
if(badgeInspect > 0) {
|
|
|
|
draw_sprite_ext(THEME.node_state, 1, xx, yy, badgeInspect, badgeInspect, 0, c_white, 1);
|
|
|
|
xx -= 28 * badgeInspect;
|
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;
|
|
|
|
}
|
|
|
|
|
2022-12-19 13:35:30 +01:00
|
|
|
static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) {}
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-12-16 09:18:09 +01:00
|
|
|
static getPreviewValue = function() {
|
|
|
|
if(preview_channel > ds_list_size(outputs)) return noone;
|
|
|
|
return outputs[| preview_channel];
|
|
|
|
}
|
|
|
|
|
2023-02-14 02:51:14 +01:00
|
|
|
static enable = function() { active = true; }
|
|
|
|
static disable = function() { active = false; }
|
|
|
|
|
2022-01-26 06:57:34 +01:00
|
|
|
static destroy = function(_merge = false) {
|
2023-02-14 02:51:14 +01:00
|
|
|
if(!active) return;
|
|
|
|
disable();
|
|
|
|
|
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];
|
2023-02-14 02:51:14 +01:00
|
|
|
if(_vt.value_from == noone) break;
|
|
|
|
if(_vt.value_from.node != self) break;
|
2022-01-26 06:57:34 +01:00
|
|
|
|
|
|
|
_vt.removeFrom(false);
|
|
|
|
|
2023-02-14 02:51:14 +01:00
|
|
|
if(!_merge) continue;
|
|
|
|
|
|
|
|
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-26 06:57:34 +01:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2023-02-23 07:02:19 +01:00
|
|
|
for( var i = 0; i < ds_list_size(inputs); i++ )
|
|
|
|
inputs[| i].destroy();
|
|
|
|
|
|
|
|
for( var i = 0; i < ds_list_size(outputs); i++ )
|
|
|
|
outputs[| i].destroy();
|
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
onDestroy();
|
|
|
|
}
|
2023-02-14 02:51:14 +01:00
|
|
|
|
|
|
|
static restore = function() {
|
|
|
|
if(active) return;
|
|
|
|
enable();
|
2023-02-28 09:43:01 +01:00
|
|
|
ds_list_add(group == noone? NODES : group.getNodeList(), self);
|
2023-02-14 02:51:14 +01:00
|
|
|
}
|
|
|
|
|
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() {}
|
|
|
|
|
2023-02-14 02:51:14 +01:00
|
|
|
static clearInputCache = function() {
|
2023-02-17 11:31:33 +01:00
|
|
|
for( var i = 0; i < ds_list_size(inputs); i++ )
|
2023-02-14 02:51:14 +01:00
|
|
|
inputs[| i].cache_value[0] = false;
|
|
|
|
}
|
|
|
|
|
2022-12-10 05:06:01 +01:00
|
|
|
static cacheArrayCheck = function() {
|
2023-03-02 07:59:14 +01:00
|
|
|
if(array_length(cached_output) != ANIMATOR.frames_total)
|
|
|
|
array_resize(cached_output, ANIMATOR.frames_total);
|
|
|
|
if(array_length(cache_result) != ANIMATOR.frames_total)
|
|
|
|
array_resize(cache_result, ANIMATOR.frames_total);
|
2022-12-10 05:06:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static cacheCurrentFrame = function(_frame) {
|
|
|
|
cacheArrayCheck();
|
2023-03-02 07:59:14 +01:00
|
|
|
if(ANIMATOR.current_frame < 0) return;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-03-02 07:59:14 +01:00
|
|
|
surface_array_free(cached_output[ANIMATOR.current_frame]);
|
|
|
|
cached_output[ANIMATOR.current_frame] = surface_array_clone(_frame);
|
2022-12-10 05:06:01 +01:00
|
|
|
|
2022-12-21 02:30:23 +01:00
|
|
|
array_safe_set(cache_result, ANIMATOR.current_frame, true);
|
2022-12-10 05:06:01 +01:00
|
|
|
}
|
2023-02-19 13:49:20 +01:00
|
|
|
|
2022-12-10 05:06:01 +01:00
|
|
|
static cacheExist = function(frame = ANIMATOR.current_frame) {
|
2023-03-02 07:59:14 +01:00
|
|
|
if(frame < 0) return false;
|
|
|
|
|
2022-12-10 05:06:01 +01:00
|
|
|
if(frame >= array_length(cached_output)) return false;
|
|
|
|
if(frame >= array_length(cache_result)) return false;
|
2023-02-23 07:02:19 +01:00
|
|
|
if(!array_safe_get(cache_result, frame, false)) return false;
|
2022-12-10 05:06:01 +01:00
|
|
|
return true;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
2022-12-10 05:06:01 +01:00
|
|
|
|
2023-02-19 13:49:20 +01:00
|
|
|
static getCacheFrame = function(frame = ANIMATOR.current_frame) {
|
2023-03-02 07:59:14 +01:00
|
|
|
if(frame < 0) return false;
|
|
|
|
|
2023-02-19 13:49:20 +01:00
|
|
|
if(!cacheExist(frame)) return noone;
|
|
|
|
var surf = array_safe_get(cached_output, frame);
|
|
|
|
return surf;
|
|
|
|
}
|
|
|
|
|
2022-12-10 05:06:01 +01:00
|
|
|
static recoverCache = function(frame = ANIMATOR.current_frame) {
|
|
|
|
if(!cacheExist(frame)) return false;
|
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
var _s = cached_output[ANIMATOR.current_frame];
|
2023-03-02 07:59:14 +01:00
|
|
|
outputs[| 0].setValue(_s);
|
2022-11-22 14:25:39 +01:00
|
|
|
|
|
|
|
return true;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
2023-03-02 07:59:14 +01:00
|
|
|
static clearCache = function() {
|
2023-02-23 07:02:19 +01:00
|
|
|
if(!use_cache) return;
|
2023-03-08 07:35:51 +01:00
|
|
|
if(!renderActive) return;
|
2023-02-19 13:49:20 +01:00
|
|
|
|
2023-03-02 07:59:14 +01:00
|
|
|
if(array_length(cached_output) != ANIMATOR.frames_total)
|
|
|
|
array_resize(cached_output, ANIMATOR.frames_total);
|
2022-01-13 05:24:03 +01:00
|
|
|
for(var i = 0; i < array_length(cached_output); i++) {
|
|
|
|
var _s = cached_output[i];
|
2022-11-22 14:25:39 +01:00
|
|
|
if(is_surface(_s))
|
2022-01-13 05:24:03 +01:00
|
|
|
surface_free(_s);
|
|
|
|
cached_output[i] = 0;
|
2022-12-10 05:06:01 +01:00
|
|
|
cache_result[i] = false;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
}
|
2023-02-23 07:02:19 +01:00
|
|
|
static clearCacheForward = function() {
|
2023-03-08 07:35:51 +01:00
|
|
|
if(!renderActive) return;
|
|
|
|
|
2023-02-23 07:02:19 +01:00
|
|
|
clearCache();
|
|
|
|
for( var i = 0; i < ds_list_size(outputs); i++ )
|
|
|
|
for( var j = 0; j < ds_list_size(outputs[| i].value_to); j++ )
|
|
|
|
outputs[| i].value_to[| j].node.clearCacheForward();
|
|
|
|
}
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-01-23 04:08:16 +01:00
|
|
|
static checkConnectGroup = function(_type = "group") {
|
2022-12-23 04:45:52 +01:00
|
|
|
var _y = y;
|
2023-02-14 02:51:14 +01:00
|
|
|
var nodes = [];
|
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
for(var i = 0; i < ds_list_size(inputs); i++) {
|
|
|
|
var _in = inputs[| i];
|
2022-12-23 04:45:52 +01:00
|
|
|
if(_in.value_from == noone) continue;
|
|
|
|
if(_in.value_from.node.group == group) continue;
|
|
|
|
var input_node = noone;
|
2023-02-14 02:51:14 +01:00
|
|
|
|
2022-12-23 04:45:52 +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;
|
|
|
|
case "feedback" : input_node = new Node_Feedback_Input(x - w - 64, _y, group); break;
|
|
|
|
}
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-12-23 04:45:52 +01:00
|
|
|
if(input_node == noone) continue;
|
|
|
|
|
2023-02-14 02:51:14 +01:00
|
|
|
array_push(nodes, input_node);
|
2022-12-23 04:45:52 +01:00
|
|
|
input_node.inputs[| 2].setValue(_in.type);
|
|
|
|
input_node.inParent.setFrom(_in.value_from);
|
|
|
|
input_node.onValueUpdate(0);
|
|
|
|
_in.setFrom(input_node.outputs[| 0]);
|
|
|
|
|
|
|
|
_y += 64;
|
|
|
|
}
|
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
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-12-12 09:08:03 +01:00
|
|
|
if(_to.value_from != _ou) continue;
|
|
|
|
if(!_to.node.active) continue;
|
|
|
|
if(_to.node.group == group) continue;
|
|
|
|
var output_node = noone;
|
2023-02-14 02:51:14 +01:00
|
|
|
|
2022-12-12 09:08:03 +01:00
|
|
|
switch(_type) {
|
2022-12-23 04:45:52 +01:00
|
|
|
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;
|
|
|
|
case "feedback" : output_node = new Node_Feedback_Output(x + w + 64, y, group); break;
|
2022-12-12 09:08:03 +01:00
|
|
|
}
|
2022-01-25 10:58:11 +01:00
|
|
|
|
2022-12-12 09:08:03 +01:00
|
|
|
if(output_node == noone) continue;
|
2022-12-23 04:45:52 +01:00
|
|
|
|
2023-02-14 02:51:14 +01:00
|
|
|
array_push(nodes, output_node);
|
2022-12-12 09:08:03 +01:00
|
|
|
_to.setFrom(output_node.outParent);
|
|
|
|
output_node.inputs[| 0].setFrom(_ou);
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
}
|
2023-02-14 02:51:14 +01:00
|
|
|
|
|
|
|
return nodes;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
2023-03-11 01:40:17 +01:00
|
|
|
static isNotUsingTool = function() {
|
|
|
|
return PANEL_PREVIEW.tool_current == noone;
|
|
|
|
}
|
|
|
|
|
|
|
|
static isUsingTool = function(index, subtool = noone) {
|
|
|
|
if(tools == -1)
|
|
|
|
return false;
|
|
|
|
if(PANEL_PREVIEW.tool_current != tools[index])
|
|
|
|
return false;
|
|
|
|
if(subtool == noone)
|
|
|
|
return true;
|
|
|
|
return tools[index].selecting == subtool;
|
|
|
|
}
|
|
|
|
|
2023-02-14 02:51:14 +01:00
|
|
|
static clone = function(target = PANEL_GRAPH.getCurrentContext()) {
|
2023-01-17 08:11:55 +01:00
|
|
|
CLONING = true;
|
2022-12-12 09:08:03 +01:00
|
|
|
var _type = instanceof(self);
|
2023-02-14 02:51:14 +01:00
|
|
|
var _node = nodeBuild(_type, x, y, target);
|
2023-01-17 08:11:55 +01:00
|
|
|
CLONING = false;
|
2023-03-07 14:29:47 +01:00
|
|
|
|
2023-02-17 04:48:54 +01:00
|
|
|
LOADING_VERSION = SAVEFILE_VERSION;
|
2023-01-17 08:11:55 +01:00
|
|
|
|
|
|
|
if(!_node) return;
|
|
|
|
|
2023-03-07 14:29:47 +01:00
|
|
|
CLONING = true;
|
2022-12-21 02:30:23 +01:00
|
|
|
var _nid = _node.node_id;
|
2023-02-14 02:51:14 +01:00
|
|
|
_node.deserialize(serialize());
|
|
|
|
_node.postDeserialize();
|
2022-12-21 02:30:23 +01:00
|
|
|
_node.applyDeserialize();
|
|
|
|
_node.node_id = _nid;
|
2022-12-18 03:20:38 +01:00
|
|
|
|
|
|
|
NODE_MAP[? node_id] = self;
|
2022-12-21 02:30:23 +01:00
|
|
|
NODE_MAP[? _nid] = _node;
|
|
|
|
PANEL_ANIMATION.updatePropertyList();
|
2023-03-07 14:29:47 +01:00
|
|
|
CLONING = false;
|
2022-12-12 09:08:03 +01:00
|
|
|
|
2023-02-28 09:43:01 +01:00
|
|
|
onClone(_node, target);
|
2023-01-25 06:49:00 +01:00
|
|
|
|
2022-12-12 09:08:03 +01:00
|
|
|
return _node;
|
|
|
|
}
|
|
|
|
|
2023-02-28 09:43:01 +01:00
|
|
|
static onClone = function(_NewNode, target = PANEL_GRAPH.getCurrentContext()) {}
|
2023-01-25 06:49:00 +01:00
|
|
|
|
2023-03-26 07:13:36 +02:00
|
|
|
draw_droppable = false;
|
|
|
|
static droppable = function(dragObj) {
|
|
|
|
for( var i = 0; i < ds_list_size(inputs); i++ ) {
|
|
|
|
if(dragObj.type == inputs[| i].drop_key)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static onDrop = function(dragObj) {
|
|
|
|
for( var i = 0; i < ds_list_size(inputs); i++ ) {
|
|
|
|
if(dragObj.type == inputs[| i].drop_key) {
|
|
|
|
inputs[| i].setValue(dragObj.data);
|
|
|
|
previewDropAnimation();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-03-25 12:27:04 +01:00
|
|
|
|
2022-12-10 05:06:01 +01:00
|
|
|
static serialize = function(scale = false, preset = false) {
|
2022-01-13 05:24:03 +01:00
|
|
|
var _map = ds_map_create();
|
2023-03-11 01:40:17 +01:00
|
|
|
//print(" > Serializing: " + name);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-12-10 05:06:01 +01:00
|
|
|
if(!preset) {
|
2023-02-19 13:49:20 +01:00
|
|
|
_map[? "id"] = node_id;
|
|
|
|
_map[? "render"] = renderActive;
|
|
|
|
_map[? "name"] = display_name;
|
|
|
|
_map[? "x"] = x;
|
|
|
|
_map[? "y"] = y;
|
|
|
|
_map[? "type"] = instanceof(self);
|
2023-02-28 09:43:01 +01:00
|
|
|
_map[? "group"] = group == noone? group : group.node_id;
|
2022-12-10 05:06:01 +01:00
|
|
|
}
|
2022-01-13 05:24:03 +01:00
|
|
|
|
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();
|
2023-02-17 04:48:54 +01:00
|
|
|
for(var i = 0; i < ds_list_size(inputs); i++)
|
|
|
|
ds_list_add_map(_inputs, inputs[| i].serialize(scale, preset));
|
2022-01-13 05:24:03 +01:00
|
|
|
ds_map_add_list(_map, "inputs", _inputs);
|
|
|
|
|
2023-03-28 06:58:28 +02:00
|
|
|
var _trigger = ds_list_create();
|
|
|
|
ds_list_add_map(_trigger, inspectInput1.serialize(scale, preset));
|
|
|
|
ds_list_add_map(_trigger, inspectInput2.serialize(scale, preset));
|
|
|
|
ds_map_add_list(_map, "inspectInputs", _trigger);
|
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
doSerialize(_map);
|
2023-02-28 09:43:01 +01:00
|
|
|
processSerialize(_map);
|
2022-01-13 05:24:03 +01:00
|
|
|
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) {}
|
2023-02-28 09:43:01 +01:00
|
|
|
static processSerialize = function(_map) {}
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-12-12 09:08:03 +01:00
|
|
|
load_scale = false;
|
2022-01-18 05:31:19 +01:00
|
|
|
load_map = -1;
|
2022-12-10 05:06:01 +01:00
|
|
|
static deserialize = function(_map, scale = false, preset = false) {
|
|
|
|
load_map = _map;
|
2022-12-12 09:08:03 +01:00
|
|
|
load_scale = scale;
|
2022-01-19 03:05:13 +01:00
|
|
|
|
2022-12-10 05:06:01 +01:00
|
|
|
if(!preset) {
|
2022-12-21 02:30:23 +01:00
|
|
|
if(APPENDING)
|
2022-12-10 05:06:01 +01:00
|
|
|
APPEND_MAP[? load_map[? "id"]] = node_id;
|
2022-12-21 02:30:23 +01:00
|
|
|
else
|
2022-12-10 05:06:01 +01:00
|
|
|
node_id = ds_map_try_get(load_map, "id");
|
2022-01-19 03:05:13 +01:00
|
|
|
|
2022-12-10 05:06:01 +01:00
|
|
|
NODE_MAP[? node_id] = self;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-12-10 05:06:01 +01:00
|
|
|
if(ds_map_exists(load_map, "name"))
|
2023-02-14 02:51:14 +01:00
|
|
|
display_name = ds_map_try_get(load_map, "name", "");
|
2023-03-02 07:59:14 +01:00
|
|
|
_group = ds_map_try_get(load_map, "group", noone);
|
|
|
|
if(_group == -1) _group = noone;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-12-10 05:06:01 +01:00
|
|
|
x = ds_map_try_get(load_map, "x");
|
|
|
|
y = ds_map_try_get(load_map, "y");
|
2023-02-19 13:49:20 +01:00
|
|
|
renderActive = ds_map_try_get(load_map, "render", true);
|
2022-12-10 05:06:01 +01:00
|
|
|
}
|
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
|
|
|
|
2023-02-28 09:43:01 +01:00
|
|
|
doDeserialize();
|
|
|
|
processDeserialize();
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
2023-03-28 06:58:28 +02:00
|
|
|
|
2023-02-28 09:43:01 +01:00
|
|
|
static doDeserialize = function() {}
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-09-23 13:28:42 +02:00
|
|
|
static attributeDeserialize = function(attr) {
|
|
|
|
ds_map_override(attributes, attr);
|
|
|
|
}
|
2022-12-21 02:30:23 +01:00
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
static postDeserialize = function() {}
|
2023-02-28 09:43:01 +01:00
|
|
|
static processDeserialize = function() {}
|
2023-03-11 01:40:17 +01:00
|
|
|
|
2023-02-14 02:51:14 +01:00
|
|
|
static applyDeserialize = function(preset = false) {
|
2022-12-21 02:30:23 +01:00
|
|
|
var _inputs = load_map[? "inputs"];
|
2022-12-22 03:09:55 +01:00
|
|
|
var amo = min(ds_list_size(inputs), ds_list_size(_inputs));
|
|
|
|
|
2023-03-11 01:40:17 +01:00
|
|
|
for(var i = 0; i < amo; i++) {
|
|
|
|
if(inputs[| i] == noone) continue;
|
2023-02-14 02:51:14 +01:00
|
|
|
inputs[| i].applyDeserialize(_inputs[| i], load_scale, preset);
|
2023-03-11 01:40:17 +01:00
|
|
|
}
|
2023-01-01 02:06:02 +01:00
|
|
|
|
2023-03-28 06:58:28 +02:00
|
|
|
if(ds_map_exists(load_map, "inspectInputs")) {
|
|
|
|
var insInp = load_map[? "inspectInputs"];
|
|
|
|
inspectInput1.applyDeserialize(insInp[| 0], load_scale, preset);
|
|
|
|
inspectInput2.applyDeserialize(insInp[| 1], load_scale, preset);
|
|
|
|
}
|
2023-01-09 03:14:20 +01:00
|
|
|
|
|
|
|
doApplyDeserialize();
|
2022-12-21 02:30:23 +01:00
|
|
|
}
|
|
|
|
|
2023-01-09 03:14:20 +01:00
|
|
|
static doApplyDeserialize = function() {}
|
|
|
|
|
2023-03-26 07:13:36 +02:00
|
|
|
static loadGroup = function(context = PANEL_GRAPH.getCurrentContext()) {
|
2023-02-28 09:43:01 +01:00
|
|
|
if(_group == noone) {
|
2023-03-26 07:13:36 +02:00
|
|
|
var c = context;
|
2023-02-28 09:43:01 +01:00
|
|
|
if(c != noone) c.add(self);
|
2022-01-13 05:24:03 +01:00
|
|
|
} 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;
|
2023-03-28 06:58:28 +02:00
|
|
|
for(var i = 0; i < ds_list_size(inputs); i++)
|
2022-09-21 06:09:40 +02:00
|
|
|
connected &= inputs[| i].connect(log);
|
2023-03-28 06:58:28 +02:00
|
|
|
|
|
|
|
if(ds_map_exists(load_map, "inspectInputs")) {
|
|
|
|
inspectInput1.connect(log);
|
|
|
|
inspectInput2.connect(log);
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
2023-03-28 06:58:28 +02:00
|
|
|
|
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() {
|
2023-02-23 07:02:19 +01:00
|
|
|
for( var i = 0; i < ds_list_size(inputs); i++ )
|
2022-01-19 06:11:17 +01:00
|
|
|
inputs[| i].cleanUp();
|
2023-02-23 07:02:19 +01:00
|
|
|
for( var i = 0; i < ds_list_size(outputs); i++ )
|
2022-01-19 06:11:17 +01:00
|
|
|
outputs[| i].cleanUp();
|
|
|
|
|
|
|
|
ds_list_destroy(inputs);
|
|
|
|
ds_list_destroy(outputs);
|
|
|
|
ds_map_destroy(attributes);
|
2023-02-23 07:02:19 +01:00
|
|
|
|
|
|
|
for( var i = 0; i < array_length(temp_surface); i++ )
|
|
|
|
surface_free(temp_surface[i]);
|
2022-01-19 06:11:17 +01:00
|
|
|
}
|
2023-02-23 07:02:19 +01:00
|
|
|
|
|
|
|
static onCleanUp = function() {}
|
2023-03-19 09:17:39 +01:00
|
|
|
|
|
|
|
// helper function
|
|
|
|
static attrDepth = function() {
|
|
|
|
if(ds_map_exists(attributes, "color_depth")) {
|
|
|
|
var form = attributes[? "color_depth"];
|
|
|
|
if(inputs[| 0].type == VALUE_TYPE.surface)
|
|
|
|
form--;
|
|
|
|
if(form >= 0)
|
|
|
|
return array_safe_get(global.SURFACE_FORMAT, form, surface_rgba8unorm);
|
|
|
|
}
|
|
|
|
|
|
|
|
var _s = inputs[| 0].getValue();
|
|
|
|
while(is_array(_s) && array_length(_s)) _s = _s[0];
|
|
|
|
if(!is_surface(_s))
|
|
|
|
return surface_rgba8unorm;
|
|
|
|
return surface_get_format(_s);
|
|
|
|
}
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|