diff --git a/#backups/scripts/draw_line_dashed/draw_line_dashed.gml.backup0 b/#backups/scripts/draw_line_dashed/draw_line_dashed.gml.backup0 new file mode 100644 index 000000000..e67683616 --- /dev/null +++ b/#backups/scripts/draw_line_dashed/draw_line_dashed.gml.backup0 @@ -0,0 +1,71 @@ +// 2024-04-22 13:36:52 +function draw_line_dashed(x0, y0, x1, y1, th = 1, dash_distance = 8, dash_shift = 0) { + var dis = point_distance(x0, y0, x1, y1); + var dir = point_direction(x0, y0, x1, y1); + var part = ceil(dis / dash_distance); + + var dx = lengthdir_x(1, dir); + var dy = lengthdir_y(1, dir); + + var ox, oy, nx, ny, od, nd; + var rat = dash_distance / dis; + + for( var i = 0; i <= part; i++ ) { + nd = dis * frac(i * rat + dash_shift / dis); + nx = x0 + dx * nd; + ny = y0 + dy * nd; + + if(i && i % 2 && nd > od) + draw_line_width(ox, oy, nx, ny, th); + + ox = nx; + oy = ny; + od = nd; + } +} + +function draw_line_dashed_color(x0, y0, x1, y1, th, c0, c1, dash_distance = 8) { + var dis = point_distance(x0, y0, x1, y1); + var dir = point_direction(x0, y0, x1, y1); + var part = ceil(dis / dash_distance); + + var dx = lengthdir_x(1, dir); + var dy = lengthdir_y(1, dir); + + var ox, oy, nx, ny, oc, nc; + var dd = 0; + + for( var i = 0; i <= part; i++ ) { + dd = min(dis, i * dash_distance); + nx = x0 + dx * dd; + ny = y0 + dy * dd; + nc = merge_color(c0, c1, i / part); + + if(i % 2) draw_line_width_color(ox, oy, nx, ny, th, oc, nc); + + oc = nc; + ox = nx; + oy = ny; + } +} + +function draw_line_dotted(x0, y0, x1, y1, radius, shift, distanceMulp = 1) { + var dis = point_distance(x0, y0, x1, y1); + var dir = point_direction(x0, y0, x1, y1); + var dtd = radius * distanceMulp * 2; + var part = floor(dis / dtd); + + var dx = lengthdir_x(1, dir); + var dy = lengthdir_y(1, dir); + + var nd, nx, ny; + var rat = dtd / dis; + + for( var i = 0; i < part; i++ ) { + nd = dis * frac(i * rat + shift / dis); + nx = x0 + dx * nd; + ny = y0 + dy * nd; + + draw_circle(nx, ny, radius, false); + } +} \ No newline at end of file diff --git a/#backups/scripts/draw_line_dashed/draw_line_dashed.gml.backup1 b/#backups/scripts/draw_line_dashed/draw_line_dashed.gml.backup1 new file mode 100644 index 000000000..434b666c1 --- /dev/null +++ b/#backups/scripts/draw_line_dashed/draw_line_dashed.gml.backup1 @@ -0,0 +1,71 @@ +// 2024-04-22 13:35:54 +function draw_line_dashed(x0, y0, x1, y1, th = 1, dash_distance = 8, dash_shift = 0) { + var dis = point_distance(x0, y0, x1, y1); + var dir = point_direction(x0, y0, x1, y1); + var part = ceil(dis / dash_distance); + + var dx = lengthdir_x(1, dir); + var dy = lengthdir_y(1, dir); + + var ox, oy, nx, ny, od, nd; + var rat = dash_distance / dis; + + for( var i = 0; i <= part; i++ ) { + nd = dis * frac(i * rat + dash_shift / dis); + nx = x0 + dx * nd; + ny = y0 + dy * nd; + + if(i && i % 2 && nd > od) + draw_line_width(ox, oy, nx, ny, th); + + ox = nx; + oy = ny; + od = nd; + } +} + +function draw_line_dashed_color(x0, y0, x1, y1, th, c0, c1, dash_distance = 8) { + var dis = point_distance(x0, y0, x1, y1); + var dir = point_direction(x0, y0, x1, y1); + var part = ceil(dis / dash_distance); + + var dx = lengthdir_x(1, dir); + var dy = lengthdir_y(1, dir); + + var ox, oy, nx, ny, oc, nc; + var dd = 0; + + for( var i = 0; i <= part; i++ ) { + dd = min(dis, i * dash_distance); + nx = x0 + dx * dd; + ny = y0 + dy * dd; + nc = merge_color(c0, c1, i / part); + + if(i % 2) draw_line_width_color(ox, oy, nx, ny, th, oc, nc); + + oc = nc; + ox = nx; + oy = ny; + } +} + +function draw_line_dotted(x0, y0, x1, y1, radius, shift, distanceMulp = 1) { + var dis = point_distance(x0, y0, x1, y1); + var dir = point_direction(x0, y0, x1, y1); + var dtd = radius * distanceMulp * 2; + var part = floor(dis / dtd); + + var dx = lengthdir_x(1, dir); + var dy = lengthdir_y(1, dir); + + var nd, nx, ny; + var rat = dtd / dis; + + for( var i = 0; i <= part; i++ ) { + nd = dis * frac(i * rat + shift / dis); + nx = x0 + dx * nd; + ny = y0 + dy * nd; + + draw_circle(nx, ny, radius, false); + } +} \ No newline at end of file diff --git a/#backups/scripts/node_pin/node_pin.gml.backup0 b/#backups/scripts/node_pin/node_pin.gml.backup0 index 67855a5c8..7fe2f4b71 100644 --- a/#backups/scripts/node_pin/node_pin.gml.backup0 +++ b/#backups/scripts/node_pin/node_pin.gml.backup0 @@ -1,8 +1,7 @@ -// 2024-04-22 13:04:19 +// 2024-04-22 14:53:29 function Node_Pin(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { name = "Pin"; - w = 32; - h = 32; + setDimension(32, 32); auto_height = false; junction_shift_y = 16; @@ -73,7 +72,6 @@ function Node_Pin(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { } #endregion static drawNode = function(_x, _y, _mx, _my, _s) { #region - // if(group != PANEL_GRAPH.getCurrentContext()) return; var xx = x * _s + _x; var yy = y * _s + _y; @@ -86,7 +84,7 @@ function Node_Pin(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { } if(hover_scale > 0) { - var _r = hover_scale * _s * 24; + var _r = hover_scale * _s * 16; shader_set(sh_node_circle); shader_set_color("color", COLORS._main_accent, hover_alpha); draw_sprite_stretched(s_fx_pixel, 0, xx - _r, yy - _r, _r * 2, _r * 2); @@ -97,8 +95,8 @@ function Node_Pin(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { hover_scale_to = 0; if(renamed && display_name != "" && display_name != "Pin") { - draw_set_text(f_p0, fa_center, fa_bottom, COLORS._main_text); - draw_text_transformed(xx, yy - 12, display_name, _s, _s, 0); + draw_set_text(f_sdf, fa_center, fa_bottom, COLORS._main_text); + draw_text_transformed(xx, yy - 12, display_name, _s * 0.4, _s * 0.4, 0); } return drawJunctions(_x, _y, _mx, _my, _s); diff --git a/#backups/scripts/node_pin/node_pin.gml.backup1 b/#backups/scripts/node_pin/node_pin.gml.backup1 index 134b1482f..30565b760 100644 --- a/#backups/scripts/node_pin/node_pin.gml.backup1 +++ b/#backups/scripts/node_pin/node_pin.gml.backup1 @@ -1,8 +1,7 @@ -// 2024-04-22 13:04:17 +// 2024-04-22 14:45:48 function Node_Pin(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { name = "Pin"; - w = 32; - h = 32; + setDimension(32, 32); auto_height = false; junction_shift_y = 16; @@ -73,7 +72,6 @@ function Node_Pin(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { } #endregion static drawNode = function(_x, _y, _mx, _my, _s) { #region - // if(group != PANEL_GRAPH.getCurrentContext()) return; var xx = x * _s + _x; var yy = y * _s + _y; @@ -86,7 +84,7 @@ function Node_Pin(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { } if(hover_scale > 0) { - var _r = hover_scale * _s * 24; + var _r = hover_scale * _s * 16; shader_set(sh_node_circle); shader_set_color("color", COLORS._main_accent, hover_alpha); draw_sprite_stretched(s_fx_pixel, 0, xx - _r, yy - _r, _r * 2, _r * 2); diff --git a/#backups/scripts/node_tunnel_in/node_tunnel_in.gml.backup0 b/#backups/scripts/node_tunnel_in/node_tunnel_in.gml.backup0 index 57cdf5b46..4125dda86 100644 --- a/#backups/scripts/node_tunnel_in/node_tunnel_in.gml.backup0 +++ b/#backups/scripts/node_tunnel_in/node_tunnel_in.gml.backup0 @@ -1,11 +1,16 @@ -// 2024-04-22 13:08:22 +// 2024-04-22 14:56:06 function Node_Tunnel_In(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { name = "Tunnel In"; color = COLORS.node_blend_tunnel; is_group_io = true; preview_draw = false; - setDimension(96, 80); + setDimension(32, 32); + + isHovering = false; + hover_scale = 0; + hover_scale_to = 0; + hover_alpha = 0; inputs[| 0] = nodeValue("Name", self, JUNCTION_CONNECT.input, VALUE_TYPE.text, "" ) .setDisplay(VALUE_DISPLAY.text_tunnel) @@ -117,11 +122,34 @@ function Node_Tunnel_In(_x, _y, _group = noone) : Node(_x, _y, _group) construct return nodes; } #endregion + ///////////////////////////////////////////////////////////////////////////// + + static pointIn = function(_x, _y, _mx, _my, _s) { #region + var xx = x * _s + _x; + var yy = y * _s + _y; + + return point_in_circle(_mx, _my, xx, yy, _s * 24); + } #endregion + + static preDraw = function(_x, _y, _s) { #region + var xx = x * _s + _x; + var yy = y * _s + _y; + + inputs[| 0].x = xx; + inputs[| 0].y = yy; + + inputs[| 1].x = xx; + inputs[| 1].y = yy; + } #endregion + + static drawBadge = function(_x, _y, _s) {} + static drawJunctionNames = function(_x, _y, _mx, _my, _s) {} + static onDrawNodeBehind = function(_x, _y, _mx, _my, _s) { #region var xx = _x + x * _s; var yy = _y + y * _s; - var hover = PANEL_GRAPH.pHOVER && point_in_rectangle(_mx, _my, xx, yy, xx + w * _s, yy + h * _s); + var hover = isHovering; var tun = findPanel("Panel_Tunnels"); hover |= tun && tun.tunnel_hover == self; if(!hover) return; @@ -129,32 +157,80 @@ function Node_Tunnel_In(_x, _y, _group = noone) : Node(_x, _y, _group) construct var _key = getInputData(0); var amo = ds_map_size(TUNNELS_OUT); var k = ds_map_find_first(TUNNELS_OUT); + + draw_set_color(COLORS.node_blend_tunnel); + repeat(amo) { if(TUNNELS_OUT[? k] == _key && ds_map_exists(PROJECT.nodeMap, k)) { var node = PROJECT.nodeMap[? k]; if(node.group != group) continue; - draw_set_color(COLORS.node_blend_tunnel); - draw_set_alpha(0.35); - var frx = xx + w * _s / 2; - var fry = yy + h * _s / 2; - var tox = _x + (node.x + node.w / 2) * _s; - var toy = _y + (node.y + node.h / 2) * _s; - draw_line_dashed(frx, fry, tox, toy, 8 * _s, 16 * _s, current_time / 10); - draw_set_alpha(1); + var tox = _x + node.x * _s; + var toy = _y + node.y * _s; + draw_line_dotted(xx, yy, tox, toy, 4 * _s, current_time / 10, 2); } k = ds_map_find_next(TUNNELS_OUT, k); } + } #endregion - static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region - draw_set_text(f_sdf, fa_center, fa_center, COLORS._main_text); - var str = string(getInputData(0)); + static drawJunctions = function(_x, _y, _mx, _my, _s) { #region + var xx = x * _s + _x; + var yy = y * _s + _y; + isHovering = point_in_circle(_mx, _my, xx, yy, _s * 24); - var bbox = drawGetBbox(xx, yy, _s); - var ss = string_scale(str, bbox.w, bbox.h); - draw_text_transformed(bbox.xc, bbox.yc, str, ss, ss, 0); + var jhov = inputs[| 1].drawJunction(_s, _mx, _my); + if(!isHovering) return noone; + + hover_scale_to = 1; + return jhov? inputs[| 1] : noone; + } #endregion + + static drawNode = function(_x, _y, _mx, _my, _s) { #region + var xx = x * _s + _x; + var yy = y * _s + _y; + + hover_alpha = 0.5; + if(active_draw_index > -1) { + hover_alpha = 1; + hover_scale_to = 1; + active_draw_index = -1; + } + + shader_set(sh_node_arc); + shader_set_color("color", inputs[| 1].color_display, hover_alpha); + shader_set_f("angle", degtorad(90)); + + var _r = _s * 20; + shader_set_f("amount", 0.4, 0.5); + draw_sprite_stretched(s_fx_pixel, 0, xx - _r, yy - _r, _r * 2, _r * 2); + + var _r = _s * 30; + shader_set_f("amount", 0.45, 0.525); + draw_sprite_stretched(s_fx_pixel, 0, xx - _r, yy - _r, _r * 2, _r * 2); + + var _r = _s * 40; + shader_set_f("amount", 0.475, 0.55); + draw_sprite_stretched(s_fx_pixel, 0, xx - _r, yy - _r, _r * 2, _r * 2); + + shader_reset(); + + if(hover_scale > 0) { + var _r = hover_scale * _s * 16; + shader_set(sh_node_circle); + shader_set_color("color", COLORS._main_accent, hover_alpha); + draw_sprite_stretched(s_fx_pixel, 0, xx - _r, yy - _r, _r * 2, _r * 2); + shader_reset(); + } + + hover_scale = lerp_float(hover_scale, hover_scale_to, 3); + hover_scale_to = 0; + + draw_set_text(f_sdf, fa_center, fa_bottom, COLORS._main_text); + draw_text_transformed(xx, yy - 12, string(getInputData(0)), _s * 0.4, _s * 0.4, 0); + + return drawJunctions(_x, _y, _mx, _my, _s); } #endregion static onClone = function() { onValueUpdate(0); } diff --git a/#backups/scripts/node_tunnel_in/node_tunnel_in.gml.backup1 b/#backups/scripts/node_tunnel_in/node_tunnel_in.gml.backup1 index c5501d650..834ea7c7b 100644 --- a/#backups/scripts/node_tunnel_in/node_tunnel_in.gml.backup1 +++ b/#backups/scripts/node_tunnel_in/node_tunnel_in.gml.backup1 @@ -1,11 +1,16 @@ -// 2024-04-22 13:07:55 +// 2024-04-22 14:56:00 function Node_Tunnel_In(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { name = "Tunnel In"; color = COLORS.node_blend_tunnel; is_group_io = true; preview_draw = false; - setDimension(96, 80); + setDimension(32, 32); + + isHovering = false; + hover_scale = 0; + hover_scale_to = 0; + hover_alpha = 0; inputs[| 0] = nodeValue("Name", self, JUNCTION_CONNECT.input, VALUE_TYPE.text, "" ) .setDisplay(VALUE_DISPLAY.text_tunnel) @@ -34,9 +39,9 @@ function Node_Tunnel_In(_x, _y, _group = noone) : Node(_x, _y, _group) construct static checkDuplicate = function() { #region var _key = getInputData(0); - var amo = ds_map_size(TUNNELS_IN_MAP); - var k = ds_map_find_first(TUNNELS_IN_MAP); - var dup = false; + var amo = ds_map_size(TUNNELS_IN_MAP); + var k = ds_map_find_first(TUNNELS_IN_MAP); + var dup = false; repeat(amo) { if(k != node_id && TUNNELS_IN_MAP[? k] == _key) @@ -117,11 +122,34 @@ function Node_Tunnel_In(_x, _y, _group = noone) : Node(_x, _y, _group) construct return nodes; } #endregion + ///////////////////////////////////////////////////////////////////////////// + + static pointIn = function(_x, _y, _mx, _my, _s) { #region + var xx = x * _s + _x; + var yy = y * _s + _y; + + return point_in_circle(_mx, _my, xx, yy, _s * 24); + } #endregion + + static preDraw = function(_x, _y, _s) { #region + var xx = x * _s + _x; + var yy = y * _s + _y; + + inputs[| 0].x = xx; + inputs[| 0].y = yy; + + inputs[| 1].x = xx; + inputs[| 1].y = yy; + } #endregion + + static drawBadge = function(_x, _y, _s) {} + static drawJunctionNames = function(_x, _y, _mx, _my, _s) {} + static onDrawNodeBehind = function(_x, _y, _mx, _my, _s) { #region var xx = _x + x * _s; var yy = _y + y * _s; - var hover = PANEL_GRAPH.pHOVER && point_in_rectangle(_mx, _my, xx, yy, xx + w * _s, yy + h * _s); + var hover = isHovering; var tun = findPanel("Panel_Tunnels"); hover |= tun && tun.tunnel_hover == self; if(!hover) return; @@ -129,32 +157,80 @@ function Node_Tunnel_In(_x, _y, _group = noone) : Node(_x, _y, _group) construct var _key = getInputData(0); var amo = ds_map_size(TUNNELS_OUT); var k = ds_map_find_first(TUNNELS_OUT); + + draw_set_color(COLORS.node_blend_tunnel); + repeat(amo) { if(TUNNELS_OUT[? k] == _key && ds_map_exists(PROJECT.nodeMap, k)) { var node = PROJECT.nodeMap[? k]; if(node.group != group) continue; - draw_set_color(COLORS.node_blend_tunnel); - draw_set_alpha(0.35); - var frx = xx + w * _s / 2; - var fry = yy + h * _s / 2; - var tox = _x + (node.x + node.w / 2) * _s; - var toy = _y + (node.y + node.h / 2) * _s; - draw_line_dashed(frx, fry, tox, toy, 8 * _s, 16 * _s, current_time / 10); - draw_set_alpha(1); + var tox = _x + node.x * _s; + var toy = _y + node.y * _s; + draw_line_dotted(xx, yy, tox, toy, 4 * _s, current_time / 10, 2); } k = ds_map_find_next(TUNNELS_OUT, k); } + } #endregion - static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region - draw_set_text(f_sdf, fa_center, fa_center, COLORS._main_text); - var str = string(getInputData(0)); + static drawJunctions = function(_x, _y, _mx, _my, _s) { #region + var xx = x * _s + _x; + var yy = y * _s + _y; + isHovering = point_in_circle(_mx, _my, xx, yy, _s * 24); - var bbox = drawGetBbox(xx, yy, _s); - var ss = string_scale(str, bbox.w, bbox.h); - draw_text_transformed(bbox.xc, bbox.yc, str, ss, ss, 0); + var jhov = inputs[| 1].drawJunction(_s, _mx, _my); + if(!isHovering) return noone; + + hover_scale_to = 1; + return jhov? inputs[| 1] : noone; + } #endregion + + static drawNode = function(_x, _y, _mx, _my, _s) { #region + var xx = x * _s + _x; + var yy = y * _s + _y; + + hover_alpha = 0.5; + if(active_draw_index > -1) { + hover_alpha = 1; + hover_scale_to = 1; + active_draw_index = -1; + } + + shader_set(sh_node_arc); + shader_set_color("color", inputs[| 1].color_display, hover_alpha); + shader_set_f("angle", degtorad(90)); + + var _r = _s * 20; + shader_set_f("amount", 0.4, 0.5); + draw_sprite_stretched(s_fx_pixel, 0, xx - _r, yy - _r, _r * 2, _r * 2); + + var _r = _s * 30; + shader_set_f("amount", 0.45, 0.525); + draw_sprite_stretched(s_fx_pixel, 0, xx - _r, yy - _r, _r * 2, _r * 2); + + var _r = _s * 40; + shader_set_f("amount", 0.475, 0.55); + draw_sprite_stretched(s_fx_pixel, 0, xx - _r, yy - _r, _r * 2, _r * 2); + + shader_reset(); + + if(hover_scale > 0) { + var _r = hover_scale * _s * 16; + shader_set(sh_node_circle); + shader_set_color("color", COLORS._main_accent, hover_alpha); + draw_sprite_stretched(s_fx_pixel, 0, xx - _r, yy - _r, _r * 2, _r * 2); + shader_reset(); + } + + hover_scale = lerp_float(hover_scale, hover_scale_to, 3); + hover_scale_to = 0; + + draw_set_text(f_sdf, fa_center, fa_bottom, COLORS._main_text); + draw_text_transformed(xx, yy - 12, string(getInputData(0)), _s * 0.4, _s * 0.4, 0); + + return drawJunctions(_x, _y, _mx, _my, _s); } #endregion static onClone = function() { onValueUpdate(0); } diff --git a/#backups/scripts/node_tunnel_out/node_tunnel_out.gml.backup0 b/#backups/scripts/node_tunnel_out/node_tunnel_out.gml.backup0 new file mode 100644 index 000000000..77cb64432 --- /dev/null +++ b/#backups/scripts/node_tunnel_out/node_tunnel_out.gml.backup0 @@ -0,0 +1,171 @@ +// 2024-04-22 14:54:19 +function Node_Tunnel_Out(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { + name = "Tunnel Out"; + color = COLORS.node_blend_tunnel; + is_group_io = true; + preview_draw = false; + + setDimension(32, 32); + + isHovering = false; + hover_scale = 0; + hover_scale_to = 0; + hover_alpha = 0; + + inputs[| 0] = nodeValue("Name", self, JUNCTION_CONNECT.input, VALUE_TYPE.text, "" ) + .setDisplay(VALUE_DISPLAY.text_tunnel) + .rejectArray(); + + outputs[| 0] = nodeValue("Value out", self, JUNCTION_CONNECT.output, VALUE_TYPE.any, noone ); + + insp2UpdateTooltip = "Goto tunnel in"; + insp2UpdateIcon = [ THEME.tunnel, 1, c_white ]; + + static onInspector2Update = function() { #region + var _key = getInputData(0); + if(!ds_map_exists(TUNNELS_IN, _key)) return; + + var _node = TUNNELS_IN[? _key].node; + graphFocusNode(_node); + } #endregion + + static isRenderable = function() { #region + var _key = getInputData(0); + if(!ds_map_exists(TUNNELS_IN, _key)) return false; + + return TUNNELS_IN[? _key].node.rendered; + } #endregion + + static onValueUpdate = function(index = -1) { #region + var _key = getInputData(0); + + TUNNELS_OUT[? node_id] = _key; + + if(index == 0) { RENDER_ALL_REORDER } + } #endregion + + static step = function() { #region + var _key = getInputData(0); + if(ds_map_exists(TUNNELS_IN, _key)) { + outputs[| 0].setType(TUNNELS_IN[? _key].type); + outputs[| 0].display_type = TUNNELS_IN[? _key].display_type; + } else { + outputs[| 0].setType(VALUE_TYPE.any); + outputs[| 0].display_type = VALUE_DISPLAY._default; + } + } #endregion + + static update = function(frame = CURRENT_FRAME) { #region + var _key = getInputData(0); + + if(ds_map_exists(TUNNELS_IN, _key)) + outputs[| 0].setValue(TUNNELS_IN[? _key].getValue()); + } #endregion + + ///////////////////////////////////////////////////////////////////////////// + + static pointIn = function(_x, _y, _mx, _my, _s) { #region + var xx = x * _s + _x; + var yy = y * _s + _y; + + return point_in_circle(_mx, _my, xx, yy, _s * 24); + } #endregion + + static preDraw = function(_x, _y, _s) { #region + var xx = x * _s + _x; + var yy = y * _s + _y; + + inputs[| 0].x = xx; + inputs[| 0].y = yy; + + outputs[| 0].x = xx; + outputs[| 0].y = yy; + } #endregion + + static drawBadge = function(_x, _y, _s) {} + static drawJunctionNames = function(_x, _y, _mx, _my, _s) {} + + static onDrawNodeBehind = function(_x, _y, _mx, _my, _s) { #region + var xx = _x + x * _s; + var yy = _y + y * _s; + + var hover = isHovering; + var tun = findPanel("Panel_Tunnels"); + hover |= tun && tun.tunnel_hover == self; + if(!hover) return; + + var _key = getInputData(0); + if(!ds_map_exists(TUNNELS_IN, _key)) return; + + var node = TUNNELS_IN[? _key].node; + if(node.group != group) return; + + draw_set_color(COLORS.node_blend_tunnel); + + var frx = _x + node.x * _s; + var fry = _y + node.y * _s; + draw_line_dotted(frx, fry, xx, yy, 4 * _s, current_time / 10, 2); + } #endregion + + static drawJunctions = function(_x, _y, _mx, _my, _s) { #region + var xx = x * _s + _x; + var yy = y * _s + _y; + isHovering = point_in_circle(_mx, _my, xx, yy, _s * 24); + + var jhov = outputs[| 0].drawJunction(_s, _mx, _my); + if(!isHovering) return noone; + + hover_scale_to = 1; + return jhov? inputs[| 1] : noone; + } #endregion + + static drawNode = function(_x, _y, _mx, _my, _s) { #region + var xx = x * _s + _x; + var yy = y * _s + _y; + + hover_alpha = 0.5; + if(active_draw_index > -1) { + hover_alpha = 1; + hover_scale_to = 1; + active_draw_index = -1; + } + + shader_set(sh_node_arc); + shader_set_color("color", outputs[| 0].color_display, hover_alpha); + shader_set_f("angle", degtorad(-90)); + + var _r = _s * 20; + shader_set_f("amount", 0.4, 0.5); + draw_sprite_stretched(s_fx_pixel, 0, xx - _r, yy - _r, _r * 2, _r * 2); + + var _r = _s * 30; + shader_set_f("amount", 0.45, 0.525); + draw_sprite_stretched(s_fx_pixel, 0, xx - _r, yy - _r, _r * 2, _r * 2); + + var _r = _s * 40; + shader_set_f("amount", 0.475, 0.55); + draw_sprite_stretched(s_fx_pixel, 0, xx - _r, yy - _r, _r * 2, _r * 2); + + shader_reset(); + + if(hover_scale > 0) { + var _r = hover_scale * _s * 16; + shader_set(sh_node_circle); + shader_set_color("color", COLORS._main_accent, hover_alpha); + draw_sprite_stretched(s_fx_pixel, 0, xx - _r, yy - _r, _r * 2, _r * 2); + shader_reset(); + } + + hover_scale = lerp_float(hover_scale, hover_scale_to, 3); + hover_scale_to = 0; + + draw_set_text(f_sdf, fa_center, fa_bottom, COLORS._main_text); + draw_text_transformed(xx, yy - 12, string(getInputData(0)), _s * 0.4, _s * 0.4, 0); + + return drawJunctions(_x, _y, _mx, _my, _s); + } #endregion + + static onClone = function() { onValueUpdate(0); } + + static postConnect = function() { onValueUpdate(0); } +} \ No newline at end of file diff --git a/#backups/scripts/node_tunnel_out/node_tunnel_out.gml.backup1 b/#backups/scripts/node_tunnel_out/node_tunnel_out.gml.backup1 new file mode 100644 index 000000000..ecd66c068 --- /dev/null +++ b/#backups/scripts/node_tunnel_out/node_tunnel_out.gml.backup1 @@ -0,0 +1,171 @@ +// 2024-04-22 14:53:30 +function Node_Tunnel_Out(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { + name = "Tunnel Out"; + color = COLORS.node_blend_tunnel; + is_group_io = true; + preview_draw = false; + + setDimension(32, 32); + + isHovering = false; + hover_scale = 0; + hover_scale_to = 0; + hover_alpha = 0; + + inputs[| 0] = nodeValue("Name", self, JUNCTION_CONNECT.input, VALUE_TYPE.text, "" ) + .setDisplay(VALUE_DISPLAY.text_tunnel) + .rejectArray(); + + outputs[| 0] = nodeValue("Value out", self, JUNCTION_CONNECT.output, VALUE_TYPE.any, noone ); + + insp2UpdateTooltip = "Goto tunnel in"; + insp2UpdateIcon = [ THEME.tunnel, 1, c_white ]; + + static onInspector2Update = function() { #region + var _key = getInputData(0); + if(!ds_map_exists(TUNNELS_IN, _key)) return; + + var _node = TUNNELS_IN[? _key].node; + graphFocusNode(_node); + } #endregion + + static isRenderable = function() { #region + var _key = getInputData(0); + if(!ds_map_exists(TUNNELS_IN, _key)) return false; + + return TUNNELS_IN[? _key].node.rendered; + } #endregion + + static onValueUpdate = function(index = -1) { #region + var _key = getInputData(0); + + TUNNELS_OUT[? node_id] = _key; + + if(index == 0) { RENDER_ALL_REORDER } + } #endregion + + static step = function() { #region + var _key = getInputData(0); + if(ds_map_exists(TUNNELS_IN, _key)) { + outputs[| 0].setType(TUNNELS_IN[? _key].type); + outputs[| 0].display_type = TUNNELS_IN[? _key].display_type; + } else { + outputs[| 0].setType(VALUE_TYPE.any); + outputs[| 0].display_type = VALUE_DISPLAY._default; + } + } #endregion + + static update = function(frame = CURRENT_FRAME) { #region + var _key = getInputData(0); + + if(ds_map_exists(TUNNELS_IN, _key)) + outputs[| 0].setValue(TUNNELS_IN[? _key].getValue()); + } #endregion + + ///////////////////////////////////////////////////////////////////////////// + + static pointIn = function(_x, _y, _mx, _my, _s) { #region + var xx = x * _s + _x; + var yy = y * _s + _y; + + return point_in_circle(_mx, _my, xx, yy, _s * 24); + } #endregion + + static preDraw = function(_x, _y, _s) { #region + var xx = x * _s + _x; + var yy = y * _s + _y; + + inputs[| 0].x = xx; + inputs[| 0].y = yy; + + outputs[| 0].x = xx; + outputs[| 0].y = yy; + } #endregion + + static drawBadge = function(_x, _y, _s) {} + static drawJunctionNames = function(_x, _y, _mx, _my, _s) {} + + static onDrawNodeBehind = function(_x, _y, _mx, _my, _s) { #region + var xx = _x + x * _s; + var yy = _y + y * _s; + + var hover = isHovering; + var tun = findPanel("Panel_Tunnels"); + hover |= tun && tun.tunnel_hover == self; + if(!hover) return; + + var _key = getInputData(0); + if(!ds_map_exists(TUNNELS_IN, _key)) return; + + var node = TUNNELS_IN[? _key].node; + if(node.group != group) return; + + draw_set_color(COLORS.node_blend_tunnel); + + var frx = _x + node.x * _s; + var fry = _y + node.y * _s; + draw_line_dotted(frx, fry, xx, yy, 4 * _s, current_time / 10, 3); + } #endregion + + static drawJunctions = function(_x, _y, _mx, _my, _s) { #region + var xx = x * _s + _x; + var yy = y * _s + _y; + isHovering = point_in_circle(_mx, _my, xx, yy, _s * 24); + + var jhov = outputs[| 0].drawJunction(_s, _mx, _my); + if(!isHovering) return noone; + + hover_scale_to = 1; + return jhov? inputs[| 1] : noone; + } #endregion + + static drawNode = function(_x, _y, _mx, _my, _s) { #region + var xx = x * _s + _x; + var yy = y * _s + _y; + + hover_alpha = 0.5; + if(active_draw_index > -1) { + hover_alpha = 1; + hover_scale_to = 1; + active_draw_index = -1; + } + + shader_set(sh_node_arc); + shader_set_color("color", outputs[| 0].color_display, hover_alpha); + shader_set_f("angle", degtorad(-90)); + + var _r = _s * 20; + shader_set_f("amount", 0.4, 0.5); + draw_sprite_stretched(s_fx_pixel, 0, xx - _r, yy - _r, _r * 2, _r * 2); + + var _r = _s * 30; + shader_set_f("amount", 0.45, 0.525); + draw_sprite_stretched(s_fx_pixel, 0, xx - _r, yy - _r, _r * 2, _r * 2); + + var _r = _s * 40; + shader_set_f("amount", 0.475, 0.55); + draw_sprite_stretched(s_fx_pixel, 0, xx - _r, yy - _r, _r * 2, _r * 2); + + shader_reset(); + + if(hover_scale > 0) { + var _r = hover_scale * _s * 16; + shader_set(sh_node_circle); + shader_set_color("color", COLORS._main_accent, hover_alpha); + draw_sprite_stretched(s_fx_pixel, 0, xx - _r, yy - _r, _r * 2, _r * 2); + shader_reset(); + } + + hover_scale = lerp_float(hover_scale, hover_scale_to, 3); + hover_scale_to = 0; + + draw_set_text(f_sdf, fa_center, fa_bottom, COLORS._main_text); + draw_text_transformed(xx, yy - 12, string(getInputData(0)), _s * 0.4, _s * 0.4, 0); + + return drawJunctions(_x, _y, _mx, _my, _s); + } #endregion + + static onClone = function() { onValueUpdate(0); } + + static postConnect = function() { onValueUpdate(0); } +} \ No newline at end of file diff --git a/#backups/shaders/sh_node_arc/sh_node_arc.fsh.backup0 b/#backups/shaders/sh_node_arc/sh_node_arc.fsh.backup0 new file mode 100644 index 000000000..75696c785 --- /dev/null +++ b/#backups/shaders/sh_node_arc/sh_node_arc.fsh.backup0 @@ -0,0 +1,29 @@ +// 2024-04-22 14:26:46 +varying vec2 v_vTexcoord; +varying vec4 v_vColour; + +uniform vec4 color; +uniform float angle; +uniform vec2 amount; + +float sdArc( in vec2 p, in float tb, in float ra, float rb ) { + vec2 sc = vec2(sin(tb), cos(tb)); + p.x = abs(p.x); + + return ((sc.y*p.x>sc.x*p.y) ? length(p-sc*ra) : + abs(length(p)-ra)) - rb; +} + +void main() { + vec2 p = v_vTexcoord - .5; + p *= mat2(cos(angle), -sin(angle), sin(angle), cos(angle)) * 1.5; + + float dist = 1. - sdArc(p, .6, .5, 0.) * 2. - 0.4; + float a; + vec4 c = vec4(0.); + + a = smoothstep(amount.x, amount.y, dist); + c = mix(c, color, a); + + gl_FragColor = c; +} diff --git a/#backups/shaders/sh_node_arc/sh_node_arc.fsh.backup1 b/#backups/shaders/sh_node_arc/sh_node_arc.fsh.backup1 new file mode 100644 index 000000000..411313e20 --- /dev/null +++ b/#backups/shaders/sh_node_arc/sh_node_arc.fsh.backup1 @@ -0,0 +1,29 @@ +// 2024-04-22 14:24:28 +varying vec2 v_vTexcoord; +varying vec4 v_vColour; + +uniform vec4 color; +uniform float angle; +uniform float amount; + +float sdArc( in vec2 p, in float tb, in float ra, float rb ) { + vec2 sc = vec2(sin(tb), cos(tb)); + p.x = abs(p.x); + + return ((sc.y*p.x>sc.x*p.y) ? length(p-sc*ra) : + abs(length(p)-ra)) - rb; +} + +void main() { + vec2 p = v_vTexcoord - .5; + p *= mat2(cos(angle), -sin(angle), sin(angle), cos(angle)) * 1.5; + + float dist = 1. - sdArc(p, .6, .5, 0.) * 2. - 0.4; + float a; + vec4 c = vec4(0.); + + a = smoothstep(amount, amount + 0.1, dist); + c = mix(c, color, a); + + gl_FragColor = c; +} diff --git a/#backups/shaders/sh_node_circle/sh_node_circle.fsh.backup0 b/#backups/shaders/sh_node_circle/sh_node_circle.fsh.backup0 new file mode 100644 index 000000000..d82203d20 --- /dev/null +++ b/#backups/shaders/sh_node_circle/sh_node_circle.fsh.backup0 @@ -0,0 +1,17 @@ +// 2024-04-22 14:55:58 +varying vec2 v_vTexcoord; +varying vec4 v_vColour; + +uniform vec4 color; + +void main() { + float dist = abs(length(v_vTexcoord - .5) * 2. - 0.9); + + float a; + vec4 c = vec4(0.); + + a = smoothstep(.1, .05, dist); + c = mix(c, color, a); + + gl_FragColor = c; +} diff --git a/#backups/shaders/sh_node_circle/sh_node_circle.fsh.backup1 b/#backups/shaders/sh_node_circle/sh_node_circle.fsh.backup1 new file mode 100644 index 000000000..de52c2891 --- /dev/null +++ b/#backups/shaders/sh_node_circle/sh_node_circle.fsh.backup1 @@ -0,0 +1,17 @@ +// 2024-04-22 14:49:52 +varying vec2 v_vTexcoord; +varying vec4 v_vColour; + +uniform vec4 color; + +void main() { + float dist = abs(length(v_vTexcoord - .5) * 2. - 0.9); + + float a; + vec4 c = vec4(0.); + + a = smoothstep(.1, .05, dist); + c = mix(c, color, a); + + gl_FragColor = c; +} diff --git a/PixelComposer.resource_order b/PixelComposer.resource_order index af57c45e9..beb0723a0 100644 --- a/PixelComposer.resource_order +++ b/PixelComposer.resource_order @@ -1370,10 +1370,11 @@ {"name":"sh_mk_tile55_edge_l","order":6,"path":"shaders/sh_mk_tile55_edge_l/sh_mk_tile55_edge_l.yy",}, {"name":"sh_mk_tile55_edge_r","order":7,"path":"shaders/sh_mk_tile55_edge_r/sh_mk_tile55_edge_r.yy",}, {"name":"sh_mk_tile55_edge_t","order":4,"path":"shaders/sh_mk_tile55_edge_t/sh_mk_tile55_edge_t.yy",}, + {"name":"sh_node_circle","order":4,"path":"shaders/sh_node_circle/sh_node_circle.yy",}, + {"name":"sh_node_arc","order":5,"path":"shaders/sh_node_arc/sh_node_arc.yy",}, {"name":"sh_node_widget_rotator","order":1,"path":"shaders/sh_node_widget_rotator/sh_node_widget_rotator.yy",}, {"name":"sh_node_widget_scalar_cross","order":2,"path":"shaders/sh_node_widget_scalar_cross/sh_node_widget_scalar_cross.yy",}, {"name":"sh_node_widget_scalar_line","order":3,"path":"shaders/sh_node_widget_scalar_line/sh_node_widget_scalar_line.yy",}, - {"name":"sh_node_circle","order":4,"path":"shaders/sh_node_circle/sh_node_circle.yy",}, {"name":"sh_noise_bubble","order":2,"path":"shaders/sh_noise_bubble/sh_noise_bubble.yy",}, {"name":"sh_noise_fbm","order":3,"path":"shaders/sh_noise_fbm/sh_noise_fbm.yy",}, {"name":"sh_noise_flow","order":4,"path":"shaders/sh_noise_flow/sh_noise_flow.yy",}, diff --git a/PixelComposer.yyp b/PixelComposer.yyp index d1483fadf..76f94e30a 100644 --- a/PixelComposer.yyp +++ b/PixelComposer.yyp @@ -1897,11 +1897,12 @@ {"id":{"name":"sh_mk_tile55_edge_r","path":"shaders/sh_mk_tile55_edge_r/sh_mk_tile55_edge_r.yy",},}, {"id":{"name":"sh_mk_tile55_edge_t","path":"shaders/sh_mk_tile55_edge_t/sh_mk_tile55_edge_t.yy",},}, {"id":{"name":"sh_morph_surface","path":"shaders/sh_morph_surface/sh_morph_surface.yy",},}, + {"id":{"name":"sh_node_circle","path":"shaders/sh_node_circle/sh_node_circle.yy",},}, + {"id":{"name":"sh_node_arc","path":"shaders/sh_node_arc/sh_node_arc.yy",},}, {"id":{"name":"sh_node_widget_rotator","path":"shaders/sh_node_widget_rotator/sh_node_widget_rotator.yy",},}, {"id":{"name":"sh_node_widget_scalar_cross","path":"shaders/sh_node_widget_scalar_cross/sh_node_widget_scalar_cross.yy",},}, {"id":{"name":"sh_node_widget_scalar_line","path":"shaders/sh_node_widget_scalar_line/sh_node_widget_scalar_line.yy",},}, {"id":{"name":"sh_node_widget_scalar","path":"shaders/sh_node_widget_scalar/sh_node_widget_scalar.yy",},}, - {"id":{"name":"sh_node_circle","path":"shaders/sh_node_circle/sh_node_circle.yy",},}, {"id":{"name":"sh_noise_bubble","path":"shaders/sh_noise_bubble/sh_noise_bubble.yy",},}, {"id":{"name":"sh_noise_fbm","path":"shaders/sh_noise_fbm/sh_noise_fbm.yy",},}, {"id":{"name":"sh_noise_flow","path":"shaders/sh_noise_flow/sh_noise_flow.yy",},}, diff --git a/datafiles/data/Theme.zip b/datafiles/data/Theme.zip index 68470bb5e..349545241 100644 Binary files a/datafiles/data/Theme.zip and b/datafiles/data/Theme.zip differ diff --git a/scripts/draw_line_dashed/draw_line_dashed.gml b/scripts/draw_line_dashed/draw_line_dashed.gml index 3763ca430..b020e23b7 100644 --- a/scripts/draw_line_dashed/draw_line_dashed.gml +++ b/scripts/draw_line_dashed/draw_line_dashed.gml @@ -46,4 +46,25 @@ function draw_line_dashed_color(x0, y0, x1, y1, th, c0, c1, dash_distance = 8) { ox = nx; oy = ny; } +} + +function draw_line_dotted(x0, y0, x1, y1, radius, shift, distanceMulp = 1) { + var dis = point_distance(x0, y0, x1, y1); + var dir = point_direction(x0, y0, x1, y1); + var dtd = radius * distanceMulp * 2; + var part = floor(dis / dtd); + + var dx = lengthdir_x(1, dir); + var dy = lengthdir_y(1, dir); + + var nd, nx, ny; + var rat = dtd / dis; + + for( var i = 0; i < part; i++ ) { + nd = dis * frac(i * rat + shift / dis); + nx = x0 + dx * nd; + ny = y0 + dy * nd; + + draw_circle(nx, ny, radius, false); + } } \ No newline at end of file diff --git a/scripts/node_pin/node_pin.gml b/scripts/node_pin/node_pin.gml index e2093a8e5..695ec9da4 100644 --- a/scripts/node_pin/node_pin.gml +++ b/scripts/node_pin/node_pin.gml @@ -1,7 +1,6 @@ function Node_Pin(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { name = "Pin"; - w = 32; - h = 32; + setDimension(32, 32); auto_height = false; junction_shift_y = 16; @@ -72,7 +71,6 @@ function Node_Pin(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { } #endregion static drawNode = function(_x, _y, _mx, _my, _s) { #region - // if(group != PANEL_GRAPH.getCurrentContext()) return; var xx = x * _s + _x; var yy = y * _s + _y; @@ -85,7 +83,7 @@ function Node_Pin(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { } if(hover_scale > 0) { - var _r = hover_scale * _s * 24; + var _r = hover_scale * _s * 16; shader_set(sh_node_circle); shader_set_color("color", COLORS._main_accent, hover_alpha); draw_sprite_stretched(s_fx_pixel, 0, xx - _r, yy - _r, _r * 2, _r * 2); @@ -96,8 +94,8 @@ function Node_Pin(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { hover_scale_to = 0; if(renamed && display_name != "" && display_name != "Pin") { - draw_set_text(f_p0, fa_center, fa_bottom, COLORS._main_text); - draw_text_transformed(xx, yy - 12, display_name, _s, _s, 0); + draw_set_text(f_sdf, fa_center, fa_bottom, COLORS._main_text); + draw_text_transformed(xx, yy - 12, display_name, _s * 0.4, _s * 0.4, 0); } return drawJunctions(_x, _y, _mx, _my, _s); diff --git a/scripts/node_tunnel_in/node_tunnel_in.gml b/scripts/node_tunnel_in/node_tunnel_in.gml index 552576815..d12668726 100644 --- a/scripts/node_tunnel_in/node_tunnel_in.gml +++ b/scripts/node_tunnel_in/node_tunnel_in.gml @@ -4,7 +4,12 @@ function Node_Tunnel_In(_x, _y, _group = noone) : Node(_x, _y, _group) construct is_group_io = true; preview_draw = false; - setDimension(96, 80); + setDimension(32, 32); + + isHovering = false; + hover_scale = 0; + hover_scale_to = 0; + hover_alpha = 0; inputs[| 0] = nodeValue("Name", self, JUNCTION_CONNECT.input, VALUE_TYPE.text, "" ) .setDisplay(VALUE_DISPLAY.text_tunnel) @@ -116,11 +121,34 @@ function Node_Tunnel_In(_x, _y, _group = noone) : Node(_x, _y, _group) construct return nodes; } #endregion + ///////////////////////////////////////////////////////////////////////////// + + static pointIn = function(_x, _y, _mx, _my, _s) { #region + var xx = x * _s + _x; + var yy = y * _s + _y; + + return point_in_circle(_mx, _my, xx, yy, _s * 24); + } #endregion + + static preDraw = function(_x, _y, _s) { #region + var xx = x * _s + _x; + var yy = y * _s + _y; + + inputs[| 0].x = xx; + inputs[| 0].y = yy; + + inputs[| 1].x = xx; + inputs[| 1].y = yy; + } #endregion + + static drawBadge = function(_x, _y, _s) {} + static drawJunctionNames = function(_x, _y, _mx, _my, _s) {} + static onDrawNodeBehind = function(_x, _y, _mx, _my, _s) { #region var xx = _x + x * _s; var yy = _y + y * _s; - var hover = PANEL_GRAPH.pHOVER && point_in_rectangle(_mx, _my, xx, yy, xx + w * _s, yy + h * _s); + var hover = isHovering; var tun = findPanel("Panel_Tunnels"); hover |= tun && tun.tunnel_hover == self; if(!hover) return; @@ -128,32 +156,80 @@ function Node_Tunnel_In(_x, _y, _group = noone) : Node(_x, _y, _group) construct var _key = getInputData(0); var amo = ds_map_size(TUNNELS_OUT); var k = ds_map_find_first(TUNNELS_OUT); + + draw_set_color(COLORS.node_blend_tunnel); + repeat(amo) { if(TUNNELS_OUT[? k] == _key && ds_map_exists(PROJECT.nodeMap, k)) { var node = PROJECT.nodeMap[? k]; if(node.group != group) continue; - draw_set_color(COLORS.node_blend_tunnel); - draw_set_alpha(0.35); - var frx = xx + w * _s / 2; - var fry = yy + h * _s / 2; - var tox = _x + (node.x + node.w / 2) * _s; - var toy = _y + (node.y + node.h / 2) * _s; - draw_line_dashed(frx, fry, tox, toy, 8 * _s, 16 * _s, current_time / 10); - draw_set_alpha(1); + var tox = _x + node.x * _s; + var toy = _y + node.y * _s; + draw_line_dotted(xx, yy, tox, toy, 4 * _s, current_time / 10, 2); } k = ds_map_find_next(TUNNELS_OUT, k); } + } #endregion - static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region - draw_set_text(f_sdf, fa_center, fa_center, COLORS._main_text); - var str = string(getInputData(0)); + static drawJunctions = function(_x, _y, _mx, _my, _s) { #region + var xx = x * _s + _x; + var yy = y * _s + _y; + isHovering = point_in_circle(_mx, _my, xx, yy, _s * 24); - var bbox = drawGetBbox(xx, yy, _s); - var ss = string_scale(str, bbox.w, bbox.h); - draw_text_transformed(bbox.xc, bbox.yc, str, ss, ss, 0); + var jhov = inputs[| 1].drawJunction(_s, _mx, _my); + if(!isHovering) return noone; + + hover_scale_to = 1; + return jhov? inputs[| 1] : noone; + } #endregion + + static drawNode = function(_x, _y, _mx, _my, _s) { #region + var xx = x * _s + _x; + var yy = y * _s + _y; + + hover_alpha = 0.5; + if(active_draw_index > -1) { + hover_alpha = 1; + hover_scale_to = 1; + active_draw_index = -1; + } + + shader_set(sh_node_arc); + shader_set_color("color", inputs[| 1].color_display, hover_alpha); + shader_set_f("angle", degtorad(90)); + + var _r = _s * 20; + shader_set_f("amount", 0.4, 0.5); + draw_sprite_stretched(s_fx_pixel, 0, xx - _r, yy - _r, _r * 2, _r * 2); + + var _r = _s * 30; + shader_set_f("amount", 0.45, 0.525); + draw_sprite_stretched(s_fx_pixel, 0, xx - _r, yy - _r, _r * 2, _r * 2); + + var _r = _s * 40; + shader_set_f("amount", 0.475, 0.55); + draw_sprite_stretched(s_fx_pixel, 0, xx - _r, yy - _r, _r * 2, _r * 2); + + shader_reset(); + + if(hover_scale > 0) { + var _r = hover_scale * _s * 16; + shader_set(sh_node_circle); + shader_set_color("color", COLORS._main_accent, hover_alpha); + draw_sprite_stretched(s_fx_pixel, 0, xx - _r, yy - _r, _r * 2, _r * 2); + shader_reset(); + } + + hover_scale = lerp_float(hover_scale, hover_scale_to, 3); + hover_scale_to = 0; + + draw_set_text(f_sdf, fa_center, fa_bottom, COLORS._main_text); + draw_text_transformed(xx, yy - 12, string(getInputData(0)), _s * 0.4, _s * 0.4, 0); + + return drawJunctions(_x, _y, _mx, _my, _s); } #endregion static onClone = function() { onValueUpdate(0); } diff --git a/scripts/node_tunnel_out/node_tunnel_out.gml b/scripts/node_tunnel_out/node_tunnel_out.gml index 9be7265e7..6ab62e3d3 100644 --- a/scripts/node_tunnel_out/node_tunnel_out.gml +++ b/scripts/node_tunnel_out/node_tunnel_out.gml @@ -4,7 +4,12 @@ function Node_Tunnel_Out(_x, _y, _group = noone) : Node(_x, _y, _group) construc is_group_io = true; preview_draw = false; - setDimension(96, 80); + setDimension(32, 32); + + isHovering = false; + hover_scale = 0; + hover_scale_to = 0; + hover_alpha = 0; inputs[| 0] = nodeValue("Name", self, JUNCTION_CONNECT.input, VALUE_TYPE.text, "" ) .setDisplay(VALUE_DISPLAY.text_tunnel) @@ -30,31 +35,6 @@ function Node_Tunnel_Out(_x, _y, _group = noone) : Node(_x, _y, _group) construc return TUNNELS_IN[? _key].node.rendered; } #endregion - static onDrawNodeBehind = function(_x, _y, _mx, _my, _s) { #region - var xx = _x + x * _s; - var yy = _y + y * _s; - - var hover = PANEL_GRAPH.pHOVER && point_in_rectangle(_mx, _my, xx, yy, xx + w * _s, yy + h * _s); - var tun = findPanel("Panel_Tunnels"); - hover |= tun && tun.tunnel_hover == self; - if(!hover) return; - - var _key = getInputData(0); - if(!ds_map_exists(TUNNELS_IN, _key)) return; - - var node = TUNNELS_IN[? _key].node; - if(node.group != group) return; - - draw_set_color(COLORS.node_blend_tunnel); - draw_set_alpha(0.35); - var frx = _x + (node.x + node.w / 2) * _s; - var fry = _y + (node.y + node.h / 2) * _s; - var tox = xx + w * _s / 2; - var toy = yy + h * _s / 2; - draw_line_dashed(frx, fry, tox, toy, 8 * _s, 16 * _s, current_time / 10); - draw_set_alpha(1); - } #endregion - static onValueUpdate = function(index = -1) { #region var _key = getInputData(0); @@ -81,13 +61,107 @@ function Node_Tunnel_Out(_x, _y, _group = noone) : Node(_x, _y, _group) construc outputs[| 0].setValue(TUNNELS_IN[? _key].getValue()); } #endregion - static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region - draw_set_text(f_sdf, fa_center, fa_center, COLORS._main_text); - var str = string(getInputData(0)); + ///////////////////////////////////////////////////////////////////////////// + + static pointIn = function(_x, _y, _mx, _my, _s) { #region + var xx = x * _s + _x; + var yy = y * _s + _y; - var bbox = drawGetBbox(xx, yy, _s); - var ss = string_scale(str, bbox.w, bbox.h); - draw_text_transformed(bbox.xc, bbox.yc, str, ss, ss, 0); + return point_in_circle(_mx, _my, xx, yy, _s * 24); + } #endregion + + static preDraw = function(_x, _y, _s) { #region + var xx = x * _s + _x; + var yy = y * _s + _y; + + inputs[| 0].x = xx; + inputs[| 0].y = yy; + + outputs[| 0].x = xx; + outputs[| 0].y = yy; + } #endregion + + static drawBadge = function(_x, _y, _s) {} + static drawJunctionNames = function(_x, _y, _mx, _my, _s) {} + + static onDrawNodeBehind = function(_x, _y, _mx, _my, _s) { #region + var xx = _x + x * _s; + var yy = _y + y * _s; + + var hover = isHovering; + var tun = findPanel("Panel_Tunnels"); + hover |= tun && tun.tunnel_hover == self; + if(!hover) return; + + var _key = getInputData(0); + if(!ds_map_exists(TUNNELS_IN, _key)) return; + + var node = TUNNELS_IN[? _key].node; + if(node.group != group) return; + + draw_set_color(COLORS.node_blend_tunnel); + + var frx = _x + node.x * _s; + var fry = _y + node.y * _s; + draw_line_dotted(frx, fry, xx, yy, 4 * _s, current_time / 10, 2); + } #endregion + + static drawJunctions = function(_x, _y, _mx, _my, _s) { #region + var xx = x * _s + _x; + var yy = y * _s + _y; + isHovering = point_in_circle(_mx, _my, xx, yy, _s * 24); + + var jhov = outputs[| 0].drawJunction(_s, _mx, _my); + if(!isHovering) return noone; + + hover_scale_to = 1; + return jhov? inputs[| 1] : noone; + } #endregion + + static drawNode = function(_x, _y, _mx, _my, _s) { #region + var xx = x * _s + _x; + var yy = y * _s + _y; + + hover_alpha = 0.5; + if(active_draw_index > -1) { + hover_alpha = 1; + hover_scale_to = 1; + active_draw_index = -1; + } + + shader_set(sh_node_arc); + shader_set_color("color", outputs[| 0].color_display, hover_alpha); + shader_set_f("angle", degtorad(-90)); + + var _r = _s * 20; + shader_set_f("amount", 0.4, 0.5); + draw_sprite_stretched(s_fx_pixel, 0, xx - _r, yy - _r, _r * 2, _r * 2); + + var _r = _s * 30; + shader_set_f("amount", 0.45, 0.525); + draw_sprite_stretched(s_fx_pixel, 0, xx - _r, yy - _r, _r * 2, _r * 2); + + var _r = _s * 40; + shader_set_f("amount", 0.475, 0.55); + draw_sprite_stretched(s_fx_pixel, 0, xx - _r, yy - _r, _r * 2, _r * 2); + + shader_reset(); + + if(hover_scale > 0) { + var _r = hover_scale * _s * 16; + shader_set(sh_node_circle); + shader_set_color("color", COLORS._main_accent, hover_alpha); + draw_sprite_stretched(s_fx_pixel, 0, xx - _r, yy - _r, _r * 2, _r * 2); + shader_reset(); + } + + hover_scale = lerp_float(hover_scale, hover_scale_to, 3); + hover_scale_to = 0; + + draw_set_text(f_sdf, fa_center, fa_bottom, COLORS._main_text); + draw_text_transformed(xx, yy - 12, string(getInputData(0)), _s * 0.4, _s * 0.4, 0); + + return drawJunctions(_x, _y, _mx, _my, _s); } #endregion static onClone = function() { onValueUpdate(0); } diff --git a/shaders/sh_node_arc/sh_node_arc.fsh b/shaders/sh_node_arc/sh_node_arc.fsh new file mode 100644 index 000000000..b06589849 --- /dev/null +++ b/shaders/sh_node_arc/sh_node_arc.fsh @@ -0,0 +1,28 @@ +varying vec2 v_vTexcoord; +varying vec4 v_vColour; + +uniform vec4 color; +uniform float angle; +uniform vec2 amount; + +float sdArc( in vec2 p, in float tb, in float ra, float rb ) { + vec2 sc = vec2(sin(tb), cos(tb)); + p.x = abs(p.x); + + return ((sc.y*p.x>sc.x*p.y) ? length(p-sc*ra) : + abs(length(p)-ra)) - rb; +} + +void main() { + vec2 p = v_vTexcoord - .5; + p *= mat2(cos(angle), -sin(angle), sin(angle), cos(angle)) * 1.5; + + float dist = 1. - sdArc(p, .6, .5, 0.) * 2. - 0.4; + float a; + vec4 c = vec4(0.); + + a = smoothstep(amount.x, amount.y, dist); + c = mix(c, color, a); + + gl_FragColor = c; +} diff --git a/shaders/sh_node_arc/sh_node_arc.vsh b/shaders/sh_node_arc/sh_node_arc.vsh new file mode 100644 index 000000000..3900c20f4 --- /dev/null +++ b/shaders/sh_node_arc/sh_node_arc.vsh @@ -0,0 +1,19 @@ +// +// Simple passthrough vertex shader +// +attribute vec3 in_Position; // (x,y,z) +//attribute vec3 in_Normal; // (x,y,z) unused in this shader. +attribute vec4 in_Colour; // (r,g,b,a) +attribute vec2 in_TextureCoord; // (u,v) + +varying vec2 v_vTexcoord; +varying vec4 v_vColour; + +void main() +{ + vec4 object_space_pos = vec4( in_Position.x, in_Position.y, in_Position.z, 1.0); + gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * object_space_pos; + + v_vColour = in_Colour; + v_vTexcoord = in_TextureCoord; +} diff --git a/shaders/sh_node_arc/sh_node_arc.yy b/shaders/sh_node_arc/sh_node_arc.yy new file mode 100644 index 000000000..732cd322b --- /dev/null +++ b/shaders/sh_node_arc/sh_node_arc.yy @@ -0,0 +1,12 @@ +{ + "$GMShader":"", + "%Name":"sh_node_arc", + "name":"sh_node_arc", + "parent":{ + "name":"node", + "path":"folders/widgets/node.yy", + }, + "resourceType":"GMShader", + "resourceVersion":"2.0", + "type":1, +} \ No newline at end of file diff --git a/shaders/sh_node_circle/sh_node_circle.fsh b/shaders/sh_node_circle/sh_node_circle.fsh index 337e9aedf..daf7b0ef7 100644 --- a/shaders/sh_node_circle/sh_node_circle.fsh +++ b/shaders/sh_node_circle/sh_node_circle.fsh @@ -9,7 +9,7 @@ void main() { float a; vec4 c = vec4(0.); - a = smoothstep(.075, .025, dist); + a = smoothstep(.1, .05, dist); c = mix(c, color, a); gl_FragColor = c;