Pixel-Composer/objects/o_dialog_add_node/Create_0.gml

1071 lines
32 KiB
Text
Raw Normal View History

2022-01-13 05:24:03 +01:00
/// @description init
event_inherited();
#region data
draggable = false;
node_target_x = 0;
node_target_y = 0;
2024-06-11 11:26:00 +02:00
node_target_x_raw = 0;
node_target_y_raw = 0;
node_called = noone;
junction_hovering = noone;
2022-01-13 05:24:03 +01:00
2023-10-31 05:30:42 +01:00
dialog_w = PREFERENCES.dialog_add_node_w;
dialog_h = PREFERENCES.dialog_add_node_h;
2022-01-13 05:24:03 +01:00
destroy_on_click_out = true;
2022-01-18 05:31:19 +01:00
node_selecting = 0;
node_focusing = -1;
2022-01-18 05:31:19 +01:00
2023-02-14 11:40:24 +01:00
node_show_connectable = true;
2023-03-05 07:16:44 +01:00
node_tooltip = noone;
node_tooltip_x = 0;
node_tooltip_y = 0;
2023-02-14 11:40:24 +01:00
anchor = ANCHOR.left | ANCHOR.top;
node_menu_selecting = noone;
2024-05-20 09:24:46 +02:00
display_grid_size = ui(64);
display_grid_size_to = display_grid_size;
display_list_size = ui(28);
display_list_size_to = display_list_size;
2024-05-20 05:16:05 +02:00
right_free = !mouse_click(mb_right);
2023-12-18 13:54:33 +01:00
is_global = PANEL_GRAPH.getCurrentContext() == noone;
#region ---- category ----
category = NODE_CATEGORY;
2023-12-18 08:27:31 +01:00
switch(instanceof(context)) {
2023-10-18 14:58:55 +02:00
case "Node_Pixel_Builder" : category = NODE_PB_CATEGORY; break;
case "Node_DynaSurf" : category = NODE_PCX_CATEGORY; break;
2023-09-11 16:08:58 +02:00
}
draw_set_font(f_p0);
var maxLen = 0;
for(var i = 0; i < ds_list_size(category); i++) {
var cat = category[| i];
2023-06-05 18:27:53 +02:00
2023-12-18 08:27:31 +01:00
if(array_length(cat.filter) && !array_exists(cat.filter, instanceof(context)))
continue;
2023-06-05 18:27:53 +02:00
var name = __txt(cat.name);
maxLen = max(maxLen, string_width(name));
}
2023-11-17 06:24:31 +01:00
category_width = maxLen + ui(56);
#endregion
2023-03-21 03:01:53 +01:00
function rightClick(node) {
2023-10-15 15:04:42 +02:00
if(!is_instanceof(node, NodeObject)) return;
2023-03-21 03:01:53 +01:00
node_menu_selecting = node;
var fav = array_exists(global.FAV_NODES, node.node);
var menu = [
2023-06-05 18:27:53 +02:00
menuItem(fav? __txtx("add_node_remove_favourite", "Remove from favourite") : __txtx("add_node_add_favourite", "Add to favourite"),
function() {
2023-11-22 05:17:13 +01:00
if(!is_array(global.FAV_NODES)) global.FAV_NODES = [];
2023-03-21 03:01:53 +01:00
if(array_exists(global.FAV_NODES, node_menu_selecting.node))
array_remove(global.FAV_NODES, node_menu_selecting.node);
else
array_push(global.FAV_NODES, node_menu_selecting.node);
}, THEME.star)
];
menuCall("add_node_window_manu",,, menu,, node_menu_selecting);
}
2023-03-21 03:01:53 +01:00
function filtered(node) {
2023-02-14 11:40:24 +01:00
if(!node_show_connectable) return true;
if(node_called == noone && junction_hovering == noone) return true;
2023-10-19 11:34:29 +02:00
if(!struct_has(node, "node")) return true;
2023-02-14 11:40:24 +01:00
if(!struct_has(global.NODE_GUIDE, node.node)) return true;
2023-12-18 13:54:33 +01:00
if(is_instanceof(node, NodeObject)) {
if(node.is_patreon_extra && !IS_PATREON) return true;
if(is_global && !node.show_in_global) return true;
}
2023-02-14 11:40:24 +01:00
var io = global.NODE_GUIDE[$ node.node];
if(node_called) {
var call_in = node_called.connect_type == JUNCTION_CONNECT.input;
var ar = call_in? io.outputs : io.inputs;
var typ = node_called.type;
2023-07-25 20:12:40 +02:00
for( var i = 0, n = array_length(ar); i < n; i++ ) {
2023-03-28 06:58:28 +02:00
if(!ar[i].visible) continue;
2023-03-05 07:16:44 +01:00
var _in = call_in? node_called.type : ar[i].type;
var _ot = call_in? ar[i].type : node_called.type;
2023-02-14 11:40:24 +01:00
if(typeCompatible(_in, _ot, false)) return true;
}
return false;
} else if(junction_hovering) {
var to = junction_hovering.type;
var fr = junction_hovering.value_from.type;
2023-07-25 20:12:40 +02:00
for( var i = 0, n = array_length(io.inputs); i < n; i++ ) {
2023-02-14 11:40:24 +01:00
var _in = fr;
2023-03-05 07:16:44 +01:00
var _ot = io.inputs[i].type;
2023-03-28 06:58:28 +02:00
if(!io.inputs[i].visible) continue;
2023-02-14 11:40:24 +01:00
if(typeCompatible(_in, _ot, false)) return true;
}
2023-07-25 20:12:40 +02:00
for( var i = 0, n = array_length(io.outputs); i < n; i++ ) {
2023-03-05 07:16:44 +01:00
var _in = io.outputs[i].type;
2023-02-14 11:40:24 +01:00
var _ot = to;
if(typeCompatible(_in, _ot, false)) return true;
}
return false;
}
return false;
}
2023-02-14 11:40:24 +01:00
function buildNode(_node, _param = {}) {
2024-03-14 14:35:19 +01:00
instance_destroy();
instance_destroy(o_dialog_menubox);
if(!_node) return;
2022-01-13 05:24:03 +01:00
2024-07-02 10:51:52 +02:00
if(is_instanceof(context, Node_Canvas) || is_instanceof(context, Node_Canvas_Group)) {
UNDO_HOLDING = true;
2024-04-21 11:52:16 +02:00
context.nodeTool = new canvas_tool_node(context, _node).init();
UNDO_HOLDING = false;
2024-04-13 14:14:42 +02:00
return;
}
2023-10-15 15:04:42 +02:00
if(is_instanceof(_node, AddNodeItem)) {
_node.onClick({
node_called,
junction_hovering
});
return;
}
2022-09-21 06:09:40 +02:00
var _new_node = noone;
2022-01-25 10:58:11 +01:00
var _inputs = 0, _outputs = 0;
2022-09-21 06:09:40 +02:00
2023-10-15 15:04:42 +02:00
if(is_instanceof(_node, NodeObject)) {
2022-12-16 09:18:09 +01:00
_new_node = _node.build(node_target_x, node_target_y,, _param);
2024-03-14 14:35:19 +01:00
if(!_new_node) return;
2023-01-25 06:49:00 +01:00
if(category == NODE_CATEGORY && _node.show_in_recent) {
2023-07-21 12:40:20 +02:00
array_remove(global.RECENT_NODES, _node.node);
array_insert(global.RECENT_NODES, 0, _node.node);
if(array_length(global.RECENT_NODES) > PREFERENCES.node_recents_amount)
2023-07-21 12:40:20 +02:00
array_pop(global.RECENT_NODES);
}
2023-03-28 06:58:28 +02:00
2023-12-18 08:27:31 +01:00
if(is_instanceof(context, Node_Collection_Inline))
context.addNode(_new_node);
2023-03-28 06:58:28 +02:00
_inputs = _new_node.inputs;
2022-01-25 10:58:11 +01:00
_outputs = _new_node.outputs;
2023-10-15 15:04:42 +02:00
} else if(is_instanceof(_node, NodeAction)) {
2023-08-02 19:11:57 +02:00
var res = _node.build(node_target_x, node_target_y,, _param);
if(_node.inputNode != noone)
2023-10-18 14:58:55 +02:00
_inputs = res[$ _node.inputNode].inputs;
2023-08-02 19:11:57 +02:00
if(_node.outputNode != noone)
2023-10-18 14:58:55 +02:00
_outputs = res[$ _node.outputNode].outputs;
2024-06-26 12:52:24 +02:00
return;
2022-01-25 10:58:11 +01:00
} else {
var _new_list = APPEND(_node.path);
2024-06-09 14:02:37 +02:00
if(_new_list == noone) return;
2023-03-28 06:58:28 +02:00
_inputs = ds_list_create();
2022-01-25 10:58:11 +01:00
_outputs = ds_list_create();
2023-01-25 06:49:00 +01:00
var tx = 99999;
var ty = 99999;
2024-06-09 14:02:37 +02:00
for( var i = 0; i < array_length(_new_list); i++ ) {
tx = min(tx, _new_list[i].x);
ty = min(tx, _new_list[i].y);
2023-12-18 08:27:31 +01:00
2024-06-09 14:02:37 +02:00
if(is_instanceof(context, Node_Collection_Inline) && !is_instanceof(_new_list[i], Node_Collection_Inline))
context.addNode(_new_list[i]);
2023-01-25 06:49:00 +01:00
}
var shx = tx - node_target_x;
var shy = ty - node_target_y;
2024-06-09 14:02:37 +02:00
for( var i = 0; i < array_length(_new_list); i++ ) {
_new_list[i].x -= shx;
_new_list[i].y -= shy;
2023-01-25 06:49:00 +01:00
}
2024-06-09 14:02:37 +02:00
for( var i = 0; i < array_length(_new_list); i++ ) {
var _in = _new_list[i].inputs;
2022-01-25 10:58:11 +01:00
for( var j = 0; j < ds_list_size(_in); j++ ) {
if(_in[| j].value_from == noone)
2022-01-25 10:58:11 +01:00
ds_list_add(_inputs, _in[| j]);
}
2024-06-09 14:02:37 +02:00
var _ot = _new_list[i].outputs;
2022-01-25 10:58:11 +01:00
for( var j = 0; j < ds_list_size(_ot); j++ ) {
2023-12-19 14:30:34 +01:00
if(array_empty(_ot[| j].value_to))
2022-01-25 10:58:11 +01:00
ds_list_add(_outputs, _ot[| j]);
}
}
}
2022-01-13 05:24:03 +01:00
2023-01-25 06:49:00 +01:00
//try to connect
2023-02-14 11:40:24 +01:00
if(node_called != noone) { //dragging from junction
var _call_input = node_called.connect_type == JUNCTION_CONNECT.input;
var _junc_list = _call_input? _outputs : _inputs;
for(var i = 0; i < ds_list_size(_junc_list); i++) {
var _target = _junc_list[| i];
2024-07-04 13:51:04 +02:00
if(!_target.auto_connect) continue;
2023-03-28 06:58:28 +02:00
2024-07-04 13:51:04 +02:00
if(_call_input && node_called.isConnectable(_junc_list[| i]) == 1) {
node_called.setFrom(_junc_list[| i]);
_new_node.x -= _new_node.w;
break;
}
if(!_call_input && _junc_list[| i].isConnectable(node_called) == 1) {
_junc_list[| i].setFrom(node_called);
2022-01-25 10:58:11 +01:00
break;
}
2022-01-25 10:58:11 +01:00
}
2024-07-04 13:51:04 +02:00
2023-02-14 11:40:24 +01:00
} else if(junction_hovering != noone) { //right click on junction
2024-06-11 11:26:00 +02:00
var to = junction_hovering;
2022-01-25 10:58:11 +01:00
var from = junction_hovering.value_from;
2024-06-11 11:26:00 +02:00
2022-01-25 10:58:11 +01:00
for( var i = 0; i < ds_list_size(_inputs); i++ ) {
var _in = _inputs[| i];
2023-02-14 11:40:24 +01:00
if(_in.auto_connect && _in.isConnectable(from)) {
2022-01-25 10:58:11 +01:00
_in.setFrom(from);
break;
}
2022-01-25 10:58:11 +01:00
}
2022-01-25 10:58:11 +01:00
for( var i = 0; i < ds_list_size(_outputs); i++ ) {
var _ot = _outputs[| i];
2023-02-14 11:40:24 +01:00
if(to.isConnectable(_ot)) {
2022-01-25 10:58:11 +01:00
to.setFrom(_ot);
break;
2022-01-13 05:24:03 +01:00
}
}
2024-06-11 11:26:00 +02:00
if(_new_node) {
var _fx = from.node.x, _fy = from.node.y;
var _tx = to.node.x, _ty = to.node.y;
var _ny = node_target_y_raw;
if(_tx > _fx) {
var _rt = abs((_ny - _fy) / (_ty - _fy));
if(_rt < 0.3) _new_node.y = _fy;
else if(_rt > 0.7) {
_new_node.y = _ty;
// _new_node.x = min(_new_node.x, _tx - _new_node.w - 32);
}
}
}
2022-01-13 05:24:03 +01:00
}
}
2022-01-13 05:24:03 +01:00
2024-04-16 10:34:05 +02:00
catagory_pane = new scrollPane(category_width, dialog_h - ui(66), function(_y, _m) { #region catagory_pane
2023-02-14 11:40:24 +01:00
draw_clear_alpha(COLORS._main_text, 0);
2022-01-13 05:24:03 +01:00
2024-04-11 05:51:13 +02:00
var ww = category_width - ui(32);
var hh = 0;
var hg = ui(28);
2022-01-13 05:24:03 +01:00
2023-11-20 13:21:50 +01:00
var start = category == NODE_CATEGORY? -2 : 0;
2023-02-14 11:40:24 +01:00
2023-07-21 12:40:20 +02:00
for(var i = start; i < ds_list_size(category); i++) {
2023-12-22 04:15:04 +01:00
var name = "";
2022-01-23 04:08:16 +01:00
2023-11-20 13:21:50 +01:00
if(i == -2) name = "All";
else if(i == -1) name = "New";
else {
2023-07-21 12:40:20 +02:00
var cat = category[| i];
2024-03-14 14:35:19 +01:00
name = cat.name;
2023-11-16 02:49:52 +01:00
2023-02-14 11:40:24 +01:00
if(array_length(cat.filter)) {
2023-12-18 08:27:31 +01:00
if(!array_exists(cat.filter, instanceof(context))) {
2023-02-14 11:40:24 +01:00
if(ADD_NODE_PAGE == i)
setPage(NODE_PAGE_DEFAULT);
continue;
}
draw_set_color(COLORS._main_text_accent);
}
2024-04-11 05:51:13 +02:00
if(cat.color != noone) {
BLEND_OVERRIDE
draw_sprite_stretched_ext(THEME.ui_panel_bg, 0, 0, _y + hh, ww, hg, merge_color(c_white, cat.color, 0.5), 1);
BLEND_NORMAL
}
2022-01-23 04:08:16 +01:00
}
2023-11-16 02:49:52 +01:00
var _hov = false;
2023-12-22 04:15:04 +01:00
2024-04-11 05:51:13 +02:00
if(sHOVER && catagory_pane.hover && point_in_rectangle(_m[0], _m[1], 0, _y + hh, ww, _y + hh + hg - 1)) {
2023-12-22 04:15:04 +01:00
BLEND_OVERRIDE
2024-04-11 05:51:13 +02:00
draw_sprite_stretched_ext(THEME.ui_panel_bg, 0, 0, _y + hh, ww, hg, CDEF.main_white, 1);
2023-12-22 04:15:04 +01:00
BLEND_NORMAL
2023-11-16 02:49:52 +01:00
_hov = true;
2023-11-14 14:29:11 +01:00
if(i != ADD_NODE_PAGE && mouse_click(mb_left, sFOCUS)) {
2022-12-16 09:18:09 +01:00
setPage(i);
2022-01-13 05:24:03 +01:00
content_pane.scroll_y = 0;
2023-02-14 11:40:24 +01:00
content_pane.scroll_y_raw = 0;
2022-01-13 05:24:03 +01:00
content_pane.scroll_y_to = 0;
}
}
var cc = COLORS._main_text_inner;
switch(name) {
case "All" :
case "New" :
case "Favourites" :
case "Action" :
case "Custom" :
case "Extra" :
2023-11-22 05:17:13 +01:00
cc = merge_color(COLORS._main_text_inner, COLORS._main_text_sub, 0.75);
break;
}
2023-11-13 15:42:14 +01:00
if(i == ADD_NODE_PAGE) draw_set_text(f_p0b, fa_left, fa_center, COLORS._main_text_accent);
2023-12-22 04:15:04 +01:00
else draw_set_text(f_p0, fa_left, fa_center, cc);
2023-11-13 15:42:14 +01:00
2023-11-20 13:21:50 +01:00
var _is_extra = name == "Extra";
2023-06-05 18:27:53 +02:00
name = __txt(name);
2023-11-16 02:49:52 +01:00
var _tx = ui(8);
var _ty = _y + hh + hg / 2;
draw_text(_tx, _ty, name);
if(_is_extra) {
var _cx = _tx + string_width(name) + ui(4);
var _cy = _ty - string_height(name) / 2 + ui(6);
gpu_set_colorwriteenable(1, 1, 1, 0);
draw_sprite_ext(s_patreon_supporter, 0, _cx, _cy, 1, 1, 0, _hov? COLORS._main_icon_dark : COLORS.panel_bg_clear, 1);
gpu_set_colorwriteenable(1, 1, 1, 1);
draw_sprite_ext(s_patreon_supporter, 1, _cx, _cy, 1, 1, 0, i == ADD_NODE_PAGE? COLORS._main_text_accent : cc, 1);
2023-11-16 02:49:52 +01:00
}
2022-01-13 05:24:03 +01:00
hh += hg;
}
return hh;
}); #endregion
2022-01-13 05:24:03 +01:00
2024-04-16 10:34:05 +02:00
content_pane = new scrollPane(dialog_w - category_width - ui(8), dialog_h - ui(66), function(_y, _m) { #region content_pane
2022-09-21 06:09:40 +02:00
draw_clear_alpha(c_white, 0);
2022-12-19 13:35:30 +01:00
var _hover = sHOVER && content_pane.hover;
2023-03-28 06:58:28 +02:00
var _list = node_list;
2023-12-05 13:49:18 +01:00
var hh = 0;
2023-02-14 11:40:24 +01:00
2023-11-20 13:21:50 +01:00
if(ADD_NODE_PAGE == -2) { #region
2023-02-14 11:40:24 +01:00
_list = ds_list_create();
2023-07-21 12:40:20 +02:00
for(var i = 0; i < ds_list_size(category); i++) {
var cat = category[| i];
2023-12-18 08:27:31 +01:00
if(array_length(cat.filter) && !array_exists(cat.filter, instanceof(context)))
2023-02-14 11:40:24 +01:00
continue;
for( var j = 0; j < ds_list_size(cat.list); j++ ) {
2023-12-15 12:56:36 +01:00
//if(is_string(cat.list[| j])) continue;
2023-02-14 11:40:24 +01:00
ds_list_add(_list, cat.list[| j]);
}
}
2023-11-20 05:10:55 +01:00
#endregion
2023-11-20 13:21:50 +01:00
} else if(ADD_NODE_PAGE == -1) { #region
_list = NEW_NODES;
#endregion
2023-11-26 13:16:38 +01:00
} else if(ADD_NODE_PAGE == NODE_PAGE_DEFAULT && category == NODE_CATEGORY) { #region
2023-03-21 03:01:53 +01:00
_list = ds_list_create();
2023-03-28 06:58:28 +02:00
2023-10-09 16:07:33 +02:00
var sug = [];
2023-07-11 14:18:23 +02:00
if(node_called != noone) {
2023-10-09 16:07:33 +02:00
array_append(sug, nodeReleatedQuery(
node_called.connect_type == JUNCTION_CONNECT.input? "connectTo" : "connectFrom",
node_called.type
2023-10-09 16:07:33 +02:00
));
}
2023-12-18 08:27:31 +01:00
array_append(sug, nodeReleatedQuery("context", instanceof(context)));
2023-12-08 12:53:31 +01:00
if(!array_empty(sug)) {
2023-10-09 16:07:33 +02:00
ds_list_add(_list, "Related");
2023-12-09 01:56:17 +01:00
for( var i = 0, n = array_length(sug); i < n; i++ ) {
2024-03-31 05:36:11 +02:00
var k = array_safe_get_fast(sug, i);
2023-12-09 01:56:17 +01:00
if(k == 0) continue;
if(ds_map_exists(ALL_NODES, k))
ds_list_add(_list, ALL_NODES[? k]);
}
2023-07-11 14:18:23 +02:00
}
2023-03-28 06:58:28 +02:00
ds_list_add(_list, "Favourites");
2023-07-25 20:12:40 +02:00
for( var i = 0, n = array_length(global.FAV_NODES); i < n; i++ ) {
2023-03-21 03:01:53 +01:00
var _nodeIndex = global.FAV_NODES[i];
2023-03-30 08:33:53 +02:00
if(!ds_map_exists(ALL_NODES, _nodeIndex)) continue;
var _node = ALL_NODES[? _nodeIndex];
if(_node.show_in_recent)
ds_list_add(_list, _node);
2023-03-21 03:01:53 +01:00
}
2023-03-28 06:58:28 +02:00
ds_list_add(_list, "Recents");
2023-07-25 20:12:40 +02:00
for( var i = 0, n = array_length(global.RECENT_NODES); i < n; i++ ) {
2023-03-28 06:58:28 +02:00
var _nodeIndex = global.RECENT_NODES[i];
2023-03-30 08:33:53 +02:00
if(!ds_map_exists(ALL_NODES, _nodeIndex)) continue;
var _node = ALL_NODES[? _nodeIndex];
if(_node.show_in_recent)
ds_list_add(_list, _node);
2023-03-28 06:58:28 +02:00
}
2023-11-20 05:10:55 +01:00
} #endregion
2023-03-28 06:58:28 +02:00
if(_list == noone) {
setPage(NODE_PAGE_DEFAULT);
return 0;
2023-02-14 11:40:24 +01:00
}
2023-11-20 05:10:55 +01:00
var node_count = ds_list_size(_list);
var group_labels = [];
var _hoverContent = _hover;
2023-06-17 14:30:49 +02:00
2023-11-20 05:10:55 +01:00
if(PREFERENCES.dialog_add_node_view == 0) { #region grid
2024-05-20 05:16:05 +02:00
var grid_size = display_grid_size;
var grid_width = grid_size * 1.25;
2022-11-03 11:44:49 +01:00
var grid_space = ui(12);
2022-09-21 06:09:40 +02:00
var col = floor(content_pane.surface_w / (grid_width + grid_space));
var row = ceil(node_count / col);
var yy = _y + grid_space;
2023-01-01 02:06:02 +01:00
var curr_height = 0;
var cProg = 0;
2022-09-21 06:09:40 +02:00
hh += grid_space;
2023-01-01 02:06:02 +01:00
2023-06-17 14:30:49 +02:00
grid_width = round(content_pane.surface_w - grid_space) / col - grid_space;
2023-03-24 05:55:34 +01:00
2023-01-01 02:06:02 +01:00
for(var index = 0; index < node_count; index++) {
2023-02-14 11:40:24 +01:00
var _node = _list[| index];
2023-10-19 11:34:29 +02:00
if(is_undefined(_node)) continue;
2023-12-18 13:54:33 +01:00
if(is_instanceof(_node, NodeObject)) {
if(_node.is_patreon_extra && !IS_PATREON) continue;
if(is_global && !_node.show_in_global) continue;
}
2023-10-19 11:34:29 +02:00
2023-01-01 02:06:02 +01:00
if(is_string(_node)) {
2023-10-31 05:30:42 +01:00
if(!PREFERENCES.dialog_add_node_grouping)
2023-01-09 03:14:20 +01:00
continue;
2023-01-01 02:06:02 +01:00
hh += curr_height;
yy += curr_height;
2022-01-13 05:24:03 +01:00
2023-01-01 02:06:02 +01:00
cProg = 0;
curr_height = 0;
2024-06-29 05:22:20 +02:00
array_push(group_labels, { y: yy, text: __txt(_node) });
2023-01-01 02:06:02 +01:00
hh += ui(24 + 12);
yy += ui(24 + 12);
continue;
}
2023-02-14 11:40:24 +01:00
if(!filtered(_node)) continue;
2023-01-01 02:06:02 +01:00
var _nx = grid_space + (grid_width + grid_space) * cProg;
var _boxx = _nx + (grid_width - grid_size) / 2;
var cc = c_white;
2024-07-15 10:43:30 +02:00
if(is_instanceof(_node, NodeObject)) cc = c_white;
else if(is_instanceof(_node, NodeAction)) cc = COLORS.add_node_blend_action;
else if(is_instanceof(_node, AddNodeItem)) cc = COLORS.add_node_blend_generic;
else cc = COLORS.dialog_add_node_collection;
2024-07-15 10:43:30 +02:00
if(!struct_try_get(_node, "hide_bg", false)) {
BLEND_OVERRIDE
draw_sprite_stretched_ext(THEME.node_bg, 0, _boxx, yy, grid_size, grid_size, cc, 1);
BLEND_NORMAL
}
2023-01-01 02:06:02 +01:00
2023-11-20 05:10:55 +01:00
if(_hoverContent && point_in_rectangle(_m[0], _m[1], _nx, yy, _nx + grid_width, yy + grid_size)) {
2023-01-01 02:06:02 +01:00
draw_sprite_stretched_ext(THEME.node_active, 0, _boxx, yy, grid_size, grid_size, COLORS._main_accent, 1);
2023-12-22 14:46:54 +01:00
if(mouse_release(mb_left, sFOCUS))
2023-01-01 02:06:02 +01:00
buildNode(_node);
else if(mouse_release(mb_right, right_free && sFOCUS))
2023-03-21 03:01:53 +01:00
rightClick(_node);
2023-01-01 02:06:02 +01:00
}
2023-08-02 19:11:57 +02:00
2023-06-05 18:27:53 +02:00
if(_node.getTooltip() != "") {
2023-03-05 07:16:44 +01:00
if(point_in_rectangle(_m[0], _m[1], _boxx, yy, _boxx + ui(16), yy + ui(16))) {
draw_sprite_ui_uniform(THEME.info, 0, _boxx + ui(8), yy + ui(8), 0.7, COLORS._main_icon, 1.0);
node_tooltip = _node;
node_tooltip_x = content_pane.x + _nx;
node_tooltip_y = content_pane.y + yy;
} else
draw_sprite_ui_uniform(THEME.info, 0, _boxx + ui(8), yy + ui(8), 0.7, COLORS._main_icon, 0.5);
}
2023-04-08 20:06:27 +02:00
2023-10-15 15:04:42 +02:00
if(is_instanceof(_node, NodeObject)) {
_node.drawGrid(_boxx, yy, _m[0], _m[1], grid_size);
} else {
var spr_x = _boxx + grid_size / 2;
var spr_y = yy + grid_size / 2;
if(variable_struct_exists(_node, "getSpr")) _node.getSpr();
if(sprite_exists(_node.spr))
draw_sprite_ui_uniform(_node.spr, 0, spr_x, spr_y, 0.5);
2024-01-24 08:38:57 +01:00
2024-07-15 10:43:30 +02:00
if(is_instanceof(_node, NodeAction) && !struct_try_get(_node, "hide_bg", false))
draw_sprite_ui_uniform(THEME.play_action, 0, _boxx + grid_size - 16, yy + grid_size - 16, 1, COLORS.add_node_blend_action);
2023-10-15 15:04:42 +02:00
}
var _name = _node.getName();
2023-01-01 02:06:02 +01:00
draw_set_text(f_p2, fa_center, fa_top, COLORS._main_text);
draw_text_ext_add(_boxx + grid_size / 2, yy + grid_size + 4, _name, -1, grid_width);
2023-01-01 02:06:02 +01:00
var name_height = string_height_ext(_name, -1, grid_width - 4) + 8;
2023-01-01 02:06:02 +01:00
curr_height = max(curr_height, grid_size + grid_space + name_height);
if(++cProg >= col) {
hh += curr_height;
yy += curr_height;
cProg = 0;
curr_height = 0;
2022-09-21 06:09:40 +02:00
}
2023-01-01 02:06:02 +01:00
}
2023-12-15 12:56:36 +01:00
if(PREFERENCES.dialog_add_node_grouping) {
var len = array_length(group_labels);
if(len) {
gpu_set_blendmode(bm_subtract);
draw_set_color(c_white);
2024-06-29 05:22:20 +02:00
draw_rectangle(0, 0, content_pane.surface_w, ui(36), false);
gpu_set_blendmode(bm_normal);
}
2023-06-17 14:30:49 +02:00
for( var i = 0; i < len; i++ ) {
var lb = group_labels[i];
var _yy = max(lb.y, i == len - 1? ui(8) : min(ui(8), group_labels[i + 1].y - ui(32)));
BLEND_OVERRIDE;
draw_sprite_stretched_ext(THEME.group_label, 0, ui(16), _yy, content_pane.surface_w - ui(32), ui(24), c_white, 0.3);
BLEND_NORMAL;
2023-06-17 14:30:49 +02:00
2024-06-29 05:22:20 +02:00
draw_set_text(f_p2, fa_left, fa_center, CDEF.main_ltgrey);
draw_text_add(ui(16 + 16), _yy + ui(12), lb.text);
}
2023-06-17 14:30:49 +02:00
}
2023-01-01 02:06:02 +01:00
hh += curr_height;
yy += curr_height;
if(sHOVER && key_mod_press(CTRL)) {
2024-05-20 09:24:46 +02:00
if(mouse_wheel_down()) display_grid_size_to = clamp(display_grid_size_to - ui(8), ui(32), ui(128));
if(mouse_wheel_up()) display_grid_size_to = clamp(display_grid_size_to + ui(8), ui(32), ui(128));
}
2024-05-20 09:24:46 +02:00
display_grid_size = lerp_float(display_grid_size, display_grid_size_to, 3);
2023-11-20 05:10:55 +01:00
#endregion
2024-05-20 05:16:05 +02:00
2023-11-20 05:10:55 +01:00
} else if(PREFERENCES.dialog_add_node_view == 1) { #region list
2022-09-21 06:09:40 +02:00
var list_width = content_pane.surface_w;
2024-05-20 05:16:05 +02:00
var list_height = display_list_size;
var yy = _y + list_height / 2;
var bg_ind = 0;
2022-09-21 06:09:40 +02:00
hh += list_height;
2023-02-14 11:40:24 +01:00
2022-09-21 06:09:40 +02:00
for(var i = 0; i < node_count; i++) {
2023-02-14 11:40:24 +01:00
var _node = _list[| i];
2023-10-19 11:34:29 +02:00
if(is_undefined(_node)) continue;
2023-12-18 13:54:33 +01:00
if(is_instanceof(_node, NodeObject)) {
if(_node.is_patreon_extra && !IS_PATREON) continue;
if(is_global && !_node.show_in_global) continue;
}
2023-01-01 02:06:02 +01:00
if(is_string(_node)) {
2023-10-31 05:30:42 +01:00
if(!PREFERENCES.dialog_add_node_grouping)
2023-01-09 03:14:20 +01:00
continue;
2023-01-01 02:06:02 +01:00
hh += ui(8);
yy += ui(8);
2023-06-17 14:30:49 +02:00
array_push(group_labels, {
y: yy,
text: __txt(_node)
});
2023-01-01 02:06:02 +01:00
hh += ui(32);
yy += ui(32);
continue;
}
2022-09-21 06:09:40 +02:00
2023-02-14 11:40:24 +01:00
if(!filtered(_node)) continue;
if(++bg_ind % 2) {
BLEND_OVERRIDE;
draw_sprite_stretched_ext(THEME.node_bg, 0, ui(16), yy, list_width - ui(32), list_height, c_white, 0.1);
2023-02-14 11:40:24 +01:00
BLEND_NORMAL;
2022-09-21 06:09:40 +02:00
}
2023-11-20 05:10:55 +01:00
if(_hoverContent && point_in_rectangle(_m[0], _m[1], 0, yy, list_width, yy + list_height - 1)) {
2023-06-05 18:27:53 +02:00
if(_node.getTooltip() != "") {
2023-03-05 07:16:44 +01:00
node_tooltip = _node;
node_tooltip_x = content_pane.x + ui(16);
2023-03-05 07:16:44 +01:00
node_tooltip_y = content_pane.y + yy
}
draw_sprite_stretched_ext(THEME.node_active, 0, ui(16), yy, list_width - ui(32), list_height, COLORS._main_accent, 1);
2023-12-22 14:46:54 +01:00
if(mouse_release(mb_left, sFOCUS))
2022-09-21 06:09:40 +02:00
buildNode(_node);
else if(mouse_release(mb_right, right_free && sFOCUS))
2023-03-21 03:01:53 +01:00
rightClick(_node);
2022-09-21 06:09:40 +02:00
}
2022-12-27 04:00:50 +01:00
var tx = list_height + ui(52);
2023-03-21 03:01:53 +01:00
if(is_instanceof(_node, NodeObject)) {
tx = _node.drawList(0, yy, _m[0], _m[1], list_height);
} else {
var spr_x = list_height / 2 + ui(44);
var spr_y = yy + list_height / 2;
2023-08-02 19:11:57 +02:00
if(variable_struct_exists(_node, "getSpr")) _node.getSpr();
if(sprite_exists(_node.spr)) {
var ss = (list_height - ui(8)) / max(sprite_get_width(_node.spr), sprite_get_height(_node.spr));
draw_sprite_ext(_node.spr, 0, spr_x, spr_y, ss, ss, 0, c_white, 1);
}
2024-07-15 10:43:30 +02:00
if(is_instanceof(_node, NodeAction) && !struct_try_get(_node, "hide_bg", false))
draw_sprite_ui_uniform(THEME.play_action, 0, spr_x + list_height / 2 - 8, spr_y + list_height / 2 - 8, 0.5, COLORS.add_node_blend_action);
draw_set_text(f_p2, fa_left, fa_center, COLORS._main_text);
draw_text_add(tx, yy + list_height / 2, _node.getName());
}
2022-09-21 06:09:40 +02:00
yy += list_height;
hh += list_height;
2022-01-13 05:24:03 +01:00
}
2023-06-17 14:30:49 +02:00
2023-12-15 12:56:36 +01:00
if(PREFERENCES.dialog_add_node_grouping) {
var len = array_length(group_labels);
if(len) {
gpu_set_blendmode(bm_subtract);
draw_set_color(c_white);
2024-06-29 05:22:20 +02:00
draw_rectangle(0, 0, content_pane.surface_w, ui(36), false);
gpu_set_blendmode(bm_normal);
}
for( var i = 0; i < len; i++ ) {
var lb = group_labels[i];
var _yy = max(lb.y, i == len - 1? ui(8) : min(ui(8), group_labels[i + 1].y - ui(32)));
2023-06-17 14:30:49 +02:00
BLEND_OVERRIDE;
draw_sprite_stretched_ext(THEME.group_label, 0, ui(16), _yy, content_pane.surface_w - ui(32), ui(24), c_white, 0.3);
BLEND_NORMAL;
2023-06-17 14:30:49 +02:00
2024-06-29 05:22:20 +02:00
draw_set_text(f_p2, fa_left, fa_center, CDEF.main_ltgrey);
draw_text_add(ui(16 + 16), _yy + ui(12), lb.text);
}
2023-06-17 14:30:49 +02:00
}
if(sHOVER && key_mod_press(CTRL)) {
2024-05-20 09:24:46 +02:00
if(mouse_wheel_down()) display_list_size_to = clamp(display_list_size_to - ui(4), ui(16), ui(64));
if(mouse_wheel_up()) display_list_size_to = clamp(display_list_size_to + ui(4), ui(16), ui(64));
display_list_size = lerp_float(display_list_size, display_list_size_to, 3);
}
2023-11-20 05:10:55 +01:00
#endregion
2022-01-13 05:24:03 +01:00
}
2022-09-21 06:09:40 +02:00
2023-11-20 13:21:50 +01:00
if(ADD_NODE_PAGE == -2)
2023-02-14 11:40:24 +01:00
ds_list_destroy(_list);
2022-01-13 05:24:03 +01:00
return hh;
}); #endregion
2023-09-14 16:29:39 +02:00
content_pane.always_scroll = true;
2024-03-14 14:35:19 +01:00
#region ---- set page ----
function setPage(pageIndex) {
ADD_NODE_PAGE = min(pageIndex, ds_list_size(category) - 1);
node_list = pageIndex < 0? noone : category[| ADD_NODE_PAGE].list;
}
if(PREFERENCES.add_node_remember) {
content_pane.scroll_y_raw = ADD_NODE_SCROLL;
content_pane.scroll_y_to = ADD_NODE_SCROLL;
} else
ADD_NODE_PAGE = 0;
setPage(ADD_NODE_PAGE);
#endregion
2022-01-13 05:24:03 +01:00
#endregion
#region resize
dialog_resizable = true;
2023-01-17 08:11:55 +01:00
dialog_w_min = ui(320);
dialog_h_min = ui(320);
2022-12-16 09:18:09 +01:00
dialog_w_max = ui(960);
dialog_h_max = ui(800);
2022-01-13 05:24:03 +01:00
onResize = function() {
2023-06-05 18:27:53 +02:00
catagory_pane.resize(category_width, dialog_h - ui(66));
content_pane.resize(dialog_w - category_width - ui(8), dialog_h - ui(66));
2023-03-25 12:27:04 +01:00
search_pane.resize(dialog_w - ui(36), dialog_h - ui(66));
2022-01-13 05:24:03 +01:00
2023-10-31 05:30:42 +01:00
PREFERENCES.dialog_add_node_w = dialog_w;
PREFERENCES.dialog_add_node_h = dialog_h;
2022-01-13 05:24:03 +01:00
}
#endregion
#region search
2023-03-23 06:57:31 +01:00
search_string = "";
search_list = ds_list_create();
KEYBOARD_RESET
2022-01-13 05:24:03 +01:00
tb_search = new textBox(TEXTBOX_INPUT.text, function(str) /*=>*/ { search_string = string(str); searchNodes(); });
2023-02-28 09:43:01 +01:00
tb_search.align = fa_left;
2022-01-13 05:24:03 +01:00
tb_search.auto_update = true;
2023-01-17 08:11:55 +01:00
WIDGET_CURRENT = tb_search;
2022-01-13 05:24:03 +01:00
2024-07-08 04:37:36 +02:00
function searchNodes() {
2022-01-25 10:58:11 +01:00
ds_list_clear(search_list);
2023-02-14 11:40:24 +01:00
var pr_list = ds_priority_create();
2022-01-13 05:24:03 +01:00
var search_lower = string_lower(search_string);
2023-03-23 06:57:31 +01:00
var search_map = ds_map_create();
2022-01-18 05:31:19 +01:00
2023-07-21 12:40:20 +02:00
for(var i = 0; i < ds_list_size(category); i++) {
var cat = category[| i];
2022-01-23 04:08:16 +01:00
2023-04-05 20:13:27 +02:00
if(!struct_has(cat, "list"))
2023-04-04 09:49:33 +02:00
continue;
2023-12-18 08:27:31 +01:00
if(array_length(cat.filter) && !array_exists(cat.filter, instanceof(context)))
2022-12-16 09:18:09 +01:00
continue;
2022-01-13 05:24:03 +01:00
2022-12-16 09:18:09 +01:00
var _content = cat.list;
for(var j = 0; j < ds_list_size(_content); j++) {
var _node = _content[| j];
2022-01-13 05:24:03 +01:00
2024-01-26 14:38:50 +01:00
if(is_string(_node)) continue;
if(ds_map_exists(search_map, _node)) continue;
2023-12-18 13:54:33 +01:00
if(is_instanceof(_node, NodeObject)) {
if(_node.is_patreon_extra && !IS_PATREON) continue;
if(is_global && !_node.show_in_global) continue;
2024-01-26 14:38:50 +01:00
if(_node.deprecated) continue;
2023-12-18 13:54:33 +01:00
}
2022-12-27 04:00:50 +01:00
2023-06-05 18:27:53 +02:00
var match = string_partial_match(string_lower(_node.getName()), search_lower);
var param = "";
2022-01-13 05:24:03 +01:00
for( var k = 0; k < array_length(_node.tags); k++ ) {
2024-07-08 04:37:36 +02:00
var mat = string_partial_match(_node.tags[k], search_lower);
2023-02-14 11:40:24 +01:00
if(mat > match) {
match = mat;
param = _node.tags[k];
}
2022-01-13 05:24:03 +01:00
}
2023-02-14 11:40:24 +01:00
if(match == -9999) continue;
2022-12-27 04:00:50 +01:00
ds_priority_add(pr_list, [ _node, param ], match);
2023-10-15 15:04:42 +02:00
search_map[? _node] = 1;
2022-01-25 10:58:11 +01:00
}
}
2022-12-27 04:00:50 +01:00
ds_map_destroy(search_map);
2023-02-14 11:40:24 +01:00
searchCollection(pr_list, search_string, false);
2023-03-23 06:57:31 +01:00
repeat(ds_priority_size(pr_list))
2023-02-14 11:40:24 +01:00
ds_list_add(search_list, ds_priority_delete_max(pr_list));
ds_priority_destroy(pr_list);
2024-07-08 04:37:36 +02:00
}
2022-01-25 10:58:11 +01:00
2023-03-25 12:27:04 +01:00
search_pane = new scrollPane(dialog_w - ui(36), dialog_h - ui(66), function(_y, _m) {
2022-09-21 06:09:40 +02:00
draw_clear_alpha(c_white, 0);
2022-01-25 10:58:11 +01:00
2023-03-23 06:57:31 +01:00
var equation = string_char_at(search_string, 0) == "=";
var amo = ds_list_size(search_list);
var hh = 0;
var _hover = sHOVER && search_pane.hover;
var grid_size = ui(64);
var grid_width = ui(80);
var grid_space = ui(16);
var highlight = PREFERENCES.dialog_add_node_search_high;
2023-11-20 05:10:55 +01:00
if(equation) { #region
2023-03-23 06:57:31 +01:00
var eq = string_replace(search_string, "=", "");
draw_set_text(f_h5, fa_center, fa_bottom, COLORS._main_text_sub);
2023-06-05 19:41:01 +02:00
draw_text_line(search_pane.w / 2, search_pane.h / 2 - ui(8),
2023-06-05 18:27:53 +02:00
__txtx("add_node_create_equation", "Create equation") + ": " + eq, -1, search_pane.w - ui(32));
2023-03-23 06:57:31 +01:00
draw_set_text(f_p0, fa_center, fa_top, COLORS._main_text_sub);
2023-08-31 18:49:57 +02:00
draw_text_add(round(search_pane.w / 2), round(search_pane.h / 2 - ui(4)),
__txtx("add_node_equation_enter", "Press Enter to create equation node."));
2023-03-23 06:57:31 +01:00
if(keyboard_check_pressed(vk_enter))
2023-09-22 17:01:56 +02:00
buildNode(ALL_NODES[? "Node_Equation"], { query: eq } );
2023-03-23 06:57:31 +01:00
return hh;
2023-11-20 05:10:55 +01:00
} #endregion
2022-01-25 10:58:11 +01:00
2024-05-20 05:16:05 +02:00
if(PREFERENCES.dialog_add_node_view == 0) { // grid
2024-02-16 07:44:36 +01:00
2024-07-15 10:43:30 +02:00
var cc;
2024-07-08 04:37:36 +02:00
var col = floor(search_pane.surface_w / (grid_width + grid_space));
var yy = _y + grid_space;
var index = 0;
2022-09-21 06:09:40 +02:00
var name_height = 0;
2023-03-25 12:27:04 +01:00
grid_width = round(search_pane.surface_w - grid_space) / col - grid_space;
2022-09-21 06:09:40 +02:00
hh += (grid_space + grid_size) * 2;
2022-01-25 10:58:11 +01:00
2022-09-21 06:09:40 +02:00
for(var i = 0; i < amo; i++) {
2024-02-16 07:44:36 +01:00
var s_res = search_list[| i];
var _node = noone;
var _param = {};
var _query = "";
2022-09-21 06:09:40 +02:00
if(is_array(s_res)) {
2024-02-16 07:44:36 +01:00
_node = s_res[0];
2023-09-22 17:01:56 +02:00
_param.query = s_res[1];
2024-02-16 07:44:36 +01:00
_query = s_res[1];
2022-09-21 06:09:40 +02:00
} else
_node = s_res;
2022-01-25 10:58:11 +01:00
2022-09-21 06:09:40 +02:00
var _nx = grid_space + (grid_width + grid_space) * index;
var _boxx = _nx + (grid_width - grid_size) / 2;
2024-07-08 04:37:36 +02:00
var _drw = yy > -grid_size && yy < search_pane.h;
2023-03-05 07:16:44 +01:00
2024-07-08 04:37:36 +02:00
if(_drw) {
2024-07-15 10:43:30 +02:00
if(is_instanceof(_node, NodeObject)) cc = c_white;
else if(is_instanceof(_node, NodeAction)) cc = COLORS.add_node_blend_action;
else if(is_instanceof(_node, AddNodeItem)) cc = COLORS.add_node_blend_generic;
else cc = COLORS.dialog_add_node_collection;
if(!struct_try_get(_node, "hide_bg", false)) {
BLEND_OVERRIDE
draw_sprite_stretched_ext(THEME.node_bg, 0, _boxx, yy, grid_size, grid_size, cc, 1);
BLEND_NORMAL
}
2024-07-08 04:37:36 +02:00
if(_hover && point_in_rectangle(_m[0], _m[1], _nx, yy, _nx + grid_size, yy + grid_size)) {
node_selecting = i;
if(mouse_release(mb_left, sFOCUS))
buildNode(_node, _param);
else if(struct_has(_node, "node") && mouse_release(mb_right, right_free && sFOCUS))
rightClick(_node);
}
if(node_selecting == i) {
draw_sprite_stretched_ext(THEME.node_active, 0, _boxx, yy, grid_size, grid_size, COLORS._main_accent, 1);
if(keyboard_check_pressed(vk_enter))
buildNode(_node, _param);
}
if(struct_has(_node, "tooltip") && _node.getTooltip() != "") {
if(point_in_rectangle(_m[0], _m[1], _boxx, yy, _boxx + ui(16), yy + ui(16))) {
draw_sprite_ui_uniform(THEME.info, 0, _boxx + ui(8), yy + ui(8), 0.7, COLORS._main_icon, 1.0);
node_tooltip = _node;
node_tooltip_x = search_pane.x + _nx;
node_tooltip_y = search_pane.y + yy
} else
draw_sprite_ui_uniform(THEME.info, 0, _boxx + ui(8), yy + ui(8), 0.7, COLORS._main_icon, 0.5);
}
2024-07-08 04:37:36 +02:00
if(is_instanceof(_node, NodeObject)) {
_node.drawGrid(_boxx, yy, _m[0], _m[1], grid_size, _param);
} else {
if(variable_struct_exists(_node, "getSpr")) _node.getSpr();
if(sprite_exists(_node.spr)) {
var _si = current_time * PREFERENCES.collection_preview_speed / 3000;
var _sw = sprite_get_width(_node.spr);
var _sh = sprite_get_height(_node.spr);
var _ss = ui(32) / max(_sw, _sh);
var _sox = sprite_get_xoffset(_node.spr);
var _soy = sprite_get_yoffset(_node.spr);
var _sx = _boxx + grid_size / 2;
var _sy = yy + grid_size / 2;
_sx += _sw * _ss / 2 - _sox * _ss;
_sy += _sh * _ss / 2 - _soy * _ss;
draw_sprite_ext(_node.spr, _si, _sx, _sy, _ss, _ss, 0, c_white, 1);
}
2024-07-15 10:43:30 +02:00
if(is_instanceof(_node, NodeAction) && !struct_try_get(_node, "hide_bg", false))
2024-07-08 04:37:36 +02:00
draw_sprite_ui_uniform(THEME.play_action, 0, _boxx + grid_size - 16, yy + grid_size - 16, 1, COLORS.add_node_blend_action);
}
2023-10-15 15:04:42 +02:00
}
2024-02-16 07:44:36 +01:00
var _name = _node.getName();
2024-07-08 04:37:36 +02:00
var _showQuery = _query != "";
2024-02-16 07:44:36 +01:00
draw_set_font(_showQuery? f_p3 : f_p2);
2024-07-08 04:37:36 +02:00
var _nmh = string_height_ext(_name, -1, grid_width);
var _nmy = yy + grid_size + 4;
var _drw = _nmy > -grid_size && _nmy < search_pane.h;
2024-02-16 07:44:36 +01:00
if(_showQuery) {
_query = string_title(_query);
draw_set_text(f_p3, fa_center, fa_top, COLORS._main_text_sub);
2024-07-08 04:37:36 +02:00
if(_drw) draw_text_ext_add(_boxx + grid_size / 2, _nmy, _name, -1, grid_width);
2024-02-16 07:44:36 +01:00
_nmy += _nmh - ui(2);
draw_set_text(f_p2, fa_center, fa_top, COLORS._main_text);
2024-07-08 04:37:36 +02:00
var _qhh = string_height_ext(_query, -1, grid_width);
if(_drw) {
if(highlight) _qhh = draw_text_match_ext(_boxx + grid_size / 2, _nmy, _query, grid_width, search_string);
else draw_text_ext( _boxx + grid_size / 2, _nmy, _query, -1, grid_width);
}
2024-07-08 04:37:36 +02:00
_nmy += _qhh;
_nmh += _qhh;
2024-02-16 07:44:36 +01:00
} else {
draw_set_text(f_p2, fa_center, fa_top, COLORS._main_text);
if(_drw) {
if(highlight) _nmh = draw_text_match_ext(_boxx + grid_size / 2, _nmy, _name, grid_width, search_string);
else draw_text_ext( _boxx + grid_size / 2, _nmy, _name, -1, grid_width);
}
2024-02-16 07:44:36 +01:00
}
2024-07-08 04:37:36 +02:00
name_height = max(name_height, _nmh);
2023-10-15 15:04:42 +02:00
2022-09-21 06:09:40 +02:00
if(node_focusing == i)
search_pane.scroll_y_to = -max(0, hh - search_pane.h);
2022-01-18 05:31:19 +01:00
2022-09-21 06:09:40 +02:00
if(++index >= col) {
index = 0;
var hght = grid_size + grid_space + name_height;
name_height = 0;
hh += hght;
yy += hght;
}
2022-01-25 10:58:11 +01:00
}
2024-07-08 04:37:36 +02:00
2024-05-20 05:16:05 +02:00
} else if(PREFERENCES.dialog_add_node_view == 1) { // list
2024-02-16 07:44:36 +01:00
2022-09-21 06:09:40 +02:00
var list_width = search_pane.surface_w;
2022-11-03 11:44:49 +01:00
var list_height = ui(28);
2024-07-08 04:37:36 +02:00
var sy = _y + list_height / 2;
hh += list_height * (amo + 1);
2022-09-21 06:09:40 +02:00
for(var i = 0; i < amo; i++) {
2024-02-16 07:44:36 +01:00
var s_res = search_list[| i];
var _node = noone;
var _param = {};
var _query = "";
2024-07-08 04:37:36 +02:00
var yy = sy + list_height * i;
if(yy < -list_height) continue;
if(yy > search_pane.h) break;
_param.search_string = search_string;
2024-02-16 07:44:36 +01:00
2022-09-21 06:09:40 +02:00
if(is_array(s_res)) {
2024-02-16 07:44:36 +01:00
_node = s_res[0];
2023-09-22 17:01:56 +02:00
_param.query = s_res[1];
2024-02-16 07:44:36 +01:00
_query = s_res[1];
2022-09-21 06:09:40 +02:00
} else
_node = s_res;
if(i % 2) {
2023-02-14 11:40:24 +01:00
BLEND_OVERRIDE;
2022-11-18 03:20:31 +01:00
draw_sprite_stretched_ext(THEME.node_bg, 0, ui(4), yy, list_width - ui(8), list_height, c_white, 0.2);
2023-02-14 11:40:24 +01:00
BLEND_NORMAL;
2022-09-21 06:09:40 +02:00
}
2022-12-19 13:35:30 +01:00
if(_hover && point_in_rectangle(_m[0], _m[1], 0, yy, list_width, yy + list_height - 1)) {
2023-06-05 18:27:53 +02:00
if(struct_has(_node, "tooltip") && _node.getTooltip() != "") {
2023-03-05 07:16:44 +01:00
node_tooltip = _node;
node_tooltip_x = search_pane.x + 0;
node_tooltip_y = search_pane.y + yy
}
2022-09-21 06:09:40 +02:00
node_selecting = i;
2023-12-22 14:46:54 +01:00
if(mouse_release(mb_left, sFOCUS))
2022-09-21 06:09:40 +02:00
buildNode(_node, _param);
else if(struct_has(_node, "node") && mouse_release(mb_right, right_free && sFOCUS))
2023-03-21 03:01:53 +01:00
rightClick(_node);
2022-09-21 06:09:40 +02:00
}
if(node_selecting == i) {
2022-11-21 06:38:44 +01:00
draw_sprite_stretched_ext(THEME.node_active, 0, ui(4), yy, list_width - ui(8), list_height, COLORS._main_accent, 1);
2022-09-21 06:09:40 +02:00
if(keyboard_check_pressed(vk_enter))
buildNode(_node, _param);
}
if(is_instanceof(_node, NodeObject)) {
2024-02-16 07:44:36 +01:00
_node.drawList(0, yy, _m[0], _m[1], list_height, _param);
} else {
if(variable_struct_exists(_node, "getSpr")) _node.getSpr();
if(sprite_exists(_node.spr)) {
var _si = current_time * PREFERENCES.collection_preview_speed / 3000;
var _sw = sprite_get_width(_node.spr);
var _sh = sprite_get_height(_node.spr);
var _ss = (list_height - ui(8)) / max(_sw, _sh);
var _sox = sprite_get_xoffset(_node.spr);
var _soy = sprite_get_yoffset(_node.spr);
2022-09-21 06:09:40 +02:00
var _sx = list_height / 2 + ui(32);
var _sy = yy + list_height / 2;
_sx += _sw * _ss / 2 - _sox * _ss;
_sy += _sh * _ss / 2 - _soy * _ss;
draw_sprite_ext(_node.spr, _si, _sx, _sy, _ss, _ss, 0, c_white, 1);
2024-07-15 10:43:30 +02:00
if(is_instanceof(_node, NodeAction) && !struct_try_get(_node, "hide_bg", false))
draw_sprite_ui_uniform(THEME.play_action, 0, _sx + list_height / 2 - 8, _sy + list_height / 2 - 8, 0.5, COLORS.add_node_blend_action);
}
2024-02-16 07:44:36 +01:00
draw_set_text(f_p2, fa_left, fa_center, COLORS._main_text);
if(highlight) draw_text_match(list_height + ui(40), yy + list_height / 2, _node.getName(), search_string);
else draw_text( list_height + ui(40), yy + list_height / 2, _node.getName());
}
if(node_focusing == i) search_pane.scroll_y_to = -max(0, hh - search_pane.h);
2022-01-13 05:24:03 +01:00
}
}
2022-01-18 05:31:19 +01:00
node_focusing = -1;
if(keyboard_check_pressed(vk_up)) {
node_selecting = safe_mod(node_selecting - 1 + amo, amo);
node_focusing = node_selecting;
}
if(keyboard_check_pressed(vk_down)) {
node_selecting = safe_mod(node_selecting + 1, amo);
node_focusing = node_selecting;
}
2022-01-13 05:24:03 +01:00
return hh;
});
#endregion