mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2025-01-23 19:38:05 +01:00
add node
This commit is contained in:
parent
be26b6413a
commit
e5d28abe59
9 changed files with 333 additions and 181 deletions
|
@ -747,7 +747,7 @@ event_inherited();
|
|||
tb_search.auto_update = true;
|
||||
WIDGET_CURRENT = tb_search;
|
||||
|
||||
function searchNodes() { #region
|
||||
function searchNodes() {
|
||||
ds_list_clear(search_list);
|
||||
var pr_list = ds_priority_create();
|
||||
|
||||
|
@ -778,7 +778,7 @@ event_inherited();
|
|||
var match = string_partial_match(string_lower(_node.getName()), search_lower);
|
||||
var param = "";
|
||||
for( var k = 0; k < array_length(_node.tags); k++ ) {
|
||||
var mat = string_partial_match(_node.tags[k], search_lower) - 1000;
|
||||
var mat = string_partial_match(_node.tags[k], search_lower);
|
||||
if(mat > match) {
|
||||
match = mat;
|
||||
param = _node.tags[k];
|
||||
|
@ -800,7 +800,7 @@ event_inherited();
|
|||
ds_list_add(search_list, ds_priority_delete_max(pr_list));
|
||||
|
||||
ds_priority_destroy(pr_list);
|
||||
} #endregion
|
||||
}
|
||||
|
||||
search_pane = new scrollPane(dialog_w - ui(36), dialog_h - ui(66), function(_y, _m) {
|
||||
draw_clear_alpha(c_white, 0);
|
||||
|
@ -832,9 +832,9 @@ event_inherited();
|
|||
|
||||
if(PREFERENCES.dialog_add_node_view == 0) { // grid
|
||||
|
||||
var col = floor(search_pane.surface_w / (grid_width + grid_space));
|
||||
var yy = _y + grid_space;
|
||||
var index = 0;
|
||||
var col = floor(search_pane.surface_w / (grid_width + grid_space));
|
||||
var yy = _y + grid_space;
|
||||
var index = 0;
|
||||
var name_height = 0;
|
||||
|
||||
grid_width = round(search_pane.surface_w - grid_space) / col - grid_space;
|
||||
|
@ -856,90 +856,94 @@ event_inherited();
|
|||
var _nx = grid_space + (grid_width + grid_space) * index;
|
||||
var _boxx = _nx + (grid_width - grid_size) / 2;
|
||||
|
||||
BLEND_OVERRIDE;
|
||||
if(is_instanceof(_node, NodeObject))
|
||||
draw_sprite_stretched(THEME.node_bg, 0, _boxx, yy, grid_size, grid_size);
|
||||
else if(is_instanceof(_node, NodeAction))
|
||||
draw_sprite_stretched_ext(THEME.node_bg, 0, _boxx, yy, grid_size, grid_size, COLORS.add_node_blend_action, 1);
|
||||
else if(is_instanceof(_node, AddNodeItem))
|
||||
draw_sprite_stretched_ext(THEME.node_bg, 0, _boxx, yy, grid_size, grid_size, COLORS.add_node_blend_generic, 1);
|
||||
else
|
||||
draw_sprite_stretched_ext(THEME.node_bg, 0, _boxx, yy, grid_size, grid_size, COLORS.dialog_add_node_collection, 1);
|
||||
BLEND_NORMAL;
|
||||
var _drw = yy > -grid_size && yy < search_pane.h;
|
||||
|
||||
if(_hover && point_in_rectangle(_m[0], _m[1], _nx, yy, _nx + grid_width, 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);
|
||||
}
|
||||
|
||||
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);
|
||||
if(_drw) {
|
||||
BLEND_OVERRIDE;
|
||||
if(is_instanceof(_node, NodeObject)) draw_sprite_stretched( THEME.node_bg, 0, _boxx, yy, grid_size, grid_size);
|
||||
else if(is_instanceof(_node, NodeAction)) draw_sprite_stretched_ext(THEME.node_bg, 0, _boxx, yy, grid_size, grid_size, COLORS.add_node_blend_action);
|
||||
else if(is_instanceof(_node, AddNodeItem)) draw_sprite_stretched_ext(THEME.node_bg, 0, _boxx, yy, grid_size, grid_size, COLORS.add_node_blend_generic);
|
||||
else draw_sprite_stretched_ext(THEME.node_bg, 0, _boxx, yy, grid_size, grid_size, COLORS.dialog_add_node_collection);
|
||||
BLEND_NORMAL;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
if(is_instanceof(_node, NodeAction))
|
||||
draw_sprite_ui_uniform(THEME.play_action, 0, _boxx + grid_size - 16, yy + grid_size - 16, 1, COLORS.add_node_blend_action);
|
||||
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);
|
||||
}
|
||||
|
||||
if(is_instanceof(_node, NodeAction))
|
||||
draw_sprite_ui_uniform(THEME.play_action, 0, _boxx + grid_size - 16, yy + grid_size - 16, 1, COLORS.add_node_blend_action);
|
||||
}
|
||||
}
|
||||
|
||||
var _name = _node.getName();
|
||||
var _showQuery = _query != "" && is_instanceof(_node, NodeObject) && _node.createNode[0] == 0;
|
||||
var _showQuery = _query != "";
|
||||
|
||||
draw_set_font(_showQuery? f_p3 : f_p2);
|
||||
var _nmh = string_height_ext(_name, -1, grid_width);
|
||||
var _nmh = string_height_ext(_name, -1, grid_width);
|
||||
var _nmy = yy + grid_size + 4;
|
||||
var _drw = _nmy > -grid_size && _nmy < search_pane.h;
|
||||
|
||||
if(_showQuery) {
|
||||
_query = string_title(_query);
|
||||
var _nmy = yy + grid_size + 4;
|
||||
|
||||
draw_set_text(f_p3, fa_center, fa_top, COLORS._main_text_sub);
|
||||
draw_text_ext_add(_boxx + grid_size / 2, _nmy, _name, -1, grid_width);
|
||||
if(_drw) draw_text_ext_add(_boxx + grid_size / 2, _nmy, _name, -1, grid_width);
|
||||
_nmy += _nmh - ui(2);
|
||||
|
||||
draw_set_text(f_p2, fa_center, fa_top, COLORS._main_text);
|
||||
draw_text_ext_add(_boxx + grid_size / 2, _nmy, _query, -1, grid_width);
|
||||
_nmy += string_height_ext(_query, -1, grid_width);
|
||||
var _qhh = string_height_ext(_query, -1, grid_width);
|
||||
if(_drw) _qhh = draw_text_match_ext(_boxx + grid_size / 2, _nmy, _query, grid_width, search_string);
|
||||
_nmy += _qhh;
|
||||
_nmh += _qhh;
|
||||
|
||||
} else {
|
||||
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);
|
||||
if(_drw) _nmh = draw_text_match_ext(_boxx + grid_size / 2, _nmy, _name, grid_width, search_string);
|
||||
}
|
||||
|
||||
name_height = max(name_height, _nmh + ui(8));
|
||||
name_height = max(name_height, _nmh);
|
||||
|
||||
if(node_focusing == i)
|
||||
search_pane.scroll_y_to = -max(0, hh - search_pane.h);
|
||||
|
@ -952,19 +956,26 @@ event_inherited();
|
|||
yy += hght;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} else if(PREFERENCES.dialog_add_node_view == 1) { // list
|
||||
|
||||
var list_width = search_pane.surface_w;
|
||||
var list_height = ui(28);
|
||||
var yy = _y + list_height / 2;
|
||||
hh += list_height;
|
||||
|
||||
var sy = _y + list_height / 2;
|
||||
hh += list_height * (amo + 1);
|
||||
|
||||
for(var i = 0; i < amo; i++) {
|
||||
var s_res = search_list[| i];
|
||||
var _node = noone;
|
||||
var _param = {};
|
||||
var _query = "";
|
||||
var yy = sy + list_height * i;
|
||||
|
||||
if(yy < -list_height) continue;
|
||||
if(yy > search_pane.h) break;
|
||||
|
||||
_param.search_string = search_string;
|
||||
|
||||
if(is_array(s_res)) {
|
||||
_node = s_res[0];
|
||||
|
@ -1024,13 +1035,10 @@ event_inherited();
|
|||
}
|
||||
|
||||
draw_set_text(f_p2, fa_left, fa_center, COLORS._main_text);
|
||||
draw_text_add(list_height + ui(40), yy + list_height / 2, _node.getName());
|
||||
draw_text_match(list_height + ui(40), yy + list_height / 2, _node.getName(), search_string);
|
||||
}
|
||||
|
||||
if(node_focusing == i) search_pane.scroll_y_to = -max(0, hh - search_pane.h);
|
||||
|
||||
hh += list_height;
|
||||
yy += list_height;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,46 +1,46 @@
|
|||
function draw_text_line(_x, _y, _text, _sep, _w, forceCut = false) { #region
|
||||
function draw_text_line(_x, _y, _text, _sep, _w, forceCut = false) {
|
||||
INLINE
|
||||
__draw_text_ext_transformed(_x, _y, _text, _sep, _w, 1, 1, 0, forceCut);
|
||||
} #endregion
|
||||
}
|
||||
|
||||
function draw_text_add(_x, _y, _text, scale = 1) { #region
|
||||
function draw_text_add(_x, _y, _text, scale = 1) {
|
||||
INLINE
|
||||
BLEND_ALPHA_MULP;
|
||||
if(scale == 1) draw_text(round(_x), round(_y), _text);
|
||||
else draw_text_transformed(round(_x), round(_y), _text, scale, scale, 0);
|
||||
BLEND_NORMAL;
|
||||
} #endregion
|
||||
}
|
||||
|
||||
function draw_text_over(_x, _y, _text, scale = 1) { #region
|
||||
function draw_text_over(_x, _y, _text, scale = 1) {
|
||||
INLINE
|
||||
BLEND_OVERRIDE;
|
||||
draw_text_transformed(round(_x), round(_y), _text, scale, scale, 0);
|
||||
BLEND_NORMAL;
|
||||
} #endregion
|
||||
}
|
||||
|
||||
function draw_text_add_float(_x, _y, _text, scale = 1) { #region
|
||||
function draw_text_add_float(_x, _y, _text, scale = 1) {
|
||||
INLINE
|
||||
BLEND_ALPHA_MULP;
|
||||
if(scale == 1) draw_text(_x, _y, _text);
|
||||
else draw_text_transformed(_x, _y, _text, scale, scale, 0);
|
||||
BLEND_NORMAL;
|
||||
} #endregion
|
||||
}
|
||||
|
||||
function draw_text_lang_add(_x, _y, _text, scale = 1) { #region
|
||||
function draw_text_lang_add(_x, _y, _text, scale = 1) {
|
||||
INLINE
|
||||
BLEND_ALPHA_MULP;
|
||||
draw_text_lang(_x, _y, _text, scale);
|
||||
BLEND_NORMAL;
|
||||
} #endregion
|
||||
}
|
||||
|
||||
function draw_text_lang_over(_x, _y, _text, scale = 1) { #region
|
||||
function draw_text_lang_over(_x, _y, _text, scale = 1) {
|
||||
INLINE
|
||||
BLEND_OVERRIDE;
|
||||
draw_text_lang(_x, _y, _text, scale);
|
||||
BLEND_NORMAL;
|
||||
} #endregion
|
||||
}
|
||||
|
||||
function draw_text_lang(_x, _y, _text, scale = 1) { #region
|
||||
function draw_text_lang(_x, _y, _text, scale = 1) {
|
||||
var _w = string_width(_text);
|
||||
var _h = string_height(_text);
|
||||
|
||||
|
@ -77,17 +77,17 @@ function draw_text_lang(_x, _y, _text, scale = 1) { #region
|
|||
|
||||
draw_set_font(_f);
|
||||
draw_set_halign(_ha);
|
||||
} #endregion
|
||||
}
|
||||
|
||||
function draw_text_ext_add(_x, _y, _text, _sep, _w, scale = 1, forceCut = false) { #region
|
||||
function draw_text_ext_add(_x, _y, _text, _sep, _w, scale = 1, forceCut = false) {
|
||||
INLINE
|
||||
BLEND_ALPHA_MULP;
|
||||
var h = __draw_text_ext_transformed(_x, _y, _text, _sep, _w, scale, scale, 0, forceCut);
|
||||
BLEND_NORMAL;
|
||||
return h;
|
||||
} #endregion
|
||||
}
|
||||
|
||||
function draw_text_bbox(bbox, text, scale = 1) { #region
|
||||
function draw_text_bbox(bbox, text, scale = 1) {
|
||||
INLINE
|
||||
var ss = min(bbox.w / string_width(text), bbox.h / string_height(text));
|
||||
ss = max(0.5, ss);
|
||||
|
@ -96,25 +96,21 @@ function draw_text_bbox(bbox, text, scale = 1) { #region
|
|||
draw_set_valign(fa_center);
|
||||
|
||||
draw_text_cut(bbox.xc, bbox.yc, text, bbox.w, ss * scale);
|
||||
} #endregion
|
||||
}
|
||||
|
||||
function draw_text_cut(x, y, str, w, scale = 1) { #region
|
||||
function draw_text_cut(x, y, str, w, scale = 1) {
|
||||
INLINE
|
||||
BLEND_ALPHA_MULP;
|
||||
draw_text_transformed(round(x), round(y), string_cut(str, w,, scale), scale, scale, 0);
|
||||
BLEND_NORMAL;
|
||||
} #endregion
|
||||
}
|
||||
|
||||
function draw_text_int(x, y, str) { #region
|
||||
function draw_text_int(x, y, str) {
|
||||
INLINE
|
||||
draw_text(round(x), round(y), str);
|
||||
} #endregion
|
||||
}
|
||||
|
||||
function draw_text_highlight() { #region
|
||||
|
||||
} #endregion
|
||||
|
||||
function __draw_text_ext_transformed(_x, _y, _text, _sep, _w, sx, sy, rotation, _break = LOCALE.config.per_character_line_break) { #region
|
||||
function __draw_text_ext_transformed(_x, _y, _text, _sep, _w, sx = 1, sy = 1, rotation = 0, _break = LOCALE.config.per_character_line_break) {
|
||||
INLINE
|
||||
_x = round(_x);
|
||||
_y = round(_y);
|
||||
|
@ -187,12 +183,12 @@ function __draw_text_ext_transformed(_x, _y, _text, _sep, _w, sx, sy, rotation,
|
|||
draw_set_valign(va);
|
||||
|
||||
return hh;
|
||||
} #endregion
|
||||
}
|
||||
|
||||
#macro _string_width_ext string_width_ext
|
||||
#macro string_width_ext __string_width_ext
|
||||
|
||||
function __string_width_ext(text, sep, w) { #region
|
||||
function __string_width_ext(text, sep, w) {
|
||||
INLINE
|
||||
if(!LOCALE.config.per_character_line_break)
|
||||
return _string_width_ext(text, sep, w);
|
||||
|
@ -214,12 +210,12 @@ function __string_width_ext(text, sep, w) { #region
|
|||
|
||||
mxw = max(mxw, lw);
|
||||
return mxw;
|
||||
} #endregion
|
||||
}
|
||||
|
||||
#macro _string_height_ext string_height_ext
|
||||
#macro string_height_ext __string_height_ext
|
||||
|
||||
function __string_height_ext(text, sep, w, _break = LOCALE.config.per_character_line_break) { #region
|
||||
function __string_height_ext(text, sep, w, _break = LOCALE.config.per_character_line_break) {
|
||||
INLINE
|
||||
if(!_break) return _string_height_ext(text, sep, w);
|
||||
|
||||
|
@ -242,4 +238,4 @@ function __string_height_ext(text, sep, w, _break = LOCALE.config.per_character_
|
|||
}
|
||||
|
||||
return hh;
|
||||
} #endregion
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
function NodeObject(_name, _spr, _node, _create, tooltip = "", tags = []) constructor { #region
|
||||
function NodeObject(_name, _spr, _node, _create, tooltip = "", tags = []) constructor {
|
||||
name = _name;
|
||||
spr = _spr;
|
||||
node = _node;
|
||||
|
@ -19,7 +19,7 @@ function NodeObject(_name, _spr, _node, _create, tooltip = "", tags = []) constr
|
|||
|
||||
is_patreon_extra = false;
|
||||
|
||||
if(!IS_CMD) { #region
|
||||
if(!IS_CMD) {
|
||||
var pth = DIRECTORY + "Nodes/tooltip/" + node + ".png";
|
||||
if(file_exists_empty(pth)) tooltip_spr = sprite_add(pth, 0, false, false, 0, 0);
|
||||
|
||||
|
@ -29,9 +29,9 @@ function NodeObject(_name, _spr, _node, _create, tooltip = "", tags = []) constr
|
|||
if(_n.tooltip != "")
|
||||
tooltip = _n.tooltip;
|
||||
}
|
||||
} #endregion
|
||||
}
|
||||
|
||||
static setVersion = function(version) { #region
|
||||
static setVersion = function(version) {
|
||||
INLINE
|
||||
if(IS_CMD) return self;
|
||||
|
||||
|
@ -46,41 +46,41 @@ function NodeObject(_name, _spr, _node, _create, tooltip = "", tags = []) constr
|
|||
ds_list_add(NEW_NODES, self);
|
||||
}
|
||||
return self;
|
||||
} #endregion
|
||||
}
|
||||
|
||||
static setIcon = function(icon) { #region
|
||||
static setIcon = function(icon) {
|
||||
INLINE
|
||||
if(IS_CMD) return self;
|
||||
|
||||
self.icon = icon;
|
||||
return self;
|
||||
} #endregion
|
||||
}
|
||||
|
||||
static isDeprecated = function() { #region
|
||||
static isDeprecated = function() {
|
||||
INLINE
|
||||
if(IS_CMD) return self;
|
||||
|
||||
deprecated = true;
|
||||
return self;
|
||||
} #endregion
|
||||
}
|
||||
|
||||
static hideRecent = function() { #region
|
||||
static hideRecent = function() {
|
||||
INLINE
|
||||
if(IS_CMD) return self;
|
||||
|
||||
show_in_recent = false;
|
||||
return self;
|
||||
} #endregion
|
||||
}
|
||||
|
||||
static hideGlobal = function() { #region
|
||||
static hideGlobal = function() {
|
||||
INLINE
|
||||
if(IS_CMD) return self;
|
||||
|
||||
show_in_global = false;
|
||||
return self;
|
||||
} #endregion
|
||||
}
|
||||
|
||||
static patreonExtra = function() { #region
|
||||
static patreonExtra = function() {
|
||||
INLINE
|
||||
if(IS_CMD) return self;
|
||||
|
||||
|
@ -88,12 +88,12 @@ function NodeObject(_name, _spr, _node, _create, tooltip = "", tags = []) constr
|
|||
|
||||
ds_list_add(SUPPORTER_NODES, self);
|
||||
return self;
|
||||
} #endregion
|
||||
}
|
||||
|
||||
static getName = function() { return __txt_node_name(node, name); }
|
||||
static getTooltip = function() { return __txt_node_tooltip(node, tooltip); }
|
||||
|
||||
static build = function(_x = 0, _y = 0, _group = PANEL_GRAPH.getCurrentContext(), _param = {}) { #region
|
||||
static build = function(_x = 0, _y = 0, _group = PANEL_GRAPH.getCurrentContext(), _param = {}) {
|
||||
INLINE
|
||||
|
||||
var _buildCon = createNode[0];
|
||||
|
@ -104,9 +104,9 @@ function NodeObject(_name, _spr, _node, _create, tooltip = "", tags = []) constr
|
|||
else _node = createNode[1](_x, _y, _group, _param);
|
||||
|
||||
return _node;
|
||||
} #endregion
|
||||
}
|
||||
|
||||
static drawGrid = function(_x, _y, _mx, _my, grid_size, _param = {}) { #region
|
||||
static drawGrid = function(_x, _y, _mx, _my, grid_size, _param = {}) {
|
||||
var spr_x = _x + grid_size / 2;
|
||||
var spr_y = _y + grid_size / 2;
|
||||
|
||||
|
@ -147,9 +147,9 @@ function NodeObject(_name, _spr, _node, _create, tooltip = "", tags = []) constr
|
|||
}
|
||||
|
||||
if(icon) draw_sprite_ext(icon, 0, spr_x, spr_y, 1, 1, 0, c_white, 1);
|
||||
} #endregion
|
||||
}
|
||||
|
||||
static drawList = function(_x, _y, _mx, _my, list_height, _param = {}) { #region
|
||||
static drawList = function(_x, _y, _mx, _my, list_height, _param = {}) {
|
||||
var fav = array_exists(global.FAV_NODES, node);
|
||||
if(fav) draw_sprite_ui_uniform(THEME.star, 0, ui(32), yy + list_height / 2, 0.7, COLORS._main_accent, 1.);
|
||||
|
||||
|
@ -175,9 +175,10 @@ function NodeObject(_name, _spr, _node, _create, tooltip = "", tags = []) constr
|
|||
tx += ui(40);
|
||||
}
|
||||
|
||||
var _txt = getName();
|
||||
var _query = struct_try_get(_param, "query", "");
|
||||
var _txt = getName();
|
||||
var _query = struct_try_get(_param, "query", "");
|
||||
var _showQuery = _query != "" && createNode[0] == 0;
|
||||
var _search = struct_try_get(_param, "search_string", 0);
|
||||
|
||||
if(_showQuery) {
|
||||
draw_set_text(f_p2, fa_left, fa_center, COLORS._main_text_sub);
|
||||
|
@ -186,12 +187,14 @@ function NodeObject(_name, _spr, _node, _create, tooltip = "", tags = []) constr
|
|||
|
||||
_query = string_title(_query);
|
||||
draw_set_text(f_p2, fa_left, fa_center, COLORS._main_text);
|
||||
draw_text_add(tx, _y + list_height / 2, _query);
|
||||
if(_search == 0) draw_text_add(tx, _y + list_height / 2, _query);
|
||||
else draw_text_match(tx, _y + list_height / 2, _query, _search);
|
||||
tx += string_width(_query);
|
||||
|
||||
} else {
|
||||
draw_set_text(f_p2, fa_left, fa_center, COLORS._main_text);
|
||||
draw_text_add(tx, _y + list_height / 2, _txt);
|
||||
if(_search == 0) draw_text_add(tx, _y + list_height / 2, _txt);
|
||||
else draw_text_match(tx, _y + list_height / 2, _txt, _search);
|
||||
tx += string_width(_txt);
|
||||
|
||||
}
|
||||
|
@ -212,8 +215,8 @@ function NodeObject(_name, _spr, _node, _create, tooltip = "", tags = []) constr
|
|||
}
|
||||
|
||||
return tx;
|
||||
} #endregion
|
||||
} #endregion
|
||||
}
|
||||
}
|
||||
|
||||
#region globalvar
|
||||
globalvar ALL_NODES, NODE_CATEGORY, NODE_PB_CATEGORY, NODE_PCX_CATEGORY;
|
||||
|
@ -653,7 +656,7 @@ function __initNodes() {
|
|||
ds_list_add(d3d, "2D Operations");
|
||||
addNodeObject(d3d, "Normal", s_node_normal, "Node_Normal", [1, Node_Normal],, "Create normal map using greyscale value as height.");
|
||||
addNodeObject(d3d, "Normal Light", s_node_normal_light, "Node_Normal_Light", [1, Node_Normal_Light],, "Light up the image using normal mapping.");
|
||||
addNodeObject(d3d, "Bevel", s_node_bevel, "Node_Bevel", [1, Node_Bevel], ["shade", "auto shade"], "Apply 2D bevel on the image.");
|
||||
addNodeObject(d3d, "Bevel", s_node_bevel, "Node_Bevel", [1, Node_Bevel],, "Apply 2D bevel on the image.");
|
||||
addNodeObject(d3d, "Sprite Stack", s_node_stack, "Node_Sprite_Stack", [1, Node_Sprite_Stack],, "Create sprite stack either from repeating a single image or stacking different images using array.");
|
||||
|
||||
ds_list_add(d3d, "3D");
|
||||
|
|
|
@ -1,39 +1,12 @@
|
|||
function string_to_array(str) { #region
|
||||
function string_to_array(str) {
|
||||
var amo = string_length(str);
|
||||
var arr = array_create(amo);
|
||||
for( var i = 0; i < amo; i++ )
|
||||
arr[i] = string_char_at(str, i + 1);
|
||||
return arr;
|
||||
} #endregion
|
||||
}
|
||||
|
||||
function string_partial_match(str, key) { #region
|
||||
var amo = string_length(str);
|
||||
var run = 1;
|
||||
var consec = 0;
|
||||
var conMax = 0;
|
||||
var misMatch = 0;
|
||||
var kchr = string_char_at(key, run);
|
||||
var ch;
|
||||
|
||||
for( var i = 1; i <= amo; i++ ) {
|
||||
ch = string_char_at(str, i);
|
||||
if(ch == kchr) {
|
||||
consec++;
|
||||
conMax = max(conMax, consec);
|
||||
run++;
|
||||
if(run > string_length(key)) return conMax - (misMatch + (amo - i));
|
||||
kchr = string_char_at(key, run);
|
||||
|
||||
} else {
|
||||
consec = 0;
|
||||
misMatch += amo - i;
|
||||
}
|
||||
}
|
||||
|
||||
return -9999;
|
||||
} #endregion
|
||||
|
||||
function string_real(val, digMax = 999, decMin = 5) { #region
|
||||
function string_real(val, digMax = 999, decMin = 5) {
|
||||
if(is_string(val)) return val;
|
||||
if(is_struct(val)) return string(val);
|
||||
|
||||
|
@ -55,17 +28,17 @@ function string_real(val, digMax = 999, decMin = 5) { #region
|
|||
}
|
||||
|
||||
return string_format(val, -1, pres);
|
||||
} #endregion
|
||||
}
|
||||
|
||||
function string_char_last(str, shift = 0) { #region
|
||||
function string_char_last(str, shift = 0) {
|
||||
INLINE
|
||||
return string_char_at(str, string_length(str) - shift);
|
||||
} #endregion
|
||||
}
|
||||
|
||||
function filename_name_only(name) { #region
|
||||
function filename_name_only(name) {
|
||||
name = filename_name(name);
|
||||
return string_replace(name, filename_ext(name), "")
|
||||
} #endregion
|
||||
}
|
||||
|
||||
function string_to_var(str) { INLINE return string_replace_all(string_lower(str), " ", "_"); }
|
||||
function string_quote(str) { INLINE return $"\"{str}\""; }
|
||||
|
@ -81,4 +54,176 @@ function array_to_string(arr) {
|
|||
s += array_to_string(arr[i])
|
||||
|
||||
return s + "]";
|
||||
}
|
||||
|
||||
function string_partial_match(str, key) {
|
||||
var amo = string_length(str);
|
||||
var run = 1;
|
||||
var consec = 0;
|
||||
var conMax = 0;
|
||||
var misMatch = 0;
|
||||
var kchr = string_char_at(key, run);
|
||||
var ch;
|
||||
var stArr = [];
|
||||
|
||||
for( var i = 1; i <= amo; i++ ) {
|
||||
ch = string_char_at(str, i);
|
||||
|
||||
if(ch == kchr) {
|
||||
consec++;
|
||||
conMax = max(conMax, consec);
|
||||
run++;
|
||||
if(run > string_length(key)) return conMax - misMatch;
|
||||
kchr = string_char_at(key, run);
|
||||
|
||||
} else {
|
||||
consec = 0;
|
||||
misMatch += amo - i;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return -9999;
|
||||
}
|
||||
|
||||
function draw_text_match(_x, _y, _text, _search) {
|
||||
INLINE
|
||||
_x = round(_x);
|
||||
_y = round(_y);
|
||||
|
||||
var ha = draw_get_halign();
|
||||
var xx = _x;
|
||||
var yy = _y;
|
||||
var cc = draw_get_color();
|
||||
|
||||
draw_set_halign(fa_left);
|
||||
_search = string_lower(_search);
|
||||
|
||||
var keylen = string_length(_search);
|
||||
var run = 1;
|
||||
var kchr = string_char_at(_search, 1);
|
||||
|
||||
BLEND_ALPHA_MULP;
|
||||
var aa = string_length(_text);
|
||||
var lw = string_width(_text);
|
||||
var tl = string_lower(_text);
|
||||
|
||||
switch(ha) {
|
||||
case fa_left : xx = _x; break;
|
||||
case fa_center : xx = _x - lw / 2; break;
|
||||
case fa_right : xx = _x - lw; break;
|
||||
}
|
||||
|
||||
var j = 1;
|
||||
repeat(aa) {
|
||||
var ch = string_char_at(_text, j);
|
||||
var cl = string_char_at(tl, j);
|
||||
|
||||
if(run > 0 && cl == kchr) {
|
||||
run++;
|
||||
if(run > keylen) run = 0;
|
||||
kchr = string_char_at(_search, run);
|
||||
draw_set_color(COLORS._main_accent);
|
||||
} else
|
||||
draw_set_color(cc);
|
||||
|
||||
draw_text(xx, yy, ch);
|
||||
xx += string_width(ch);
|
||||
j++;
|
||||
}
|
||||
|
||||
BLEND_NORMAL;
|
||||
|
||||
draw_set_halign(ha);
|
||||
}
|
||||
|
||||
function draw_text_match_ext(_x, _y, _text, _w, _search) {
|
||||
INLINE
|
||||
_x = round(_x);
|
||||
_y = round(_y);
|
||||
|
||||
var lines = [];
|
||||
var line = "";
|
||||
var line_w = 0;
|
||||
var words = string_split(_text, " ");
|
||||
var amo = array_length(words);
|
||||
|
||||
for( var i = 0; i < amo; i++ ) {
|
||||
var wr = words[i] + " ";
|
||||
var ww = string_width(wr);
|
||||
|
||||
if(line_w + ww > _w) {
|
||||
array_push(lines, line);
|
||||
line = wr;
|
||||
line_w = ww;
|
||||
|
||||
} else {
|
||||
line += wr;
|
||||
line_w += ww;
|
||||
}
|
||||
}
|
||||
|
||||
if(line != "") array_push(lines, line);
|
||||
|
||||
var ha = draw_get_halign();
|
||||
var va = draw_get_valign();
|
||||
var xx = _x;
|
||||
var yy = _y;
|
||||
var lh = line_get_height();
|
||||
var hh = lh * array_length(lines);
|
||||
var cc = draw_get_color();
|
||||
|
||||
draw_set_halign(fa_left);
|
||||
draw_set_valign(fa_top);
|
||||
_search = string_lower(_search);
|
||||
|
||||
var keylen = string_length(_search);
|
||||
var run = 1;
|
||||
var kchr = string_char_at(_search, 1);
|
||||
|
||||
switch(va) {
|
||||
case fa_top : yy = _y; break;
|
||||
case fa_middle : yy = _y - hh / 2; break;
|
||||
case fa_bottom : yy = _y - hh; break;
|
||||
}
|
||||
|
||||
BLEND_ALPHA_MULP;
|
||||
for( var i = 0, n = array_length(lines); i < n; i++ ) {
|
||||
var ll = lines[i];
|
||||
var aa = string_length(ll);
|
||||
var lw = string_width(ll);
|
||||
var tl = string_lower(ll);
|
||||
|
||||
switch(ha) {
|
||||
case fa_left : xx = _x; break;
|
||||
case fa_center : xx = _x - lw / 2; break;
|
||||
case fa_right : xx = _x - lw; break;
|
||||
}
|
||||
|
||||
var j = 1;
|
||||
repeat(aa) {
|
||||
var ch = string_char_at(ll, j);
|
||||
var cl = string_char_at(tl, j);
|
||||
|
||||
if(run > 0 && cl == kchr) {
|
||||
run++;
|
||||
if(run > keylen) run = 0;
|
||||
kchr = string_char_at(_search, run);
|
||||
draw_set_color(COLORS._main_accent);
|
||||
} else
|
||||
draw_set_color(cc);
|
||||
|
||||
draw_text(xx, yy, ch);
|
||||
xx += string_width(ch);
|
||||
j++;
|
||||
}
|
||||
|
||||
yy += lh;
|
||||
}
|
||||
BLEND_NORMAL;
|
||||
|
||||
draw_set_halign(ha);
|
||||
draw_set_valign(va);
|
||||
|
||||
return hh;
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 1,005 B |
Binary file not shown.
Before Width: | Height: | Size: 674 B |
Binary file not shown.
After Width: | Height: | Size: 1,005 B |
Binary file not shown.
Before Width: | Height: | Size: 674 B |
|
@ -2,24 +2,24 @@
|
|||
"$GMSprite":"",
|
||||
"%Name":"s_node_pin_array",
|
||||
"bboxMode":0,
|
||||
"bbox_bottom":29,
|
||||
"bbox_bottom":59,
|
||||
"bbox_left":0,
|
||||
"bbox_right":31,
|
||||
"bbox_top":2,
|
||||
"bbox_right":63,
|
||||
"bbox_top":4,
|
||||
"collisionKind":1,
|
||||
"collisionTolerance":0,
|
||||
"DynamicTexturePage":false,
|
||||
"edgeFiltering":false,
|
||||
"For3D":false,
|
||||
"frames":[
|
||||
{"$GMSpriteFrame":"","%Name":"efdb099c-6a09-49f8-b757-7c61da7d3788","name":"efdb099c-6a09-49f8-b757-7c61da7d3788","resourceType":"GMSpriteFrame","resourceVersion":"2.0",},
|
||||
{"$GMSpriteFrame":"","%Name":"5c785a94-16e0-44d3-97f7-8fa4cf4dc2b0","name":"5c785a94-16e0-44d3-97f7-8fa4cf4dc2b0","resourceType":"GMSpriteFrame","resourceVersion":"2.0",},
|
||||
],
|
||||
"gridX":0,
|
||||
"gridY":0,
|
||||
"height":32,
|
||||
"height":64,
|
||||
"HTile":false,
|
||||
"layers":[
|
||||
{"$GMImageLayer":"","%Name":"d4ee30a5-0c99-4fd9-963a-8ed42dfb2b50","blendMode":0,"displayName":"default","isLocked":false,"name":"d4ee30a5-0c99-4fd9-963a-8ed42dfb2b50","opacity":100.0,"resourceType":"GMImageLayer","resourceVersion":"2.0","visible":true,},
|
||||
{"$GMImageLayer":"","%Name":"aceff530-ae45-478b-99ce-df517e435524","blendMode":0,"displayName":"default","isLocked":false,"name":"aceff530-ae45-478b-99ce-df517e435524","opacity":100.0,"resourceType":"GMImageLayer","resourceVersion":"2.0","visible":true,},
|
||||
],
|
||||
"name":"s_node_pin_array",
|
||||
"nineSlice":null,
|
||||
|
@ -69,14 +69,14 @@
|
|||
"tracks":[
|
||||
{"$GMSpriteFramesTrack":"","builtinName":0,"events":[],"inheritsTrackColour":true,"interpolation":1,"isCreationTrack":false,"keyframes":{"$KeyframeStore<SpriteFrameKeyframe>":"","Keyframes":[
|
||||
{"$Keyframe<SpriteFrameKeyframe>":"","Channels":{
|
||||
"0":{"$SpriteFrameKeyframe":"","Id":{"name":"efdb099c-6a09-49f8-b757-7c61da7d3788","path":"sprites/s_node_pin_array/s_node_pin_array.yy",},"resourceType":"SpriteFrameKeyframe","resourceVersion":"2.0",},
|
||||
},"Disabled":false,"id":"a34b85e7-1398-4d9d-933b-5c858d7598ae","IsCreationKey":false,"Key":0.0,"Length":1.0,"resourceType":"Keyframe<SpriteFrameKeyframe>","resourceVersion":"2.0","Stretch":false,},
|
||||
"0":{"$SpriteFrameKeyframe":"","Id":{"name":"5c785a94-16e0-44d3-97f7-8fa4cf4dc2b0","path":"sprites/s_node_pin_array/s_node_pin_array.yy",},"resourceType":"SpriteFrameKeyframe","resourceVersion":"2.0",},
|
||||
},"Disabled":false,"id":"25649453-ee1a-47fb-8972-650b7b74bdfd","IsCreationKey":false,"Key":0.0,"Length":1.0,"resourceType":"Keyframe<SpriteFrameKeyframe>","resourceVersion":"2.0","Stretch":false,},
|
||||
],"resourceType":"KeyframeStore<SpriteFrameKeyframe>","resourceVersion":"2.0",},"modifiers":[],"name":"frames","resourceType":"GMSpriteFramesTrack","resourceVersion":"2.0","spriteId":null,"trackColour":0,"tracks":[],"traits":0,},
|
||||
],
|
||||
"visibleRange":null,
|
||||
"volume":1.0,
|
||||
"xorigin":16,
|
||||
"yorigin":16,
|
||||
"xorigin":32,
|
||||
"yorigin":32,
|
||||
},
|
||||
"swatchColours":null,
|
||||
"swfPrecision":0.5,
|
||||
|
@ -86,5 +86,5 @@
|
|||
},
|
||||
"type":0,
|
||||
"VTile":false,
|
||||
"width":32,
|
||||
"width":64,
|
||||
}
|
Loading…
Reference in a new issue