2023-02-28 09:43:01 +01:00
|
|
|
function Node_Pin(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
2023-02-14 05:32:32 +01:00
|
|
|
name = "Pin";
|
2022-01-25 04:05:30 +01:00
|
|
|
w = 32;
|
2022-01-13 05:24:03 +01:00
|
|
|
h = 32;
|
2023-01-17 08:11:55 +01:00
|
|
|
|
2023-10-27 13:55:31 +02:00
|
|
|
auto_height = false;
|
2022-01-13 05:24:03 +01:00
|
|
|
junction_shift_y = 16;
|
2022-01-26 06:57:34 +01:00
|
|
|
|
2023-10-27 13:55:31 +02:00
|
|
|
isHovering = false;
|
|
|
|
hover_scale = 0;
|
2023-10-04 05:52:20 +02:00
|
|
|
hover_scale_to = 0;
|
2023-10-27 13:55:31 +02:00
|
|
|
hover_alpha = 0;
|
2023-03-05 07:16:44 +01:00
|
|
|
|
2023-10-27 13:55:31 +02:00
|
|
|
bg_spr = THEME.node_pin_bg;
|
2022-11-18 03:20:31 +01:00
|
|
|
bg_sel_spr = THEME.node_pin_bg_active;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
inputs[| 0] = nodeValue("In", self, JUNCTION_CONNECT.input, VALUE_TYPE.any, 0 )
|
2022-01-13 05:24:03 +01:00
|
|
|
.setVisible(true, true);
|
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
outputs[| 0] = nodeValue("Out", self, JUNCTION_CONNECT.output, VALUE_TYPE.any, 0);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-10-27 13:55:31 +02:00
|
|
|
static step = function() { #region
|
|
|
|
if(inputs[| 0].isLeaf()) return;
|
2023-10-16 12:54:20 +02:00
|
|
|
|
|
|
|
inputs[| 0].setType(inputs[| 0].value_from.type);
|
|
|
|
outputs[| 0].setType(inputs[| 0].value_from.type);
|
|
|
|
|
|
|
|
inputs[| 0].color_display = inputs[| 0].value_from.color_display;
|
|
|
|
outputs[| 0].color_display = inputs[| 0].color_display;
|
2023-10-27 13:55:31 +02:00
|
|
|
} #endregion
|
2022-01-25 14:13:47 +01:00
|
|
|
|
2023-10-27 13:55:31 +02:00
|
|
|
static update = function() { #region
|
|
|
|
var _val = getInputData(0);
|
|
|
|
outputs[| 0].setValue(_val);
|
|
|
|
} #endregion
|
|
|
|
|
|
|
|
static pointIn = function(_x, _y, _mx, _my, _s) { #region
|
2022-11-01 03:06:03 +01:00
|
|
|
var xx = x * _s + _x;
|
|
|
|
var yy = y * _s + _y;
|
|
|
|
|
2023-03-13 10:45:56 +01:00
|
|
|
return point_in_circle(_mx, _my, xx, yy, _s * 24);
|
2023-10-27 13:55:31 +02:00
|
|
|
} #endregion
|
2022-01-26 06:57:34 +01:00
|
|
|
|
2023-10-27 13:55:31 +02:00
|
|
|
static preDraw = function(_x, _y, _s) { #region
|
2022-01-26 06:57:34 +01:00
|
|
|
var xx = x * _s + _x;
|
|
|
|
var yy = y * _s + _y;
|
|
|
|
|
2023-10-04 05:52:20 +02:00
|
|
|
inputs[| 0].x = xx;
|
2022-01-26 06:57:34 +01:00
|
|
|
inputs[| 0].y = yy;
|
|
|
|
|
2023-10-04 05:52:20 +02:00
|
|
|
outputs[| 0].x = xx;
|
2022-01-26 06:57:34 +01:00
|
|
|
outputs[| 0].y = yy;
|
2023-10-27 13:55:31 +02:00
|
|
|
} #endregion
|
2022-01-26 06:57:34 +01:00
|
|
|
|
2023-10-04 05:52:20 +02:00
|
|
|
static drawJunctionNames = function(_x, _y, _mx, _my, _s) {}
|
|
|
|
|
2023-10-27 13:55:31 +02:00
|
|
|
static drawJunctions = function(_x, _y, _mx, _my, _s) { #region
|
2023-03-05 07:16:44 +01:00
|
|
|
isHovering = false;
|
2022-01-26 06:57:34 +01:00
|
|
|
var hover = noone;
|
2023-03-05 07:16:44 +01:00
|
|
|
var xx = x * _s + _x;
|
|
|
|
var yy = y * _s + _y;
|
|
|
|
var hov = PANEL_GRAPH.value_dragging;
|
|
|
|
|
2023-10-04 05:52:20 +02:00
|
|
|
if(hov == noone && point_in_circle(_mx, _my, xx, yy, _s * 24)) {
|
2023-03-05 07:16:44 +01:00
|
|
|
isHovering = true;
|
2023-10-04 05:52:20 +02:00
|
|
|
hover_scale_to = 1;
|
2023-03-05 07:16:44 +01:00
|
|
|
}
|
2022-01-26 06:57:34 +01:00
|
|
|
|
2023-10-04 05:52:20 +02:00
|
|
|
if(outputs[| 0].drawJunction(_s, _mx, _my))
|
|
|
|
hover = outputs[| 0];
|
2022-01-26 06:57:34 +01:00
|
|
|
|
|
|
|
return hover;
|
2023-10-27 13:55:31 +02:00
|
|
|
} #endregion
|
2022-01-26 06:57:34 +01:00
|
|
|
|
2023-10-27 13:55:31 +02:00
|
|
|
static drawNode = function(_x, _y, _mx, _my, _s) { #region
|
2022-01-26 06:57:34 +01:00
|
|
|
if(group != PANEL_GRAPH.getCurrentContext()) return;
|
|
|
|
|
|
|
|
var xx = x * _s + _x;
|
|
|
|
var yy = y * _s + _y;
|
|
|
|
|
2023-10-04 05:52:20 +02:00
|
|
|
hover_alpha = 0.5;
|
2022-01-26 06:57:34 +01:00
|
|
|
if(active_draw_index > -1) {
|
2023-10-04 05:52:20 +02:00
|
|
|
hover_alpha = 1;
|
|
|
|
hover_scale_to = 1;
|
|
|
|
active_draw_index = -1;
|
2022-01-25 14:13:47 +01:00
|
|
|
}
|
2022-01-26 06:57:34 +01:00
|
|
|
|
2023-10-16 12:54:20 +02:00
|
|
|
if(hover_scale > 0) {
|
|
|
|
draw_set_color(COLORS._main_accent);
|
|
|
|
draw_set_alpha(hover_alpha);
|
|
|
|
draw_circle_border(xx, yy, _s * hover_scale * 20, 2);
|
|
|
|
draw_set_alpha(1);
|
|
|
|
}
|
|
|
|
|
2023-10-04 05:52:20 +02:00
|
|
|
hover_scale = lerp_float(hover_scale, hover_scale_to, 3);
|
|
|
|
hover_scale_to = 0;
|
|
|
|
|
2023-10-01 06:17:39 +02:00
|
|
|
if(renamed && display_name != "" && display_name != "Pin") {
|
2023-01-25 06:49:00 +01:00
|
|
|
draw_set_text(f_p0, fa_center, fa_bottom, COLORS._main_text);
|
2023-02-14 05:32:32 +01:00
|
|
|
draw_text_transformed(xx, yy - 12, display_name, _s, _s, 0);
|
2023-01-25 06:49:00 +01:00
|
|
|
}
|
|
|
|
|
2022-01-26 06:57:34 +01:00
|
|
|
return drawJunctions(_x, _y, _mx, _my, _s);
|
2023-10-27 13:55:31 +02:00
|
|
|
} #endregion
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|