2023-10-04 05:52:20 +02:00
|
|
|
global.__FRAME_LABEL_SCALE = 1;
|
|
|
|
|
2023-02-28 09:43:01 +01:00
|
|
|
function Node_Frame(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
2023-02-14 05:32:32 +01:00
|
|
|
name = "Frame";
|
2022-01-13 05:24:03 +01:00
|
|
|
w = 240;
|
|
|
|
h = 160;
|
2023-11-03 14:43:28 +01:00
|
|
|
alpha = 1;
|
|
|
|
bg_spr = THEME.node_frame_bg;
|
|
|
|
|
|
|
|
size_dragging = false;
|
|
|
|
size_dragging_w = w;
|
|
|
|
size_dragging_h = h;
|
2022-01-13 05:24:03 +01:00
|
|
|
size_dragging_mx = w;
|
|
|
|
size_dragging_my = h;
|
|
|
|
|
2023-11-03 14:43:28 +01:00
|
|
|
auto_height = false;
|
|
|
|
name_hover = false;
|
2023-10-04 05:52:20 +02:00
|
|
|
hover_progress = 0;
|
|
|
|
|
|
|
|
color = c_white;
|
|
|
|
alpha = 1;
|
|
|
|
scale = 1;
|
|
|
|
label_color = false;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
inputs[| 0] = nodeValue("Size", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, [ 240, 160 ] )
|
|
|
|
.setDisplay(VALUE_DISPLAY.vector)
|
|
|
|
.rejectArray();
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
inputs[| 1] = nodeValue("Color", self, JUNCTION_CONNECT.input, VALUE_TYPE.color, c_white )
|
|
|
|
.rejectArray();
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-03-05 07:16:44 +01:00
|
|
|
inputs[| 2] = nodeValue("Alpha", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.75 )
|
2023-10-02 08:57:44 +02:00
|
|
|
.setDisplay(VALUE_DISPLAY.slider)
|
2023-03-05 07:16:44 +01:00
|
|
|
.rejectArray();
|
|
|
|
|
2023-10-04 05:52:20 +02:00
|
|
|
inputs[| 3] = nodeValue("Label size", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, global.__FRAME_LABEL_SCALE )
|
|
|
|
.setDisplay(VALUE_DISPLAY.slider)
|
|
|
|
.rejectArray();
|
|
|
|
|
|
|
|
inputs[| 4] = nodeValue("Blend label", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0 )
|
|
|
|
.setDisplay(VALUE_DISPLAY.slider)
|
|
|
|
.rejectArray();
|
|
|
|
|
2023-11-03 14:43:28 +01:00
|
|
|
static onValueUpdate = function(index = 3) { #region
|
2023-10-04 05:52:20 +02:00
|
|
|
global.__FRAME_LABEL_SCALE = getInputData(3);
|
2023-11-03 14:43:28 +01:00
|
|
|
} #endregion
|
2023-10-04 05:52:20 +02:00
|
|
|
|
2023-11-03 14:43:28 +01:00
|
|
|
static step = function() { #region
|
2023-10-02 08:57:44 +02:00
|
|
|
var si = getInputData(0);
|
2022-01-13 05:24:03 +01:00
|
|
|
w = si[0];
|
|
|
|
h = si[1];
|
|
|
|
|
2023-10-04 05:52:20 +02:00
|
|
|
color = getInputData(1);
|
|
|
|
alpha = getInputData(2);
|
|
|
|
scale = getInputData(3);
|
|
|
|
label_color = getInputData(4);
|
2023-11-03 14:43:28 +01:00
|
|
|
} #endregion
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-11-03 14:43:28 +01:00
|
|
|
static drawNodeBase = function(xx, yy, _s) { #region
|
2023-03-05 07:16:44 +01:00
|
|
|
draw_sprite_stretched_ext(bg_spr, 0, xx, yy, w * _s, h * _s, color, alpha);
|
2023-11-19 09:05:42 +01:00
|
|
|
var txt = renamed? display_name : name;
|
2023-01-17 08:11:55 +01:00
|
|
|
|
2023-10-04 05:52:20 +02:00
|
|
|
hover_progress = lerp_float(hover_progress, name_hover, 2);
|
|
|
|
|
|
|
|
draw_set_text(f_h5, fa_left, fa_top, merge_color(COLORS._main_text, color, label_color));
|
2023-03-05 07:16:44 +01:00
|
|
|
draw_set_alpha(clamp(alpha + name_hover * 0.5, 0, 1));
|
2023-10-04 05:52:20 +02:00
|
|
|
draw_text_cut(xx + 8 + 16 * hover_progress, yy + 4 * _s, txt, (w - 8) * _s - 24, scale);
|
2022-01-13 05:24:03 +01:00
|
|
|
draw_set_alpha(1);
|
2023-11-03 14:43:28 +01:00
|
|
|
} #endregion
|
2022-01-13 05:24:03 +01:00
|
|
|
|
|
|
|
draw_scale = 1;
|
2023-11-03 14:43:28 +01:00
|
|
|
static drawNodeBG = function(_x, _y, _mx, _my, _s) { #region
|
2022-01-13 05:24:03 +01:00
|
|
|
draw_scale = _s;
|
|
|
|
|
|
|
|
if(size_dragging) {
|
|
|
|
w = size_dragging_w + (mouse_mx - size_dragging_mx) / _s;
|
|
|
|
h = size_dragging_h + (mouse_my - size_dragging_my) / _s;
|
2023-03-05 07:16:44 +01:00
|
|
|
if(!key_mod_press(CTRL)) {
|
|
|
|
w = round(w / 32) * 32;
|
|
|
|
h = round(h / 32) * 32;
|
|
|
|
}
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-12-10 05:06:01 +01:00
|
|
|
if(mouse_release(mb_left)) {
|
2022-01-13 05:24:03 +01:00
|
|
|
size_dragging = false;
|
|
|
|
inputs[| 0].setValue([ w, h ]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var xx = x * _s + _x;
|
|
|
|
var yy = y * _s + _y;
|
|
|
|
drawNodeBase(xx, yy, _s);
|
|
|
|
|
|
|
|
if(active_draw_index > -1) {
|
2022-11-21 06:38:44 +01:00
|
|
|
draw_sprite_stretched_ext(bg_sel_spr, 0, x * _s + _x, y * _s + _y, w * _s, h * _s, COLORS._main_accent, 1);
|
2022-01-13 05:24:03 +01:00
|
|
|
active_draw_index = -1;
|
|
|
|
}
|
|
|
|
|
2022-12-12 09:08:03 +01:00
|
|
|
var x1 = xx + w * _s;
|
|
|
|
var y1 = yy + h * _s;
|
2023-03-05 07:16:44 +01:00
|
|
|
var x0 = x1 - 16;
|
|
|
|
var y0 = y1 - 16;
|
|
|
|
var ics = 0.5;
|
|
|
|
|
2023-10-04 05:52:20 +02:00
|
|
|
if(name_hover) draw_sprite_ext(THEME.node_move, 0, xx + 4, yy + 4 * _s, ics, ics * scale, 0, color, 0.4);
|
2023-03-05 07:16:44 +01:00
|
|
|
|
|
|
|
if(point_in_rectangle(_mx, _my, xx, yy, x1, y1) || size_dragging)
|
|
|
|
draw_sprite_ext(THEME.node_resize, 0, x1 - 4, y1 - 4, ics, ics, 0, c_white, 0.5);
|
2023-01-17 08:11:55 +01:00
|
|
|
|
2022-12-12 09:08:03 +01:00
|
|
|
if(!name_hover && point_in_rectangle(_mx, _my, x0, y0, x1, y1)) {
|
2023-03-05 07:16:44 +01:00
|
|
|
draw_sprite_ext(THEME.node_resize, 0, x1 - 4, y1 - 4, ics, ics, 0, c_white, 1);
|
2022-11-01 03:06:03 +01:00
|
|
|
PANEL_GRAPH.drag_locking = true;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-12-10 05:06:01 +01:00
|
|
|
if(mouse_press(mb_left)) {
|
2022-01-13 05:24:03 +01:00
|
|
|
size_dragging = true;
|
|
|
|
size_dragging_w = w;
|
|
|
|
size_dragging_h = h;
|
|
|
|
size_dragging_mx = mouse_mx;
|
|
|
|
size_dragging_my = mouse_my;
|
|
|
|
}
|
|
|
|
}
|
2023-11-16 02:49:52 +01:00
|
|
|
|
|
|
|
return point_in_rectangle(_mx, _my, xx, yy, x1, y1);
|
2023-11-03 14:43:28 +01:00
|
|
|
} #endregion
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-11-03 14:43:28 +01:00
|
|
|
static pointIn = function(_x, _y, _mx, _my, _s) { #region
|
2023-03-05 07:16:44 +01:00
|
|
|
var xx = x * _s + _x;
|
|
|
|
var yy = y * _s + _y;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-11-19 09:05:42 +01:00
|
|
|
var txt = renamed? display_name : name;
|
2023-03-05 07:16:44 +01:00
|
|
|
draw_set_font(f_h5);
|
|
|
|
var ww = string_width(txt) + 24 + 8;
|
|
|
|
var hh = string_height("l") + 8;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-03-05 07:16:44 +01:00
|
|
|
var hover = point_in_rectangle(_mx, _my, xx, yy, xx + ww, yy + hh);
|
2022-01-13 05:24:03 +01:00
|
|
|
name_hover = hover;
|
|
|
|
|
|
|
|
return hover;
|
2023-11-03 14:43:28 +01:00
|
|
|
} #endregion
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|