diff --git a/PixelComposer.resource_order b/PixelComposer.resource_order index 9a4e9bfa2..f79dcb78e 100644 --- a/PixelComposer.resource_order +++ b/PixelComposer.resource_order @@ -176,22 +176,21 @@ {"name":"sprites","order":3,"path":"folders/panels/preview/sprites.yy",}, {"name":"what?","order":10,"path":"folders/panels/what?.yy",}, {"name":"shader","order":8,"path":"folders/shader.yy",}, - {"name":"_helper","order":49,"path":"folders/shader/_helper.yy",}, - {"name":"3d","order":29,"path":"folders/shader/3d.yy",}, + {"name":"_helper","order":12,"path":"folders/shader/_helper.yy",}, + {"name":"3d","order":3,"path":"folders/shader/3d.yy",}, {"name":"2d effect","order":14,"path":"folders/shader/3d/2d effect.yy",}, {"name":"legacy","order":13,"path":"folders/shader/3d/legacy.yy",}, {"name":"ssao","order":24,"path":"folders/shader/3d/ssao.yy",}, - {"name":"blend","order":18,"path":"folders/shader/blend.yy",}, - {"name":"blur","order":38,"path":"folders/shader/blur.yy",}, - {"name":"channels","order":42,"path":"folders/shader/channels.yy",}, - {"name":"color picker","order":56,"path":"folders/shader/color picker.yy",}, - {"name":"color selector","order":51,"path":"folders/shader/color selector.yy",}, - {"name":"draw","order":39,"path":"folders/shader/draw.yy",}, - {"name":"filter","order":30,"path":"folders/shader/filter.yy",}, + {"name":"blur","order":6,"path":"folders/shader/blur.yy",}, + {"name":"channels","order":9,"path":"folders/shader/channels.yy",}, + {"name":"color picker","order":19,"path":"folders/shader/color picker.yy",}, + {"name":"color selector","order":14,"path":"folders/shader/color selector.yy",}, + {"name":"draw","order":7,"path":"folders/shader/draw.yy",}, + {"name":"filter","order":4,"path":"folders/shader/filter.yy",}, {"name":"color","order":53,"path":"folders/shader/filter/color.yy",}, {"name":"shadow caster","order":46,"path":"folders/shader/filter/shadow caster.yy",}, - {"name":"flood fill","order":47,"path":"folders/shader/flood fill.yy",}, - {"name":"generator","order":19,"path":"folders/shader/generator.yy",}, + {"name":"flood fill","order":11,"path":"folders/shader/flood fill.yy",}, + {"name":"generator","order":1,"path":"folders/shader/generator.yy",}, {"name":"blinker","order":30,"path":"folders/shader/generator/blinker.yy",}, {"name":"cell","order":31,"path":"folders/shader/generator/cell.yy",}, {"name":"grid","order":32,"path":"folders/shader/generator/grid.yy",}, @@ -199,15 +198,15 @@ {"name":"noise","order":33,"path":"folders/shader/generator/noise.yy",}, {"name":"random shape","order":29,"path":"folders/shader/generator/random shape.yy",}, {"name":"region","order":34,"path":"folders/shader/generator/region.yy",}, - {"name":"mask","order":45,"path":"folders/shader/mask.yy",}, - {"name":"misc","order":50,"path":"folders/shader/misc.yy",}, - {"name":"morph","order":54,"path":"folders/shader/morph.yy",}, - {"name":"pixel builder","order":55,"path":"folders/shader/pixel builder.yy",}, - {"name":"shape seperator","order":35,"path":"folders/shader/shape seperator.yy",}, - {"name":"sprites","order":20,"path":"folders/shader/sprites.yy",}, - {"name":"surface replace","order":53,"path":"folders/shader/surface replace.yy",}, - {"name":"transition","order":52,"path":"folders/shader/transition.yy",}, - {"name":"warp","order":41,"path":"folders/shader/warp.yy",}, + {"name":"mask","order":10,"path":"folders/shader/mask.yy",}, + {"name":"misc","order":13,"path":"folders/shader/misc.yy",}, + {"name":"morph","order":17,"path":"folders/shader/morph.yy",}, + {"name":"pixel builder","order":18,"path":"folders/shader/pixel builder.yy",}, + {"name":"shape seperator","order":5,"path":"folders/shader/shape seperator.yy",}, + {"name":"sprites","order":2,"path":"folders/shader/sprites.yy",}, + {"name":"surface replace","order":16,"path":"folders/shader/surface replace.yy",}, + {"name":"transition","order":15,"path":"folders/shader/transition.yy",}, + {"name":"warp","order":8,"path":"folders/shader/warp.yy",}, {"name":"sprites","order":11,"path":"folders/sprites.yy",}, {"name":"bs","order":4,"path":"folders/sprites/bs.yy",}, {"name":"gameframe","order":2,"path":"folders/sprites/gameframe.yy",}, @@ -216,6 +215,7 @@ {"name":"biterator","order":2,"path":"folders/VCT/biterator.yy",}, {"name":"widget","order":3,"path":"folders/VCT/widget.yy",}, {"name":"widgets","order":5,"path":"folders/widgets.yy",}, + {"name":"fluid","order":20,"path":"folders/shader/fluid.yy",}, ], "ResourceOrderSettings": [ {"name":"s_node_corner","order":16,"path":"sprites/s_node_corner/s_node_corner.yy",}, diff --git a/PixelComposer.yyp b/PixelComposer.yyp index de2826745..607d29742 100644 --- a/PixelComposer.yyp +++ b/PixelComposer.yyp @@ -249,6 +249,7 @@ {"resourceType":"GMFolder","resourceVersion":"1.0","name":"biterator","folderPath":"folders/VCT/biterator.yy",}, {"resourceType":"GMFolder","resourceVersion":"1.0","name":"widget","folderPath":"folders/VCT/widget.yy",}, {"resourceType":"GMFolder","resourceVersion":"1.0","name":"widgets","folderPath":"folders/widgets.yy",}, + {"resourceType":"GMFolder","resourceVersion":"1.0","name":"fluid","folderPath":"folders/shader/fluid.yy",}, ], "IncludedFiles": [ {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"ApolloHelp.html","ConfigValues":{"Itch":{"CopyToMask":"0",},},"CopyToMask":-1,"filePath":"datafiles",}, @@ -308,6 +309,8 @@ {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_ac_function.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_ac_node.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_action_history.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",}, + {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_add_16.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",}, + {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_add_20.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_add_24.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_add_32.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_addon_setting.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",}, @@ -395,6 +398,8 @@ {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_loading.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_lock.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_loop_16.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",}, + {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_minus_16.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",}, + {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_minus_20.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_minus_24.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_name.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_new_line_shift.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",}, @@ -1422,6 +1427,7 @@ {"id":{"name":"fd_rectangle_set_material_size","path":"scripts/fd_rectangle_set_material_size/fd_rectangle_set_material_size.yy",},}, {"id":{"name":"fd_rectangle_shift_content","path":"scripts/fd_rectangle_shift_content/fd_rectangle_shift_content.yy",},}, {"id":{"name":"sh_texture_remap","path":"shaders/sh_texture_remap/sh_texture_remap.yy",},}, + {"id":{"name":"sh_fluid_bleach","path":"shaders/sh_fluid_bleach/sh_fluid_bleach.yy",},}, {"id":{"name":"__node_3d_mesh_modifier","path":"scripts/__node_3d_mesh_modifier/__node_3d_mesh_modifier.yy",},}, {"id":{"name":"obj_fd_rectangle","path":"objects/obj_fd_rectangle/obj_fd_rectangle.yy",},}, {"id":{"name":"node_noise_simplex","path":"scripts/node_noise_simplex/node_noise_simplex.yy",},}, diff --git a/datafiles/data/themes/default.zip b/datafiles/data/themes/default.zip index 5fb93c74c..eb37a5009 100644 Binary files a/datafiles/data/themes/default.zip and b/datafiles/data/themes/default.zip differ diff --git a/objects/o_dialog_menubox/Draw_64.gml b/objects/o_dialog_menubox/Draw_64.gml index e45c17c88..5f1bfc8de 100644 --- a/objects/o_dialog_menubox/Draw_64.gml +++ b/objects/o_dialog_menubox/Draw_64.gml @@ -79,19 +79,28 @@ if(!ready) exit; var _spr = noone, _ind = 0; var _sprs = _submenu[0]; var _tlp = array_safe_get(_submenu, 2, ""); + var _str = ""; - if(is_array(_sprs)) { - _spr = _sprs[0]; - _ind = _sprs[1]; + var _sw = ui(28); + var _sh = ui(28); + + if(is_string(_sprs)) { + _str = _sprs; + draw_set_text(f_p2, fa_center, fa_center, COLORS._main_text); + + _sw = string_width(_str) + ui(12); + _sh = string_height(_str) + ui(8); } else { - _spr = _sprs; - _ind = 0; + if(is_array(_sprs)) { + _spr = _sprs[0]; + _ind = _sprs[1]; + } else _spr = _sprs; } - if(sHOVER && point_in_rectangle(mouse_mx, mouse_my, _bx - ui(14), _by - ui(14), _bx + ui(14), _by + ui(14))) { + if(sHOVER && point_in_rectangle(mouse_mx, mouse_my, _bx - _sw / 2, _by - _sh / 2, _bx + _sw / 2, _by + _sh / 2)) { if(_tlp != "") TOOLTIP = _tlp; - draw_sprite_stretched_ext(THEME.textbox, 3, _bx - ui(14), _by - ui(14), ui(28), ui(28), COLORS.dialog_menubox_highlight, 1); - draw_sprite_stretched_ext(THEME.textbox, 1, _bx - ui(14), _by - ui(14), ui(28), ui(28), COLORS.dialog_menubox_highlight, 1); + draw_sprite_stretched_ext(THEME.textbox, 3, _bx - _sw / 2, _by - _sh / 2, _sw, _sh, COLORS.dialog_menubox_highlight, 1); + draw_sprite_stretched_ext(THEME.textbox, 1, _bx - _sw / 2, _by - _sh / 2, _sw, _sh, COLORS.dialog_menubox_highlight, 1); if(mouse_press(mb_left, sFOCUS)) { _submenu[1](); @@ -99,7 +108,11 @@ if(!ready) exit; } } - draw_sprite_ui_uniform(_spr, _ind, _bx, _by); + if(_spr != noone) + draw_sprite_ui_uniform(_spr, _ind, _bx, _by); + + if(_str != "") + draw_text(_bx, _by, _str); } } else { var tx = dialog_x + show_icon * ui(32) + ui(16); diff --git a/scripts/__surface/__surface.gml b/scripts/__surface/__surface.gml index 2852b8241..0ec95bd56 100644 --- a/scripts/__surface/__surface.gml +++ b/scripts/__surface/__surface.gml @@ -32,6 +32,7 @@ function SurfaceAtlas(surface, _x = 0, _y = 0, rot = 0, sx = 1, sy = 1, blend = static setSurface = function(surface) { gml_pragma("forceinline"); + self.surface.set(surface); w = surface_get_width_safe(surface); diff --git a/scripts/contextMenu_controller/contextMenu_controller.gml b/scripts/contextMenu_controller/contextMenu_controller.gml index 111fae536..42e3d4923 100644 --- a/scripts/contextMenu_controller/contextMenu_controller.gml +++ b/scripts/contextMenu_controller/contextMenu_controller.gml @@ -67,6 +67,7 @@ function menuItemGroup(name, group) { return new MenuItemGroup(name, group); } + function MenuItemGroup(name, group) constructor { active = true; self.name = name; diff --git a/scripts/curveBox/curveBox.gml b/scripts/curveBox/curveBox.gml index 9cb96bf59..a2c36c142 100644 --- a/scripts/curveBox/curveBox.gml +++ b/scripts/curveBox/curveBox.gml @@ -4,15 +4,34 @@ function curveBox(_onModify) : widget() constructor { curve_surface = surface_create(1, 1); node_dragging = -1; node_drag_typ = -1; + zoom_level = 1; + zoom_level_to = 1; + zoom_min = 1; + zoom_max = 3; + zooming = false; + miny = 0; maxy = 1; + progress_draw = -1; + + display_pos_x = 0; + display_pos_y = 0; + display_sel = false; + + grid_snap = false; + grid_step = 0.05; + grid_show = false; + static get_x = function(val, _x, _w) { return _x + _w * val; } static get_y = function(val, _y, _h) { return _y + _h * (1 - (val - miny) / (maxy - miny)); } static register = function() {} static drawParam = function(params) { + rx = params.rx; + ry = params.ry; + return draw(params.x, params.y, params.w, params.h, params.data, params.m); } @@ -22,19 +41,33 @@ function curveBox(_onModify) : widget() constructor { w = _w; h = _h; + var cw = _w - ui(32); + if(!is_array(_data) || array_length(_data) == 0) return 0; if(is_array(_data[0])) return 0; var points = array_length(_data) / 6; - curve_surface = surface_verify(curve_surface, _w, _h); + #region display + zoom_level = lerp_float(zoom_level, zoom_level_to, 2); + miny = 0.5 - 0.5 * zoom_level; + maxy = 0.5 + 0.5 * zoom_level; + + display_pos_x = clamp((_m[0] - _x) / cw, 0, 1); + display_pos_y = lerp(miny, maxy, 1 - (_m[1] - _y) / _h); + display_sel = false; + #endregion + + curve_surface = surface_verify(curve_surface, cw, _h); if(node_dragging != -1) { #region editing if(node_drag_typ == 0) { var node_point = (node_dragging - 2) / 6; if(node_point > 0 && node_point < points - 1) { - var _mx = (_m[0] - _x) / _w; + var _mx = (_m[0] - _x) / cw; _mx = clamp(_mx, 0, 1); + if(key_mod_press(CTRL) || grid_snap) + _mx = value_snap(_mx, grid_step); var bfx = _data[node_dragging - 6]; var afx = _data[node_dragging + 6]; @@ -46,8 +79,13 @@ function curveBox(_onModify) : widget() constructor { var _my = 1 - (_m[1] - _y) / _h; _my = clamp(_my * (maxy - miny) + miny, 0, 1); + if(key_mod_press(CTRL) || grid_snap) _my = value_snap(_my, grid_step); _data[node_dragging + 1] = _my; + display_pos_x = _data[node_dragging + 0]; + display_pos_y = _data[node_dragging + 1]; + display_sel = 1; + //sort by x var _xindex = []; var _pindex = []; @@ -81,16 +119,22 @@ function curveBox(_onModify) : widget() constructor { var _px = _data[node_dragging + 0]; var _py = _data[node_dragging + 1]; - var _mx = (_m[0] - _x) / _w; + var _mx = (_m[0] - _x) / cw; _mx = clamp(_mx, 0, 1); + if(key_mod_press(CTRL) || grid_snap) _mx = value_snap(_mx, grid_step); _data[node_dragging - 2] = (_px - _mx) * node_drag_typ; _data[node_dragging + 2] = (_mx - _px) * node_drag_typ; var _my = 1 - (_m[1] - _y) / _h; - _my = _my * (maxy - miny) + miny; + _my = lerp(miny, maxy, _my); + if(key_mod_press(CTRL) || grid_snap) _my = value_snap(_my, grid_step); _data[node_dragging - 1] = clamp(_py - _my, -1, 1) * node_drag_typ; _data[node_dragging + 3] = clamp(_my - _py, -1, 1) * node_drag_typ; + display_pos_x = node_drag_typ? _data[node_dragging - 2] : _data[node_dragging + 2]; + display_pos_y = node_drag_typ? _data[node_dragging - 1] : _data[node_dragging + 3]; + display_sel = 2; + if(onModify(_data)) UNDO_HOLDING = true; } @@ -116,12 +160,34 @@ function curveBox(_onModify) : widget() constructor { DRAW_CLEAR draw_set_color(COLORS.widget_curve_line); draw_set_alpha(0.75); + + if(grid_show) { + var st = max(grid_step, 0.02); + + for( var i = st; i < 1; i += st ) { + var y0 = _h - _h * (i - miny) / (maxy - miny); + draw_line(0, y0, cw, y0); + + var x0 = cw * i; + draw_line(x0, 0, x0, _h); + } + } + + draw_set_alpha(0.9); var y0 = _h - _h * (0 - miny) / (maxy - miny); - draw_line(0, y0, _w, y0); + draw_line(0, y0, cw, y0); var y1 = _h - _h * (1 - miny) / (maxy - miny); - draw_line(0, y1, _w, y1); + draw_line(0, y1, cw, y1); draw_set_alpha(1); - + + if(progress_draw > -1) { + var _prg = clamp(progress_draw, 0, 1); + + var _px = cw * _prg; + draw_set_color(COLORS.widget_curve_line); + draw_line(_px, 0, _px, _h); + } + for( var i = 0; i < points; i++ ) { var ind = i * 6; var _x0 = _data[ind + 2]; @@ -131,11 +197,11 @@ function curveBox(_onModify) : widget() constructor { var ax0 = _x0 + _data[ind + 4]; var ay0 = _y0 + _data[ind + 5]; - bx0 = get_x(bx0, 0, _w); + bx0 = get_x(bx0, 0, cw); by0 = get_y(by0, 0, _h); - _x0 = get_x(_x0, 0, _w); + _x0 = get_x(_x0, 0, cw); _y0 = get_y(_y0, 0, _h); - ax0 = get_x(ax0, 0, _w); + ax0 = get_x(ax0, 0, cw); ay0 = get_y(ay0, 0, _h); draw_set_color(COLORS.widget_curve_line); @@ -147,6 +213,10 @@ function curveBox(_onModify) : widget() constructor { draw_circle_prec(bx0, by0, 5, false); node_hovering = ind + 2; node_hover_typ = -1; + + display_pos_x = _data[ind + 0]; + display_pos_y = _data[ind + 1]; + display_sel = 2; } } @@ -158,6 +228,10 @@ function curveBox(_onModify) : widget() constructor { draw_circle_prec(ax0, ay0, 5, false); node_hovering = ind + 2; node_hover_typ = 1; + + display_pos_x = _data[ind + 4]; + display_pos_y = _data[ind + 5]; + display_sel = 2; } } @@ -167,6 +241,10 @@ function curveBox(_onModify) : widget() constructor { draw_circle_prec(_x0, _y0, 5, false); node_hovering = ind + 2; node_hover_typ = 0; + + display_pos_x = _data[ind + 2]; + display_pos_y = _data[ind + 3]; + display_sel = 1; } if(msx >= _x1 && msy <= _x0) @@ -175,66 +253,110 @@ function curveBox(_onModify) : widget() constructor { } draw_set_color(COLORS._main_accent); - draw_curve(0, 0, _w, -_h, _data, miny, maxy); + draw_curve(0, 0, cw, -_h, _data, miny, maxy); surface_reset_target(); #endregion #region ==== buttons ==== - var bx = _x + _w - ui(6 + 24); - var by = _y + _h - ui(6 + 24); + var bs = ui(20); + + var bxF = _x + cw + ui(8); + var bx = bxF + ui(0); + + var by0 = _y; + var by1 = _y + _h - bs + ui(2); + + var byF = _y + (bs + ui(6)); + var byH = _h + ui(2) - (bs + ui(6)) * 2; + + draw_sprite_stretched_ext(THEME.ui_panel_bg, 0, bxF, byF, bs, byH, COLORS.assetbox_current_bg, 1); + + var zH = ui(16); + var zy = byF + zH / 2 + (byH - zH) * (zoom_level_to - zoom_min) / (zoom_max - zoom_min); + + if(zooming) { + zoom_level_to = lerp(zoom_min, zoom_max, clamp((_m[1] - byF - zH / 2) / (byH - zH), 0, 1)); - if(buttonInstant(THEME.button_hide, bx, by, ui(24), ui(24), _m, active, hover,, THEME.add) == 2) { - miny = 0; - maxy = 1; + if(mouse_release(mb_left)) + zooming = false; } + + var cc = merge_color(COLORS._main_icon, COLORS._main_icon_dark, 0.5); + if(point_in_rectangle(_m[0], _m[1], bxF, byF, _x + _w, byF + byH)) { + cc = COLORS._main_icon; + if(mouse_click(mb_left, active)) + zooming = true; + } + + draw_sprite_stretched_ext(THEME.timeline_dopesheet_bg, 0, bxF, zy - zH / 2, bs, zH, cc, 1); + + if(buttonInstant(THEME.button_hide, bx, by0, bs, bs, _m, active, hover,, THEME.add_16) == 2) + zoom_level_to = clamp(zoom_level_to - 1, zoom_min, zoom_max); - bx -= ui(24 + 4); - if(buttonInstant(THEME.button_hide, bx, by, ui(24), ui(24), _m, active, hover,, THEME.minus) == 2) { - miny = -1; - maxy = 2; - } + if(buttonInstant(THEME.button_hide, bx, by1, bs, bs, _m, active, hover,, THEME.minus_16) == 2) + zoom_level_to = clamp(zoom_level_to + 1, zoom_min, zoom_max); #endregion - if(hover) { #region - if(point_in_rectangle(_m[0], _m[1], _x + _w - ui(6 + 24 * 2 + 4), _y + _h - ui(6 + 24), _x + _w + ui(5), _y + _h + ui(5))) { - } else if(point_in_rectangle(msx, msy, -ui(5), -ui(5), _w + ui(5), _h + ui(5))) { - if(mouse_press(mb_left, active)) { - if(node_hovering == -1) { - var _ind = point_insert * 6; - var _px = (_m[0] - _x) / _w; - var _py = 1 - (_m[1] - _y) / _h; + if(hover && point_in_rectangle(_m[0], _m[1], _x, _y, _x + cw, _y + _h)) { #region + if(mouse_press(mb_left, active)) { + if(node_hovering == -1) { + var _ind = point_insert * 6; + var _px = (_m[0] - _x) / cw; + var _py = 1 - (_m[1] - _y) / _h; - array_insert(_data, _ind + 0, -0.1); - array_insert(_data, _ind + 1, 0); - array_insert(_data, _ind + 2, _px); - array_insert(_data, _ind + 3, _py); - array_insert(_data, _ind + 4, 0.1); - array_insert(_data, _ind + 5, 0); - if(onModify(_data)) - UNDO_HOLDING = true; + array_insert(_data, _ind + 0, -0.1); + array_insert(_data, _ind + 1, 0); + array_insert(_data, _ind + 2, _px); + array_insert(_data, _ind + 3, _py); + array_insert(_data, _ind + 4, 0.1); + array_insert(_data, _ind + 5, 0); + if(onModify(_data)) + UNDO_HOLDING = true; - node_dragging = _ind + 2; - node_drag_typ = 0; - } else { - node_dragging = node_hovering; - node_drag_typ = node_hover_typ; - } - } else if(mouse_press(mb_right, active)) { - var node_point = (node_hovering - 2) / 6; - if(node_hover_typ == 0 && node_point > 0 && node_point < points - 1) { - array_delete(_data, node_point * 6, 6); - if(onModify(_data)) - UNDO_HOLDING = true; - } + node_dragging = _ind + 2; + node_drag_typ = 0; + } else { + node_dragging = node_hovering; + node_drag_typ = node_hover_typ; } + } else if(mouse_press(mb_right, active)) { + var node_point = (node_hovering - 2) / 6; + if(node_hover_typ == 0 && node_point > 0 && node_point < points - 1) { + array_delete(_data, node_point * 6, 6); + if(onModify(_data)) + UNDO_HOLDING = true; + } + } + + if(mouse_press(mb_right, active)) { + menuCall("widget_curve", rx + _m[0], ry + _m[1], [ + menuItem(grid_show? __txt("Hide grid") : __txt("Show grid"), function() { grid_show = !grid_show; }), + menuItem(__txt("Snap to grid"), function() { grid_snap = !grid_snap; },,, function() { return grid_snap } ), + menuItemGroup("Grid size", [ + [ "1%", function() { grid_step = 0.01; } ], + [ "5%", function() { grid_step = 0.05; } ], + [ "10%", function() { grid_step = 0.10; } ], + [ "25%", function() { grid_step = 0.25; } ], + ]) + ]); } } #endregion draw_surface(curve_surface, _x, _y); draw_set_color(COLORS.widget_curve_outline); - draw_rectangle(_x, _y, _x + _w, _y + _h, true); + draw_rectangle(_x, _y, _x + cw, _y + _h, true); + var tx = _x + cw - ui(6); + var ty = _y + _h - ui(6); + + draw_set_text(f_p2, fa_right, fa_bottom, display_sel? COLORS._main_text: COLORS._main_text_sub); + draw_text_add(tx, ty, $"{display_sel == 2? "dy" : "y"}: {string_format(display_pos_y * 100, -1, 2)}%"); + + ty -= line_get_height(); + draw_text_add(tx, ty, $"{display_sel == 2? "dx" : "x"}: {string_format(display_pos_x * 100, -1, 2)}%"); + + resetFocus(); return h; diff --git a/scripts/fd_rectangle_add_velocity_surface/fd_rectangle_add_velocity_surface.gml b/scripts/fd_rectangle_add_velocity_surface/fd_rectangle_add_velocity_surface.gml index aeadbd99f..9e4498c57 100644 --- a/scripts/fd_rectangle_add_velocity_surface/fd_rectangle_add_velocity_surface.gml +++ b/scripts/fd_rectangle_add_velocity_surface/fd_rectangle_add_velocity_surface.gml @@ -12,8 +12,10 @@ function fd_rectangle_add_velocity_surface(domain, surface, _x, _y, xscale, ysca // blend linearly. The parameter values should be kept between -2 and 2. with (domain) { - fd_rectangle_set_target(id, FD_TARGET_TYPE.ADD_VELOCITY); + fd_rectangle_set_target(id, FD_TARGET_TYPE.ADD_VELOCITY); var color = make_color_rgb(ceil((clamp(xvelo, -1, 1) * 0.125 + 0.5) * 255), ceil((clamp(yvelo, -1, 1) * 0.125 + 0.5) * 255), 0); + + //print($"Applying velocity {xvelo}, {yvelo} = {ceil((clamp(xvelo, -1, 1) * 0.125 + 0.5) * 255)}, {ceil((clamp(yvelo, -1, 1) * 0.125 + 0.5) * 255)}"); draw_surface_ext_safe(surface, _x, _y, xscale, yscale, 0, color, 1); fd_rectangle_reset_target(id); } diff --git a/scripts/fd_rectangle_clear/fd_rectangle_clear.gml b/scripts/fd_rectangle_clear/fd_rectangle_clear.gml index a0d9633d7..559502a05 100644 --- a/scripts/fd_rectangle_clear/fd_rectangle_clear.gml +++ b/scripts/fd_rectangle_clear/fd_rectangle_clear.gml @@ -9,7 +9,4 @@ function fd_rectangle_clear(domain) { surface_free(sf_material_0); surface_free(sf_material_1); surface_free(sf_world); } - - - } diff --git a/scripts/fd_rectangle_set_target/fd_rectangle_set_target.gml b/scripts/fd_rectangle_set_target/fd_rectangle_set_target.gml index 0c8a29bf7..9d9a51dbd 100644 --- a/scripts/fd_rectangle_set_target/fd_rectangle_set_target.gml +++ b/scripts/fd_rectangle_set_target/fd_rectangle_set_target.gml @@ -41,6 +41,7 @@ function fd_rectangle_set_target(domain, type) { surface_set_target(sf_velocity_temporary); draw_enable_alphablend(false); draw_surface(sf_velocity, 0, 0); + shader_set(sh_fd_add_velocity_glsl); shader_set_uniform_f(shader_get_uniform(sh_fd_add_velocity_glsl, "addend"), 0.5 + 0.5 * sf_velocity_texel_width, 0.5 + 0.5 * sf_velocity_texel_height); texture_set_stage(shader_get_sampler_index(sh_fd_add_velocity_glsl, "texture_velocity"), surface_get_texture(sf_velocity)); diff --git a/scripts/locale_data/locale_data.gml b/scripts/locale_data/locale_data.gml index db6b88011..020a185ab 100644 --- a/scripts/locale_data/locale_data.gml +++ b/scripts/locale_data/locale_data.gml @@ -129,7 +129,7 @@ function __txt_junction_data(node, type, index, def = []) { gml_pragma("forceinline"); - if(TESTING) return def; + return def; if(!struct_has(LOCALE.node, node)) return def; diff --git a/scripts/nodeValue_drawer/nodeValue_drawer.gml b/scripts/nodeValue_drawer/nodeValue_drawer.gml index 4647b0ed6..deab87acf 100644 --- a/scripts/nodeValue_drawer/nodeValue_drawer.gml +++ b/scripts/nodeValue_drawer/nodeValue_drawer.gml @@ -256,8 +256,10 @@ function drawWidget(xx, yy, ww, _m, jun, global_var = true, _hover = false, _foc case VALUE_TYPE.curve : param.h = ui(160); - if(point_in_rectangle(_m[0], _m[1], ui(32), _hsy, ui(32) + ww - ui(16), _hsy + editBoxH)) + if(point_in_rectangle(_m[0], _m[1], ui(32), _hsy, ui(32) + ww - ui(16), _hsy + param.h)) { mbRight = false; + //_scrollPane.scroll_lock = true; // Not good UX-wise + } break; } diff --git a/scripts/node_animate_curve/node_animate_curve.gml b/scripts/node_animate_curve/node_animate_curve.gml index d016382d2..b5f6952f3 100644 --- a/scripts/node_animate_curve/node_animate_curve.gml +++ b/scripts/node_animate_curve/node_animate_curve.gml @@ -12,15 +12,27 @@ function Node_Anim_Curve(_x, _y, _group = noone) : Node_Processor(_x, _y, _group inputs[| 2] = nodeValue("Minimum", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0); inputs[| 3] = nodeValue("Maximum", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1); + inputs[| 4] = nodeValue("Animated", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false); + outputs[| 0] = nodeValue("Curve", self, JUNCTION_CONNECT.output, VALUE_TYPE.float, []); + input_display_list = [ 0, 4, 1, 2, 3 ]; + + static step = function() { + var _anim = getSingleValue(4); + + inputs[| 1].setVisible(!_anim); + } + static processData = function(_output, _data, _output_index, _array_index = 0) { var curve = _data[0]; - var time = _data[1]; + var time = _data[4]? PROJECT.animator.current_frame / (PROJECT.animator.frames_total - 1) : _data[1]; var _min = _data[2]; var _max = _data[3]; var val = eval_curve_x(curve, time) * (_max - _min) + _min; + inputs[| 0].editWidget.progress_draw = time; + return val; } diff --git a/scripts/node_atlas_set/node_atlas_set.gml b/scripts/node_atlas_set/node_atlas_set.gml index 7cddd0a7b..bb5b47c12 100644 --- a/scripts/node_atlas_set/node_atlas_set.gml +++ b/scripts/node_atlas_set/node_atlas_set.gml @@ -51,11 +51,24 @@ function Node_Atlas_Set(_x, _y, _group = noone) : Node(_x, _y, _group) construct for( var i = 0, n = array_length(atl); i < n; i++ ) { natl[i] = atl[i].clone(); - if(use[1]) natl[i].surface.set(array_safe_get(surf, i)); - if(use[2]) natl[i].position = array_safe_get(posi, i); + if(use[1]) natl[i].setSurface(array_safe_get(surf, i)); + + if(use[2]) { + var pos = array_safe_get(posi, i); + natl[i].x = array_safe_get(pos, 0); + natl[i].y = array_safe_get(pos, 1); + } + if(use[3]) natl[i].rotation = array_safe_get(rota, i); - if(use[4]) natl[i].scale = array_safe_get(scal, i); + + if(use[4]) { + var sca = array_safe_get(scal, i); + natl[i].sx = array_safe_get(sca, 0, 1); + natl[i].sy = array_safe_get(sca, 1, 1); + } + if(use[5]) natl[i].blend = array_safe_get(blns, i); + if(use[6]) natl[i].alpha = array_safe_get(alph, i); } diff --git a/scripts/node_blend/node_blend.gml b/scripts/node_blend/node_blend.gml index 700e8f4dc..5a90be017 100644 --- a/scripts/node_blend/node_blend.gml +++ b/scripts/node_blend/node_blend.gml @@ -61,7 +61,7 @@ function Node_Blend(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) con var _atlas = is_instanceof(_fore, SurfaceAtlas); - inputs[| 5].editWidget.data_list = _atlas? [ "None", "Stretch" ] : [ "None", "Stretch", "Tile" ]; + inputs[| 5].setVisible(!_atlas); inputs[| 6].editWidget.data_list = _atlas? [ "Background", "Forground" ] : [ "Background", "Forground", "Mask", "Maximum", "Constant" ]; inputs[| 7].setVisible(_outp == 4); @@ -114,7 +114,7 @@ function Node_Blend(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) con break; } - if(_fill == 0) { // Direct placement + if(_fill == 0 || _atlas) { // Direct placement for( var i = 0; i < 2; i++ ) temp_surface[i] = surface_verify(temp_surface[i], ww, hh, cDep); @@ -174,7 +174,13 @@ function Node_Blend(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) con if(_atlas) { var _newAtl = _fore.clone(); - _newAtl.surface.set(_output); + + if(_outp == 0) { + _newAtl.x = 0; + _newAtl.y = 0; + } + + _newAtl.setSurface(_output); return _newAtl; } diff --git a/scripts/node_collection/node_collection.gml b/scripts/node_collection/node_collection.gml index 0d9e8817f..4db80ac4c 100644 --- a/scripts/node_collection/node_collection.gml +++ b/scripts/node_collection/node_collection.gml @@ -69,6 +69,7 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc isInstancer = false; instanceBase = noone; + input_display_list_def = []; custom_input_index = 0; custom_output_index = 0; @@ -78,6 +79,27 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc attributes.w = 128; attributes.h = 128; + input_dummy = nodeValue("Add to group", self, JUNCTION_CONNECT.input, VALUE_TYPE.any, 0); + draw_dummy = false; + + input_dummy.onSetFrom = function(juncFrom) { + ds_list_remove(juncFrom.value_to, input_dummy); + input_dummy.value_from = noone; + + var input = nodeBuild("Node_Group_Input", 0, 0, self); + var _type = juncFrom.type; + var _tind = array_find(input.data_type_map, juncFrom.type); + + //input.attributes.inherit_name = false; + //input.setDisplayName(juncFrom.name); + + input.attributes.inherit_type = false; + if(_tind != -1) + input.inputs[| 2].setValue(_tind); + + input.inParent.setFrom(juncFrom); + } + tool_node = noone; draw_input_overlay = true; @@ -120,6 +142,8 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc for( var i = 0; i < ds_list_size(inputs); i++ ) if(inputs[| i].isVisible()) _hi += 24; + if(active_draw_index == 1) _hi += 24; + draw_dummy = active_draw_index == 1; for( var i = 0; i < ds_list_size(outputs); i++ ) if(outputs[| i].isVisible()) _ho += 24; @@ -154,6 +178,10 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc return nodes; } #endregion + static getInput = function(junc = noone) { #region + return input_dummy; + } #endregion + static getNextNodes = function() { #region //get node inside the group LOG_BLOCK_START(); LOG_IF(global.FLAG.render == 1, $"→→→→→ Call get next node from group"); @@ -324,14 +352,31 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc PATCH_STATIC + static onPreDraw = function(_x, _y, _s, _iny, _outy) { #region + var xx = x * _s + _x; + var yy = y * _s + _y; + + input_dummy.x = xx; + input_dummy.y = _iny; + } #endregion + static preConnect = function() { #region sortIO(); deserialize(load_map, load_scale); } #endregion - static sortIO = function() { #region - input_display_list = []; + static onDrawJunctions = function(_x, _y, _mx, _my, _s) { #region + input_dummy.visible = false; + if(draw_dummy) { + input_dummy.visible = true; + input_dummy.drawJunction(_s, _mx, _my); + } + + draw_dummy = false; + } #endregion + + static sortIO = function() { #region var sep = attributes.separator; array_sort(sep, function(a0, a1) { return a0[0] - a1[0]; }); var siz = ds_list_size(inputs); @@ -347,9 +392,14 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc for( var i = siz - 1; i >= custom_input_index; i-- ) ds_list_delete(inputs, i); - for( var i = 0; i < custom_input_index; i++ ) - array_push(input_display_list, i); - + if(array_empty(input_display_list_def)) { + input_display_list = []; + for( var i = 0; i < custom_input_index; i++ ) + array_push(input_display_list, i); + } else { + input_display_list = array_clone(input_display_list_def); + } + for( var i = custom_input_index; i < siz; i++ ) { var _jin = ds_priority_delete_min(ar); _jin.index = i; @@ -357,9 +407,8 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc array_push(input_display_list, i); } - for( var i = array_length(sep) - 1; i >= 0; i-- ) { - array_insert(input_display_list, sep[i][0], [ sep[i][1], false, i ]); - } + for( var i = array_length(sep) - 1; i >= 0; i-- ) + array_insert(input_display_list, array_length(input_display_list_def) + sep[i][0], [ sep[i][1], false, i ]); ds_priority_destroy(ar); @@ -469,6 +518,8 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc _output_junc = nodes[| i].inputs[| 0]; } + if(!is_instanceof(_output_junc, NodeValue)) return noone; + switch(_output_junc.type) { case VALUE_TYPE.surface : case VALUE_TYPE.dynaSurface : diff --git a/scripts/node_data/node_data.gml b/scripts/node_data/node_data.gml index 30261a0bd..1d7732cfc 100644 --- a/scripts/node_data/node_data.gml +++ b/scripts/node_data/node_data.gml @@ -667,7 +667,7 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x updatedOutTrigger.y = yy + 10; var inamo = (input_display_list == -1 || !use_display_list)? ds_list_size(inputs) : array_length(input_display_list); - var _in = yy + ui(junction_draw_pad_y) * _s; + var _iny = yy + ui(junction_draw_pad_y) * _s; for(var i = 0; i < inamo; i++) { var idx = getInputJunctionIndex(i); @@ -676,24 +676,28 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x jun = ds_list_get(inputs, idx, noone); if(jun == noone || is_undefined(jun)) continue; jun.x = xx; - jun.y = _in; - _in += 24 * _s * jun.isVisible(); + jun.y = _iny; + _iny += 24 * _s * jun.isVisible(); } var outamo = output_display_list == -1? ds_list_size(outputs) : array_length(output_display_list); xx = xx + w * _s; - _in = yy + ui(junction_draw_pad_y) * _s; + var _outy = yy + ui(junction_draw_pad_y) * _s; for(var i = 0; i < outamo; i++) { var idx = getOutputJunctionIndex(i); jun = outputs[| idx]; jun.x = xx; - jun.y = _in; - _in += 24 * _s * jun.isVisible(); + jun.y = _outy; + _outy += 24 * _s * jun.isVisible(); } + + onPreDraw(_x, _y, _s, _iny, _outy); } #endregion + static onPreDraw = function(_x, _y, _s, _iny, _outy) {} + static drawNodeBase = function(xx, yy, _s) { #region if(draw_graph_culled) return; if(!active) return; @@ -792,9 +796,12 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x if(updatedOutTrigger.drawJunction(_s, _mx, _my)) hover = updatedOutTrigger; } + onDrawJunctions(_x, _y, _mx, _my, _s); return hover; } #endregion + static onDrawJunctions = function(_x, _y, _mx, _my, _s) {} + static drawJunctionNames = function(_x, _y, _mx, _my, _s) { #region if(draw_graph_culled) return; if(!active) return; diff --git a/scripts/node_fluid_add/node_fluid_add.gml b/scripts/node_fluid_add/node_fluid_add.gml index 8fbabafbe..8772427f0 100644 --- a/scripts/node_fluid_add/node_fluid_add.gml +++ b/scripts/node_fluid_add/node_fluid_add.gml @@ -36,6 +36,8 @@ function Node_Fluid_Add(_x, _y, _group = noone) : Node_Fluid(_x, _y, _group) con outputs[| 0] = nodeValue("Fluid Domain", self, JUNCTION_CONNECT.output, VALUE_TYPE.fdomain, noone); + temp_surface = [ surface_create(1, 1) ]; + static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) { #region var _mat = getInputData(1); var _pos = getInputData(2); @@ -62,7 +64,7 @@ function Node_Fluid_Add(_x, _y, _group = noone) : Node_Fluid(_x, _y, _group) con var _msk = inputs[| 6].getValue(frame); var _vel = inputs[| 7].getValue(frame); - if(_dom == noone || !instance_exists(_dom)) return; + FLUID_DOMAIN_CHECK outputs[| 0].setValue(_dom); if(!_act) return; @@ -79,16 +81,21 @@ function Node_Fluid_Add(_x, _y, _group = noone) : Node_Fluid(_x, _y, _group) con dy += (_pos[1] - _prevPos[1]) * _inh; } + temp_surface[0] = surface_verify(temp_surface[0], sw, sh); + surface_set_shader(temp_surface[0], sh_fluid_bleach); + draw_surface_safe(_mat); + surface_reset_shader(); + if(dx != 0 || dy != 0) { if(_msk == 0) - fd_rectangle_add_velocity_surface(_dom, _mat, _pos[0] - sw / 2, _pos[1] - sh / 2, 1, 1, dx, dy); + fd_rectangle_add_velocity_surface(_dom, temp_surface[0], _pos[0] - sw / 2, _pos[1] - sh / 2, 1, 1, dx, dy); else { var _vw = sw + max(0, _msk * 2); var _vh = sh + max(0, _msk * 2); var _vmask = surface_create(_vw, _vh); surface_set_shader(_vmask,,, BLEND.over); - draw_surface_safe(_mat, max(0, _msk), max(0, _msk)); + draw_surface_safe(temp_surface[0], max(0, _msk), max(0, _msk)); surface_reset_shader(); var vel_mask = surface_create(_vw, _vh); @@ -99,13 +106,13 @@ function Node_Fluid_Add(_x, _y, _group = noone) : Node_Fluid(_x, _y, _group) con surface_reset_shader(); fd_rectangle_add_velocity_surface(_dom, vel_mask, _pos[0] - _vw / 2, _pos[1] - _vh / 2, 1, 1, dx, dy); - + surface_free(_vmask); surface_free(vel_mask); } } - fd_rectangle_add_material_surface(_dom, _mat, _pos[0] - sw / 2, _pos[1] - sh / 2, 1, 1, c_white, _den); + fd_rectangle_add_material_surface(_dom, temp_surface[0], _pos[0] - sw / 2, _pos[1] - sh / 2, 1, 1, c_white, _den); _prevPos[0] = _pos[0]; _prevPos[1] = _pos[1]; diff --git a/scripts/node_fluid_add_collider/node_fluid_add_collider.gml b/scripts/node_fluid_add_collider/node_fluid_add_collider.gml index beb0ee852..d3a0ae87a 100644 --- a/scripts/node_fluid_add_collider/node_fluid_add_collider.gml +++ b/scripts/node_fluid_add_collider/node_fluid_add_collider.gml @@ -38,9 +38,10 @@ function Node_Fluid_Add_Collider(_x, _y, _group = noone) : Node_Fluid(_x, _y, _g var _dom = inputs[| 0].getValue(frame); var _mat = inputs[| 1].getValue(frame); var _area = inputs[| 2].getValue(frame); - if(_dom == noone || !instance_exists(_dom)) return; + FLUID_DOMAIN_CHECK outputs[| 0].setValue(_dom); + if(!is_surface(_mat)) return; if(!is_surface(_dom.sf_world)) return; diff --git a/scripts/node_fluid_apply_velo/node_fluid_apply_velo.gml b/scripts/node_fluid_apply_velo/node_fluid_apply_velo.gml index 2d74c06fe..eea8c35e7 100644 --- a/scripts/node_fluid_apply_velo/node_fluid_apply_velo.gml +++ b/scripts/node_fluid_apply_velo/node_fluid_apply_velo.gml @@ -46,7 +46,7 @@ function Node_Fluid_Apply_Velocity(_x, _y, _group = noone) : Node_Fluid(_x, _y, var _vel = inputs[| 3].getValue(frame); var _act = inputs[| 4].getValue(frame); - if(_dom == noone || !instance_exists(_dom)) return; + FLUID_DOMAIN_CHECK outputs[| 0].setValue(_dom); if(!_act) return; @@ -55,7 +55,12 @@ function Node_Fluid_Apply_Velocity(_x, _y, _group = noone) : Node_Fluid(_x, _y, var sw = surface_get_width_safe(_mat); var sh = surface_get_height_safe(_mat); - fd_rectangle_add_velocity_surface(_dom, _mat, _pos[0] - sw / 2, _pos[1] - sh / 2, 1, 1, _vel[0], _vel[1]); + temp_surface[0] = surface_verify(temp_surface[0], sw, sh); + surface_set_shader(temp_surface[0], sh_fluid_bleach); + draw_surface_safe(_mat); + surface_reset_shader(); + + fd_rectangle_add_velocity_surface(_dom, temp_surface[0], _pos[0] - sw / 2, _pos[1] - sh / 2, 1, 1, _vel[0], _vel[1]); } static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { diff --git a/scripts/node_fluid_domain/node_fluid_domain.gml b/scripts/node_fluid_domain/node_fluid_domain.gml index 14d649852..211f1cd18 100644 --- a/scripts/node_fluid_domain/node_fluid_domain.gml +++ b/scripts/node_fluid_domain/node_fluid_domain.gml @@ -31,16 +31,14 @@ function Node_Fluid_Domain(_x, _y, _group = noone) : Node_Fluid(_x, _y, _group) inputs[| 8] = nodeValue("Initial pressure", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.75) .setDisplay(VALUE_DISPLAY.slider); - inputs[| 9] = nodeValue("Material maccormack weight", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1) + inputs[| 9] = nodeValue("Material Maccormack weight", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1) .setDisplay(VALUE_DISPLAY.slider); - inputs[| 10] = nodeValue("Velocity maccormack weight", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0) + inputs[| 10] = nodeValue("Velocity Maccormack weight", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0) .setDisplay(VALUE_DISPLAY.slider); inputs[| 11] = nodeValue("Wrap", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false); - inputs[| 12] = nodeValue("Loop", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false ); - outputs[| 0] = nodeValue("Fluid Domain", self, JUNCTION_CONNECT.output, VALUE_TYPE.fdomain, noone); input_display_list = [ @@ -53,7 +51,7 @@ function Node_Fluid_Domain(_x, _y, _group = noone) : Node_Fluid(_x, _y, _group) domain = fd_rectangle_create(256, 256); _dim_old = [0, 0]; - static update = function(frame = PROJECT.animator.current_frame) { + static update = function(frame = PROJECT.animator.current_frame) { #region RETURN_ON_REST var _dim = inputs[| 0].getValue(frame); @@ -68,7 +66,6 @@ function Node_Fluid_Domain(_x, _y, _group = noone) : Node_Fluid(_x, _y, _group) var mMac = inputs[| 9].getValue(frame); var vMac = inputs[| 10].getValue(frame); var wrap = inputs[| 11].getValue(frame); - //var loop = inputs[| 12].getValue(frame); if(PROJECT.animator.current_frame == 0 || !is_surface(domain.sf_world)) { fd_rectangle_clear(domain); @@ -84,15 +81,6 @@ function Node_Fluid_Domain(_x, _y, _group = noone) : Node_Fluid(_x, _y, _group) fd_rectangle_set_initial_value_pressure(domain, inPress); } - if(_dim[0] != _dim_old[0] || _dim[1] != _dim_old[1]) { - fd_rectangle_set_pressure_size(domain, _dim[0], _dim[1]); - fd_rectangle_set_velocity_size(domain, _dim[0], _dim[1]); - fd_rectangle_set_material_size(domain, _dim[0], _dim[1]); - - _dim_old[0] = _dim[0]; - _dim_old[1] = _dim[1]; - } - surface_set_target(domain.sf_world); draw_clear_alpha($00FFFF, 0); if(is_surface(coll)) @@ -113,13 +101,7 @@ function Node_Fluid_Domain(_x, _y, _group = noone) : Node_Fluid(_x, _y, _group) fd_rectangle_set_repeat(domain, wrap); outputs[| 0].setValue(domain); - - //if(!loop) return; - //if(PROJECT.animator.current_frame != 0) return; - - //for( var i = 0; i < PROJECT.animator.frames_total; i++ ) - // updateForward(i, false); - } + } #region static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { var bbox = drawGetBbox(xx, yy, _s); diff --git a/scripts/node_fluid_render/node_fluid_render.gml b/scripts/node_fluid_render/node_fluid_render.gml index ced6ab734..3045a3318 100644 --- a/scripts/node_fluid_render/node_fluid_render.gml +++ b/scripts/node_fluid_render/node_fluid_render.gml @@ -13,10 +13,12 @@ function Node_Fluid_Render(_x, _y, _group = noone) : Node_Fluid(_x, _y, _group) inputs[| 2] = nodeValue("Interpolate", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false); inputs[| 3] = nodeValue("Draw Domain", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false); + + inputs[| 4] = nodeValue("Auto Update", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true); input_display_list = [ ["Domain", false], 0, - ["Render", false], 1, 2, 3, + ["Render", false], 4, 1, 2, 3, ]; outputs[| 0] = nodeValue("Fluid", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone); @@ -51,11 +53,16 @@ function Node_Fluid_Render(_x, _y, _group = noone) : Node_Fluid(_x, _y, _group) var _dom = inputs[| 0].getValue(frame); var _int = inputs[| 2].getValue(frame); var _drw = inputs[| 3].getValue(frame); + var _upd = inputs[| 4].getValue(frame); - if(_dom == noone || !instance_exists(_dom)) return; + FLUID_DOMAIN_CHECK var fSurf = _dom.sf_material_0; if(!is_surface(fSurf)) return; + + if(_upd) fd_rectangle_update(_dom); + texture_set_interpolation(false); + outputs[| 1].setValue(_dom.sf_world); surface_set_shader(_outSurf, sh_fd_visualize_colorize_glsl); diff --git a/scripts/node_fluid_repulse/node_fluid_repulse.gml b/scripts/node_fluid_repulse/node_fluid_repulse.gml index fe7aea5c3..645571a0d 100644 --- a/scripts/node_fluid_repulse/node_fluid_repulse.gml +++ b/scripts/node_fluid_repulse/node_fluid_repulse.gml @@ -44,7 +44,7 @@ function Node_Fluid_Repulse(_x, _y, _group = noone) : Node_Fluid(_x, _y, _group) var _str = inputs[| 3].getValue(frame); var _mod = inputs[| 4].getValue(frame); - if(_dom == noone || !instance_exists(_dom)) return; + FLUID_DOMAIN_CHECK outputs[| 0].setValue(_dom); _rad = max(_rad, 1); diff --git a/scripts/node_fluid_sim/node_fluid_sim.gml b/scripts/node_fluid_sim/node_fluid_sim.gml index 8aeb1c1ff..9a2f14dad 100644 --- a/scripts/node_fluid_sim/node_fluid_sim.gml +++ b/scripts/node_fluid_sim/node_fluid_sim.gml @@ -1,3 +1,5 @@ +#macro FLUID_DOMAIN_CHECK if(!is_instanceof(group, Node_Fluid_Group)) return; if(!instance_exists(_dom)) _dom = group.domain; if(_dom == noone || !instance_exists(_dom)) return; + function Node_Fluid_Group(_x, _y, _group = noone) : Node_Collection(_x, _y, _group) constructor { name = "FluidSim"; color = COLORS.node_blend_fluid; @@ -6,15 +8,60 @@ function Node_Fluid_Group(_x, _y, _group = noone) : Node_Collection(_x, _y, _gro ungroupable = false; update_on_frame = true; + inputs[| 0] = nodeValue("Dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, DEF_SURF) + .setDisplay(VALUE_DISPLAY.vector); + + inputs[| 1] = nodeValue("Collision", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone); + + inputs[| 2] = nodeValue("Material dissipation type", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 1) + .setDisplay(VALUE_DISPLAY.enum_button, [ "Multiply", "Subtract" ]); + + inputs[| 3] = nodeValue("Material dissipation", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.02) + .setDisplay(VALUE_DISPLAY.slider, { range: [ 0, 0.1, 0.01 ] }); + + inputs[| 4] = nodeValue("Velocity dissipation type", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 1) + .setDisplay(VALUE_DISPLAY.enum_button, [ "Multiply", "Subtract" ]); + + inputs[| 5] = nodeValue("Velocity dissipation", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.00) + .setDisplay(VALUE_DISPLAY.slider, { range: [ 0, 0.1, 0.01 ] }); + + inputs[| 6] = nodeValue("Acceleration", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 0 ]) + .setDisplay(VALUE_DISPLAY.vector); + + inputs[| 7] = nodeValue("Material intertia", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 1, -0.2 ]) + .setDisplay(VALUE_DISPLAY.vector); + + inputs[| 8] = nodeValue("Initial pressure", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.75) + .setDisplay(VALUE_DISPLAY.slider); + + inputs[| 9] = nodeValue("Material Maccormack weight", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1) + .setDisplay(VALUE_DISPLAY.slider); + + inputs[| 10] = nodeValue("Velocity Maccormack weight", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0) + .setDisplay(VALUE_DISPLAY.slider); + + inputs[| 11] = nodeValue("Wrap", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false); + + input_display_list_def = [ + ["Domain", false], 0, 11, 1, + ["Properties", false], 8, 6, 7, + ["Dissipation", false], 2, 3, 4, 5, + ["Huh?", true], 9, 10, + ["Inputs", false], + ]; + + custom_input_index = ds_list_size(inputs); + + domain = fd_rectangle_create(PROJECT.attributes.surface_dimension[0], PROJECT.attributes.surface_dimension[1]); + //_dim_old = [0, 0]; + if(!LOADING && !APPENDING && !CLONING) { - var _domain = nodeBuild("Node_Fluid_Domain", -384, -32, self); - var _update = nodeBuild("Node_Fluid_Update", 0, -32, self); + //var _domain = nodeBuild("Node_Fluid_Domain", -384, -32, self); var _render = nodeBuild("Node_Fluid_Render", 128, -32, self); var _output = nodeBuild("Node_Group_Output", 384, -32, self); _output.inputs[| 0].setFrom(_render.outputs[| 0]); - _render.inputs[| 0].setFrom(_update.outputs[| 0]); - _update.inputs[| 0].setFrom(_domain.outputs[| 0]); + //_render.inputs[| 0].setFrom(_domain.outputs[| 0]); } static update = function() { @@ -24,6 +71,51 @@ function Node_Fluid_Group(_x, _y, _group = noone) : Node_Collection(_x, _y, _gro if(!is_instanceof(node, Node_Fluid_Render)) continue; if(node.cacheExist()) node.cachedPropagate(); } + + var _dim = getInputData( 0); + var coll = getInputData( 1); + var mdisTyp = getInputData( 2); + var mdis = getInputData( 3); + var vdisTyp = getInputData( 4); + var vdis = getInputData( 5); + var acc = getInputData( 6); + var matInr = getInputData( 7); + var inPress = getInputData( 8); + var mMac = getInputData( 9); + var vMac = getInputData(10); + var wrap = getInputData(11); + + if(PROJECT.animator.current_frame == 0 || !is_surface(domain.sf_world)) { + fd_rectangle_clear(domain); + fd_rectangle_destroy(domain); + domain = fd_rectangle_create(_dim[0], _dim[1]); + + fd_rectangle_set_visualization_shader(domain, FD_VISUALIZATION_SHADER.COLORIZE); + fd_rectangle_set_material_type(domain, FD_MATERIAL_TYPE.A_16); + fd_rectangle_set_velocity_time_step(domain, 1); + fd_rectangle_set_material_time_step(domain, 1); + + fd_rectangle_set_pressure_iteration_type(domain, -2); + fd_rectangle_set_initial_value_pressure(domain, inPress); + } + + surface_set_target(domain.sf_world); + draw_clear_alpha($00FFFF, 0); + if(is_surface(coll)) draw_surface_stretched_safe(coll, 0, 0, _dim[0], _dim[1]); + surface_reset_target(); + + fd_rectangle_set_material_dissipation_type(domain, mdisTyp); + fd_rectangle_set_material_dissipation_value(domain, mdis); + + fd_rectangle_set_velocity_dissipation_type(domain, vdisTyp); + fd_rectangle_set_velocity_dissipation_value(domain, vdis); + + fd_rectangle_set_acceleration(domain, acc[0], acc[1], matInr[0], matInr[1]); + + fd_rectangle_set_velocity_maccormack_weight(domain, vMac); + fd_rectangle_set_material_maccormack_weight(domain, mMac); + + fd_rectangle_set_repeat(domain, wrap); } PATCH_STATIC diff --git a/scripts/node_fluid_turbulence/node_fluid_turbulence.gml b/scripts/node_fluid_turbulence/node_fluid_turbulence.gml index e8b9914d9..64935481b 100644 --- a/scripts/node_fluid_turbulence/node_fluid_turbulence.gml +++ b/scripts/node_fluid_turbulence/node_fluid_turbulence.gml @@ -39,7 +39,7 @@ function Node_Fluid_Turbulence(_x, _y, _group = noone) : Node_Fluid(_x, _y, _gro var _sed = inputs[| 4].getValue(frame); var _mod = inputs[| 5].getValue(frame); - if(_dom == noone || !instance_exists(_dom)) return; + FLUID_DOMAIN_CHECK outputs[| 0].setValue(_dom); var vSurface = surface_create_size(_dom.sf_velocity); diff --git a/scripts/node_fluid_update/node_fluid_update.gml b/scripts/node_fluid_update/node_fluid_update.gml index 8dea147f5..d389a9d7d 100644 --- a/scripts/node_fluid_update/node_fluid_update.gml +++ b/scripts/node_fluid_update/node_fluid_update.gml @@ -22,7 +22,8 @@ function Node_Fluid_Update(_x, _y, _group = noone) : Node_Fluid(_x, _y, _group) var _dom = inputs[| 0].getValue(frame); var _act = inputs[| 1].getValue(frame); - if(_dom == noone || !instance_exists(_dom)) return; + + FLUID_DOMAIN_CHECK outputs[| 0].setValue(_dom); if(!_act) return; diff --git a/scripts/node_fluid_vortex/node_fluid_vortex.gml b/scripts/node_fluid_vortex/node_fluid_vortex.gml index 8f5c5c1f0..e8f72b7cb 100644 --- a/scripts/node_fluid_vortex/node_fluid_vortex.gml +++ b/scripts/node_fluid_vortex/node_fluid_vortex.gml @@ -49,7 +49,7 @@ function Node_Fluid_Vortex(_x, _y, _group = noone) : Node_Fluid(_x, _y, _group) var _aio = inputs[| 4].getValue(frame); var _mod = inputs[| 5].getValue(frame); - if(_dom == noone || !instance_exists(_dom)) return; + FLUID_DOMAIN_CHECK outputs[| 0].setValue(_dom); _rad = max(_rad, 1); diff --git a/scripts/node_group_input/node_group_input.gml b/scripts/node_group_input/node_group_input.gml index 13ba7b2d2..21d857c94 100644 --- a/scripts/node_group_input/node_group_input.gml +++ b/scripts/node_group_input/node_group_input.gml @@ -40,7 +40,7 @@ function Node_Group_Input(_x, _y, _group = noone) : Node(_x, _y, _group) constru /*Surface*/ [ "Default", ], /*Path*/ [ "Default", ], - /*Curve*/ [ "Default", ], + /*Curve*/ [ "Curve", ], /*Text*/ [ "Default", ], /*Object*/ [ "Default", ], /*Node*/ [ "Default", ], @@ -60,10 +60,9 @@ function Node_Group_Input(_x, _y, _group = noone) : Node(_x, _y, _group) constru #endregion inputs[| 0] = nodeValue("Display type", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0) - .setDisplay(VALUE_DISPLAY.enum_scroll, display_list[0]) + .setDisplay(VALUE_DISPLAY.enum_scroll, { data: display_list[0], update_hover: false }) .uncache() .rejectArray(); - inputs[| 0].editWidget.update_hover = false; inputs[| 1] = nodeValue("Range", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, [0, 1]) .setDisplay(VALUE_DISPLAY.range) @@ -71,11 +70,10 @@ function Node_Group_Input(_x, _y, _group = noone) : Node(_x, _y, _group) constru .setVisible(false) .rejectArray(); - inputs[| 2] = nodeValue("Input type", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0) + inputs[| 2] = nodeValue("Input type", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 11) .setDisplay(VALUE_DISPLAY.enum_scroll, { data: data_type_list, update_hover: false }) .uncache() .rejectArray(); - inputs[| 2].editWidget.update_hover = false; inputs[| 3] = nodeValue("Enum label", self, JUNCTION_CONNECT.input, VALUE_TYPE.text, "") .setVisible(false) @@ -115,12 +113,26 @@ function Node_Group_Input(_x, _y, _group = noone) : Node(_x, _y, _group) constru .uncache(); attributes.inherit_name = !LOADING && !APPENDING; + attributes.inherit_type = !LOADING && !APPENDING; doTrigger = 0; _onSetDisplayName = function() { attributes.inherit_name = false; } + outputs[| 0].onSetTo = function(juncTo) { + if(!attributes.inherit_type) return; + attributes.inherit_type = false; + + var ind = array_find(data_type_map, juncTo.type); + if(ind == -1) return; + + if(ind == inputs[| 2].getValue()) return; + + outputs[| 0].type = juncTo.type; + inputs[| 2].setValue(ind); + } + static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) { #region if(inParent.isArray()) return; inParent.drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny); @@ -138,14 +150,17 @@ function Node_Group_Input(_x, _y, _group = noone) : Node(_x, _y, _group) constru var _step = getInputData(7); if(index == 2) { - var _o = outputs[| 0]; - for(var j = 0; j < ds_list_size(_o.value_to); j++) { - var _to = _o.value_to[| j]; - if(_to.value_from == _o) - _to.removeFrom(); + if(outputs[| 0].type != _val_type) { + var _o = outputs[| 0]; + for(var j = 0; j < ds_list_size(_o.value_to); j++) { + var _to = _o.value_to[| j]; + if(_to.value_from == _o) + _to.removeFrom(); + } } inputs[| 0].setValue(0); + attributes.inherit_type = false; } _dtype = array_safe_get(array_safe_get(display_list, _val_type, []), _dtype); @@ -227,6 +242,11 @@ function Node_Group_Input(_x, _y, _group = noone) : Node(_x, _y, _group) constru inParent.setDisplay(VALUE_DISPLAY._default); break; + case "Curve": + inParent.animator = new valueAnimator(CURVE_DEF_11, inParent); + inParent.setDisplay(VALUE_DISPLAY.curve); + break; + default: inParent.setDisplay(VALUE_DISPLAY._default); break; diff --git a/scripts/node_iterate_filter/node_iterate_filter.gml b/scripts/node_iterate_filter/node_iterate_filter.gml index 76ddaa97b..0b52415df 100644 --- a/scripts/node_iterate_filter/node_iterate_filter.gml +++ b/scripts/node_iterate_filter/node_iterate_filter.gml @@ -14,7 +14,7 @@ function Node_Iterate_Filter(_x, _y, _group = noone) : Node_Iterator(_x, _y, _gr outputs[| 0] = nodeValue("Array", self, JUNCTION_CONNECT.output, VALUE_TYPE.any, noone ); - custom_input_index = ds_list_size(inputs); + custom_input_index = ds_list_size(inputs); custom_output_index = ds_list_size(inputs); loop_start_time = 0; ALWAYS_FULL = true; diff --git a/scripts/node_rigid_force_apply/node_rigid_force_apply.gml b/scripts/node_rigid_force_apply/node_rigid_force_apply.gml index 1e3ede902..b02336f6f 100644 --- a/scripts/node_rigid_force_apply/node_rigid_force_apply.gml +++ b/scripts/node_rigid_force_apply/node_rigid_force_apply.gml @@ -44,7 +44,21 @@ function Node_Rigid_Force_Apply(_x, _y, _group = noone) : Node(_x, _y, _group) c ["Force", false], 1, 6, 4, 2, 3, 5, 8, 7, ] + attributes.show_objects = true; + array_push(attributeEditors, "Display"); + array_push(attributeEditors, ["Show objects", function() { return attributes.show_objects; }, + new checkBox(function() { + attributes.show_objects = !attributes.show_objects; + })]); + static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) { + if(attributes.show_objects) + for( var i = 0, n = ds_list_size(group.nodes); i < n; i++ ) { + var _node = group.nodes[| i]; + if(!is_instanceof(_node, Node_Rigid_Object)) continue; + _node.drawOverlayPreview(_x, _y, _s, _mx, _my, _snx, _sny); + } + var _typ = getInputData(1); var _pos = getInputData(2); var px = _x + _pos[0] * _s; @@ -62,7 +76,7 @@ function Node_Rigid_Force_Apply(_x, _y, _group = noone) : Node(_x, _y, _group) c draw_set_alpha(1); inputs[| 2].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny); - inputs[| 5].drawOverlay(active, px, py, _s, _mx, _my, _snx, _sny, THEME.anchor, 10); + inputs[| 5].drawOverlay(active, px, py, _s * 10, _mx, _my, _snx, _sny, THEME.anchor, 10); } else if(_typ == 3) { var _rad = getInputData(8); diff --git a/scripts/node_rigid_object/node_rigid_object.gml b/scripts/node_rigid_object/node_rigid_object.gml index baf813ca2..814ccd13c 100644 --- a/scripts/node_rigid_object/node_rigid_object.gml +++ b/scripts/node_rigid_object/node_rigid_object.gml @@ -43,16 +43,10 @@ function Node_Rigid_Object(_x, _y, _group = noone) : Node(_x, _y, _group) constr .setDisplay(VALUE_DISPLAY.slider, { range: [ -2, 2, 0.1 ] }) .rejectArray(); - inputs[| 11] = nodeValue("Texture type", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0) - .setDisplay(VALUE_DISPLAY.enum_scroll, [ "Surface", "Atlas" ]) - .rejectArray(); - - inputs[| 12] = nodeValue("Atlas", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, []); - outputs[| 0] = nodeValue("Object", self, JUNCTION_CONNECT.output, VALUE_TYPE.rigid, self); input_display_list = [ 8, - ["Texture", false], 11, 6, 12, + ["Texture", false], 6, ["Physical", false], 0, 1, 2, 3, 4, ["Shape", false], 7, 5, 9, 10, ]; @@ -71,24 +65,7 @@ function Node_Rigid_Object(_x, _y, _group = noone) : Node(_x, _y, _group) constr new NodeTool( "Mesh edit", THEME.mesh_tool_edit ), new NodeTool( "Anchor remove", THEME.mesh_tool_delete ), ]; - - static getPreviewValues = function() { - var _typ = getInputData(11); - return _typ? getInputData(12) : getInputData(6); - } - - static generateAllMesh = function() { - var _typ = getInputData(11); - var _tex = _typ? getInputData(12) : getInputData(6); - - if(is_array(_tex)) { - for( var i = 0, n = array_length(_tex); i < n; i++ ) - generateMesh(i); - } else - generateMesh(); - doUpdate(); - } - + is_convex = true; hover = -1; anchor_dragging = -1; @@ -97,20 +74,36 @@ function Node_Rigid_Object(_x, _y, _group = noone) : Node(_x, _y, _group) constr anchor_drag_mx = -1; anchor_drag_my = -1; - static drawOverlayPreview = function(_i, _x, _y, _s, _pr_x, _pr_y, _atl_s, _tex_s) { #region + static getPreviewValues = function() { #region + return getInputData(6); + } #endregion + + static generateAllMesh = function() { #region + var _tex = getInputData(6); + + if(is_array(_tex)) { + for( var i = 0, n = array_length(_tex); i < n; i++ ) + generateMesh(i); + } else + generateMesh(); + doUpdate(); + } #endregion + + static drawOverlayPreviewSingle = function(_i, _x, _y, _s, _pr_x, _pr_y, _tex_s) { #region var meshes = attributes.mesh; var _shp = getInputData(5); - var _typ = getInputData(11); - var ww = max(1, surface_get_width_safe(_tex_s)); - var hh = max(1, surface_get_height_safe(_tex_s)); + var ww = surface_get_width_safe(_tex_s); + var hh = surface_get_height_safe(_tex_s); + var _tex = _tex_s; - if(_typ == 0) { + if(is_instanceof(_tex_s, SurfaceAtlas)) { + _tex = _tex_s.getSurface(); + _pr_x += _tex_s.x * _s; + _pr_y += _tex_s.y * _s; + } else { _pr_x -= ww * _s / 2; _pr_y -= hh * _s / 2; - } else if(_typ == 1) { - _pr_x += _atl_s.x * _s; - _pr_y += _atl_s.y * _s; } if(_shp == 2 && array_length(meshes) > _i) { @@ -132,57 +125,37 @@ function Node_Rigid_Object(_x, _y, _group = noone) : Node(_x, _y, _group) constr draw_line_width(_px0, _py0, _px1, _py1, 1); } - } + } - draw_surface_ext_safe(_tex_s, _pr_x, _pr_y, _s, _s, 0, c_white, 0.5); + draw_surface_ext_safe(_tex, _pr_x, _pr_y, _s, _s, 0, c_white, 0.5); + } #endregion + + static drawOverlayPreview = function(_x, _y, _s, _mx, _my, _snx, _sny) { #region + var _pos = getInputData(7); + var _tex = getInputData(6); + + var _pr_x = _x + _pos[0] * _s; + var _pr_y = _y + _pos[1] * _s; + + if(is_array(_tex)) { + for( var i = 0, n = array_length(_tex); i < n; i++ ) + drawOverlayPreviewSingle(i, _x, _y, _s, _pr_x, _pr_y, _tex[i]); + } else + drawOverlayPreviewSingle(0, _x, _y, _s, _pr_x, _pr_y, _tex); + inputs[| 7].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny); } #endregion static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) { #region - var _shp = getInputData(5); - var _pos = getInputData(7); - var _typ = getInputData(11); - - var _typ = getInputData(11); - var _atl = getInputData(12); - var _tex = getInputData(6); - - var _atl_s = _atl; - var _tex_s = _tex; - - var _isArr = false; - - if(_typ == 0) { - if(is_array(_tex)) { - _tex_s = array_safe_get(_tex, preview_index); - _isArr = true; + if(previewing == 0 && is_instanceof(group, Node_Rigid_Group)) { + for( var i = 0, n = ds_list_size(group.nodes); i < n; i++ ) { + var _node = group.nodes[| i]; + if(!is_instanceof(_node, Node_Rigid_Object)) continue; + _node.drawOverlayPreview(_x, _y, _s, _mx, _my, _snx, _sny); } - } else if(_typ == 1) { - if(is_array(_atl)) { - _atl_s = array_safe_get(_atl, preview_index); - _isArr = true; - } - if(_atl_s == 0) return; - _tex_s = _atl_s.getSurface(); - } - - if(previewing == 0) { - var _pr_x = _x + _pos[0] * _s; - var _pr_y = _y + _pos[1] * _s; - - if(_isArr) { - if(_typ == 0) { - for( var i = 0, n = array_length(_tex); i < n; i++ ) - drawOverlayPreview(i, _x, _y, _s, _pr_x, _pr_y, noone, _tex[i]); - } else { - for( var i = 0, n = array_length(_atl); i < n; i++ ) - drawOverlayPreview(i, _x, _y, _s, _pr_x, _pr_y, _atl[i], _atl[i].getSurface()); - } - } else - drawOverlayPreview(0, _x, _y, _s, _pr_x, _pr_y, _atl, _tex); - inputs[| 7].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny); return; } + var _shp = getInputData(5); if(_shp != 2) return; var meshes = attributes.mesh; @@ -287,16 +260,11 @@ function Node_Rigid_Object(_x, _y, _group = noone) : Node(_x, _y, _group) constr static generateMesh = function(index = 0) { #region var _tex = getInputData(6); var _exp = getInputData(10); - var _typ = getInputData(11); - var _atl = getInputData(12); - if(_typ == 0) { - if(is_array(_tex)) _tex = array_safe_get(_tex, index); - } else if(_typ == 1) { - if(is_array(_atl)) _atl = array_safe_get(_atl, index); - if(_atl == 0) return; - _tex = _atl.getSurface(); - } + if(is_array(_tex)) _tex = array_safe_get(_tex, index); + + if(is_instanceof(_tex, SurfaceAtlas)) + _tex = _tex.getSurface(); if(!is_surface(_tex)) return; @@ -326,6 +294,8 @@ function Node_Rigid_Object(_x, _y, _group = noone) : Node(_x, _y, _group) constr } } + if(cmA == 0) return; + cmX /= cmA; cmY /= cmA; @@ -354,15 +324,17 @@ function Node_Rigid_Object(_x, _y, _group = noone) : Node(_x, _y, _group) constr var cc = buffer_read(surface_buffer, buffer_u32); var _a = (cc & (0b11111111 << 24)) >> 24; - if(_a > 0) + if(_a > 0) _pm[? point_direction_positive(cmX, cmY, i, j)] = [i, j]; } if(ds_map_size(_pm)) { var keys = ds_map_keys_to_array(_pm); array_sort(keys, false); - + for( var i = 0, n = array_length(keys); i < n; i++ ) { + //print($"Getting key {keys[i]} - {_pm[? keys[i]]}"); + var px = _pm[? keys[i]][0]; var py = _pm[? keys[i]][1]; @@ -532,32 +504,29 @@ function Node_Rigid_Object(_x, _y, _group = noone) : Node(_x, _y, _group) constr } #endregion static spawn = function(index = 0, object = noone) { #region - var _shp = getInputData(5); - var _tex = getInputData(6); - var _typ = getInputData(11); - var _atl = getInputData(12); + var _shp = getInputData(5); + var _tex = getInputData(6); + var _spos = getInputData(7); - if(_typ == 0 && is_array(_tex)) { index = safe_mod(index, array_length(_tex)); _tex = array_safe_get(_tex, index); } - if(_typ == 1 && is_array(_atl)) { index = safe_mod(index, array_length(_atl)); _atl = array_safe_get(_atl, index); } - if(_typ == 1) { - if(_atl == 0) return; - _tex = _atl.getSurface(); + if(is_array(_tex)) { + index = safe_mod(index, array_length(_tex)); + _tex = array_safe_get(_tex, index); } - var _spos = getInputData(7); - - var ww = max(1, surface_get_width_safe(_tex)); - var hh = max(1, surface_get_height_safe(_tex)); + var ww = surface_get_width_safe(_tex); + var hh = surface_get_height_safe(_tex); var sw = ww, sh = hh; var ox = _spos[0]; var oy = _spos[1]; - if(_typ == 1) { - ox += _atl.x; - oy += _atl.y; + if(is_instanceof(_tex, SurfaceAtlas)) { + ox += _tex.x; + oy += _tex.y; sw = 0; sh = 0; + + _tex = _tex.getSurface(); } if(object == noone) { @@ -657,10 +626,6 @@ function Node_Rigid_Object(_x, _y, _group = noone) : Node(_x, _y, _group) constr static step = function() { #region var _shp = getInputData(5); - var _tex = getInputData(11); - - inputs[| 6].setVisible(_tex == 0, _tex == 0); - inputs[| 12].setVisible(_tex == 1, _tex == 1); inputs[| 9].setVisible(_shp == 2); @@ -675,8 +640,7 @@ function Node_Rigid_Object(_x, _y, _group = noone) : Node(_x, _y, _group) constr } #endregion static reset = function() { #region - var _typ = getInputData(11); - var _tex = _typ? getInputData(12) : getInputData(6); + var _tex = getInputData(6); for( var i = 0, n = array_length(object); i < n; i++ ) { if(instance_exists(object[i])) @@ -696,15 +660,14 @@ function Node_Rigid_Object(_x, _y, _group = noone) : Node(_x, _y, _group) constr static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region var bbox = drawGetBbox(xx, yy, _s); - var _typ = getInputData(11); - var _tex = _typ? getInputData(12) : getInputData(6); + var _tex = getInputData(6); if(is_array(_tex)) { if(array_empty(_tex)) return; _tex = _tex[0]; } - draw_surface_bbox(_typ? _tex.getSurface() : _tex, bbox); + draw_surface_bbox(_tex, bbox); } #endregion static attributeSerialize = function() { #region diff --git a/scripts/node_rigid_object_spawner/node_rigid_object_spawner.gml b/scripts/node_rigid_object_spawner/node_rigid_object_spawner.gml index e7b65eef0..22376bb74 100644 --- a/scripts/node_rigid_object_spawner/node_rigid_object_spawner.gml +++ b/scripts/node_rigid_object_spawner/node_rigid_object_spawner.gml @@ -40,7 +40,21 @@ function Node_Rigid_Object_Spawner(_x, _y, _group = noone) : Node(_x, _y, _group spawn_index = 0; + attributes.show_objects = true; + array_push(attributeEditors, "Display"); + array_push(attributeEditors, ["Show objects", function() { return attributes.show_objects; }, + new checkBox(function() { + attributes.show_objects = !attributes.show_objects; + })]); + static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) { + if(attributes.show_objects) + for( var i = 0, n = ds_list_size(group.nodes); i < n; i++ ) { + var _node = group.nodes[| i]; + if(!is_instanceof(_node, Node_Rigid_Object)) continue; + _node.drawOverlayPreview(_x, _y, _s, _mx, _my, _snx, _sny); + } + inputs[| 1].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny); } diff --git a/scripts/node_rigid_render/node_rigid_render.gml b/scripts/node_rigid_render/node_rigid_render.gml index 92f4ce3e0..16d75b2de 100644 --- a/scripts/node_rigid_render/node_rigid_render.gml +++ b/scripts/node_rigid_render/node_rigid_render.gml @@ -18,6 +18,13 @@ function Node_Rigid_Render(_x, _y, _group = noone) : Node(_x, _y, _group) constr attribute_surface_depth(); + attributes.show_objects = true; + array_push(attributeEditors, "Display"); + array_push(attributeEditors, ["Show objects", function() { return attributes.show_objects; }, + new checkBox(function() { + attributes.show_objects = !attributes.show_objects; + })]); + static createNewInput = function() { var index = ds_list_size(inputs); inputs[| index] = nodeValue("Object", self, JUNCTION_CONNECT.input, VALUE_TYPE.rigid, noone ) @@ -55,6 +62,17 @@ function Node_Rigid_Render(_x, _y, _group = noone) : Node(_x, _y, _group) constr refreshDynamicInput(); } + static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) { #region + if(!is_instanceof(group, Node_Rigid_Group)) return; + if(!attributes.show_objects) return; + + for( var i = 0, n = ds_list_size(group.nodes); i < n; i++ ) { + var _node = group.nodes[| i]; + if(!is_instanceof(_node, Node_Rigid_Object)) continue; + _node.drawOverlayPreview(_x, _y, _s, _mx, _my, _snx, _sny); + } + } #endregion + static step = function() { var _dim = getInputData(0); var _outSurf = outputs[| 0].getValue(); diff --git a/scripts/node_statistic/node_statistic.gml b/scripts/node_statistic/node_statistic.gml index fa16574c5..9edc8a7c8 100644 --- a/scripts/node_statistic/node_statistic.gml +++ b/scripts/node_statistic/node_statistic.gml @@ -35,16 +35,16 @@ function Node_Statistic(_x, _y, _group = noone) : Node(_x, _y, _group) construct setIsDynamicInput(1); - static createNewInput = function() { + static createNewInput = function() { #region var index = ds_list_size(inputs); inputs[| index] = nodeValue("Input", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, -1 ) - .setVisible(true, true); - } + .setVisible(false, true); + } #endregion if(!LOADING && !APPENDING) createNewInput(); outputs[| 0] = nodeValue("Statistic", self, JUNCTION_CONNECT.output, VALUE_TYPE.float, -1); - static refreshDynamicInput = function() { + static refreshDynamicInput = function() { #region var _l = ds_list_create(); for( var i = 0; i < input_fix_len; i++ ) { @@ -54,6 +54,7 @@ function Node_Statistic(_x, _y, _group = noone) : Node(_x, _y, _group) construct for( var i = input_fix_len; i < ds_list_size(inputs); i++ ) { if(inputs[| i].value_from) { ds_list_add(_l, inputs[| i]); + inputs[| i].setVisible(true, true); } else { delete inputs[| i]; } @@ -67,18 +68,23 @@ function Node_Statistic(_x, _y, _group = noone) : Node(_x, _y, _group) construct inputs = _l; createNewInput(); - } + } #endregion - static onValueFromUpdate = function(index) { + static onValueFromUpdate = function(index) { #region if(LOADING || APPENDING) return; refreshDynamicInput(); - } + } #endregion - static update = function(frame = PROJECT.animator.current_frame) { + static update = function(frame = PROJECT.animator.current_frame) { #region var type = getInputData(0); var res = 0; + if(ds_list_size(inputs) - 1 == input_fix_len) { + outputs[| 0].setValue(0); + return; + } + switch(type) { case STAT_OPERATOR._sum : for( var i = input_fix_len; i < ds_list_size(inputs) - 1; i++ ) { @@ -171,9 +177,9 @@ function Node_Statistic(_x, _y, _group = noone) : Node(_x, _y, _group) construct } outputs[| 0].setValue(res); - } + } #endregion - static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { + static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region draw_set_text(f_h3, fa_center, fa_center, COLORS._main_text); var str = ""; switch(getInputData(0)) { @@ -187,5 +193,5 @@ function Node_Statistic(_x, _y, _group = noone) : Node(_x, _y, _group) construct var bbox = drawGetBbox(xx, yy, _s); var ss = string_scale(str, bbox.w, bbox.h); draw_text_transformed(bbox.xc, bbox.yc, str, ss, ss, 0); - } + } #endregion } \ No newline at end of file diff --git a/scripts/node_value/node_value.gml b/scripts/node_value/node_value.gml index 6831b64e2..41c5c9740 100644 --- a/scripts/node_value/node_value.gml +++ b/scripts/node_value/node_value.gml @@ -495,6 +495,9 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru array_depth = 0; auto_connect = true; setFrom_condition = -1; + + onSetFrom = noone; + onSetTo = noone; #endregion #region ---- animation ---- @@ -533,6 +536,8 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru fullUpdate = false; attributes = {}; + + node.inputs_data[index] = _value; #endregion #region ---- draw ---- @@ -1743,6 +1748,10 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru } UPDATE_RENDER_ORDER = true; + + if(onSetFrom != noone) onSetFrom(_valueFrom); + if(_valueFrom.onSetTo != noone) _valueFrom.onSetTo(self); + return true; } #endregion diff --git a/scripts/panel_graph/panel_graph.gml b/scripts/panel_graph/panel_graph.gml index 46ad0f2fe..b53064c81 100644 --- a/scripts/panel_graph/panel_graph.gml +++ b/scripts/panel_graph/panel_graph.gml @@ -1118,7 +1118,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor { } } - if(target != noone && target.connect_type == JUNCTION_CONNECT.input && target.node.auto_input) + if(key_mod_press(CTRL) && target != noone && target.connect_type == JUNCTION_CONNECT.input && target.node.auto_input) _addInput = true; var _mmx = target != noone? target.x : _mx; @@ -1636,8 +1636,10 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor { function doPaste() { #region var txt = clipboard_get_text(); var _map = json_try_parse(txt, noone); - - if(_map != noone) { + + if(txt == "") return; + + if(is_struct(_map)) { ds_map_clear(APPEND_MAP); APPENDING = true; CLONING = true; diff --git a/scripts/panel_inspector/panel_inspector.gml b/scripts/panel_inspector/panel_inspector.gml index c584b5f2f..4fbc023e3 100644 --- a/scripts/panel_inspector/panel_inspector.gml +++ b/scripts/panel_inspector/panel_inspector.gml @@ -77,7 +77,8 @@ function Panel_Inspector() : PanelContent() constructor { meta_display = [ [ __txt("Project Settings"), false ], [ __txt("Metadata"), true ], - [ __txtx("panel_globalvar", "Global variables"), true, button(function() { panelAdd("Panel_Globalvar", true); }, THEME.node_goto).setIcon(THEME.node_goto, 0, COLORS._main_icon) ] + [ __txtx("panel_globalvar", "Global variables"), true, button(function() { panelAdd("Panel_Globalvar", true); }, THEME.node_goto).setIcon(THEME.node_goto, 0, COLORS._main_icon) ], + [ __txt("Group Properties"), true ], ]; #endregion @@ -162,6 +163,11 @@ function Panel_Inspector() : PanelContent() constructor { var ry = y + top_bar_h; for( var i = 0, n = array_length(meta_display); i < n; i++ ) { + if(i == 3) { + var context = PANEL_GRAPH.getCurrentContext(); + if(context == noone) continue; + } + var _meta = meta_display[i]; var _txt = array_safe_get(_meta, 0); var _b = array_safe_get(_meta, 2, noone); @@ -194,148 +200,148 @@ function Panel_Inspector() : PanelContent() constructor { continue; } - if(i == 0) { - var _edt = PROJECT.attributeEditor; - for( var j = 0; j < array_length(_edt); j++ ) { - var title = _edt[j][0]; - var param = _edt[j][1]; - var editW = _edt[j][2]; + switch(i) { + case 0 : + var _edt = PROJECT.attributeEditor; + for( var j = 0; j < array_length(_edt); j++ ) { + var title = _edt[j][0]; + var param = _edt[j][1]; + var editW = _edt[j][2]; - draw_set_text(f_p0, fa_left, fa_top, COLORS._main_text_inner); - draw_text_add(ui(16), yy, __txt(title)); - yy += line_get_height() + ui(6); - hh += line_get_height() + ui(6); + draw_set_text(f_p0, fa_left, fa_top, COLORS._main_text_inner); + draw_text_add(ui(16), yy, __txt(title)); + yy += line_get_height() + ui(6); + hh += line_get_height() + ui(6); - editW.setFocusHover(pFOCUS, _hover); - if(pFOCUS) editW.register(contentPane); + editW.setFocusHover(pFOCUS, _hover); + if(pFOCUS) editW.register(contentPane); - var wh = 0; - var _data = PROJECT.attributes[$ param]; + var wh = 0; + var _data = PROJECT.attributes[$ param]; - wh = editW.drawParam(new widgetParam(ui(16), yy, w - ui(16 + 48), TEXTBOX_HEIGHT, _data, {}, _m, rx, ry)); + wh = editW.drawParam(new widgetParam(ui(16), yy, w - ui(16 + 48), TEXTBOX_HEIGHT, _data, {}, _m, rx, ry)); - yy += wh + ui(8); - hh += wh + ui(8); - } - } else if(i == 1) { - for( var j = 0; j < array_length(meta.displays); j++ ) { - var display = meta.displays[j]; - - draw_set_text(f_p0, fa_left, fa_top, COLORS._main_text_inner); - draw_text_add(ui(16), yy, __txt(display[0])); - yy += line_get_height() + ui(6); - hh += line_get_height() + ui(6); - - meta_tb[j].setFocusHover(pFOCUS, _hover); - if(pFOCUS) meta_tb[j].register(contentPane); - - var wh = 0; - var _dataFunc = display[1]; - var _data = _dataFunc(meta); - - switch(instanceof(meta_tb[j])) { - case "textArea" : - wh = meta_tb[j].draw(ui(16), yy, w - ui(16 + 48), display[2], _data, _m); - break; - case "textArrayBox" : - meta_tb[j].arraySet = current_meta.tags; - wh = meta_tb[j].draw(ui(16), yy, w - ui(16 + 48), display[2], _m, rx, ry); - break; + yy += wh + ui(8); + hh += wh + ui(8); } + break; + case 1 : + for( var j = 0; j < array_length(meta.displays); j++ ) { + var display = meta.displays[j]; - yy += wh + ui(8); - hh += wh + ui(8); - } - } else if (i == 2) { - if(findPanel("Panel_Globalvar")) { - yy += ui(4); - hh += ui(4); - continue; - } + draw_set_text(f_p0, fa_left, fa_top, COLORS._main_text_inner); + draw_text_add(ui(16), yy, __txt(display[0])); + yy += line_get_height() + ui(6); + hh += line_get_height() + ui(6); - var gvh = globalvar_viewer_draw(ui(16), yy, contentPane.surface_w - ui(24), _m, pFOCUS, _hover, contentPane, ui(16) + x, top_bar_h + y); - yy += gvh + ui(8); - hh += gvh + ui(8); - - var bh = ui(36); - var bx = ui(16); - var by = yy; - var bbw = contentPane.surface_w - ui(24); - - if(var_editing) { - var bw = bbw / 2 - ui(4); + meta_tb[j].setFocusHover(pFOCUS, _hover); + if(pFOCUS) meta_tb[j].register(contentPane); - if(buttonInstant(THEME.button_hide, bx, by, bw, bh, _m, pFOCUS, _hover) == 2) - var_editing = !var_editing; + var wh = 0; + var _dataFunc = display[1]; + var _data = _dataFunc(meta); + + switch(instanceof(meta_tb[j])) { + case "textArea" : + wh = meta_tb[j].draw(ui(16), yy, w - ui(16 + 48), display[2], _data, _m); + break; + case "textArrayBox" : + meta_tb[j].arraySet = current_meta.tags; + wh = meta_tb[j].draw(ui(16), yy, w - ui(16 + 48), display[2], _m, rx, ry); + break; + } + + yy += wh + ui(8); + hh += wh + ui(8); + } + break; + case 2 : + if(findPanel("Panel_Globalvar")) { + yy += ui(4); + hh += ui(4); + continue; + } + + var gvh = globalvar_viewer_draw(ui(16), yy, contentPane.surface_w - ui(24), _m, pFOCUS, _hover, contentPane, ui(16) + x, top_bar_h + y); + yy += gvh + ui(8); + hh += gvh + ui(8); + + var bh = ui(36); + var bx = ui(16); + var by = yy; + var bbw = contentPane.surface_w - ui(24); + + if(var_editing) { + var bw = bbw / 2 - ui(4); + + if(buttonInstant(THEME.button_hide, bx, by, bw, bh, _m, pFOCUS, _hover) == 2) + var_editing = !var_editing; - var txt = __txt("Apply"); - var icon = THEME.accept; - var colr = COLORS._main_value_positive; + var txt = __txt("Apply"); + var icon = THEME.accept; + var colr = COLORS._main_value_positive; - draw_set_text(f_p0b, fa_left, fa_center, COLORS._main_icon) - var bxc = bx + bw / 2 - (string_width(txt) + ui(48)) / 2; - var byc = by + bh / 2; - draw_sprite_ui(icon, 0, bxc + ui(24), byc,,,, colr); - draw_text_add(bxc + ui(48), byc, txt); + draw_set_text(f_p0b, fa_left, fa_center, COLORS._main_icon) + var bxc = bx + bw / 2 - (string_width(txt) + ui(48)) / 2; + var byc = by + bh / 2; + draw_sprite_ui(icon, 0, bxc + ui(24), byc,,,, colr); + draw_text_add(bxc + ui(48), byc, txt); - bx += bw + ui(4); + bx += bw + ui(4); - if(buttonInstant(THEME.button_hide, bx, by, bw, bh, _m, pFOCUS, _hover) == 2) - PROJECT.globalNode.createValue(); + if(buttonInstant(THEME.button_hide, bx, by, bw, bh, _m, pFOCUS, _hover) == 2) + PROJECT.globalNode.createValue(); - var txt = __txt("Add"); - var icon = THEME.add; + var txt = __txt("Add"); + var icon = THEME.add; - draw_set_text(f_p0b, fa_left, fa_center, COLORS._main_icon) - var bxc = bx + bw / 2 - (string_width(txt) + ui(48)) / 2; - var byc = by + bh / 2; - draw_sprite_ui(icon, 0, bxc + ui(24), byc,,,, colr); - draw_text_add(bxc + ui(48), byc, txt); - } else { - var bw = bbw; + draw_set_text(f_p0b, fa_left, fa_center, COLORS._main_icon) + var bxc = bx + bw / 2 - (string_width(txt) + ui(48)) / 2; + var byc = by + bh / 2; + draw_sprite_ui(icon, 0, bxc + ui(24), byc,,,, colr); + draw_text_add(bxc + ui(48), byc, txt); + } else { + var bw = bbw; - if(buttonInstant(THEME.button_hide, bx, by, bw, bh, _m, pFOCUS, _hover) == 2) - var_editing = !var_editing; + if(buttonInstant(THEME.button_hide, bx, by, bw, bh, _m, pFOCUS, _hover) == 2) + var_editing = !var_editing; - var txt = __txt("Edit"); - var icon = THEME.gear; - var colr = COLORS._main_icon; + var txt = __txt("Edit"); + var icon = THEME.gear; + var colr = COLORS._main_icon; - draw_set_text(f_p0b, fa_left, fa_center, colr) - var bxc = bx + bw / 2 - (string_width(txt) + ui(48)) / 2; - var byc = by + bh / 2; - draw_sprite_ui(icon, 0, bxc + ui(24), byc,,,, colr); - draw_text_add(bxc + ui(48), byc, txt); - } - - yy += bh + ui(16); - hh += bh + ui(16); + draw_set_text(f_p0b, fa_left, fa_center, colr) + var bxc = bx + bw / 2 - (string_width(txt) + ui(48)) / 2; + var byc = by + bh / 2; + draw_sprite_ui(icon, 0, bxc + ui(24), byc,,,, colr); + draw_text_add(bxc + ui(48), byc, txt); + } + break; + case 3 : + var context = PANEL_GRAPH.getCurrentContext(); + var _h = drawNodeProperties(yy, _m, context); + + yy += _h; + hh += _h; + break; } yy += ui(8); hh += ui(8); } - + return hh; } #endregion - contentPane = new scrollPane(content_w, content_h, function(_y, _m) { #region - var con_w = contentPane.surface_w - ui(4); + static drawNodeProperties = function(_y, _m, _inspecting = inspecting) { #region + var con_w = contentPane.surface_w - ui(4); var _hover = pHOVER && contentPane.hover; - draw_clear_alpha(COLORS.panel_bg_clear, 0); - - if(point_in_rectangle(_m[0], _m[1], 0, 0, con_w, content_h) && mouse_press(mb_left, pFOCUS)) - prop_selecting = noone; - - if(inspecting == noone) // metadata - return drawMeta(_y, _m); - - inspecting.inspecting = true; + _inspecting.inspecting = true; prop_hover = noone; var jun = noone; - var amoIn = inspecting.input_display_list == -1? ds_list_size(inspecting.inputs) : array_length(inspecting.input_display_list); - var amoOut = ds_list_size(inspecting.outputs); + var amoIn = _inspecting.input_display_list == -1? ds_list_size(_inspecting.inputs) : array_length(_inspecting.input_display_list); + var amoOut = ds_list_size(_inspecting.outputs); var amo = amoIn + 1 + amoOut; var hh = ui(40); @@ -357,8 +363,8 @@ function Panel_Inspector() : PanelContent() constructor { var ww = max(ui(180), con_w / 3); var wx0 = wx1 - ww; - for( var i = 0, n = array_length(inspecting.attributeEditors); i < n; i++ ) { - var edt = inspecting.attributeEditors[i]; + for( var i = 0, n = array_length(_inspecting.attributeEditors); i < n; i++ ) { + var edt = _inspecting.attributeEditors[i]; if(is_string(edt)) { var lby = yy + ui(12); @@ -410,11 +416,11 @@ function Panel_Inspector() : PanelContent() constructor { var yy = hh + _y; if(i < amoIn) { #region inputs - if(inspecting.input_display_list == -1) { - jun = inspecting.inputs[| i]; + if(_inspecting.input_display_list == -1) { + jun = _inspecting.inputs[| i]; } else { - if(i >= array_length(inspecting.input_display_list)) break; - var jun_disp = inspecting.input_display_list[i]; + if(i >= array_length(_inspecting.input_display_list)) break; + var jun_disp = _inspecting.input_display_list[i]; if(is_array(jun_disp)) { var txt = __txt(jun_disp[0]); var coll = jun_disp[1] && filter_text == ""; @@ -425,7 +431,7 @@ function Panel_Inspector() : PanelContent() constructor { if(mouse_press(mb_left, pFOCUS)) jun_disp[@ 1] = !coll; if(mouse_press(mb_right, pFOCUS)) - menuCall("inspector_group_menu",,, group_menu,, inspecting); + menuCall("inspector_group_menu",,, group_menu,, _inspecting); } else draw_sprite_stretched_ext(THEME.group_label, 0, 0, yy, con_w, ui(32), COLORS.panel_inspector_group_bg, 1); @@ -440,10 +446,10 @@ function Panel_Inspector() : PanelContent() constructor { if(coll) { var j = i + 1; - var _len = array_length(inspecting.input_display_list); + var _len = array_length(_inspecting.input_display_list); while(j < _len) { - var j_jun = inspecting.input_display_list[j]; + var j_jun = _inspecting.input_display_list[j]; if(is_array(j_jun)) break; j++; @@ -461,7 +467,7 @@ function Panel_Inspector() : PanelContent() constructor { hh += jun_disp.draw(ui(6), yy, con_w - ui(12), _m, _hover, pFOCUS) + ui(8); continue; } - jun = inspecting.inputs[| inspecting.input_display_list[i]]; + jun = _inspecting.inputs[| _inspecting.input_display_list[i]]; } #endregion } else if(i == amoIn) { #region output label @@ -474,7 +480,7 @@ function Panel_Inspector() : PanelContent() constructor { #endregion } else { #region outputs var outInd = i - amoIn - 1; - jun = inspecting.outputs[| outInd]; + jun = _inspecting.outputs[| outInd]; #endregion } @@ -654,6 +660,19 @@ function Panel_Inspector() : PanelContent() constructor { #endregion return hh; + } #endregion + + contentPane = new scrollPane(content_w, content_h, function(_y, _m) { #region + var con_w = contentPane.surface_w - ui(4); + + draw_clear_alpha(COLORS.panel_bg_clear, 0); + + if(point_in_rectangle(_m[0], _m[1], 0, 0, con_w, content_h) && mouse_press(mb_left, pFOCUS)) + prop_selecting = noone; + + if(inspecting == noone) // metadata + return drawMeta(_y, _m); + return drawNodeProperties(_y, _m); }); #endregion function propSelectCopy() { #region diff --git a/scripts/surface_functions/surface_functions.gml b/scripts/surface_functions/surface_functions.gml index 07de96e64..34486fded 100644 --- a/scripts/surface_functions/surface_functions.gml +++ b/scripts/surface_functions/surface_functions.gml @@ -155,6 +155,7 @@ function surface_get_width_safe(s, crop = true) { if(is_struct(s)) { if(is_instanceof(s, dynaSurf)) return s.getWidth(); else if(is_instanceof(s, SurfaceAtlas)) return crop? surface_get_width(s.getSurface()) : s.oriSurf_w; + else return 1; } return surface_get_width(s); @@ -166,6 +167,7 @@ function surface_get_height_safe(s, crop = true) { if(is_struct(s)) { if(is_instanceof(s, dynaSurf)) return s.getHeight(); else if(is_instanceof(s, SurfaceAtlas)) return crop? surface_get_height(s.getSurface()) : s.oriSurf_h; + else return 1; } return surface_get_height(s); diff --git a/shaders/sh_fluid_bleach/sh_fluid_bleach.fsh b/shaders/sh_fluid_bleach/sh_fluid_bleach.fsh new file mode 100644 index 000000000..d6e85c4fa --- /dev/null +++ b/shaders/sh_fluid_bleach/sh_fluid_bleach.fsh @@ -0,0 +1,10 @@ +// +// Simple passthrough fragment shader +// +varying vec2 v_vTexcoord; +varying vec4 v_vColour; + +void main() { + vec4 samp = texture2D( gm_BaseTexture, v_vTexcoord ); + gl_FragColor = vec4(vec3(1.), samp.a); +} diff --git a/shaders/sh_fluid_bleach/sh_fluid_bleach.vsh b/shaders/sh_fluid_bleach/sh_fluid_bleach.vsh new file mode 100644 index 000000000..3900c20f4 --- /dev/null +++ b/shaders/sh_fluid_bleach/sh_fluid_bleach.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_fluid_bleach/sh_fluid_bleach.yy b/shaders/sh_fluid_bleach/sh_fluid_bleach.yy new file mode 100644 index 000000000..810b5ddbe --- /dev/null +++ b/shaders/sh_fluid_bleach/sh_fluid_bleach.yy @@ -0,0 +1,10 @@ +{ + "resourceType": "GMShader", + "resourceVersion": "1.0", + "name": "sh_fluid_bleach", + "parent": { + "name": "fluid", + "path": "folders/shader/fluid.yy", + }, + "type": 1, +} \ No newline at end of file