- [Graph Panel] Add context button to convert connection to tunnel.

This commit is contained in:
Tanasart 2024-07-15 10:54:28 +07:00
parent 2891194037
commit b005475a21
11 changed files with 196 additions and 127 deletions

View file

@ -38,7 +38,7 @@
LATEST_VERSION = 11700; LATEST_VERSION = 11700;
VERSION = 11770; VERSION = 11770;
SAVE_VERSION = 11700; SAVE_VERSION = 11700;
VERSION_STRING = "1.17.7"; VERSION_STRING = "1.17.8";
BUILD_NUMBER = 11770; BUILD_NUMBER = 11770;
globalvar HOTKEYS, HOTKEY_CONTEXT; globalvar HOTKEYS, HOTKEY_CONTEXT;

View file

@ -548,9 +548,7 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc
var _hv = PANEL_GRAPH.pHOVER && PANEL_GRAPH.node_hovering == self && PANEL_GRAPH._value_focus == noone; var _hv = PANEL_GRAPH.pHOVER && PANEL_GRAPH.node_hovering == self && PANEL_GRAPH._value_focus == noone;
_hv &= point_in_circle(_mx, _my, _bx, _by, 8); _hv &= point_in_circle(_mx, _my, _bx, _by, 8);
BLEND_ADD draw_sprite_ext_add(THEME.animate_node_go, 0, _bx, _by, 1, 1, 0, _hv? COLORS._main_accent : c_white, 0.3 + _hv * 0.7);
draw_sprite_ext(THEME.animate_node_go, 0, _bx, _by, 1, 1, 0, getColor(), 0.2 + _hv * 0.3);
BLEND_NORMAL
if(_hv && PANEL_GRAPH.pFOCUS && mouse_press(mb_left)) if(_hv && PANEL_GRAPH.pFOCUS && mouse_press(mb_left))
panelSetContext(PANEL_GRAPH); panelSetContext(PANEL_GRAPH);

View file

