Pixel-Composer/scripts/node_pin/node_pin.gml

70 lines
1.8 KiB
Plaintext
Raw Normal View History

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";
w = 32;
2022-01-13 05:24:03 +01:00
h = 32;
2023-01-17 08:11:55 +01:00
2022-01-13 05:24:03 +01:00
auto_height = false;
junction_shift_y = 16;
previewable = false;
2022-01-26 06:57:34 +01:00
2022-11-18 03:20:31 +01:00
bg_spr = THEME.node_pin_bg;
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-02-14 05:32:32 +01:00
static update = function(frame = ANIMATOR.current_frame) {
2022-01-25 10:58:11 +01:00
inputs[| 0].type = inputs[| 0].value_from == noone? VALUE_TYPE.any : inputs[| 0].value_from.type;
2022-01-25 14:13:47 +01:00
outputs[| 0].type = inputs[| 0].type;
outputs[| 0].value_from = inputs[| 0].value_from;
2022-01-13 05:24:03 +01:00
}
2022-01-25 14:13:47 +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;
return point_in_circle(_mx, _my, xx, yy, 24);
2022-01-26 06:57:34 +01:00
}
static preDraw = function(_x, _y, _s) {
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;
}
static drawJunctions = function(_x, _y, _mx, _my, _s) {
var hover = noone;
var jun = inputs[| 0].value_from == noone? inputs[| 0] : outputs[| 0];
if(jun.drawJunction(_s, _mx, _my, false))
hover = jun;
return hover;
}
static drawNode = function(_x, _y, _mx, _my, _s) {
if(group != PANEL_GRAPH.getCurrentContext()) return;
var xx = x * _s + _x;
var yy = y * _s + _y;
if(active_draw_index > -1) {
2022-11-21 06:38:44 +01:00
draw_sprite_ext(bg_sel_spr, 0, xx, yy, _s, _s, 0, COLORS._main_accent, 1);
2022-01-26 06:57:34 +01:00
active_draw_index = -1;
2022-01-25 14:13:47 +01:00
}
2022-01-26 06:57:34 +01:00
2023-02-14 05:32:32 +01:00
if(display_name != "") {
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);
2022-01-25 14:13:47 +01:00
}
2022-01-13 05:24:03 +01:00
}