From c1d13aec4d858d6230229d44ca412d1a2e258e03 Mon Sep 17 00:00:00 2001 From: Tanasart <22589759+Ttanasart-pt@users.noreply.github.com> Date: Sun, 26 Mar 2023 12:13:36 +0700 Subject: [PATCH] Drag drop --- PixelComposer.resource_order | 3 + PixelComposer.yyp | 5 + objects/o_dialog_panel/Draw_64.gml | 4 +- objects/o_main/Create_0.gml | 4 + objects/o_main/Draw_75.gml | 31 ++- objects/o_main/Step_0.gml | 4 + scripts/Tweener/Tweener.gml | 64 ++++++ scripts/Tweener/Tweener.yy | 11 + scripts/append_function/append_function.gml | 4 +- scripts/buttonGradient/buttonGradient.gml | 10 +- scripts/buttonPalette/buttonPalette.gml | 6 +- scripts/controlPointBox/controlPointBox.gml | 52 +---- scripts/directory_object/directory_object.gml | 6 + scripts/draw_UI_scale/draw_UI_scale.gml | 11 + .../draw_text_function/draw_text_function.gml | 4 +- .../gradients_function/gradients_function.gml | 6 +- scripts/nodeValue_drawer/nodeValue_drawer.gml | 2 +- scripts/node_color/node_color.gml | 3 - scripts/node_data/node_data.gml | 214 +++++++++++------- scripts/node_feedback/node_feedback.gml | 2 +- .../node_group_output/node_group_output.gml | 4 +- scripts/node_image/node_image.gml | 2 +- scripts/node_iterate/node_iterate.gml | 2 +- .../node_iterator_each_output.gml | 2 +- .../node_iterator_filter_output.gml | 2 +- .../node_iterator_output.gml | 2 +- scripts/node_palette/node_palette.gml | 3 - scripts/node_registry/node_registry.gml | 4 +- scripts/node_solid/node_solid.gml | 5 +- scripts/node_tunnel_out/node_tunnel_out.gml | 2 +- scripts/node_value/node_value.gml | 52 ++++- scripts/node_wrap_mesh/node_wrap_mesh.gml | 100 ++++---- scripts/panel_collection/panel_collection.gml | 2 +- scripts/panel_data/panel_data.gml | 6 +- scripts/panel_graph/panel_graph.gml | 73 ++++-- scripts/panel_inspector/panel_inspector.gml | 34 ++- scripts/panel_palette/panel_palette.gml | 2 +- .../preview_overlay_puppet.gml | 108 +++++++-- scripts/render_data/render_data.gml | 15 +- scripts/save_function/save_function.gml | 23 +- scripts/shader_functions/shader_functions.gml | 8 +- scripts/textArea/textArea.gml | 12 +- scripts/textBox/textBox.gml | 13 +- shaders/sh_downsample/sh_downsample.fsh | 23 ++ shaders/sh_downsample/sh_downsample.vsh | 19 ++ shaders/sh_downsample/sh_downsample.yy | 10 + .../sh_gradient_display.fsh | 6 +- .../sh_trans_node_prev_drop.fsh | 17 ++ .../sh_trans_node_prev_drop.vsh | 19 ++ .../sh_trans_node_prev_drop.yy | 10 + 50 files changed, 720 insertions(+), 306 deletions(-) create mode 100644 scripts/Tweener/Tweener.gml create mode 100644 scripts/Tweener/Tweener.yy create mode 100644 shaders/sh_downsample/sh_downsample.fsh create mode 100644 shaders/sh_downsample/sh_downsample.vsh create mode 100644 shaders/sh_downsample/sh_downsample.yy create mode 100644 shaders/sh_trans_node_prev_drop/sh_trans_node_prev_drop.fsh create mode 100644 shaders/sh_trans_node_prev_drop/sh_trans_node_prev_drop.vsh create mode 100644 shaders/sh_trans_node_prev_drop/sh_trans_node_prev_drop.yy diff --git a/PixelComposer.resource_order b/PixelComposer.resource_order index 01ddca2a5..8990244e3 100644 --- a/PixelComposer.resource_order +++ b/PixelComposer.resource_order @@ -136,6 +136,8 @@ {"name":"sprites","order":12,"path":"folders/sprites.yy",}, {"name":"gameframe","order":2,"path":"folders/sprites/gameframe.yy",}, {"name":"widgets","order":5,"path":"folders/widgets.yy",}, + {"name":"transition","order":52,"path":"folders/shader/transition.yy",}, + {"name":"tween","order":33,"path":"folders/functions/tween.yy",}, ], "ResourceOrderSettings": [ {"name":"s_node_corner","order":14,"path":"sprites/s_node_corner/s_node_corner.yy",}, @@ -978,6 +980,7 @@ {"name":"sh_blend_normal_dim","order":10,"path":"shaders/sh_blend_normal_dim/sh_blend_normal_dim.yy",}, {"name":"node_skew","order":11,"path":"scripts/node_skew/node_skew.yy",}, {"name":"s_node_canvas","order":3,"path":"sprites/s_node_canvas/s_node_canvas.yy",}, + {"name":"sh_downsample","order":1,"path":"shaders/sh_downsample/sh_downsample.yy",}, {"name":"sh_remove_black","order":33,"path":"shaders/sh_remove_black/sh_remove_black.yy",}, {"name":"path_parser","order":3,"path":"scripts/path_parser/path_parser.yy",}, {"name":"node_crop_content","order":14,"path":"scripts/node_crop_content/node_crop_content.yy",}, diff --git a/PixelComposer.yyp b/PixelComposer.yyp index 9e7f247e4..dced12098 100644 --- a/PixelComposer.yyp +++ b/PixelComposer.yyp @@ -168,6 +168,8 @@ {"resourceType":"GMFolder","resourceVersion":"1.0","name":"Steamworks","folderPath":"folders/Steamworks.yy",}, {"resourceType":"GMFolder","resourceVersion":"1.0","name":"UGC","folderPath":"folders/Steamworks/UGC.yy",}, {"resourceType":"GMFolder","resourceVersion":"1.0","name":"widgets","folderPath":"folders/widgets.yy",}, + {"resourceType":"GMFolder","resourceVersion":"1.0","name":"transition","folderPath":"folders/shader/transition.yy",}, + {"resourceType":"GMFolder","resourceVersion":"1.0","name":"tween","folderPath":"folders/functions/tween.yy",}, ], "IncludedFiles": [ {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"ApolloHelp.html","CopyToMask":-1,"filePath":"datafiles",}, @@ -629,6 +631,7 @@ {"id":{"name":"node_blend","path":"scripts/node_blend/node_blend.yy",},}, {"id":{"name":"fd_rectangle_set_pressure_iteration_type","path":"scripts/fd_rectangle_set_pressure_iteration_type/fd_rectangle_set_pressure_iteration_type.yy",},}, {"id":{"name":"node_array_reverse","path":"scripts/node_array_reverse/node_array_reverse.yy",},}, + {"id":{"name":"Tweener","path":"scripts/Tweener/Tweener.yy",},}, {"id":{"name":"_f_h1","path":"fonts/_f_h1/_f_h1.yy",},}, {"id":{"name":"_f_h2","path":"fonts/_f_h2/_f_h2.yy",},}, {"id":{"name":"s_node_level","path":"sprites/s_node_level/s_node_level.yy",},}, @@ -724,6 +727,7 @@ {"id":{"name":"s_workshop_badge","path":"sprites/s_workshop_badge/s_workshop_badge.yy",},}, {"id":{"name":"node_compare","path":"scripts/node_compare/node_compare.yy",},}, {"id":{"name":"node_iterator_each_size","path":"scripts/node_iterator_each_size/node_iterator_each_size.yy",},}, + {"id":{"name":"sh_trans_node_prev_drop","path":"shaders/sh_trans_node_prev_drop/sh_trans_node_prev_drop.yy",},}, {"id":{"name":"fd_draw_self_to_collision_mask_surface","path":"scripts/fd_draw_self_to_collision_mask_surface/fd_draw_self_to_collision_mask_surface.yy",},}, {"id":{"name":"spr_gameframe_border","path":"sprites/spr_gameframe_border/spr_gameframe_border.yy",},}, {"id":{"name":"s_node_HSV_combine","path":"sprites/s_node_HSV_combine/s_node_HSV_combine.yy",},}, @@ -1497,6 +1501,7 @@ {"id":{"name":"sh_blend_normal_dim","path":"shaders/sh_blend_normal_dim/sh_blend_normal_dim.yy",},}, {"id":{"name":"node_skew","path":"scripts/node_skew/node_skew.yy",},}, {"id":{"name":"s_node_canvas","path":"sprites/s_node_canvas/s_node_canvas.yy",},}, + {"id":{"name":"sh_downsample","path":"shaders/sh_downsample/sh_downsample.yy",},}, {"id":{"name":"sh_remove_black","path":"shaders/sh_remove_black/sh_remove_black.yy",},}, {"id":{"name":"path_parser","path":"scripts/path_parser/path_parser.yy",},}, {"id":{"name":"node_crop_content","path":"scripts/node_crop_content/node_crop_content.yy",},}, diff --git a/objects/o_dialog_panel/Draw_64.gml b/objects/o_dialog_panel/Draw_64.gml index 774f6bfe5..d5b00868f 100644 --- a/objects/o_dialog_panel/Draw_64.gml +++ b/objects/o_dialog_panel/Draw_64.gml @@ -17,8 +17,8 @@ if !ready exit; content.y = cy; content.onStepBegin(); - content.pFOCUS = sFOCUS; - content.pHOVER = sHOVER; + content.pFOCUS = sFOCUS && m_in; + content.pHOVER = sHOVER && m_in; panel = surface_verify(panel, dialog_w - content.showHeader * padding * 2, dialog_h - content.showHeader * (padding * 2 + title_height)); diff --git a/objects/o_main/Create_0.gml b/objects/o_main/Create_0.gml index f42687f2d..85d518022 100644 --- a/objects/o_main/Create_0.gml +++ b/objects/o_main/Create_0.gml @@ -248,4 +248,8 @@ STEAM_USERNAME = steam_get_persona_name(); steam_set_warning_message_hook(); } +#endregion + +#region tween + tweenInit(); #endregion \ No newline at end of file diff --git a/objects/o_main/Draw_75.gml b/objects/o_main/Draw_75.gml index cb6301d09..f3f9875fe 100644 --- a/objects/o_main/Draw_75.gml +++ b/objects/o_main/Draw_75.gml @@ -73,18 +73,20 @@ #region dragging if(DRAGGING != noone) { switch(DRAGGING.type) { - case "Palette" : - drawPalette(DRAGGING.data, mouse_mx, mouse_my, ui(128), ui(24)); - break; case "Color" : - draw_set_color(DRAGGING.data); - draw_set_alpha(0.5); - draw_rectangle(mouse_mx + ui(-16), mouse_my + ui(-16), mouse_mx + ui(-16 + 32), mouse_my + ui(-16 + 32), false); - draw_set_alpha(1); + draw_sprite_stretched_ext(THEME.color_picker_box, 1, mouse_mx + ui(-16), mouse_my + ui(-16), ui(32), ui(32), DRAGGING.data, 0.5); + break; + case "Palette" : + drawPalette(DRAGGING.data, mouse_mx - ui(64), mouse_my - ui(12), ui(128), ui(24), 0.5); + break; + case "Gradient" : + DRAGGING.data.draw(mouse_mx - ui(64), mouse_my - ui(12), ui(128), ui(24), 0.5); break; case "Asset" : - var ss = 32 / max(sprite_get_width(DRAGGING.data.spr), sprite_get_height(DRAGGING.data.spr)) - draw_sprite_ext(DRAGGING.data.spr, 0, mouse_mx, mouse_my, ss, ss, 0, c_white, 0.5); + if(DRAGGING.data.spr) { + var ss = 32 / max(sprite_get_width(DRAGGING.data.spr), sprite_get_height(DRAGGING.data.spr)) + draw_sprite_ext(DRAGGING.data.spr, 0, mouse_mx, mouse_my, ss, ss, 0, c_white, 0.5); + } break; case "Collection" : if(DRAGGING.data.spr) { @@ -92,6 +94,17 @@ draw_sprite_ext(DRAGGING.data.spr, 0, mouse_mx, mouse_my, ss, ss, 0, c_white, 0.5); } break; + case "Bool" : + draw_set_alpha(0.5); + draw_set_text(f_h3, fa_center, fa_center, COLORS._main_text); + draw_text_bbox({ xc: mouse_mx, yc: mouse_my, w: ui(128), h: ui(24) }, DRAGGING.data? "True" : "False"); + draw_set_alpha(1); + break; + default: + draw_set_alpha(0.5); + draw_set_text(f_h3, fa_center, fa_center, COLORS._main_text); + draw_text_bbox({ xc: mouse_mx, yc: mouse_my, w: ui(128), h: ui(24) }, DRAGGING.data); + draw_set_alpha(1); } if(mouse_release(mb_left)) diff --git a/objects/o_main/Step_0.gml b/objects/o_main/Step_0.gml index f0326e5aa..d67a6d2b1 100644 --- a/objects/o_main/Step_0.gml +++ b/objects/o_main/Step_0.gml @@ -142,6 +142,10 @@ } } #endregion + +#region tween + tweenStep(); +#endregion //print("===== Step end ====="); //if(keyboard_check_pressed(ord("Q"))) { diff --git a/scripts/Tweener/Tweener.gml b/scripts/Tweener/Tweener.gml new file mode 100644 index 000000000..ce1111e71 --- /dev/null +++ b/scripts/Tweener/Tweener.gml @@ -0,0 +1,64 @@ +enum TWEEN_TYPE { + linear, + log +} + +enum TWEEN_VALUE { + number, + color +} + +function Tween(value, valType = TWEEN_VALUE.number, twType = TWEEN_TYPE.log, twSpeed = 5) constructor { + array_push(TWEEN_VALUES, self); + + realVal = value; + showVal = value; + self.valType = valType; + + tweenType = twType; + tweenSpeed = twSpeed; + colTrans = 0; + + static set = function(value) { + if(valType == VALUE_TYPE.color) { + showVal = get(); + colTrans = 0; + } + + realVal = value; + } + static get = function(value) { + if(valType == VALUE_TYPE.color) + return colTrans == 1? realVal : merge_color(showVal, realVal, colTrans); + else + return showVal; + } + + static step = function() { + if(valType == VALUE_TYPE.color) { + if(tweenType == TWEEN_TYPE.linear) + colTrans = lerp_linear(colTrans, 1, 1 / tweenSpeed); + else if(tweenType == TWEEN_TYPE.log) + colTrans = lerp_float(colTrans, 1, tweenSpeed); + if(colTrans == 1) + showVal = realVal; + } else if(valType == VALUE_TYPE.number) { + if(tweenType == TWEEN_TYPE.linear) + showVal = lerp_linear(showVal, realVal, 1 / tweenSpeed); + else if(tweenType == TWEEN_TYPE.log) + showVal = lerp_float(showVal, realVal, tweenSpeed); + } + } + + static destroy = function() { array_remove(TWEEN_VALUES, self); } +} + +function tweenInit() { + globalvar TWEEN_VALUES; + TWEEN_VALUES = []; +} + +function tweenStep() { + for( var i = 0; i < array_length(TWEEN_VALUES); i++ ) + TWEEN_VALUES[i].step(); +} \ No newline at end of file diff --git a/scripts/Tweener/Tweener.yy b/scripts/Tweener/Tweener.yy new file mode 100644 index 000000000..1a66815ba --- /dev/null +++ b/scripts/Tweener/Tweener.yy @@ -0,0 +1,11 @@ +{ + "resourceType": "GMScript", + "resourceVersion": "1.0", + "name": "Tweener", + "isCompatibility": false, + "isDnD": false, + "parent": { + "name": "tween", + "path": "folders/functions/tween.yy", + }, +} \ No newline at end of file diff --git a/scripts/append_function/append_function.gml b/scripts/append_function/append_function.gml index 94fa07529..32869f6be 100644 --- a/scripts/append_function/append_function.gml +++ b/scripts/append_function/append_function.gml @@ -38,7 +38,7 @@ function __APPEND_MAP(_map, context = PANEL_GRAPH.getCurrentContext()) { var t = current_time; for(var i = 0; i < ds_list_size(_node_list); i++) { - var _node = nodeLoad(_node_list[| i], true); + var _node = nodeLoad(_node_list[| i], true, context); if(_node) ds_list_add(appended_list, _node); } printlog("Load time: " + string(current_time - t)); t = current_time; @@ -46,7 +46,7 @@ function __APPEND_MAP(_map, context = PANEL_GRAPH.getCurrentContext()) { try { for(var i = 0; i < ds_list_size(appended_list); i++) { var _node = appended_list[| i]; - _node.loadGroup(); + _node.loadGroup(context); if(_node.group == context) ds_list_add(node_create, _node); diff --git a/scripts/buttonGradient/buttonGradient.gml b/scripts/buttonGradient/buttonGradient.gml index 23a0348da..38de4ffc6 100644 --- a/scripts/buttonGradient/buttonGradient.gml +++ b/scripts/buttonGradient/buttonGradient.gml @@ -27,7 +27,8 @@ function buttonGradient(_onApply, dialog = noone) : widget() constructor { current_gradient = _gradient; var click = false; - if(ihover && point_in_rectangle(_m[0], _m[1], _x, _y, _x + _w, _y + _h)) { + var hoverRect = point_in_rectangle(_m[0], _m[1], _x, _y, _x + _w, _y + _h); + if(ihover && hoverRect) { draw_sprite_stretched(THEME.button, 1, _x, _y, _w, _h); if(mouse_press(mb_left, iactive)) { trigger(); @@ -45,8 +46,13 @@ function buttonGradient(_onApply, dialog = noone) : widget() constructor { if(WIDGET_CURRENT == self) draw_sprite_stretched(THEME.widget_selecting, 0, _x - ui(3), _y - ui(3), _w + ui(6), _h + ui(6)); - resetFocus(); + if(DRAGGING && DRAGGING.type == "Gradient" && hover && hoverRect) { + draw_sprite_stretched_ext(THEME.ui_panel_active, 0, _x, _y, _w, _h, COLORS._main_value_positive, 1); + if(mouse_release(mb_left)) + onApply(DRAGGING.data); + } + resetFocus(); return click; } } \ No newline at end of file diff --git a/scripts/buttonPalette/buttonPalette.gml b/scripts/buttonPalette/buttonPalette.gml index 1ba362974..c3afd6989 100644 --- a/scripts/buttonPalette/buttonPalette.gml +++ b/scripts/buttonPalette/buttonPalette.gml @@ -56,15 +56,17 @@ function buttonPalette(_onApply, dialog = noone) : widget() constructor { } } -function drawPalette(_pal, _x, _y, _w, _h) { +function drawPalette(_pal, _x, _y, _w, _h, _a = 1) { var ww = _w / array_length(_pal); + draw_set_alpha(_a); for(var i = 0; i < array_length(_pal); i++) { if(!is_real(_pal[i])) continue; draw_set_color(_pal[i]); var _x0 = _x + i * ww; - var _x1 = _x0 + ww; + var _x1 = _x0 + ww - 1; draw_rectangle(_x0, _y, _x1, _y + _h, false); } + draw_set_alpha(1); } diff --git a/scripts/controlPointBox/controlPointBox.gml b/scripts/controlPointBox/controlPointBox.gml index 82cf0ce0f..a24291303 100644 --- a/scripts/controlPointBox/controlPointBox.gml +++ b/scripts/controlPointBox/controlPointBox.gml @@ -10,8 +10,6 @@ enum PUPPET_CONTROL { enum PUPPET_FORCE_MODE { move, - pinch, - inflate, wind, } @@ -33,48 +31,32 @@ function controlPointBox(_onModify) : widget() constructor { sW = new slider(0, 32, 0.1, function(val) { onModify(PUPPET_CONTROL.width, toNumber(val)); }); - sMode = ["Move", "Pinch", "Inflate", "Wind"]; + sMode = ["Move", "Wind"]; scMode = new scrollBox( sMode, function(val) { onModify(PUPPET_CONTROL.mode, toNumber(val)); } ); + widgets = [ scMode, tbCx, tbCy, tbFx, tbFy, tbW, tbH, rot ]; + static setInteract = function(interactable = noone) { self.interactable = interactable; - scMode.interactable = interactable; - tbCx.interactable = interactable; - tbCy.interactable = interactable; - tbFx.interactable = interactable; - tbFy.interactable = interactable; - tbW.interactable = interactable; - tbH.interactable = interactable; - rot.interactable = interactable; + + for( var i = 0; i < array_length(widgets); i++ ) + widgets[i].setInteract(interactable); } static register = function(parent = noone) { - scMode.register(parent); - tbCx.register(parent); - tbCy.register(parent); - tbFx.register(parent); - tbFy.register(parent); - tbW.register(parent); - tbH.register(parent); - rot.register(parent); + for( var i = 0; i < array_length(widgets); i++ ) + widgets[i].register(parent); } static draw = function(_x, _y, _w, _data, _m, _rx, _ry) { x = _x; y = _y; - tbCx.setActiveFocus(hover, active); - tbCy.setActiveFocus(hover, active); - tbFx.setActiveFocus(hover, active); - tbFy.setActiveFocus(hover, active); - tbW.setActiveFocus(hover, active); - sW.setActiveFocus(hover, active); - tbH.setActiveFocus(hover, active); - scMode.setActiveFocus(hover, active); - rot.setActiveFocus(hover, active); + for( var i = 0; i < array_length(widgets); i++ ) + widgets[i].setActiveFocus(hover, active); var yy = _y; @@ -105,20 +87,9 @@ function controlPointBox(_onModify) : widget() constructor { sW.draw(_x + lw, yy, _w - lw, TEXTBOX_HEIGHT, _data[PUPPET_CONTROL.width], _m); yy += TEXTBOX_HEIGHT + ui(8); break; - case PUPPET_FORCE_MODE.pinch: - case PUPPET_FORCE_MODE.inflate: - draw_set_text(f_p0, fa_left, fa_center, COLORS._main_text); - draw_text(_x, yy + ui(17), "radius"); - sW.draw(_x + lw, yy, _w - lw, TEXTBOX_HEIGHT, _data[PUPPET_CONTROL.width], _m); - yy += TEXTBOX_HEIGHT + ui(8); - - draw_text(_x, yy + ui(17), "strength"); - tbH.draw(_x + lw, yy, _w - lw, TEXTBOX_HEIGHT, _data[PUPPET_CONTROL.height], _m); - yy += TEXTBOX_HEIGHT + ui(8); - break; case PUPPET_FORCE_MODE.wind: draw_set_text(f_p0, fa_left, fa_center, COLORS._main_text); - draw_text(_x, yy + ui(17), "stength"); + draw_text(_x, yy + ui(17), "strength"); tbFx.draw(_x + lw, yy, _w - lw, TEXTBOX_HEIGHT, _data[PUPPET_CONTROL.fx], _m); yy += TEXTBOX_HEIGHT + ui(8); @@ -133,7 +104,6 @@ function controlPointBox(_onModify) : widget() constructor { } resetFocus(); - return yy - _y; } } \ No newline at end of file diff --git a/scripts/directory_object/directory_object.gml b/scripts/directory_object/directory_object.gml index affa10956..ffe9eab5e 100644 --- a/scripts/directory_object/directory_object.gml +++ b/scripts/directory_object/directory_object.gml @@ -41,6 +41,12 @@ function FileObject(_name, _path) constructor { static getSpr = function() { if(sprite_exists(spr)) return spr; + if(array_length(spr_path) == 0) { + spr = sprite_add(self.path, 0, false, false, 0, 0); + sprite_set_offset(spr, sprite_get_width(spr) / 2, sprite_get_height(spr) / 2); + return spr; + } + var path = array_safe_get(spr_path, 0); var amo = array_safe_get(spr_path, 1); var cent = array_safe_get(spr_path, 2); diff --git a/scripts/draw_UI_scale/draw_UI_scale.gml b/scripts/draw_UI_scale/draw_UI_scale.gml index 7c227e3ff..7ee433a56 100644 --- a/scripts/draw_UI_scale/draw_UI_scale.gml +++ b/scripts/draw_UI_scale/draw_UI_scale.gml @@ -9,6 +9,17 @@ function line_height(font = noone, offset = 0) { return hh; } +function line_width(txt, font = noone, offset = 0) { + var ff = draw_get_font(); + + if(font != noone) + draw_set_font(font); + var ww = string_width(txt) + offset * UI_SCALE; + + draw_set_font(ff); + return ww; +} + #macro TEXTBOX_HEIGHT line_height(f_p0, 12) gml_pragma("forceinline"); diff --git a/scripts/draw_text_function/draw_text_function.gml b/scripts/draw_text_function/draw_text_function.gml index 2cbc46f31..b9cd79d25 100644 --- a/scripts/draw_text_function/draw_text_function.gml +++ b/scripts/draw_text_function/draw_text_function.gml @@ -11,13 +11,13 @@ function draw_text_ext_over(_x, _y, _text, _sep, _w) { } function draw_text_add(_x, _y, _text) { - BLEND_ADD; + BLEND_ALPHA_MULP; draw_text(_x, _y, _text); BLEND_NORMAL; } function draw_text_ext_add(_x, _y, _text, _sep, _w) { - BLEND_ADD; + BLEND_ALPHA_MULP; draw_text_ext(_x, _y, _text, _sep, _w); BLEND_NORMAL; } diff --git a/scripts/gradients_function/gradients_function.gml b/scripts/gradients_function/gradients_function.gml index 4075bf2fa..c5e9369ac 100644 --- a/scripts/gradients_function/gradients_function.gml +++ b/scripts/gradients_function/gradients_function.gml @@ -82,7 +82,7 @@ function gradientObject(color = c_black) constructor { return keys[array_length(keys) - 1].value; //after last color } - static draw = function(_x, _y, _w, _h) { + static draw = function(_x, _y, _w, _h, _a = 1) { static RES = 48; var _step = _w / RES; var _ox, _oc; @@ -106,7 +106,7 @@ function gradientObject(color = c_black) constructor { } if(array_length(keys) == 0) { - draw_sprite_stretched(s_fx_pixel, 0, _x, _y, _w, _h) + draw_sprite_stretched_ext(s_fx_pixel, 0, _x, _y, _w, _h, c_white, _a) } else { shader_set(sh_gradient_display); shader_set_uniform_i(uniform_grad_blend, type); @@ -114,7 +114,7 @@ function gradientObject(color = c_black) constructor { shader_set_uniform_f_array_safe(uniform_grad_time, _grad_time); shader_set_uniform_i(uniform_grad_key, array_length(keys)); - draw_sprite_stretched(s_fx_pixel, 0, _x, _y, _w, _h) + draw_sprite_stretched_ext(s_fx_pixel, 0, _x, _y, _w, _h, c_white, _a) shader_reset(); } } diff --git a/scripts/nodeValue_drawer/nodeValue_drawer.gml b/scripts/nodeValue_drawer/nodeValue_drawer.gml index 93ba47552..1c00a13e5 100644 --- a/scripts/nodeValue_drawer/nodeValue_drawer.gml +++ b/scripts/nodeValue_drawer/nodeValue_drawer.gml @@ -72,7 +72,7 @@ function drawWidget(xx, yy, ww, _m, jun, global_var = true, _hover, _focus, _scr cc = GLOBAL.inputGetable(jun, jun.global_key)? COLORS._main_value_positive : COLORS._main_value_negative; draw_set_text(f_p0, fa_left, fa_center, cc); - draw_text_over(xx + ui(40), lb_y - ui(2), jun.name); + draw_text_add(xx + ui(40), lb_y - ui(2), jun.name); var lb_w = string_width(jun.name) + ui(32); #region tooltip diff --git a/scripts/node_color/node_color.gml b/scripts/node_color/node_color.gml index 6512af286..9a088ccd4 100644 --- a/scripts/node_color/node_color.gml +++ b/scripts/node_color/node_color.gml @@ -11,9 +11,6 @@ function Node_Color(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) con return _data[0]; } - droppable = ["Color"]; - static onDrop = function() { inputs[| 0].setValue(DRAGGING.data); } - static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { var bbox = drawGetBbox(xx, yy, _s); if(bbox.h < 1) return; diff --git a/scripts/node_data/node_data.gml b/scripts/node_data/node_data.gml index 0bb7d4551..1a371ac23 100644 --- a/scripts/node_data/node_data.gml +++ b/scripts/node_data/node_data.gml @@ -35,7 +35,6 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x draw_name = true; draggable = true; - droppable = []; input_display_list = -1; output_display_list = -1; @@ -53,7 +52,7 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x inspecting = false; previewing = 0; - preview_surface = noone; + preview_surface = noone; preview_amount = 0; previewable = true; preview_speed = 0; @@ -62,7 +61,14 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x preview_alpha = 1; preview_x = 0; preview_y = 0; - preview_align = fa_center; + + preview_surface_prev = noone; + preview_trans = 1; + preview_drop_x = 0; + preview_drop_y = 0; + + preview_mx = 0; + preview_my = 0; rendered = false; update_on_frame = false; @@ -128,7 +134,6 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x doUpdate(); } - run_in(1, method(self, resetDefault)); static getInputJunctionIndex = function(index) { @@ -309,23 +314,6 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x static onValueUpdate = function(index = 0) {} static onValueFromUpdate = function(index) {} - static isUpdateReady = function() { - //if(rendered) return false; - - for(var j = 0; j < ds_list_size(inputs); j++) { - var _in = inputs[| j]; - var val_from = _in.value_from; - if(val_from == noone) continue; - if(!val_from.node.active) continue; - if(!val_from.node.renderActive) continue; - - if (!val_from.node.rendered) - return false; - } - - return true; - } - static triggerRender = function() { setRenderStatus(false); UPDATE |= RENDER_TYPE.partial; @@ -341,6 +329,63 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x } } + //static isUpdateReady = function() { //Removed, same as isRenderable() + // for(var j = 0; j < ds_list_size(inputs); j++) { + // var _in = inputs[| j]; + // var val_from = _in.value_from; + // if(val_from == noone) continue; + // if(!val_from.node.active) continue; + // if(!val_from.node.renderActive) continue; + + // if (!val_from.node.rendered) + // return false; + // } + + // return true; + //} + + static isRenderable = function() { //Check if every input is ready (updated) + if(!active) return false; + if(!renderActive) return false; + + var _startNode = true; + for(var j = 0; j < ds_list_size(inputs); j++) { + var _in = inputs[| j]; + if( _in.type == VALUE_TYPE.node) continue; + + var val_from = _in.value_from; + if( val_from == noone) continue; + if(!val_from.node.active) continue; + if(!val_from.node.renderActive) continue; + if(!val_from.node.rendered) + return false; + } + + return true; + } + + static getNextNodes = function() { + for(var i = 0; i < ds_list_size(outputs); i++) { + var _ot = outputs[| i]; + //if(_ot.type == VALUE_TYPE.node) continue; + + for(var j = 0; j < ds_list_size(_ot.value_to); j++) { + var _to = _ot.value_to[| j]; + if(!_to.node.renderActive) continue; + if(!_to.node.active || _to.value_from == noone) continue; + if(_to.value_from.node != self) continue; + + _to.node.triggerRender(); + + if(_to.node.isRenderable()) { + ds_queue_enqueue(RENDER_QUEUE, _to.node); + printIf(global.RENDER_LOG, " >| Push " + _to.node.name + " (" + _to.node.display_name + ") node to stack"); + } else + printIf(global.RENDER_LOG, " >| Node " + _to.node.name + " not ready"); + } + } + } + static onInspect = function() {} static setRenderStatus = function(result) { @@ -427,7 +472,7 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x var cc = COLORS._main_text; if(PREF_MAP[? "node_show_render_status"] && !rendered) - cc = isUpdateReady()? COLORS._main_value_positive : COLORS._main_value_negative; + cc = isRenderable()? COLORS._main_value_positive : COLORS._main_value_negative; draw_set_text(f_p1, fa_left, fa_center, cc); @@ -598,6 +643,7 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x if(jun.type == VALUE_TYPE.node) ty = LINE_STYLE.dashed; + var ss = _s * aa; jx *= aa; jy *= aa; frx *= aa; @@ -605,7 +651,6 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x th *= aa; cx *= aa; cy *= aa; - var ss = _s * aa; corner *= aa; switch(PREF_MAP[? "curve_connection_line"]) { @@ -649,23 +694,45 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x } preview_surface = is_surface(surf)? surf : noone; - if(!is_surface(surf)) return; + if(preview_surface == noone) return; - var pw = surface_get_width(surf); - var ph = surface_get_height(surf); + var pw = surface_get_width(preview_surface); + var ph = surface_get_height(preview_surface); var ps = min((w * _s - 8) / pw, (h * _s - 8) / ph); - var px = xx + w * _s / 2 - pw * ps / 2, py = yy; - switch(preview_align) { - case fa_center : - py = yy + h * _s / 2 - ph * ps / 2; - break; - case fa_top : - py = yy; - break; + var px = xx + w * _s / 2 - pw * ps / 2; + var py = yy + h * _s / 2 - ph * ps / 2; + var aa = 0.5 + 0.5 * renderActive; + + if(preview_trans == 1) { + draw_surface_ext_safe(preview_surface, px, py, ps, ps, 0, c_white, aa); + return; } - var aa = 0.5 + 0.5 * renderActive; - draw_surface_ext_safe(surf, px, py, ps, ps, 0, c_white, aa); + if(preview_trans < 1 && is_surface(preview_surface_prev)) { + preview_trans = lerp_float(preview_trans, 1, 8); + var _pw = surface_get_width(preview_surface_prev); + var _ph = surface_get_height(preview_surface_prev); + var _ps = min((w * _s - 8) / _pw, (h * _s - 8) / _ph); + var _px = xx + w * _s / 2 - _pw * _ps / 2; + var _py = yy + h * _s / 2 - _ph * _ps / 2; + + draw_surface_ext_safe(preview_surface_prev, _px, _py, _ps, _ps, 0, c_white, aa); + + shader_set(sh_trans_node_prev_drop); + shader_set_f("dimension", _pw, _ph); + shader_set_f("position", (preview_drop_x - px) / (_pw * _ps), (preview_drop_y - py) / (_ph * _ps)); + shader_set_f("prog", preview_trans); + draw_surface_ext_safe(preview_surface, px, py, ps, ps, 0, c_white, aa); + shader_reset(); + } else if(is_surface(preview_surface_prev)) + surface_free(preview_surface_prev); + } + + static previewDropAnimation = function() { + preview_surface_prev = surface_clone(preview_surface); + preview_trans = 0; + preview_drop_x = preview_mx; + preview_drop_y = preview_my; } static getNodeDimension = function() { @@ -736,6 +803,9 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x var xx = x * _s + _x; var yy = y * _s + _y; + preview_mx = _mx; + preview_my = _my; + if(value_validation[VALIDATION.error] || error_noti_update != noone) draw_sprite_stretched_ext(THEME.node_glow, 0, xx - 9, yy - 9, w * _s + 18, h * _s + 18, COLORS._main_value_negative, 1); @@ -755,6 +825,10 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x active_draw_index = -1; } + if(draw_droppable) + draw_sprite_stretched_ext(THEME.ui_panel_active, 0, xx, yy, w * _s, h * _s, COLORS._main_value_positive, 1); + draw_droppable = false; + return drawJunctions(xx, yy, _mx, _my, _s); } static onDrawNodeBehind = function(_x, _y, _mx, _my, _s) {} @@ -853,51 +927,6 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x static onDestroy = function() {} - static isRenderable = function(trigger = false) { - if(!active) return false; - if(!renderActive) return false; - - var _startNode = true; - for(var j = 0; j < ds_list_size(inputs); j++) { - var _in = inputs[| j]; - if( _in.type == VALUE_TYPE.node) continue; - - if(trigger) triggerRender(); - - var val_from = _in.value_from; - if( val_from == noone) continue; - if(!val_from.node.active) continue; - if(!val_from.node.renderActive) continue; - if( val_from.node.rendered == noone) continue; - - return false; - } - - return true; - } - - static getNextNodes = function() { - for(var i = 0; i < ds_list_size(outputs); i++) { - var _ot = outputs[| i]; - //if(_ot.type == VALUE_TYPE.node) continue; - - for(var j = 0; j < ds_list_size(_ot.value_to); j++) { - var _to = _ot.value_to[| j]; - if(!_to.node.renderActive) continue; - if(!_to.node.active || _to.value_from == noone) continue; - if(_to.value_from.node != self) continue; - - _to.node.triggerRender(); - - if(_to.node.isUpdateReady()) { - ds_queue_enqueue(RENDER_QUEUE, _to.node); - printIf(global.RENDER_LOG, " >| Push " + _to.node.name + " (" + _to.node.display_name + ") node to stack"); - } else - printIf(global.RENDER_LOG, " >| Node " + _to.node.name + " not ready"); - } - } - } - static clearInputCache = function() { for( var i = 0; i < ds_list_size(inputs); i++ ) inputs[| i].cache_value[0] = false; @@ -1064,7 +1093,24 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x static onClone = function(_NewNode, target = PANEL_GRAPH.getCurrentContext()) {} - static onDrop = function() {} + draw_droppable = false; + static droppable = function(dragObj) { + for( var i = 0; i < ds_list_size(inputs); i++ ) { + if(dragObj.type == inputs[| i].drop_key) + return true; + } + return false; + } + + static onDrop = function(dragObj) { + for( var i = 0; i < ds_list_size(inputs); i++ ) { + if(dragObj.type == inputs[| i].drop_key) { + inputs[| i].setValue(dragObj.data); + previewDropAnimation(); + return; + } + } + } static serialize = function(scale = false, preset = false) { var _map = ds_map_create(); @@ -1160,9 +1206,9 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x static doApplyDeserialize = function() {} - static loadGroup = function() { + static loadGroup = function(context = PANEL_GRAPH.getCurrentContext()) { if(_group == noone) { - var c = PANEL_GRAPH.getCurrentContext(); + var c = context; if(c != noone) c.add(self); } else { if(APPENDING) _group = GetAppendID(_group); diff --git a/scripts/node_feedback/node_feedback.gml b/scripts/node_feedback/node_feedback.gml index 40c81a62f..ff33ed95f 100644 --- a/scripts/node_feedback/node_feedback.gml +++ b/scripts/node_feedback/node_feedback.gml @@ -24,7 +24,7 @@ function Node_Feedback(_x, _y, _group = noone) : Node_Collection(_x, _y, _group) var _in = inputs[| i].from; if(!_in.renderActive) continue; - allReady &= _in.isUpdateReady() + allReady &= _in.isRenderable() } if(!allReady) return; diff --git a/scripts/node_group_output/node_group_output.gml b/scripts/node_group_output/node_group_output.gml index 3c546790d..73c48875e 100644 --- a/scripts/node_group_output/node_group_output.gml +++ b/scripts/node_group_output/node_group_output.gml @@ -44,9 +44,9 @@ function Node_Group_Output(_x, _y, _group = noone) : Node(_x, _y, _group) constr continue; } - printIf(global.RENDER_LOG, "Group output ready " + string(_to.node.isUpdateReady())); + printIf(global.RENDER_LOG, "Group output ready " + string(_to.node.isRenderable())); - if(_to.node.isUpdateReady()) { + if(_to.node.isRenderable()) { ds_queue_enqueue(RENDER_QUEUE, _to.node); printIf(global.RENDER_LOG, "Push node " + _to.node.name + " to stack"); } diff --git a/scripts/node_image/node_image.gml b/scripts/node_image/node_image.gml index 28588a637..989c0f954 100644 --- a/scripts/node_image/node_image.gml +++ b/scripts/node_image/node_image.gml @@ -95,7 +95,7 @@ function Node_Image(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { if(!spr || !sprite_exists(spr)) return; - var ww = sprite_get_width(spr) + pad[0] + pad[2]; + var ww = sprite_get_width(spr) + pad[0] + pad[2]; var hh = sprite_get_height(spr) + pad[1] + pad[3]; var _outsurf = outputs[| 0].getValue(); diff --git a/scripts/node_iterate/node_iterate.gml b/scripts/node_iterate/node_iterate.gml index 11b8b73d8..debc1718f 100644 --- a/scripts/node_iterate/node_iterate.gml +++ b/scripts/node_iterate/node_iterate.gml @@ -46,7 +46,7 @@ function Node_Iterate(_x, _y, _group = noone) : Node_Collection(_x, _y, _group) var _in = inputs[| i].from; if(!_in.renderActive) continue; - allReady &= _in.isUpdateReady() + allReady &= _in.isRenderable() } if(!allReady) return; diff --git a/scripts/node_iterator_each_output/node_iterator_each_output.gml b/scripts/node_iterator_each_output/node_iterator_each_output.gml index 6e0fb00b9..0bf22b06d 100644 --- a/scripts/node_iterator_each_output/node_iterator_each_output.gml +++ b/scripts/node_iterator_each_output/node_iterator_each_output.gml @@ -28,7 +28,7 @@ function Node_Iterator_Each_Output(_x, _y, _group = noone) : Node(_x, _y, _group if(_to.node.active && _to.value_from != noone && _to.value_from.node == group) { _to.node.triggerRender(); - if(_to.node.isUpdateReady()) ds_queue_enqueue(RENDER_QUEUE, _to.node); + if(_to.node.isRenderable()) ds_queue_enqueue(RENDER_QUEUE, _to.node); } } } else diff --git a/scripts/node_iterator_filter_output/node_iterator_filter_output.gml b/scripts/node_iterator_filter_output/node_iterator_filter_output.gml index 5baa2d64d..06380f2a8 100644 --- a/scripts/node_iterator_filter_output/node_iterator_filter_output.gml +++ b/scripts/node_iterator_filter_output/node_iterator_filter_output.gml @@ -28,7 +28,7 @@ function Node_Iterator_Filter_Output(_x, _y, _group = noone) : Node(_x, _y, _gro if(_to.node.active && _to.value_from != noone && _to.value_from.node == group) { _to.node.triggerRender(); - if(_to.node.isUpdateReady()) ds_queue_enqueue(RENDER_QUEUE, _to.node); + if(_to.node.isRenderable()) ds_queue_enqueue(RENDER_QUEUE, _to.node); } } } else diff --git a/scripts/node_iterator_output/node_iterator_output.gml b/scripts/node_iterator_output/node_iterator_output.gml index c4273ba2b..1595dcf5a 100644 --- a/scripts/node_iterator_output/node_iterator_output.gml +++ b/scripts/node_iterator_output/node_iterator_output.gml @@ -52,7 +52,7 @@ function Node_Iterator_Output(_x, _y, _group = noone) : Node_Group_Output(_x, _y if(_to.node.active && _to.value_from != noone && _to.value_from.node == group) { _to.node.triggerRender(); - if(_to.node.isUpdateReady()) ds_queue_enqueue(RENDER_QUEUE, _to.node); + if(_to.node.isRenderable()) ds_queue_enqueue(RENDER_QUEUE, _to.node); } } } else diff --git a/scripts/node_palette/node_palette.gml b/scripts/node_palette/node_palette.gml index 1255e776f..1e301e932 100644 --- a/scripts/node_palette/node_palette.gml +++ b/scripts/node_palette/node_palette.gml @@ -17,9 +17,6 @@ function Node_Palette(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c ["Trim", true], 1 ]; - droppable = ["Palette"]; - static onDrop = function() { inputs[| 0].setValue(DRAGGING.data); } - static process_data = function(_outSurf, _data, _output_index, _array_index) { var pal = _data[0]; var ran = _data[1]; diff --git a/scripts/node_registry/node_registry.gml b/scripts/node_registry/node_registry.gml index 21d872f56..93e8af468 100644 --- a/scripts/node_registry/node_registry.gml +++ b/scripts/node_registry/node_registry.gml @@ -556,14 +556,14 @@ function NodeObject(_name, _spr, _node, _create, tags = []) constructor { #endregion #region node function - function nodeLoad(_data, scale = false) { + function nodeLoad(_data, scale = false, _group = PANEL_GRAPH.getCurrentContext()) { if(!ds_exists(_data, ds_type_map)) return noone; var _x = ds_map_try_get(_data, "x", 0); var _y = ds_map_try_get(_data, "y", 0); var _type = ds_map_try_get(_data, "type", 0); - var _node = nodeBuild(_type, _x, _y); + var _node = nodeBuild(_type, _x, _y, _group); if(_node) { var map = ds_map_clone(_data); diff --git a/scripts/node_solid/node_solid.gml b/scripts/node_solid/node_solid.gml index 213dd669e..c4db38682 100644 --- a/scripts/node_solid/node_solid.gml +++ b/scripts/node_solid/node_solid.gml @@ -20,10 +20,7 @@ function Node_Solid(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) con ]; attribute_surface_depth(); - - droppable = ["Color"]; - static onDrop = function() { inputs[| 1].setValue(DRAGGING.data); } - + static process_data = function(_outSurf, _data, _output_index, _array_index) { var _dim = _data[0]; var _col = _data[1]; diff --git a/scripts/node_tunnel_out/node_tunnel_out.gml b/scripts/node_tunnel_out/node_tunnel_out.gml index 725a757b6..a8a082d3d 100644 --- a/scripts/node_tunnel_out/node_tunnel_out.gml +++ b/scripts/node_tunnel_out/node_tunnel_out.gml @@ -21,7 +21,7 @@ function Node_Tunnel_Out(_x, _y, _group = noone) : Node(_x, _y, _group) construc graphFocusNode(_node); } - static isRenderable = function(trigger = false) { + static isRenderable = function() { var _key = inputs[| 0].getValue(); return !ds_map_exists(TUNNELS_IN, _key); } diff --git a/scripts/node_value/node_value.gml b/scripts/node_value/node_value.gml index f124542fc..898f2f341 100644 --- a/scripts/node_value/node_value.gml +++ b/scripts/node_value/node_value.gml @@ -448,6 +448,29 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru return true; } + static setDropKey = function() { + switch(type) { + case VALUE_TYPE.integer : drop_key = "Number"; break; + case VALUE_TYPE.float : drop_key = "Number"; break; + case VALUE_TYPE.boolean : drop_key = "Bool"; break; + case VALUE_TYPE.color : + switch(display_type) { + case VALUE_DISPLAY.palette : drop_key = "Palette"; break; + case VALUE_DISPLAY.gradient : drop_key = "Gradient"; break; + default : drop_key = "Color"; + } + break; + case VALUE_TYPE.path : drop_key = "Asset"; break; + case VALUE_TYPE.text : drop_key = "Text"; break; + case VALUE_TYPE.pathnode : drop_key = "Path"; break; + case VALUE_TYPE.struct : drop_key = "Struct"; break; + + default: + drop_key = "None"; + } + } + setDropKey(); + static resetDisplay = function() { editWidget = noone; switch(display_type) { @@ -788,6 +811,8 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru show_in_inspector = true; break; } + + setDropKey(); } resetDisplay(); @@ -959,8 +984,6 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru var typ = nod.type; var dis = nod.display_type; - var _base = __getAnimValue(_time); - if(typ == VALUE_TYPE.surface && (type == VALUE_TYPE.integer || type == VALUE_TYPE.float) && accept_array) { //Dimension conversion if(is_array(val)) { var eqSize = true; @@ -986,12 +1009,12 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru return [1, 1]; } - if(is_array(_base) && !typeArrayDynamic(display_type)) { //Balance array (generate uniform array from single values) + if(is_array(def_val) && !typeArrayDynamic(display_type)) { //Balance array (generate uniform array from single values) if(!is_array(val)) { - val = array_create(array_length(_base), val); + val = array_create(array_length(def_val), val); return valueProcess(val, nod, applyUnit, arrIndex); - } else if(array_length(val) < array_length(_base)) { - for( var i = array_length(val); i < array_length(_base); i++ ) + } else if(array_length(val) < array_length(def_val)) { + for( var i = array_length(val); i < array_length(def_val); i++ ) val[i] = 0; } } @@ -1455,6 +1478,23 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru PANEL_ANIMATION.updatePropertyList(); } + static dragValue = function() { + if(drop_key == "None") return; + + DRAGGING = { + type: drop_key, + data: showValue(), + } + + if(type == VALUE_TYPE.path) { + DRAGGING.data = new FileObject(node.name, DRAGGING.data); + DRAGGING.data.getSpr(); + } + + if(connect_type == JUNCTION_CONNECT.input) + DRAGGING.from = self; + } + static serialize = function(scale = false, preset = false) { var _map = ds_map_create(); diff --git a/scripts/node_wrap_mesh/node_wrap_mesh.gml b/scripts/node_wrap_mesh/node_wrap_mesh.gml index 7b4b0d476..febbef407 100644 --- a/scripts/node_wrap_mesh/node_wrap_mesh.gml +++ b/scripts/node_wrap_mesh/node_wrap_mesh.gml @@ -3,8 +3,8 @@ function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) data = { points : [[]], - tris : ds_list_create(), - links : ds_list_create() + tris : [], + links : [] } inputs[| 0] = nodeValue("Surface in", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, 0); @@ -22,6 +22,9 @@ function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) inputs[| 5] = nodeValue("Active", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true); active_index = 5; + + inputs[| 6] = nodeValue("Link strength", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0, "Link length preservation, setting it to 1 will prevent any stretching, contraction.") + .setDisplay(VALUE_DISPLAY.slider, [ 0, 1, 0.01 ] ); control_index = ds_list_size(inputs); @@ -39,7 +42,8 @@ function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) outputs[| 1] = nodeValue("Mesh data", self, JUNCTION_CONNECT.output, VALUE_TYPE.object, data); input_display_list = [ 5, - ["Mesh", false], 0, 1, 2, 4, 3, + ["Mesh", false], 0, 1, 3, + ["Link", false], 4, 6, ["Control points", false], ]; @@ -66,12 +70,10 @@ function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) } static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) { - for(var i = 0; i < ds_list_size(data.links); i++) { - data.links[| i].draw(_x, _y, _s); - } - for(var i = 0; i < ds_list_size(data.tris); i++) { - data.tris[| i].drawPoints(_x, _y, _s); - } + for(var i = 0; i < array_length(data.links); i++) + data.links[i].draw(_x, _y, _s); + for(var i = 0; i < array_length(data.tris); i++) + data.tris[i].drawPoints(_x, _y, _s); var hover = -1; for(var i = control_index; i < ds_list_size(inputs); i++) { @@ -113,8 +115,8 @@ function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) var _yy = (_my - _y) / _s; if(mouse_click(mb_left)) { - for(var j = 0; j < ds_list_size(data.tris); j++) { - var t = data.tris[| j]; + for(var j = 0; j < array_length(data.tris); j++) { + var t = data.tris[j]; if(point_in_circle(t.p0.x, t.p0.y, _xx, _yy, rad / _s)) t.p0.setPin(!key_mod_press(SHIFT)); @@ -210,11 +212,12 @@ function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) len = point_distance(p0.x, p0.y, p1.x, p1.y); - static resolve = function() { + static resolve = function(strength = 1) { var _len = point_distance(p0.x, p0.y, p1.x, p1.y); var _dir = point_direction(p0.x, p0.y, p1.x, p1.y); - - var f = k * (_len - len); + + var _slen = lerp(_len, len, strength); + var f = k * (_len - _slen); var dx = lengthdir_x(f, _dir); var dy = lengthdir_y(f, _dir); @@ -358,17 +361,16 @@ function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) } static reset = function() { - for(var i = 0; i < ds_list_size(data.tris); i++) - data.tris[| i].reset(); + for(var i = 0; i < array_length(data.tris); i++) + data.tris[i].reset(); } static setTriangle = function() { - var _inSurf = inputs[| 0].getValue(); - + var _inSurf = inputs[| 0].getValue(); regularTri(_inSurf); - for(var i = 0; i < ds_list_size(data.tris); i++) - data.tris[| i].initSurface(is_array(_inSurf)? _inSurf[0] : _inSurf); + for(var i = 0; i < array_length(data.tris); i++) + data.tris[i].initSurface(is_array(_inSurf)? _inSurf[0] : _inSurf); } static affectPoint = function(c, p) { @@ -388,20 +390,6 @@ function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) p.planMove(fx * inf, fy * inf); break; - case PUPPET_FORCE_MODE.pinch: - var dis = point_distance(cx, cy, p.x, p.y); - var inf = power(clamp(1 - dis / cw, 0, 1), 2) / 2; - var dir = point_direction(p.x, p.y, cx, cy); - - p.planMove(lengthdir_x(inf, dir) * ch, lengthdir_y(inf, dir) * ch); - break; - case PUPPET_FORCE_MODE.inflate: - var dis = point_distance(cx, cy, p.x, p.y); - var inf = power(clamp(1 - dis / cw, 0, 1), 2) / 2; - var dir = point_direction(cx, cy, p.x, p.y); - - p.planMove(lengthdir_x(inf, dir) * ch, lengthdir_y(inf, dir) * ch); - break; case PUPPET_FORCE_MODE.wind: var lx0 = cx + lengthdir_x(1000, fy); var ly0 = cy + lengthdir_y(1000, fy); @@ -418,39 +406,39 @@ function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) } static control = function() { + var lStr = inputs[| 6].getValue(); + for(var i = control_index; i < ds_list_size(inputs); i++) { var c = inputs[| i].getValue(); - for(var j = 0; j < ds_list_size(data.tris); j++) { - affectPoint(c, data.tris[| j].p0); - affectPoint(c, data.tris[| j].p1); - affectPoint(c, data.tris[| j].p2); + for( var j = 0; j < array_length(data.points); j++ ) + for( var k = 0; k < array_length(data.points[j]); k++ ) { + if(data.points[j][k] == 0) continue; + affectPoint(c, data.points[j][k]); } } - var it = attributes[? "iteration"]; - var resit = it; - var _rat = power(1 / it, 2); + var it = attributes[? "iteration"]; + var _rat = 1 / it; repeat(it) { - for(var j = 0; j < ds_list_size(data.tris); j++) { - var t = data.tris[| j]; - t.p0.stepMove(_rat); - t.p1.stepMove(_rat); - t.p2.stepMove(_rat); + for( var j = 0; j < array_length(data.points); j++ ) + for( var k = 0; k < array_length(data.points[j]); k++ ) { + if(data.points[j][k] == 0) continue; + data.points[j][k].stepMove(_rat); } - repeat(resit) { - for(var i = 0; i < ds_list_size(data.links); i++) - data.links[| i].resolve(); + if(lStr > 0) + repeat(it) { + for(var i = 0; i < array_length(data.links); i++) + data.links[i].resolve(lStr); } } - for(var j = 0; j < ds_list_size(data.tris); j++) { - var t = data.tris[| j]; - t.p0.clearMove(); - t.p1.clearMove(); - t.p2.clearMove(); + for( var j = 0; j < array_length(data.points); j++ ) + for( var k = 0; k < array_length(data.points[j]); k++ ) { + if(data.points[j][k] == 0) continue; + data.points[j][k].clearMove(); } } @@ -465,8 +453,8 @@ function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) surface_set_shader(_outSurf); shader_set_interpolation(_outSurf); - for(var i = 0; i < ds_list_size(data.tris); i++) - data.tris[| i].drawSurface(_inSurf); + for(var i = 0; i < array_length(data.tris); i++) + data.tris[i].drawSurface(_inSurf); surface_reset_shader(); return _outSurf; diff --git a/scripts/panel_collection/panel_collection.gml b/scripts/panel_collection/panel_collection.gml index 6407221eb..d3ff74e85 100644 --- a/scripts/panel_collection/panel_collection.gml +++ b/scripts/panel_collection/panel_collection.gml @@ -325,7 +325,7 @@ function Panel_Collection() : PanelContent() constructor { var _path = ext == ".pxcc"? _pre_name : _pre_name + ".pxcc"; if(ds_list_empty(PANEL_GRAPH.nodes_select_list)) - SAVE_COLLECTION(PANEL_INSPECTOR.inspecting, _path, save_surface, metadata); + SAVE_COLLECTION(PANEL_INSPECTOR.inspecting, _path, save_surface, metadata, PANEL_INSPECTOR.inspecting.group); else SAVE_COLLECTIONS(PANEL_GRAPH.nodes_select_list, _path, save_surface, metadata); diff --git a/scripts/panel_data/panel_data.gml b/scripts/panel_data/panel_data.gml index 965193112..6167db138 100644 --- a/scripts/panel_data/panel_data.gml +++ b/scripts/panel_data/panel_data.gml @@ -859,8 +859,10 @@ function PanelContent() constructor { function draw(panel) { self.panel = panel; - pFOCUS = FOCUS == panel && panel.mouse_active; - pHOVER = HOVER == panel && panel.mouse_active; + if(o_main.panel_dragging == noone) { + pFOCUS = FOCUS == panel && panel.mouse_active; + pHOVER = HOVER == panel && panel.mouse_active; + } drawContent(panel); } diff --git a/scripts/panel_graph/panel_graph.gml b/scripts/panel_graph/panel_graph.gml index de383f54b..8077b111e 100644 --- a/scripts/panel_graph/panel_graph.gml +++ b/scripts/panel_graph/panel_graph.gml @@ -17,8 +17,8 @@ function Panel_Graph() : PanelContent() constructor { graph_drag_my = 0; graph_drag_sx = 0; graph_drag_sy = 0; - drag_key = mb_middle; - drag_locking = false; + drag_key = mb_middle; + drag_locking = false; mouse_graph_x = 0; mouse_graph_y = 0; @@ -640,9 +640,11 @@ function Panel_Graph() : PanelContent() constructor { } //print("Draw connection: " + string(current_time - t)); t = current_time; surface_reset_target(); - gpu_set_texfilter(true); - draw_surface_ext(connection_surface, 0, 0, 1 / aa, 1 / aa, 0, c_white, 1); - gpu_set_texfilter(false); + shader_set(sh_downsample); + shader_set_f("down", aa); + shader_set_f("dimension", surface_get_width(connection_surface), surface_get_height(connection_surface)); + draw_surface(connection_surface, 0, 0); + shader_reset(); junction_hovering = node_hovering == noone? hov : noone; value_focus = noone; @@ -886,7 +888,7 @@ function Panel_Graph() : PanelContent() constructor { var _map = ds_map_create(); var _node = ds_list_create(); for(var i = 0; i < array_length(nodeArray); i++) - SAVE_NODE(_node, nodeArray[i]); + SAVE_NODE(_node, nodeArray[i],,,, getCurrentContext()); ds_map_add_list(_map, "nodes", _node); APPENDING = true; @@ -960,7 +962,7 @@ function Panel_Graph() : PanelContent() constructor { var _map = ds_map_create(); var _node = ds_list_create(); for(var i = 0; i < array_length(nodeArray); i++) - SAVE_NODE(_node, nodeArray[i]); + SAVE_NODE(_node, nodeArray[i],,,, getCurrentContext()); ds_map_add_list(_map, "nodes", _node); clipboard_set_text(json_encode_minify(_map)); @@ -1720,17 +1722,10 @@ function Panel_Graph() : PanelContent() constructor { draw_text(w - ui(8), ui(28), get_text("panel_graph_rendering_partial", "Rendering partial") + "..."); if(DRAGGING && pHOVER) { - var droppable = true; - if(node_hovering && array_exists(node_hovering.droppable, DRAGGING.type)) { - var n = node_hovering; - var nx = graph_x + n.x * graph_s; - var ny = graph_y + n.y * graph_s; - var nw = n.w * graph_s; - var nh = n.h * graph_s; - - draw_sprite_stretched_ext(THEME.ui_panel_active, 0, nx, ny, nw, nh, COLORS._main_value_positive, 1); + if(node_hovering && node_hovering.droppable(DRAGGING)) { + node_hovering.draw_droppable = true; if(mouse_release(mb_left)) - node_hovering.onDrop(); + node_hovering.onDrop(DRAGGING); } else { draw_sprite_stretched_ext(THEME.ui_panel_active, 0, 2, 2, w - 4, h - 4, COLORS._main_value_positive, 1); if(mouse_release(mb_left)) @@ -1740,15 +1735,52 @@ function Panel_Graph() : PanelContent() constructor { } static checkDropItem = function() { + var node = noone; + switch(DRAGGING.type) { case "Color": - var node = nodeBuild("Node_Color", mouse_grid_x, mouse_grid_y, getCurrentContext()); + node = nodeBuild("Node_Color", mouse_grid_x, mouse_grid_y, getCurrentContext()); node.inputs[| 0].setValue(DRAGGING.data); break; case "Palette": - var node = nodeBuild("Node_Palette", mouse_grid_x, mouse_grid_y, getCurrentContext()); + node = nodeBuild("Node_Palette", mouse_grid_x, mouse_grid_y, getCurrentContext()); node.inputs[| 0].setValue(DRAGGING.data); break; + case "Gradient": + node = nodeBuild("Node_Gradient_Out", mouse_grid_x, mouse_grid_y, getCurrentContext()); + node.inputs[| 0].setValue(DRAGGING.data); + break; + + case "Number": + if(is_array(DRAGGING.data) && array_length(DRAGGING.data) <= 4) { + switch(array_length(DRAGGING.data)) { + case 2 : node = nodeBuild("Node_Vector2", mouse_grid_x, mouse_grid_y, getCurrentContext()); break; + case 3 : node = nodeBuild("Node_Vector3", mouse_grid_x, mouse_grid_y, getCurrentContext()); break; + case 4 : node = nodeBuild("Node_Vector4", mouse_grid_x, mouse_grid_y, getCurrentContext()); break; + } + + for( var i = 0; i < array_length(DRAGGING.data); i++ ) + node.inputs[| i].setValue(DRAGGING.data[i]); + } else { + node = nodeBuild("Node_Number", mouse_grid_x, mouse_grid_y, getCurrentContext()); + node.inputs[| 0].setValue(DRAGGING.data); + } + break; + case "Bool": + node = nodeBuild("Node_Boolean", mouse_grid_x, mouse_grid_y, getCurrentContext()); + node.inputs[| 0].setValue(DRAGGING.data); + break; + case "Text": + node = nodeBuild("Node_String", mouse_grid_x, mouse_grid_y, getCurrentContext()); + node.inputs[| 0].setValue(DRAGGING.data); + break; + case "Path": + node = nodeBuild("Node_Path", mouse_grid_x, mouse_grid_y, getCurrentContext()); + break; + case "Struct": + node = nodeBuild("Node_Struct", mouse_grid_x, mouse_grid_y, getCurrentContext()); + break; + case "Asset": var app = Node_create_Image_path(mouse_grid_x, mouse_grid_y, DRAGGING.data.path); break; @@ -1782,6 +1814,9 @@ function Panel_Graph() : PanelContent() constructor { } break; } + + if(key_mod_press(SHIFT) && node && struct_has(DRAGGING, "from") && DRAGGING.from.value_from == noone) + DRAGGING.from.setFrom(node.outputs[| 0]); } static bringNodeToFront = function(node) { diff --git a/scripts/panel_inspector/panel_inspector.gml b/scripts/panel_inspector/panel_inspector.gml index 2494fc494..b69cf8b69 100644 --- a/scripts/panel_inspector/panel_inspector.gml +++ b/scripts/panel_inspector/panel_inspector.gml @@ -15,8 +15,12 @@ function Panel_Inspector() : PanelContent() constructor { inspecting = noone; top_bar_h = ui(96); - prop_hover = noone; - prop_selecting = noone; + prop_hover = noone; + prop_selecting = noone; + + prop_dragging = noone; + prop_sel_drag_x = 0; + prop_sel_drag_y = 0; function initSize() { content_w = w - ui(32); @@ -413,18 +417,32 @@ function Panel_Inspector() : PanelContent() constructor { } var lb_h = line_height(f_p0) + ui(8); + var lb_w = line_width(jun.name, f_p0) + ui(16); var padd = ui(8); + var _selY = yy - ui(0); + var lbHov = point_in_rectangle(_m[0], _m[1], ui(48), _selY, ui(48) + lb_w, _selY + lb_h); + if(lbHov) + draw_sprite_stretched_ext(THEME.group_label, 0, ui(48), _selY + ui(2), lb_w, lb_h - ui(4), COLORS._main_icon_dark, 0.85); + var widg = drawWidget(ui(16), yy, contentPane.surface_w - ui(24), _m, jun, false, pHOVER && contentPane.hover, pFOCUS, contentPane, ui(16) + x, top_bar_h + y); var widH = widg[0]; var mbRight = widg[1]; hh += lb_h + widH + padd; - var _selY = yy - ui(0); var _selY1 = yy + lb_h + widH + ui(2); var _selH = _selY1 - _selY; + if(_hover && lbHov) { + if(prop_dragging == noone && mouse_press(mb_left, pFOCUS)) { + prop_dragging = jun; + + prop_sel_drag_x = mouse_mx; + prop_sel_drag_y = mouse_my; + } + } + if(_hover && point_in_rectangle(_m[0], _m[1], 4, _selY, contentPane.surface_w - ui(4), _selY + _selH)) { draw_sprite_stretched_ext(THEME.prop_selecting, 0, 4, _selY, contentPane.surface_w - ui(8), _selH, COLORS._main_accent, 1); if(anim_toggling) { @@ -489,6 +507,16 @@ function Panel_Inspector() : PanelContent() constructor { } } + if(prop_dragging) { + if(DRAGGING == noone && point_distance(prop_sel_drag_x, prop_sel_drag_y, mouse_mx, mouse_my) > 16) { + prop_dragging.dragValue(); + prop_dragging = noone; + } + + if(mouse_release(mb_left)) + prop_dragging = noone; + } + return hh; }); diff --git a/scripts/panel_palette/panel_palette.gml b/scripts/panel_palette/panel_palette.gml index 2f1711f60..aa7796593 100644 --- a/scripts/panel_palette/panel_palette.gml +++ b/scripts/panel_palette/panel_palette.gml @@ -115,7 +115,7 @@ function Panel_Palette() : PanelContent() constructor { presetCollect(); bx -= ui(32) - if(buttonInstant(THEME.button_hide, bx, by, ui(32), ui(32), [mx, my], pFOCUS, pHOVER, "Change view", THEME.icon_visibility, 1, COLORS._main_icon) == 2) + if(buttonInstant(THEME.button_hide, bx, by, ui(32), ui(32), [mx, my], pFOCUS, pHOVER, "Change preview size", THEME.icon_visibility, 1, COLORS._main_icon) == 2) view_mode = (view_mode + 1) % 3; } } \ No newline at end of file diff --git a/scripts/preview_overlay_puppet/preview_overlay_puppet.gml b/scripts/preview_overlay_puppet/preview_overlay_puppet.gml index 64bf92f9b..96cde5226 100644 --- a/scripts/preview_overlay_puppet/preview_overlay_puppet.gml +++ b/scripts/preview_overlay_puppet/preview_overlay_puppet.gml @@ -7,6 +7,7 @@ function preview_overlay_puppet(active, _x, _y, _s, _mx, _my, _snx, _sny) { var __ay = _val[PUPPET_CONTROL.cy]; var __ax1 = _val[PUPPET_CONTROL.fx]; var __ay1 = _val[PUPPET_CONTROL.fy]; + var __wd = _val[PUPPET_CONTROL.width]; var _ax = __ax * _s + _x; var _ay = __ay * _s + _y; @@ -18,20 +19,30 @@ function preview_overlay_puppet(active, _x, _y, _s, _mx, _my, _snx, _sny) { switch(_val[PUPPET_CONTROL.mode]) { case PUPPET_FORCE_MODE.move : draw_line_width2(_ax, _ay, _ax1, _ay1, 6, 1); - + draw_circle(_ax, _ay, __wd * _s, true); + draw_sprite_ui_uniform(THEME.anchor_selector, 0, _ax, _ay); draw_sprite_ui_uniform(THEME.anchor_selector, 2, _ax1, _ay1); - draw_circle(_ax, _ay, _val[PUPPET_CONTROL.width] * _s, true); - break; - case PUPPET_FORCE_MODE.pinch : - case PUPPET_FORCE_MODE.inflate : - draw_sprite_ui_uniform(THEME.anchor_selector, 0, _ax, _ay); - draw_circle(_ax, _ay, _val[PUPPET_CONTROL.width] * _s, true); + + if(point_in_circle(_mx, _my, _ax + __wd * _s, _ay, 8)) { + hover = 3; + draw_sprite_ui_uniform(THEME.anchor_scale_hori, 1, _ax + __wd * _s, _ay); + if(mouse_press(mb_left, active)) { + drag_type = 3; + drag_mx = _mx; + drag_sx = __wd; + } + } else + draw_sprite_ui_uniform(THEME.anchor_scale_hori, drag_type == 3, _ax + __wd * _s, _ay); break; case PUPPET_FORCE_MODE.wind : var dir = _val[PUPPET_CONTROL.fy]; + var str = _val[PUPPET_CONTROL.fx] * _s; var rad = _val[PUPPET_CONTROL.width] * _s; + var _lx = _ax + lengthdir_x(str, dir); + var _ly = _ay + lengthdir_y(str, dir); + var _l0x = _ax + lengthdir_x(rad, dir + 90); var _l0y = _ay + lengthdir_y(rad, dir + 90); var _l1x = _ax + lengthdir_x(rad, dir - 90); @@ -46,10 +57,49 @@ function preview_overlay_puppet(active, _x, _y, _s, _mx, _my, _snx, _sny) { var _l1y0 = _l1y + lengthdir_y(1000, dir); var _l1x1 = _l1x + lengthdir_x(1000, dir + 180); var _l1y1 = _l1y + lengthdir_y(1000, dir + 180); - + draw_line(_l0x0, _l0y0, _l0x1, _l0y1); draw_line(_l1x0, _l1y0, _l1x1, _l1y1); draw_sprite_ui_uniform(THEME.anchor_selector, 0, _ax, _ay); + + if(point_in_circle(_mx, _my, _l0x, _l0y, 8)) { + hover = 4; + draw_sprite_ui_uniform(THEME.anchor_scale_hori, 1, _l0x, _l0y,,,, dir + 90); + if(mouse_press(mb_left, active)) { + drag_type = 4; + drag_sx = _ax; + drag_sy = _ay; + } + } else + draw_sprite_ui_uniform(THEME.anchor_scale_hori, drag_type == 4, _l0x, _l0y,,,, dir + 90); + + if(point_in_circle(_mx, _my, _lx, _ly, 8)) { + hover = 5; + draw_sprite_ui_uniform(THEME.anchor_scale_hori, 1, _lx, _ly,,,, dir); + if(mouse_press(mb_left, active)) { + drag_type = 5; + drag_sx = _ax; + drag_sy = _ay; + } + } else + draw_sprite_ui_uniform(THEME.anchor_scale_hori, drag_type == 5, _lx, _ly,,,, dir); + + var rx = _ax + lengthdir_x(64, dir + 45); + var ry = _ay + lengthdir_y(64, dir + 45); + + if(point_in_circle(_mx, _my, rx, ry, 8)) { + draw_set_color(COLORS._main_accent); + draw_circle(_ax, _ay, 64, true); + + hover = 6; + draw_sprite_ui_uniform(THEME.anchor_rotate, 1, rx, ry,,,, dir - 45); + if(mouse_press(mb_left, active)) { + drag_type = 6; + drag_sx = _ax; + drag_sy = _ay; + } + } else + draw_sprite_ui_uniform(THEME.anchor_rotate, drag_type == 6, rx, ry,,,, dir - 45); break; } @@ -65,14 +115,6 @@ function preview_overlay_puppet(active, _x, _y, _s, _mx, _my, _snx, _sny) { _val[PUPPET_CONTROL.cx] = _nx; _val[PUPPET_CONTROL.cy] = _ny; } - - if(setValue( _val )) - UNDO_HOLDING = true; - - if(mouse_release(mb_left)) { - drag_type = 0; - UNDO_HOLDING = false; - } } else if(drag_type == 2) { draw_sprite_ui_uniform(THEME.anchor_selector, 0, _ax1, _ay1); var _nx = value_snap(drag_sx + (_mx - drag_mx) / _s, _snx); @@ -85,10 +127,40 @@ function preview_overlay_puppet(active, _x, _y, _s, _mx, _my, _snx, _sny) { _val[PUPPET_CONTROL.fx] = _nx; _val[PUPPET_CONTROL.fy] = _ny; } - + } else if(drag_type == 3) { + var _nx = value_snap(drag_sx + (_mx - drag_mx) / _s, _snx); + + if(key_mod_press(CTRL)) + _val[PUPPET_CONTROL.width] = round(_nx); + else + _val[PUPPET_CONTROL.width] = _nx; + } else if(drag_type == 4) { + var _nx = value_snap(point_distance(_mx, _my, drag_sx, drag_sy) / _s, _snx); + + if(key_mod_press(CTRL)) + _val[PUPPET_CONTROL.width] = round(_nx); + else + _val[PUPPET_CONTROL.width] = _nx; + } else if(drag_type == 5) { + var _nx = value_snap(point_distance(_mx, _my, drag_sx, drag_sy) / _s, _snx); + + if(key_mod_press(CTRL)) + _val[PUPPET_CONTROL.fx] = round(_nx); + else + _val[PUPPET_CONTROL.fx] = _nx; + } else if(drag_type == 6) { + var _nx = point_direction(drag_sx, drag_sy, _mx, _my) - 45; + + if(key_mod_press(CTRL)) + _val[PUPPET_CONTROL.fy] = round(_nx); + else + _val[PUPPET_CONTROL.fy] = _nx; + } + + if(drag_type >= 0) { if(setValue( _val )) UNDO_HOLDING = true; - + if(mouse_release(mb_left)) { drag_type = 0; UNDO_HOLDING = false; diff --git a/scripts/render_data/render_data.gml b/scripts/render_data/render_data.gml index ae0ed6881..58a02bb10 100644 --- a/scripts/render_data/render_data.gml +++ b/scripts/render_data/render_data.gml @@ -13,7 +13,8 @@ function __nodeLeafList(_list, _queue) { if(!_node.active) continue; if(!_node.renderActive) continue; - var _startNode = _node.isRenderable(true); + _node.triggerRender(); + var _startNode = _node.isRenderable(); if(_startNode) { ds_queue_enqueue(_queue, _node); printIf(global.RENDER_LOG, "Push node " + _node.name + " to stack"); @@ -68,19 +69,19 @@ function Render(partial = false, runAction = false) { key = ds_map_find_next(NODE_MAP, key); if(is_undefined(_node)) continue; - if(!is_struct(_node)) continue; + if(!is_struct(_node)) continue; if(array_exists(global.group_inputs, instanceof(_node))) continue; - if(!_node.active) continue; + if(!_node.active) continue; if(!_node.renderActive) continue; - if(_node.rendered) continue; + if(_node.rendered) continue; if(__nodeInLoop(_node)) continue; var _startNode = _node.isRenderable(); - if(_startNode) { + printIf(global.RENDER_LOG, " > Check leaf " + _node.name + " (" + _node.display_name + "): " + string(_startNode)); + + if(_startNode) ds_queue_enqueue(RENDER_QUEUE, _node); - printIf(global.RENDER_LOG, " > Push " + _node.name + " (" + _node.display_name + ") node to stack"); - } } // render forward diff --git a/scripts/save_function/save_function.gml b/scripts/save_function/save_function.gml index f62a70673..b447a7c29 100644 --- a/scripts/save_function/save_function.gml +++ b/scripts/save_function/save_function.gml @@ -122,7 +122,7 @@ function SAVE_AT(path, log = "save at ") { return true; } -function SAVE_COLLECTIONS(_list, _path, save_surface = true, metadata = noone) { +function SAVE_COLLECTIONS(_list, _path, save_surface = true, metadata = noone, context = PANEL_GRAPH.getCurrentContext()) { var _map = ds_map_create(); _map[? "version"] = SAVEFILE_VERSION; @@ -145,7 +145,7 @@ function SAVE_COLLECTIONS(_list, _path, save_surface = true, metadata = noone) { } for(var i = 0; i < ds_list_size(_list); i++) - SAVE_NODE(_node_list, _list[| i], cx, cy, true); + SAVE_NODE(_node_list, _list[| i], cx, cy, true, context); ds_map_add_list(_map, "nodes", _node_list); if(metadata != noone) @@ -163,7 +163,7 @@ function SAVE_COLLECTIONS(_list, _path, save_surface = true, metadata = noone) { PANEL_MENU.setNotiIcon(THEME.noti_icon_file_save); } -function SAVE_COLLECTION(_node, _path, save_surface = true, metadata = noone) { +function SAVE_COLLECTION(_node, _path, save_surface = true, metadata = noone, context = PANEL_GRAPH.getCurrentContext()) { if(save_surface) { var preview_surface = PANEL_PREVIEW.getNodePreviewSurface(); if(is_surface(preview_surface)) { @@ -176,7 +176,7 @@ function SAVE_COLLECTION(_node, _path, save_surface = true, metadata = noone) { _map[? "version"] = SAVEFILE_VERSION; var _node_list = ds_list_create(); - SAVE_NODE(_node_list, _node, _node.x, _node.y, true); + SAVE_NODE(_node_list, _node, _node.x, _node.y, true, context); ds_map_add_list(_map, "nodes", _node_list); if(metadata != noone) @@ -194,20 +194,19 @@ function SAVE_COLLECTION(_node, _path, save_surface = true, metadata = noone) { PANEL_MENU.setNotiIcon(THEME.noti_icon_file_save); } -function SAVE_NODE(_list, _node, dx = 0, dy = 0, scale = false) { +function SAVE_NODE(_list, _node, dx = 0, dy = 0, scale = false, context = PANEL_GRAPH.getCurrentContext()) { if(variable_struct_exists(_node, "nodes")) { - for(var i = 0; i < ds_list_size(_node.nodes); i++) { - var _n = _node.nodes[| i]; - SAVE_NODE(_list, _n, dx, dy, scale); - } + for(var i = 0; i < ds_list_size(_node.nodes); i++) + SAVE_NODE(_list, _node.nodes[| i], dx, dy, scale, context); } var m = _node.serialize(scale); m[? "x"] -= dx; m[? "y"] -= dy; - var c = PANEL_GRAPH.getCurrentContext(); - if(c != noone) c = c.node_id; - if(m[? "group"] == c) m[? "group"] = noone; + + var c = context == noone? noone : context.node_id; + if(m[? "group"] == c) + m[? "group"] = noone; ds_list_add(_list, m); ds_list_mark_as_map(_list, ds_list_size(_list) - 1); diff --git a/scripts/shader_functions/shader_functions.gml b/scripts/shader_functions/shader_functions.gml index 256a37185..d430c4f7d 100644 --- a/scripts/shader_functions/shader_functions.gml +++ b/scripts/shader_functions/shader_functions.gml @@ -5,9 +5,9 @@ function shader_set_i(uniform, value) { return; } - if(argument_count > 3) { + if(argument_count > 2) { var array = []; - for( var i = 2; i < argument_count; i++ ) + for( var i = 1; i < argument_count; i++ ) array_push(array, argument[i]); shader_set_i_array(shader, uniform, array) return; @@ -27,9 +27,9 @@ function shader_set_f(uniform, value) { return; } - if(argument_count > 3) { + if(argument_count > 2) { var array = []; - for( var i = 2; i < argument_count; i++ ) + for( var i = 1; i < argument_count; i++ ) array_push(array, argument[i]); shader_set_f_array(shader, uniform, array) return; diff --git a/scripts/textArea/textArea.gml b/scripts/textArea/textArea.gml index 5c2419e53..fcb8573fe 100644 --- a/scripts/textArea/textArea.gml +++ b/scripts/textArea/textArea.gml @@ -403,6 +403,8 @@ function textArea(_input, _onModify, _extras = noone) : textInput(_input, _onMod } } + var hoverRect = point_in_rectangle(_m[0], _m[1], _x, _y, _x + _w, _y + hh); + if(self == WIDGET_CURRENT) { draw_set_text(font, fa_left, fa_top, COLORS._main_text); draw_sprite_stretched(THEME.textbox, 2, _x, _y, _w, hh); @@ -570,7 +572,7 @@ function textArea(_input, _onModify, _extras = noone) : textInput(_input, _onMod var _mx = -1; var _my = -1; - if(hover && point_in_rectangle(_m[0], _m[1], _x, _y, _x + _w, _y + hh)) { + if(hover && hoverRect) { _mx = _m[0]; _my = _m[1]; } @@ -587,7 +589,7 @@ function textArea(_input, _onModify, _extras = noone) : textInput(_input, _onMod deactivate(); } } else { - if(hover && point_in_rectangle(_m[0], _m[1], _x, _y, _x + _w, _y + hh)) { + if(hover && hoverRect) { if(hide) draw_sprite_stretched_ext(THEME.textbox, 1, _x, _y, _w, hh, c_white, 0.5); else @@ -601,6 +603,12 @@ function textArea(_input, _onModify, _extras = noone) : textInput(_input, _onMod display_text(tx, _y + ui(7), _text, _w - ui(4)); } + if(DRAGGING && (DRAGGING.type == "Text" || DRAGGING.type == "Number") && hover && hoverRect) { + draw_sprite_stretched_ext(THEME.ui_panel_active, 0, _x, _y, _w, hh, COLORS._main_value_positive, 1); + if(mouse_release(mb_left)) + onModify(DRAGGING.data); + } + resetFocus(); return hh; diff --git a/scripts/textBox/textBox.gml b/scripts/textBox/textBox.gml index 5a4983eaf..bf29f47b4 100644 --- a/scripts/textBox/textBox.gml +++ b/scripts/textBox/textBox.gml @@ -388,6 +388,8 @@ function textBox(_input, _onModify, _extras = noone) : textInput(_input, _onModi draw_sprite_stretched_ext(THEME.textbox, 3, _x, _y, _w, _h, boxColor, 1); disp_x = lerp_float(disp_x, disp_x_to, 5); + var hoverRect = point_in_rectangle(_m[0], _m[1], _x, _y, _x + _w, _y + _h); + if(self == WIDGET_CURRENT) { draw_sprite_stretched(THEME.textbox, sprite_index == -1? 2 : sprite_index, _x, _y, _w, _h); editText(); @@ -481,7 +483,7 @@ function textBox(_input, _onModify, _extras = noone) : textInput(_input, _onModi var _mx = -1; var _my = -1; - if(mouse_press(mb_any, active) && hover && point_in_rectangle(_m[0], _m[1], _x, _y, _x + _w, _y + _h)) { + if(mouse_press(mb_any, active) && hover && hoverRect) { _mx = _m[0]; _my = _m[1]; } @@ -516,7 +518,7 @@ function textBox(_input, _onModify, _extras = noone) : textInput(_input, _onModi case fa_right : tx -= tw; break; } - if(hover && point_in_rectangle(_m[0], _m[1], _x, _y, _x + _w, _y + _h)) { + if(hover && hoverRect) { if(hide) draw_sprite_stretched_ext(THEME.textbox, 1, _x, _y, _w, _h, boxColor, 0.5); else @@ -554,8 +556,13 @@ function textBox(_input, _onModify, _extras = noone) : textInput(_input, _onModi draw_surface(text_surface, tb_surf_x, tb_surf_y); } - resetFocus(); + if(DRAGGING && (DRAGGING.type == "Text" || DRAGGING.type == "Number") && hover && hoverRect) { + draw_sprite_stretched_ext(THEME.ui_panel_active, 0, _x, _y, _w, _h, COLORS._main_value_positive, 1); + if(mouse_release(mb_left)) + onModify(DRAGGING.data); + } + resetFocus(); sprite_index = -1; return _h; } diff --git a/shaders/sh_downsample/sh_downsample.fsh b/shaders/sh_downsample/sh_downsample.fsh new file mode 100644 index 000000000..8ee3669b3 --- /dev/null +++ b/shaders/sh_downsample/sh_downsample.fsh @@ -0,0 +1,23 @@ +// +// Simple passthrough fragment shader +// +varying vec2 v_vTexcoord; +varying vec4 v_vColour; + +uniform float down; +uniform vec2 dimension; + +void main() { + vec4 col = vec4(0.); + float wei = 0.; + + for( float i = 0.; i < down; i++ ) + for( float j = 0.; j < down; j++ ) { + vec4 samp = texture2D( gm_BaseTexture, v_vTexcoord * down + vec2(i, j) / dimension ); + col += samp; + } + + col /= down * down; + + gl_FragColor = col; +} diff --git a/shaders/sh_downsample/sh_downsample.vsh b/shaders/sh_downsample/sh_downsample.vsh new file mode 100644 index 000000000..3900c20f4 --- /dev/null +++ b/shaders/sh_downsample/sh_downsample.vsh @@ -0,0 +1,19 @@ +// +// Simple passthrough vertex shader +// +attribute vec3 in_Position; // (x,y,z) +//attribute vec3 in_Normal; // (x,y,z) unused in this shader. +attribute vec4 in_Colour; // (r,g,b,a) +attribute vec2 in_TextureCoord; // (u,v) + +varying vec2 v_vTexcoord; +varying vec4 v_vColour; + +void main() +{ + vec4 object_space_pos = vec4( in_Position.x, in_Position.y, in_Position.z, 1.0); + gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * object_space_pos; + + v_vColour = in_Colour; + v_vTexcoord = in_TextureCoord; +} diff --git a/shaders/sh_downsample/sh_downsample.yy b/shaders/sh_downsample/sh_downsample.yy new file mode 100644 index 000000000..2b5aaf5b8 --- /dev/null +++ b/shaders/sh_downsample/sh_downsample.yy @@ -0,0 +1,10 @@ +{ + "resourceType": "GMShader", + "resourceVersion": "1.0", + "name": "sh_downsample", + "parent": { + "name": "_helper", + "path": "folders/shader/_helper.yy", + }, + "type": 1, +} \ No newline at end of file diff --git a/shaders/sh_gradient_display/sh_gradient_display.fsh b/shaders/sh_gradient_display/sh_gradient_display.fsh index 67ab377bf..1c70bfbbf 100644 --- a/shaders/sh_gradient_display/sh_gradient_display.fsh +++ b/shaders/sh_gradient_display/sh_gradient_display.fsh @@ -45,7 +45,7 @@ vec3 hsvMix(vec3 c1, vec3 c2, float t) { return hsv2rgb(h); } -vec4 gradientEval(in float prog) { +vec3 gradientEval(in float prog) { vec4 col = vec4(0.); for(int i = 0; i < 16; i++) { @@ -72,9 +72,9 @@ vec4 gradientEval(in float prog) { } } - return col; + return col.rgb; } void main() { - gl_FragColor = gradientEval(v_vTexcoord.x); + gl_FragColor = vec4(gradientEval(v_vTexcoord.x), v_vColour.a); } diff --git a/shaders/sh_trans_node_prev_drop/sh_trans_node_prev_drop.fsh b/shaders/sh_trans_node_prev_drop/sh_trans_node_prev_drop.fsh new file mode 100644 index 000000000..43958aac4 --- /dev/null +++ b/shaders/sh_trans_node_prev_drop/sh_trans_node_prev_drop.fsh @@ -0,0 +1,17 @@ +// +// Simple passthrough fragment shader +// +varying vec2 v_vTexcoord; +varying vec4 v_vColour; + +uniform vec2 dimension; +uniform vec2 position; +uniform float prog; + +void main() { + vec4 col = texture2D( gm_BaseTexture, v_vTexcoord ); + float p = distance(position, v_vTexcoord); + col.a *= smoothstep(p - 0.1, p + 0.1, prog * 1.5); + + gl_FragColor = col; +} diff --git a/shaders/sh_trans_node_prev_drop/sh_trans_node_prev_drop.vsh b/shaders/sh_trans_node_prev_drop/sh_trans_node_prev_drop.vsh new file mode 100644 index 000000000..3900c20f4 --- /dev/null +++ b/shaders/sh_trans_node_prev_drop/sh_trans_node_prev_drop.vsh @@ -0,0 +1,19 @@ +// +// Simple passthrough vertex shader +// +attribute vec3 in_Position; // (x,y,z) +//attribute vec3 in_Normal; // (x,y,z) unused in this shader. +attribute vec4 in_Colour; // (r,g,b,a) +attribute vec2 in_TextureCoord; // (u,v) + +varying vec2 v_vTexcoord; +varying vec4 v_vColour; + +void main() +{ + vec4 object_space_pos = vec4( in_Position.x, in_Position.y, in_Position.z, 1.0); + gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * object_space_pos; + + v_vColour = in_Colour; + v_vTexcoord = in_TextureCoord; +} diff --git a/shaders/sh_trans_node_prev_drop/sh_trans_node_prev_drop.yy b/shaders/sh_trans_node_prev_drop/sh_trans_node_prev_drop.yy new file mode 100644 index 000000000..b4ff07c6e --- /dev/null +++ b/shaders/sh_trans_node_prev_drop/sh_trans_node_prev_drop.yy @@ -0,0 +1,10 @@ +{ + "resourceType": "GMShader", + "resourceVersion": "1.0", + "name": "sh_trans_node_prev_drop", + "parent": { + "name": "transition", + "path": "folders/shader/transition.yy", + }, + "type": 1, +} \ No newline at end of file