@ -1147,11 +1147,15 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
} }
var _iny = yy + (junction_draw_pad_y + junction_draw_hei_y * 0.5 * SHOW_PARAM) * _s; var _iny = yy + (junction_draw_pad_y + junction_draw_hei_y * 0.5 * SHOW_PARAM) * _s;
var rx = x, ry = y + junction_draw_pad_y + junction_draw_hei_y * 0.5 * SHOW_PARAM;
for( var i = 0, n = ds_list_size(inputs); i < n; i++ ) { for( var i = 0, n = ds_list_size(inputs); i < n; i++ ) {
jun = inputs[| i]; jun = inputs[| i];
jun.x = xx; jun.x = xx;
jun.y = _iny; jun.y = _iny;
jun.rx = rx;
jun.ry = ry;
} }
for(var i = 0; i < in_cache_len; i++) { for(var i = 0; i < in_cache_len; i++) {
@ -1160,10 +1164,15 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
jun.x = xx; jun.x = xx;
jun.y = _iny; jun.y = _iny;
_iny += junction_draw_hei_y * _s; _iny += junction_draw_hei_y * _s;
jun.rx = rx;
jun.ry = ry;
ry += junction_draw_hei_y;
} }
xx = xx + w * _s; xx = xx + w * _s;
var _outy = yy + (junction_draw_pad_y + junction_draw_hei_y * 0.5 * SHOW_PARAM) * _s; var _outy = yy + (junction_draw_pad_y + junction_draw_hei_y * 0.5 * SHOW_PARAM) * _s;
var rx = x + w, ry = y + junction_draw_pad_y + junction_draw_hei_y * 0.5 * SHOW_PARAM;
for(var i = 0; i < outputs_amount; i++) { for(var i = 0; i < outputs_amount; i++) {
var idx = outputs_index[i]; var idx = outputs_index[i];
@ -1172,6 +1181,10 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
jun.x = xx; jun.x = xx;
jun.y = _outy; jun.y = _outy;
_outy += junction_draw_hei_y * _s * jun.isVisible(); _outy += junction_draw_hei_y * _s * jun.isVisible();
jun.rx = rx;
jun.ry = ry;
ry += junction_draw_hei_y * jun.isVisible();
} }
if(SHOW_PARAM) h = h_param; if(SHOW_PARAM) h = h_param;
@ -1790,25 +1803,25 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
static drawBadge = function(_x, _y, _s) { static drawBadge = function(_x, _y, _s) {
if(!active) return; if(!active) return;
var xx = x * _s + _x + w * _s;
var yy = y * _s + _y;
badgePreview = lerp_float(badgePreview, !!previewing, 2); badgePreview = lerp_float(badgePreview, !!previewing, 2);
badgeInspect = lerp_float(badgeInspect, inspecting, 2); badgeInspect = lerp_float(badgeInspect, inspecting, 2);
if(badgePreview > 0) { if(previewable) {
draw_sprite_ext(THEME.node_state, is_3D? 3 : 0, xx, yy, badgePreview, badgePreview, 0, c_white, 1); var xx = x * _s + _x + w * _s;
xx -= 28 * badgePreview; var yy = y * _s + _y;
}
if(badgeInspect > 0) { if(badgePreview > 0) { draw_sprite_ext(THEME.node_state, is_3D? 3 : 0, xx, yy, badgePreview, badgePreview, 0, c_white, 1); xx -= 28 * badgePreview; }
draw_sprite_ext(THEME.node_state, 1, xx, yy, badgeInspect, badgeInspect, 0, c_white, 1); if(badgeInspect > 0) { draw_sprite_ext(THEME.node_state, 1, xx, yy, badgeInspect, badgeInspect, 0, c_white, 1); xx -= 28 * badgeInspect; }
xx -= 28 * badgeInspect; if(isTool) { draw_sprite_ext(THEME.node_state, 2, xx, yy, 1, 1, 0, c_white, 1); xx -= 28 * 2; }
}
if(isTool) { } else {
draw_sprite_ext(THEME.node_state, 2, xx, yy, 1, 1, 0, c_white, 1); var xx = _x + _s * (x + w - 10);
xx -= 28 * 2; var yy = _y + _s * y;
if(badgePreview > 0) { draw_sprite_ext(THEME.circle_16, 0, xx, yy, .5 * _s, .5 * _s, 0, CDEF.orange); xx -= 12 * _s; }
if(badgeInspect > 0) { draw_sprite_ext(THEME.circle_16, 0, xx, yy, .5 * _s, .5 * _s, 0, CDEF.lime); xx -= 12 * _s; }
if(isTool) { draw_sprite_ext(THEME.circle_16, 0, xx, yy, .5 * _s, .5 * _s, 0, CDEF.blue); xx -= 12 * _s; }
} }
inspecting = false; inspecting = false;

View file

@ -38,7 +38,7 @@ enum NODE_EXPORT_FORMAT {
function Node_Export(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { function Node_Export(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "Export"; name = "Export";
preview_channel = 1; preview_channel = 0;
playing = false; playing = false;
played = 0; played = 0;

View file

@ -22,6 +22,11 @@ function Node_Frame(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
scale = 1; scale = 1;
lcolor = false; lcolor = false;
tb_name = new textBox(TEXTBOX_INPUT.text, function(txt) /*=>*/ { setDisplayName(txt); });
tb_name.font = f_p2;
tb_name.hide = true;
tb_name.align = fa_center;
name_height = 16; name_height = 16;
draw_x0 = 0; draw_x0 = 0;
@ -29,6 +34,7 @@ function Node_Frame(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
draw_x1 = 0; draw_x1 = 0;
draw_y1 = 0; draw_y1 = 0;
inputs[| 0] = nodeValue("Size", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, [ 240, 160 ] ) inputs[| 0] = nodeValue("Size", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, [ 240, 160 ] )
.setDisplay(VALUE_DISPLAY.vector) .setDisplay(VALUE_DISPLAY.vector)
.rejectArray(); .rejectArray();
@ -50,14 +56,14 @@ function Node_Frame(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
input_display_list = [ 0, 1, 3, 4 ]; input_display_list = [ 0, 1, 3, 4 ];
static onValueUpdate = function(index = 3) { static onValueUpdate = function(index = 3) { global.__FRAME_LABEL_SCALE = getInputData(3); }
global.__FRAME_LABEL_SCALE = getInputData(3);
}
static step = function() { static step = function() {
var si = getInputData(0); previewable = true;
w = si[0];
h = si[1]; var sz = getInputData(0);
w = sz[0];
h = sz[1];
color = getInputData(1); color = getInputData(1);
alpha = _color_get_alpha(color); alpha = _color_get_alpha(color);
@ -67,7 +73,6 @@ function Node_Frame(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
} }
static drawNodeBase = function(xx, yy, _s, _panel) { static drawNodeBase = function(xx, yy, _s, _panel) {
var px0 = 3; var px0 = 3;
var py0 = 3; var py0 = 3;
var px1 = -3 + _panel.w; var px1 = -3 + _panel.w;
@ -101,15 +106,31 @@ function Node_Frame(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
var _w = draw_x1 - draw_x0; var _w = draw_x1 - draw_x0;
var _h = draw_y1 - draw_y0; var _h = draw_y1 - draw_y0;
var txt = renamed? display_name : name;
draw_sprite_stretched_ext(bg_spr, 1, draw_x0, draw_y0, _w, _h, color, alpha * .50); draw_sprite_stretched_ext(bg_spr, 1, draw_x0, draw_y0, _w, _h, color, alpha * .50);
draw_sprite_stretched_ext(nm_spr, 0, draw_x0, draw_y0, _w, name_height, color, alpha * .75);
draw_sprite_stretched_add(bg_spr, 1, draw_x0, draw_y0, _w, _h, c_white, .20);
var txt = renamed? display_name : name; if(WIDGET_CURRENT == tb_name) {
var nh = 24;
draw_sprite_stretched_ext(nm_spr, 0, draw_x0, draw_y0, _w, nh, color, alpha * .75);
tb_name.setFocusHover(PANEL_GRAPH.pFOCUS, PANEL_GRAPH.pHOVER);
tb_name.draw(draw_x0, draw_y0, _w, nh, txt, [ _mx, _my ]);
} else {
draw_sprite_stretched_ext(nm_spr, 0, draw_x0, draw_y0, _w, name_height, color, alpha * .75);
draw_set_text(f_p2, fa_center, fa_bottom, COLORS._main_text); draw_set_text(f_p2, fa_center, fa_bottom, COLORS._main_text);
draw_text_cut((draw_x0 + draw_x1) / 2, draw_y0 + name_height + 2, txt, _w - 4); draw_text_cut((draw_x0 + draw_x1) / 2, draw_y0 + name_height + 2, txt, _w - 4);
if(point_in_rectangle(_mx, _my, draw_x0, draw_y0, draw_x0 + _w, draw_y0 + name_height)) {
if(PANEL_GRAPH.pFOCUS && DOUBLE_CLICK)
tb_name.activate();
}
}
draw_sprite_stretched_add(bg_spr, 1, draw_x0, draw_y0, _w, _h, c_white, .20);
if(active_draw_index > -1) { if(active_draw_index > -1) {
draw_sprite_stretched_ext(bg_sel_spr, 0, draw_x0, draw_y0, _w, _h, COLORS._main_accent, 1); draw_sprite_stretched_ext(bg_sel_spr, 0, draw_x0, draw_y0, _w, _h, COLORS._main_accent, 1);
active_draw_index = -1; active_draw_index = -1;

View file

@ -15,8 +15,7 @@ function Node_Tunnel_In(_x, _y, _group = noone) : Node(_x, _y, _group) construct
preview_scale = 1; preview_scale = 1;
var tname = ""; var tname = "";
if(!LOADING && !APPENDING) if(!LOADING && !APPENDING) tname = $"tunnel{ds_map_size(TUNNELS_IN_MAP)}";
tname = $"tunnel{ds_map_size(TUNNELS_IN_MAP)}";
inputs[| 0] = nodeValue("Name", self, JUNCTION_CONNECT.input, VALUE_TYPE.text, tname ) inputs[| 0] = nodeValue("Name", self, JUNCTION_CONNECT.input, VALUE_TYPE.text, tname )
.rejectArray(); .rejectArray();
@ -29,20 +28,20 @@ function Node_Tunnel_In(_x, _y, _group = noone) : Node(_x, _y, _group) construct
insp2UpdateTooltip = "Create tunnel out"; insp2UpdateTooltip = "Create tunnel out";
insp2UpdateIcon = [ THEME.tunnel, 0, c_white ]; insp2UpdateIcon = [ THEME.tunnel, 0, c_white ];
static onInspector2Update = function() { #region static onInspector2Update = function() {
var _node = nodeBuild("Node_Tunnel_Out", x + 128, y); var _node = nodeBuild("Node_Tunnel_Out", x + 128, y);
_node.inputs[| 0].setValue(inputs[| 0].getValue()); _node.inputs[| 0].setValue(inputs[| 0].getValue());
} #endregion }
static update = function(frame = CURRENT_FRAME) { onValueUpdate(); } static update = function(frame = CURRENT_FRAME) { onValueUpdate(); }
static resetMap = function() { #region static resetMap = function() {
var _key = inputs[| 0].getValue(); var _key = inputs[| 0].getValue();
TUNNELS_IN_MAP[? node_id] = _key; TUNNELS_IN_MAP[? node_id] = _key;
TUNNELS_IN[? _key] = inputs[| 1]; TUNNELS_IN[? _key] = inputs[| 1];
} resetMap(); #endregion } resetMap();
static checkDuplicate = function() { #region static checkDuplicate = function() {
var _key = inputs[| 0].getValue(); var _key = inputs[| 0].getValue();
var amo = ds_map_size(TUNNELS_IN_MAP); var amo = ds_map_size(TUNNELS_IN_MAP);
var k = ds_map_find_first(TUNNELS_IN_MAP); var k = ds_map_find_first(TUNNELS_IN_MAP);
@ -62,9 +61,9 @@ function Node_Tunnel_In(_x, _y, _group = noone) : Node(_x, _y, _group) construct
noti_remove(error_notification); noti_remove(error_notification);
error_notification = noone; error_notification = noone;
} }
} #endregion }
static onValueUpdate = function(index = -1) { #region static onValueUpdate = function(index = -1) {
var _key = inputs[| 0].getValue(); var _key = inputs[| 0].getValue();
resetMap(); resetMap();
@ -84,9 +83,9 @@ function Node_Tunnel_In(_x, _y, _group = noone) : Node(_x, _y, _group) construct
} }
if(index == 0) { RENDER_ALL_REORDER } if(index == 0) { RENDER_ALL_REORDER }
} #endregion }
static step = function() { #region static step = function() {
var _key = inputs[| 0].getValue(); var _key = inputs[| 0].getValue();
value_validation[VALIDATION.error] = error_notification != noone; value_validation[VALIDATION.error] = error_notification != noone;
@ -98,9 +97,9 @@ function Node_Tunnel_In(_x, _y, _group = noone) : Node(_x, _y, _group) construct
inputs[| 1].setType(inputs[| 1].value_from.type); inputs[| 1].setType(inputs[| 1].value_from.type);
inputs[| 1].display_type = inputs[| 1].value_from.display_type; inputs[| 1].display_type = inputs[| 1].value_from.display_type;
} }
} #endregion }
static getNextNodes = function() { #region static getNextNodes = function() {
var nodes = []; var nodes = [];
var nodeNames = []; var nodeNames = [];
var _key = inputs[| 0].getValue(); var _key = inputs[| 0].getValue();
@ -123,18 +122,18 @@ function Node_Tunnel_In(_x, _y, _group = noone) : Node(_x, _y, _group) construct
LOG_BLOCK_END(); LOG_BLOCK_END();
return nodes; return nodes;
} #endregion }
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
static pointIn = function(_x, _y, _mx, _my, _s) { #region static pointIn = function(_x, _y, _mx, _my, _s) {
var xx = x * _s + _x; var xx = x * _s + _x;
var yy = y * _s + _y; var yy = y * _s + _y;
return point_in_circle(_mx, _my, xx, yy, _s * 24); return point_in_circle(_mx, _my, xx, yy, _s * 24);
} #endregion }
static preDraw = function(_x, _y, _s) { #region static preDraw = function(_x, _y, _s) {
var xx = x * _s + _x; var xx = x * _s + _x;
var yy = y * _s + _y; var yy = y * _s + _y;
@ -143,12 +142,12 @@ function Node_Tunnel_In(_x, _y, _group = noone) : Node(_x, _y, _group) construct
inputs[| 1].x = xx; inputs[| 1].x = xx;
inputs[| 1].y = yy; inputs[| 1].y = yy;
} #endregion }
static drawBadge = function(_x, _y, _s) {} static drawBadge = function(_x, _y, _s) {}
static drawJunctionNames = function(_x, _y, _mx, _my, _s) {} static drawJunctionNames = function(_x, _y, _mx, _my, _s) {}
static onDrawNodeBehind = function(_x, _y, _mx, _my, _s) { #region static onDrawNodeBehind = function(_x, _y, _mx, _my, _s) {
var xx = _x + x * _s; var xx = _x + x * _s;
var yy = _y + y * _s; var yy = _y + y * _s;
@ -181,9 +180,9 @@ function Node_Tunnel_In(_x, _y, _group = noone) : Node(_x, _y, _group) construct
} }
draw_set_alpha(1); draw_set_alpha(1);
} #endregion }
static drawJunctions = function(_x, _y, _mx, _my, _s) { #region static drawJunctions = function(_x, _y, _mx, _my, _s) {
var xx = x * _s + _x; var xx = x * _s + _x;
var yy = y * _s + _y; var yy = y * _s + _y;
isHovering = point_in_circle(_mx, _my, xx, yy, _s * 24); isHovering = point_in_circle(_mx, _my, xx, yy, _s * 24);
@ -193,9 +192,9 @@ function Node_Tunnel_In(_x, _y, _group = noone) : Node(_x, _y, _group) construct
hover_scale_to = 1; hover_scale_to = 1;
return jhov? inputs[| 1] : noone; return jhov? inputs[| 1] : noone;
} #endregion }
static drawNode = function(_x, _y, _mx, _my, _s) { #region static drawNode = function(_x, _y, _mx, _my, _s) {
var xx = x * _s + _x; var xx = x * _s + _x;
var yy = y * _s + _y; var yy = y * _s + _y;
@ -242,17 +241,17 @@ function Node_Tunnel_In(_x, _y, _group = noone) : Node(_x, _y, _group) construct
hover_scale_to = 0; hover_scale_to = 0;
draw_set_text(f_sdf, fa_center, fa_bottom, COLORS._main_text); draw_set_text(f_sdf, fa_center, fa_bottom, COLORS._main_text);
draw_text_transformed(xx, yy - 12 * _s, string(inputs[| 0].getValue()), _s * 0.4, _s * 0.4, 0); draw_text_transformed(xx, yy - 12 * _s, string(inputs[| 0].getValue()), _s * .3, _s * .3, 0);
return drawJunctions(_x, _y, _mx, _my, _s); return drawJunctions(_x, _y, _mx, _my, _s);
} #endregion }
static onClone = function() { onValueUpdate(0); } static onClone = function() { onValueUpdate(0); }
static postConnect = function() { onValueUpdate(0); } static postConnect = function() { onValueUpdate(0); }
static onDestroy = function() { #region static onDestroy = function() {
if(error_notification != noone) if(error_notification != noone)
noti_remove(error_notification); noti_remove(error_notification);
} #endregion }
} }

View file

@ -27,28 +27,28 @@ function Node_Tunnel_Out(_x, _y, _group = noone) : Node(_x, _y, _group) construc
insp2UpdateTooltip = "Goto tunnel in"; insp2UpdateTooltip = "Goto tunnel in";
insp2UpdateIcon = [ THEME.tunnel, 1, c_white ]; insp2UpdateIcon = [ THEME.tunnel, 1, c_white ];
static onInspector2Update = function() { #region static onInspector2Update = function() {
var _key = inputs[| 0].getValue(); var _key = inputs[| 0].getValue();
if(!ds_map_exists(TUNNELS_IN, _key)) return; if(!ds_map_exists(TUNNELS_IN, _key)) return;
var _node = TUNNELS_IN[? _key].node; var _node = TUNNELS_IN[? _key].node;
graphFocusNode(_node); graphFocusNode(_node);
} #endregion }
static isRenderable = function() { #region static isRenderable = function() {
var _key = inputs[| 0].getValue(); var _key = inputs[| 0].getValue();
if(!ds_map_exists(TUNNELS_IN, _key)) return false; if(!ds_map_exists(TUNNELS_IN, _key)) return false;
return TUNNELS_IN[? _key].node.rendered; return TUNNELS_IN[? _key].node.rendered;
} #endregion }
static onValueUpdate = function(index = -1) { #region static onValueUpdate = function(index = -1) {
var _key = inputs[| 0].getValue(); var _key = inputs[| 0].getValue();
if(index == 0) { RENDER_ALL_REORDER } if(index == 0) { RENDER_ALL_REORDER }
} #endregion }
static step = function() { #region static step = function() {
var _key = inputs[| 0].getValue(); var _key = inputs[| 0].getValue();
TUNNELS_OUT[? node_id] = _key; TUNNELS_OUT[? node_id] = _key;
@ -59,25 +59,25 @@ function Node_Tunnel_Out(_x, _y, _group = noone) : Node(_x, _y, _group) construc
outputs[| 0].setType(VALUE_TYPE.any); outputs[| 0].setType(VALUE_TYPE.any);
outputs[| 0].display_type = VALUE_DISPLAY._default; outputs[| 0].display_type = VALUE_DISPLAY._default;
} }
} #endregion }
static update = function(frame = CURRENT_FRAME) { #region static update = function(frame = CURRENT_FRAME) {
var _key = inputs[| 0].getValue(); var _key = inputs[| 0].getValue();
if(ds_map_exists(TUNNELS_IN, _key)) if(ds_map_exists(TUNNELS_IN, _key))
outputs[| 0].setValue(TUNNELS_IN[? _key].getValue()); outputs[| 0].setValue(TUNNELS_IN[? _key].getValue());
} #endregion }
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
static pointIn = function(_x, _y, _mx, _my, _s) { #region static pointIn = function(_x, _y, _mx, _my, _s) {
var xx = x * _s + _x; var xx = x * _s + _x;
var yy = y * _s + _y; var yy = y * _s + _y;
return point_in_circle(_mx, _my, xx, yy, _s * 24); return point_in_circle(_mx, _my, xx, yy, _s * 24);
} #endregion }
static preDraw = function(_x, _y, _s) { #region static preDraw = function(_x, _y, _s) {
var xx = x * _s + _x; var xx = x * _s + _x;
var yy = y * _s + _y; var yy = y * _s + _y;
@ -86,12 +86,12 @@ function Node_Tunnel_Out(_x, _y, _group = noone) : Node(_x, _y, _group) construc
outputs[| 0].x = xx; outputs[| 0].x = xx;
outputs[| 0].y = yy; outputs[| 0].y = yy;
} #endregion }
static drawBadge = function(_x, _y, _s) {} static drawBadge = function(_x, _y, _s) {}
static drawJunctionNames = function(_x, _y, _mx, _my, _s) {} static drawJunctionNames = function(_x, _y, _mx, _my, _s) {}
static onDrawNodeBehind = function(_x, _y, _mx, _my, _s) { #region static onDrawNodeBehind = function(_x, _y, _mx, _my, _s) {
var xx = _x + x * _s; var xx = _x + x * _s;
var yy = _y + y * _s; var yy = _y + y * _s;
@ -117,9 +117,9 @@ function Node_Tunnel_Out(_x, _y, _group = noone) : Node(_x, _y, _group) construc
draw_line_dotted(frx, fry, xx, yy, 2 * _s, current_time / 10, 3); draw_line_dotted(frx, fry, xx, yy, 2 * _s, current_time / 10, 3);
draw_set_alpha(1); draw_set_alpha(1);
} #endregion }
static drawJunctions = function(_x, _y, _mx, _my, _s) { #region static drawJunctions = function(_x, _y, _mx, _my, _s) {
var xx = x * _s + _x; var xx = x * _s + _x;
var yy = y * _s + _y; var yy = y * _s + _y;
isHovering = point_in_circle(_mx, _my, xx, yy, _s * 24); isHovering = point_in_circle(_mx, _my, xx, yy, _s * 24);
@ -129,9 +129,9 @@ function Node_Tunnel_Out(_x, _y, _group = noone) : Node(_x, _y, _group) construc
hover_scale_to = 1; hover_scale_to = 1;
return jhov? outputs[| 0] : noone; return jhov? outputs[| 0] : noone;
} #endregion }
static drawNode = function(_x, _y, _mx, _my, _s) { #region static drawNode = function(_x, _y, _mx, _my, _s) {
var xx = x * _s + _x; var xx = x * _s + _x;
var yy = y * _s + _y; var yy = y * _s + _y;
@ -178,10 +178,10 @@ function Node_Tunnel_Out(_x, _y, _group = noone) : Node(_x, _y, _group) construc
hover_scale_to = 0; hover_scale_to = 0;
draw_set_text(f_sdf, fa_center, fa_bottom, COLORS._main_text); draw_set_text(f_sdf, fa_center, fa_bottom, COLORS._main_text);
draw_text_transformed(xx, yy - 12 * _s, string(inputs[| 0].getValue()), _s * 0.4, _s * 0.4, 0); draw_text_transformed(xx, yy - 12 * _s, string(inputs[| 0].getValue()), _s * .3, _s * .3, 0);
return drawJunctions(_x, _y, _mx, _my, _s); return drawJunctions(_x, _y, _mx, _my, _s);
} #endregion }
static onClone = function() { onValueUpdate(0); } static onClone = function() { onValueUpdate(0); }

View file

@ -11,6 +11,9 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
node = _node; node = _node;
x = node.x; x = node.x;
y = node.y; y = node.y;
rx = x;
ry = y;
index = _connect == JUNCTION_CONNECT.input? ds_list_size(node.inputs) : ds_list_size(node.outputs); index = _connect == JUNCTION_CONNECT.input? ds_list_size(node.inputs) : ds_list_size(node.outputs);
type = _type; type = _type;
forward = true; forward = true;

View file

@ -1559,7 +1559,7 @@ function Panel_Animation() : PanelContent() constructor {
tx = tool_width - ui(16); tx = tool_width - ui(16);
if(pHOVER && point_in_rectangle(msx, msy, tx - ui(9), ty - ui(10), tx + ui(10), ty + ui(8))) { if(pHOVER && point_in_rectangle(msx, msy, tx - ui(9), ty - ui(10), tx + ui(10), ty + ui(8))) {
draw_sprite_ui_uniform(THEME.timeline_graph, 1, tx, ty, 1, COLORS._main_icon_on_inner, _tool_a); draw_sprite_ui_uniform(THEME.timeline_graph, 1, tx, ty, 1, COLORS._main_icon_on_inner, _tool_a);
TOOLTIP = __txtx("panel_animation_show_graph", "Show graph"); TOOLTIP = _graph_show? __txtx("panel_animation_hide_graph", "Hide graph") : __txtx("panel_animation_show_graph", "Show graph");
if(mouse_press(mb_left, pFOCUS)) { if(mouse_press(mb_left, pFOCUS)) {
if(prop.sep_axis) prop.show_graphs[animator.index] = !_graph_show; if(prop.sep_axis) prop.show_graphs[animator.index] = !_graph_show;

View file

@ -686,6 +686,8 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
menu_node_copy_prop = menuItem(__txtx("panel_graph_copy_prop", "Copy all properties"), function() /*=>*/ { doCopyProp(); }); menu_node_copy_prop = menuItem(__txtx("panel_graph_copy_prop", "Copy all properties"), function() /*=>*/ { doCopyProp(); });
menu_node_paste_prop = menuItem(__txtx("panel_graph_paste_prop", "Paste all properties"), function() /*=>*/ { doPasteProp(); }); menu_node_paste_prop = menuItem(__txtx("panel_graph_paste_prop", "Paste all properties"), function() /*=>*/ { doPasteProp(); });
menu_connection_tunnel = menuItem(__txtx("panel_graph_tunnel", "Create tunnels"), function() /*=>*/ { createTunnel(); });
#region node color #region node color
function setSelectingNodeColor(color) { function setSelectingNodeColor(color) {
__temp_color = color; __temp_color = color;
@ -912,9 +914,8 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
toCenterNode(); toCenterNode();
} #endregion } #endregion
function addContext(node) { #region function addContext(node) {
var _node = node.getNodeBase(); var _node = node.getNodeBase();
setContextFrame(false, _node);
nodes_list = _node.nodes; nodes_list = _node.nodes;
array_push(node_context, _node); array_push(node_context, _node);
@ -923,18 +924,29 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
nodes_selecting = []; nodes_selecting = [];
selection_block = 1; selection_block = 1;
setContextFrame(false, _node);
toCenterNode(); toCenterNode();
} #endregion }
function setContextFrame(dirr, node) { #region function setContextFrame(dirr, node) {
context_framing = true; context_framing = true;
context_frame_direct = dirr; context_frame_direct = dirr;
context_frame_progress = 0; context_frame_progress = 0;
context_frame_sx = w / 2 - 8; context_frame_sx = w / 2 - 8;
context_frame_sy = h / 2 - 8; context_frame_sy = h / 2 - 8;
context_frame_ex = context_frame_sx + 16; context_frame_ex = context_frame_sx + 16;
context_frame_ey = context_frame_sy + 16; context_frame_ey = context_frame_sy + 16;
} #endregion
var gr_x = graph_x * graph_s;
var gr_y = graph_y * graph_s;
context_frame_sx = gr_x + node.x * graph_s;
context_frame_sy = gr_y + node.y * graph_s;
context_frame_ex = context_frame_sx + node.w * graph_s;
context_frame_ey = context_frame_sy + node.h * graph_s;
}
//// ============ Step ============ //// ============ Step ============
@ -1159,11 +1171,13 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
array_push(nodes_selecting, node_hovering); array_push(nodes_selecting, node_hovering);
} else } else
nodes_selecting = []; nodes_selecting = [];
} else if(value_focus || node_hovering == noone) { } else if(value_focus || node_hovering == noone) {
nodes_selecting = []; nodes_selecting = [];
if(DOUBLE_CLICK && !PANEL_INSPECTOR.locked) if(DOUBLE_CLICK && !PANEL_INSPECTOR.locked)
PANEL_INSPECTOR.inspecting = noone; PANEL_INSPECTOR.inspecting = noone;
} else { } else {
if(is_instanceof(node_hovering, Node_Frame)) { if(is_instanceof(node_hovering, Node_Frame)) {
var fx0 = (node_hovering.x + graph_x) * graph_s; var fx0 = (node_hovering.x + graph_x) * graph_s;
@ -1188,6 +1202,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
if(_w && _h && rectangle_inside_rectangle(fx0, fy0, fx1, fy1, _x, _y, _x + _w, _y + _h)) if(_w && _h && rectangle_inside_rectangle(fx0, fy0, fx1, fy1, _x, _y, _x + _w, _y + _h))
array_push_unique(nodes_selecting, _node); array_push_unique(nodes_selecting, _node);
} }
} else if(DOUBLE_CLICK) { } else if(DOUBLE_CLICK) {
PANEL_PREVIEW.setNodePreview(node_hovering); PANEL_PREVIEW.setNodePreview(node_hovering);
@ -1195,6 +1210,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
if(PANEL_INSPECTOR.panel && struct_has(PANEL_INSPECTOR.panel, "switchContent")) if(PANEL_INSPECTOR.panel && struct_has(PANEL_INSPECTOR.panel, "switchContent"))
PANEL_INSPECTOR.panel.switchContent(PANEL_INSPECTOR); PANEL_INSPECTOR.panel.switchContent(PANEL_INSPECTOR);
} }
} else { } else {
var hover_selected = false; var hover_selected = false;
for( var i = 0; i < array_length(nodes_selecting); i++ ) { for( var i = 0; i < array_length(nodes_selecting); i++ ) {
@ -1203,6 +1219,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
hover_selected = true; hover_selected = true;
break; break;
} }
if(!hover_selected) if(!hover_selected)
nodes_selecting = [ node_hovering ]; nodes_selecting = [ node_hovering ];
@ -1235,38 +1252,33 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
if(!sep) { array_push(menu, -1); sep = true; } if(!sep) { array_push(menu, -1); sep = true; }
var _to = value_focus.value_to[i]; var _to = value_focus.value_to[i];
array_push(menu, menuItem($"[{_to.node.display_name}] {_to.getName()}", function(data) { var _lb = $"[{_to.node.display_name}] {_to.getName()}";
data.params.juncTo.removeFrom(); array_push(menu, menuItem(_lb, function(data) /*=>*/ { data.params.juncTo.removeFrom(); }, THEME.cross, noone, noone, { juncTo: _to }));
}, THEME.cross,,, { juncTo: _to }));
} }
for( var i = 0, n = array_length(value_focus.value_to_loop); i < n; i++ ) { for( var i = 0, n = array_length(value_focus.value_to_loop); i < n; i++ ) {
if(!sep) { array_push(menu, -1); sep = true; } if(!sep) { array_push(menu, -1); sep = true; }
var _to = value_focus.value_to_loop[i]; var _to = value_focus.value_to_loop[i];
array_push(menu, menuItem($"[{_to.junc_in.node.display_name}] {_to.junc_in.getName()}", function(data) { var _lb = $"[{_to.junc_in.node.display_name}] {_to.junc_in.getName()}";
data.params.juncTo.destroy(); array_push(menu, menuItem(_lb, function(data) /*=>*/ { data.params.juncTo.destroy(); }, _to.icon_24, noone, noone, { juncTo: _to }));
}, _to.icon_24,,, { juncTo: _to }));
} }
} else { } else {
var sep = false; var sep = false;
var _lb = $"[{_jun.node.display_name}] {_jun.getName()}";
if(value_focus.value_from) { if(value_focus.value_from) {
if(!sep) { array_push(menu, -1); sep = true; } if(!sep) { array_push(menu, -1); sep = true; }
var _jun = value_focus.value_from; var _jun = value_focus.value_from;
array_push(menu, menuItem($"[{_jun.node.display_name}] {_jun.getName()}", function(data) { array_push(menu, menuItem(_lb, function(data) /*=>*/ { __junction_hovering.removeFrom(); }, THEME.cross));
__junction_hovering.removeFrom();
}, THEME.cross));
} }
if(value_focus.value_from_loop) { if(value_focus.value_from_loop) {
if(!sep) { array_push(menu, -1); sep = true; } if(!sep) { array_push(menu, -1); sep = true; }
var _jun = value_focus.value_from_loop.junc_out; var _jun = value_focus.value_from_loop.junc_out;
array_push(menu, menuItem($"[{_jun.node.display_name}] {_jun.getName()}", function(data) { array_push(menu, menuItem(_lb, function(data) /*=>*/ { __junction_hovering.removeFromLoop(); }, value_focus.value_from_loop.icon_24));
__junction_hovering.removeFromLoop();
}, value_focus.value_from_loop.icon_24));
} }
} }
@ -1298,6 +1310,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
array_push(menu, -1, menu_nodes_align, menu_nodes_blend, menu_nodes_compose, menu_nodes_array); array_push(menu, -1, menu_nodes_align, menu_nodes_blend, menu_nodes_compose, menu_nodes_array);
menuCall("graph_node_selected_multiple_menu",,, menu ); menuCall("graph_node_selected_multiple_menu",,, menu );
} else if(node_hover == noone) { } else if(node_hover == noone) {
// print($"Right click not node hover"); // print($"Right click not node hover");
@ -1305,7 +1318,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
__junction_hovering = junction_hovering; __junction_hovering = junction_hovering;
if(junction_hovering != noone) if(junction_hovering != noone)
array_push(menu, menu_junc_color, -1); array_push(menu, menu_junc_color, menu_connection_tunnel, -1);
array_push(menu, menuItem(__txt("Copy"), function() { doCopy(); }, THEME.copy, ["Graph", "Copy"]).setActive(array_length(nodes_selecting))); array_push(menu, menuItem(__txt("Copy"), function() { doCopy(); }, THEME.copy, ["Graph", "Copy"]).setActive(array_length(nodes_selecting)));
array_push(menu, menuItem(__txt("Paste"), function() { doPaste(); }, THEME.paste, ["Graph", "Paste"]).setActive(clipboard_get_text() != "")); array_push(menu, menuItem(__txt("Paste"), function() { doPaste(); }, THEME.paste, ["Graph", "Paste"]).setActive(clipboard_get_text() != ""));
@ -1590,6 +1603,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
nodes_junction_d = junction_hovering; nodes_junction_d = junction_hovering;
nodes_junction_dx = junction_hovering.draw_line_shift_x; nodes_junction_dx = junction_hovering.draw_line_shift_x;
nodes_junction_dy = junction_hovering.draw_line_shift_y; nodes_junction_dy = junction_hovering.draw_line_shift_y;
} else if(array_empty(nodes_selecting) && !value_focus && !drag_locking) { } else if(array_empty(nodes_selecting) && !value_focus && !drag_locking) {
nodes_select_drag = 1; nodes_select_drag = 1;
nodes_select_frame = frame_hovering == noone; nodes_select_frame = frame_hovering == noone;
@ -1907,8 +1921,9 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
node_hover = noone; node_hover = noone;
nodes_selecting = []; nodes_selecting = [];
PANEL_PREVIEW.resetNodePreview(); PANEL_PREVIEW.resetNodePreview();
setContextFrame(true, node_context[i + 1]);
var _nodeFocus = node_context[i + 1]; var _ctx = node_context[i + 1];
var _nodeFocus = _ctx;
if(i == -1) if(i == -1)
resetContext(); resetContext();
@ -1919,6 +1934,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
nodes_selecting = [ _nodeFocus ]; nodes_selecting = [ _nodeFocus ];
toCenterNode(nodes_selecting); toCenterNode(nodes_selecting);
setContextFrame(true, _ctx);
break; break;
} }
@ -2164,14 +2180,16 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
mouse_on_graph = false; mouse_on_graph = false;
} }
function drawContextFrame() { #region function drawContextFrame() {
if(!context_framing) return; if(!context_framing) return;
context_frame_progress = lerp_float(context_frame_progress, 1, 5); context_frame_progress = lerp_float(context_frame_progress, 1, 8);
if(context_frame_progress == 1) if(context_frame_progress == 1)
context_framing = false; context_framing = false;
var _fr_x0 = 0, _fr_y0 = 0; var _fr_x0 = 0;
var _fr_x1 = w, _fr_y1 = h; var _fr_y0 = 0;
var _fr_x1 = w;
var _fr_y1 = h - toolbar_height;
var _to_x0 = context_frame_sx; var _to_x0 = context_frame_sx;
var _to_y0 = context_frame_sy; var _to_y0 = context_frame_sy;
@ -2185,10 +2203,10 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
var frm_y1 = lerp(_fr_y1, _to_y1, prog); var frm_y1 = lerp(_fr_y1, _to_y1, prog);
draw_set_color(COLORS._main_accent); draw_set_color(COLORS._main_accent);
draw_set_alpha(0.5); draw_set_alpha(0.8);
draw_roundrect_ext(frm_x0, frm_y0, frm_x1, frm_y1, THEME_VALUE.panel_corner_radius, THEME_VALUE.panel_corner_radius, true); draw_roundrect_ext(frm_x0, frm_y0, frm_x1, frm_y1, THEME_VALUE.panel_corner_radius, THEME_VALUE.panel_corner_radius, true);
draw_set_alpha(1); draw_set_alpha(1);
} #endregion }
function drawContent(panel) { #region //// Main Draw function drawContent(panel) { #region //// Main Draw
if(!project.active) return; if(!project.active) return;
@ -2860,6 +2878,25 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
} }
} }
function createTunnel() {
if(__junction_hovering == noone) return;
if(__junction_hovering.value_from == noone) return;
var _jo = __junction_hovering.value_from;
var _ji = __junction_hovering;
var _key = $"{__junction_hovering.name} {seed_random(3)}";
var _ti = nodeBuild("Node_Tunnel_In", _jo.rx + 32, _jo.ry);
var _to = nodeBuild("Node_Tunnel_Out", _ji.rx - 32, _ji.ry);
_to.inputs[| 0].setValue(_key);
_ti.inputs[| 0].setValue(_key);
_ti.inputs[| 1].setFrom(_jo);
_ji.setFrom(_to.outputs[| 0]);
}
//// =========== Serialize =========== //// =========== Serialize ===========
static serialize = function() { static serialize = function() {

View file

@ -86,11 +86,9 @@ function Panel_Inspector() : PanelContent() constructor {
drawWidgetInit(); drawWidgetInit();
#region ---- header labels ---- #region ---- header labels ----
tb_node_name = new textBox(TEXTBOX_INPUT.text, function(txt) { tb_node_name = new textBox(TEXTBOX_INPUT.text, function(txt) /*=>*/ { if(inspecting) inspecting.setDisplayName(txt); });
if(inspecting) inspecting.setDisplayName(txt);
})
tb_prop_filter = new textBox(TEXTBOX_INPUT.text, function(txt) { filter_text = txt; }) tb_prop_filter = new textBox(TEXTBOX_INPUT.text, function(txt) /*=>*/ { filter_text = txt; });
tb_prop_filter.no_empty = false; tb_prop_filter.no_empty = false;
tb_prop_filter.auto_update = true; tb_prop_filter.auto_update = true;
tb_prop_filter.font = f_p0; tb_prop_filter.font = f_p0;
@ -99,7 +97,7 @@ function Panel_Inspector() : PanelContent() constructor {
tb_prop_filter.hide = true; tb_prop_filter.hide = true;
filter_text = ""; filter_text = "";
prop_page_button = new buttonGroup([ "Properties", "Settings", THEME.message_16 ], function(val) { prop_page = val; }); prop_page_button = new buttonGroup([ "Properties", "Settings", THEME.message_16 ], function(val) /*=>*/ { prop_page = val; });
prop_page_button.buttonSpr = [ THEME.button_hide_left, THEME.button_hide_middle, THEME.button_hide_right ]; prop_page_button.buttonSpr = [ THEME.button_hide_left, THEME.button_hide_middle, THEME.button_hide_right ];
prop_page_button.font = f_p2; prop_page_button.font = f_p2;
prop_page_button.fColor = COLORS._main_text_sub; prop_page_button.fColor = COLORS._main_text_sub;