2023-02-28 09:43:01 +01:00
|
|
|
function Node_Boolean(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
|
2023-12-03 05:02:04 +01:00
|
|
|
name = "Boolean";
|
2023-01-09 03:14:20 +01:00
|
|
|
color = COLORS.node_blend_number;
|
2024-03-28 14:18:02 +01:00
|
|
|
setDimension(64, 64);
|
2023-01-09 03:14:20 +01:00
|
|
|
|
2024-03-28 14:18:02 +01:00
|
|
|
hover_state = 0;
|
2023-06-13 21:24:05 +02:00
|
|
|
hover_state_to = 0;
|
2023-01-09 03:14:20 +01:00
|
|
|
|
2023-10-02 08:57:44 +02:00
|
|
|
wd_checkBox = new checkBox( function() { inputs[| 0].setValue(!getInputData(0)); } );
|
2023-03-05 07:16:44 +01:00
|
|
|
wd_checkBox.spr = THEME.node_checkbox;
|
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
inputs[| 0] = nodeValue("Value", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false)
|
2023-01-09 03:14:20 +01:00
|
|
|
.setVisible(true, true);
|
|
|
|
|
2023-06-13 21:24:05 +02:00
|
|
|
inputs[| 1] = nodeValue("Hide Background", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false);
|
|
|
|
|
|
|
|
inputs[| 2] = nodeValue("Name location", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 1)
|
|
|
|
.setDisplay(VALUE_DISPLAY.enum_button, [ "Top", "Bottom" ]);
|
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
outputs[| 0] = nodeValue("Boolean", self, JUNCTION_CONNECT.output, VALUE_TYPE.boolean, false);
|
2023-01-09 03:14:20 +01:00
|
|
|
|
2023-06-13 21:24:05 +02:00
|
|
|
input_display_list = [ 0,
|
|
|
|
["Display", false], 1, 2,
|
|
|
|
]
|
|
|
|
|
2023-08-17 16:56:54 +02:00
|
|
|
static processData = function(_output, _data, _output_index, _array_index = 0) {
|
2023-01-09 03:14:20 +01:00
|
|
|
return _data[0];
|
|
|
|
}
|
|
|
|
|
2023-06-13 21:24:05 +02:00
|
|
|
static pointIn = function(_x, _y, _mx, _my, _s) {
|
2023-10-02 08:57:44 +02:00
|
|
|
var align = getInputData(2);
|
2023-06-13 21:24:05 +02:00
|
|
|
var xx = x * _s + _x;
|
|
|
|
var yy = (y - (!align * 20)) * _s + _y;
|
|
|
|
|
|
|
|
return point_in_rectangle(_mx, _my, xx, yy, xx + w * _s, yy + (h + 20) * _s);
|
|
|
|
}
|
|
|
|
|
|
|
|
static onDrawHover = function(xx, yy, _mx, _my, _s, _hover = false, _focus = false) {
|
|
|
|
hover_state_to = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static drawNodeBase = function(xx, yy, _s) {
|
|
|
|
if(!active) return;
|
2023-10-02 08:57:44 +02:00
|
|
|
var hid = getInputData(1);
|
2023-06-13 21:24:05 +02:00
|
|
|
|
|
|
|
if(hid) {
|
|
|
|
hover_state = lerp_float(hover_state, hover_state_to, 3);
|
|
|
|
hover_state_to = 0;
|
|
|
|
} else
|
|
|
|
hover_state = 1;
|
|
|
|
|
|
|
|
var aa = (0.25 + 0.5 * renderActive) * hover_state;
|
|
|
|
draw_sprite_stretched_ext(bg_spr, 0, xx, yy, w * _s, h * _s, color, aa);
|
|
|
|
}
|
|
|
|
|
|
|
|
static drawNodeName = function(xx, yy, _s) {
|
|
|
|
draw_name = false;
|
|
|
|
if(!active) return;
|
|
|
|
if(_s < 0.75) return;
|
|
|
|
|
2023-11-19 09:05:42 +01:00
|
|
|
var _name = renamed? display_name : name;
|
2023-06-13 21:24:05 +02:00
|
|
|
if(_name == "") return;
|
|
|
|
|
2023-10-02 08:57:44 +02:00
|
|
|
var hid = getInputData(1);
|
|
|
|
var align = getInputData(2);
|
2023-06-13 21:24:05 +02:00
|
|
|
|
|
|
|
if(align == 0) {
|
|
|
|
draw_set_text(f_p2, fa_center, fa_bottom, COLORS._main_text);
|
|
|
|
draw_text_ext_add(xx + w * _s / 2, yy - 2 + hid * ((1 - hover_state) * 8), _name, -1, 128 * _s);
|
|
|
|
} else if(align == 1) {
|
|
|
|
draw_set_text(f_p2, fa_center, fa_top, COLORS._main_text);
|
|
|
|
draw_text_ext_add(xx + w * _s / 2, yy + h * _s - hid * ((1 - hover_state) * 8), _name, -1, 128 * _s);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static drawDimension = function(xx, yy, _s) {}
|
|
|
|
|
2023-03-05 07:16:44 +01:00
|
|
|
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
|
2023-11-23 08:28:04 +01:00
|
|
|
draw_set_text(f_sdf, fa_center, fa_center, COLORS._main_text);
|
2023-10-02 08:57:44 +02:00
|
|
|
var val = getInputData(0);
|
2023-01-09 03:14:20 +01:00
|
|
|
var bbox = drawGetBbox(xx, yy, _s);
|
2023-03-05 07:16:44 +01:00
|
|
|
|
2023-06-21 20:36:53 +02:00
|
|
|
wd_checkBox.setFocusHover(_focus, _hover);
|
2023-06-13 21:24:05 +02:00
|
|
|
wd_checkBox.draw(bbox.xc, bbox.yc, val, [ _mx, _my ], bbox.h - 8 * _s, fa_center, fa_center);
|
2023-01-09 03:14:20 +01:00
|
|
|
}
|
|
|
|
}
|