diff --git a/scripts/globals/globals.gml b/scripts/globals/globals.gml index e48e95b53..3ddc8649c 100644 --- a/scripts/globals/globals.gml +++ b/scripts/globals/globals.gml @@ -41,13 +41,16 @@ globalvar VERSION, SAVE_VERSION, VERSION_STRING, BUILD_NUMBER, LATEST_VERSION, NIGHTLY; globalvar HOTKEYS, HOTKEY_CONTEXT; - NIGHTLY = false; LATEST_VERSION = 1_18_00_0; VERSION = 1_18_05_1; SAVE_VERSION = 1_18_05_0; - VERSION_STRING = MAC? "1.18.003m" : "1.18.5.1"; + VERSION_STRING = MAC? "1.18.003m" : "1.18.5.1.001"; BUILD_NUMBER = 1_18_05_1; + var _vsp = string_split(VERSION_STRING, "."); + var _lsp = _vsp[array_length(_vsp) - 1]; + NIGHTLY = string_length(_lsp) == 3; + HOTKEYS = ds_map_create(); HOTKEY_CONTEXT = ds_list_create(); HOTKEY_CONTEXT[| 0] = ""; diff --git a/scripts/node_data/node_data.gml b/scripts/node_data/node_data.gml index b6bbfce86..ca69d2e74 100644 --- a/scripts/node_data/node_data.gml +++ b/scripts/node_data/node_data.gml @@ -305,6 +305,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor { tools = -1; rightTools = -1; isTool = false; + isGizmoGlobal = false; tool_settings = []; tool_attribute = {}; #endregion diff --git a/scripts/node_gm_room/node_gm_room.gml b/scripts/node_gm_room/node_gm_room.gml index e075e1ee1..cbc8d725e 100644 --- a/scripts/node_gm_room/node_gm_room.gml +++ b/scripts/node_gm_room/node_gm_room.gml @@ -93,4 +93,54 @@ function Node_GMRoom(_x, _y, _group = noone) : Node(_x, _y, _group) constructor if(_gm != noone) gmRoom = struct_try_get(_gm.resourcesMap, _ey, noone); } } -} \ No newline at end of file +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scripts/node_number/node_number.gml b/scripts/node_number/node_number.gml index 1edb89776..f1e3d0f9c 100644 --- a/scripts/node_number/node_number.gml +++ b/scripts/node_number/node_number.gml @@ -39,13 +39,36 @@ function Node_Number(_x, _y, _group = noone) : Node(_x, _y, _group) constructor newInput(8, nodeValue_Bool("Show on global", self, false, "Whether to show overlay gizmo when not selecting any nodes.")); + newInput(9, nodeValue_Vec2("Gizmo offset", self, [ 0, 0 ])); + + newInput(10, nodeValue_Float("Gizmo scale", self, 1)); + + newInput(11, nodeValue_Enum_Scroll("Gizmo style", self, 0, [ "Default", "Shapes", "Sprite" ])); + + newInput(12, nodeValue_Enum_Scroll("Gizmo shape", self, 0, [ "Rectangle", "Ellipse", "Arrow" ])); + + newInput(13, nodeValue_Surface("Gizmo sprite", self, noone)); + + newInput(14, nodeValue_Vec2("Gizmo size", self, [ 32, 32 ])); + newOutput(0, nodeValue_Output("Number", self, VALUE_TYPE.float, 0)); input_display_list = [ 0, 1, ["Editor", false], 2, 6, 3, 5, 4, 7, - ["Gizmo", false], 8, + ["Gizmo", false], 8, 11, 12, 13, 14, 9, 10, ] + gz_style = 0; + gz_shape = 0; + gz_sprite = 0; + gz_pos = [ 0, 0 ]; + gz_size = [ 0, 0 ]; + gz_scale = 1; + + gz_dragging = false; + gz_drag_sx = 0; + gz_drag_mx = 0; + static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { var _val = getInputData(0); var _dsp = getInputData(2); @@ -54,7 +77,76 @@ function Node_Number(_x, _y, _group = noone) : Node(_x, _y, _group) constructor if(_dsp == 0 || _dsp == 1) inputs[0].display_type = VALUE_DISPLAY._default; else if(_dsp == 2) inputs[0].display_type = VALUE_DISPLAY.rotation; - var _h = inputs[0].drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny); + var _gx = _x + gz_pos[0] * _s; + var _gy = _y + gz_pos[1] * _s; + var _h = false; + + if(gz_style == 0) _h = inputs[0].drawOverlay(hover, active, _gx, _gy, _s, _mx, _my, _snx, _sny, 0, gz_scale); + else { + var val = inputs[0].getValue(); + + if(gz_dragging) { + var _nv = gz_drag_sx + (_mx - gz_drag_mx) / (_s * gz_scale); + + if(inputs[0].setValue(_nv)) + UNDO_HOLDING = true; + + if(mouse_release(mb_left)) { + gz_dragging = false; + UNDO_HOLDING = false; + } + } + + var _rx = _gx + val * (_s * gz_scale); + var _ry = _gy; + var _rw = gz_size[0] * _s; + var _rh = gz_size[1] * _s; + var _rx0 = _rx - _rw / 2; + var _ry0 = _ry - _rh / 2; + var _rx1 = _rx + _rw / 2; + var _ry1 = _ry + _rh / 2; + + _h = hover && point_in_rectangle(_mx, _my, _rx0, _ry0, _rx1, _ry1); + + if(gz_style == 1) { + draw_set_color(_h || gz_dragging? COLORS._main_accent : COLORS._main_icon); + draw_set_circle_precision(32); + + switch(gz_shape) { + case 0 : draw_rectangle(_rx0, _ry0, _rx1, _ry1, true); break; + case 1 : draw_ellipse(_rx0, _ry0, _rx1, _ry1, true); break; + case 2 : + var _ah = min(_rw, _rh) / 4; + var _lt = min(_rw, _rh) / 3; + + draw_primitive_begin(pr_linestrip); + draw_vertex(_rx0, _ry); + draw_vertex(_rx0 + _ah, _ry0); + draw_vertex(_rx0 + _ah, _ry0 + _lt); + draw_vertex(_rx1 - _ah, _ry0 + _lt); + draw_vertex(_rx1 - _ah, _ry0); + draw_vertex(_rx1, _ry); + draw_vertex(_rx1 - _ah, _ry1); + draw_vertex(_rx1 - _ah, _ry1 - _lt); + draw_vertex(_rx0 + _ah, _ry1 - _lt); + draw_vertex(_rx0 + _ah, _ry1); + draw_vertex(_rx0, _ry); + draw_primitive_end(); + break; + } + + } else if(gz_style == 2) { + if(is_surface(gz_sprite)) draw_surface_stretched_ext(gz_sprite, _rx0, _ry0, _rw, _rh, c_white, 0.5 + 0.5 * _h); + } + + if(_h && mouse_press(mb_left, active)) { + gz_dragging = true; + + gz_drag_sx = val; + gz_drag_mx = _mx; + } + } + inputs[0].display_type = VALUE_DISPLAY._default; return _h; @@ -113,9 +205,21 @@ function Node_Number(_x, _y, _group = noone) : Node(_x, _y, _group) constructor doUpdate = doUpdateLite; static update = function() { setType(); + isGizmoGlobal = getInputData( 8); + gz_pos = getInputData( 9); + gz_scale = getInputData(10); + gz_style = getInputData(11); + gz_shape = getInputData(12); + gz_sprite = getInputData(13); + gz_size = getInputData(14); + + inputs[12].setVisible(gz_style == 1); + inputs[13].setVisible(gz_style == 2, gz_style == 2); + inputs[14].setVisible(gz_style != 0); var _dat = getInputData(0); var _int = getInputData(1); + var _res = processNumber(_dat, _int); outputs[0].setValue(_res); diff --git a/scripts/panel_preview/panel_preview.gml b/scripts/panel_preview/panel_preview.gml index 3356cd7b0..de163e3ca 100644 --- a/scripts/panel_preview/panel_preview.gml +++ b/scripts/panel_preview/panel_preview.gml @@ -516,7 +516,7 @@ function Panel_Preview() : PanelContent() constructor { static d3_view_action_top = function() /*=>*/ { d3_camLerp = 1; d3_camLerp_x = 0; d3_camLerp_y = 89; } #endregion - ////============ DATA ============ + ////- DATA function setNodePreview(node) { if(locked) return; @@ -597,7 +597,7 @@ function Panel_Preview() : PanelContent() constructor { function onFocusBegin() { PANEL_PREVIEW = self; } - ////============ VIEW ============ + ////- VIEW function dragCanvas() { if(canvas_dragging) { @@ -858,7 +858,7 @@ function Panel_Preview() : PanelContent() constructor { static onFullScreen = function() { run_in(1, fullView); } - ////============ DRAW ============ + ////- DRAW function drawOnionSkin(node, psx, psy, ss) { var _surf = preview_surfaces[0]; @@ -1727,6 +1727,49 @@ function Panel_Preview() : PanelContent() constructor { } } + function drawAllNodeGizmo(active) { + var _mx = mx; + var _my = my; + var overHover = pHOVER && mouse_on_preview == 1; + var tool_size = ui(32); + + var cx = canvas_x; + var cy = canvas_y; + var _snx = 0, _sny = 0; + + if(key_mod_press(CTRL)) { + _snx = PROJECT.previewGrid.show? PROJECT.previewGrid.size[0] : 1; + _sny = PROJECT.previewGrid.show? PROJECT.previewGrid.size[1] : 1; + + } else if(PROJECT.previewGrid.snap) { + _snx = PROJECT.previewGrid.size[0]; + _sny = PROJECT.previewGrid.size[1]; + } + + overHover &= !view_hovering; + overHover &= tool_hovering == noone && !overlay_hovering; + overHover &= !canvas_dragging && !canvas_zooming; + overHover &= point_in_rectangle(mx, my, 0, toolbar_height, w, h - toolbar_height); + + var overActive = active && overHover; + var params = { w, h, toolbar_height }; + params.panel = self; + + var _nlist = PANEL_GRAPH.nodes_list; + for( var i = 0, n = array_length(_nlist); i < n; i++ ) { + var _n = _nlist[i]; + if(!is(_n, Node)) continue; + if(!_n.isGizmoGlobal) continue; + + var _h = _n.drawOverlay(overHover, overActive, cx, cy, canvas_s, _mx, _my, _snx, _sny, params); + + if(_h == true) { + overHover = false; + overActive = false; + } + } + } + function drawNodeTools(active, _node) { var _mx = mx; var _my = my; @@ -1750,8 +1793,7 @@ function Panel_Preview() : PanelContent() constructor { overHover &= !canvas_dragging && !canvas_zooming; overHover &= point_in_rectangle(mx, my, (_node.tools != -1) * toolbar_width, toolbar_height, w, h - toolbar_height); - var overActive = active && overHover; - + var overActive = active && overHover; var params = { w, h, toolbar_height }; params.panel = self; @@ -2311,6 +2353,7 @@ function Panel_Preview() : PanelContent() constructor { } else { tool_current = noone; + drawAllNodeGizmo(pFOCUS); } } @@ -2482,7 +2525,7 @@ function Panel_Preview() : PanelContent() constructor { draw_sprite_ui(THEME.node_resize, 0, mx0 + ui(10), my0 + ui(10), 0.5, 0.5, 180, c_white, 0.3); } - ////=========== ACTION =========== + ////- ACTION function copyCurrentFrame() { var prevS = getNodePreviewSurface(); @@ -2561,7 +2604,7 @@ function Panel_Preview() : PanelContent() constructor { } } - //// =========== Serialize =========== + ////- Serialize static serialize = function() { return { diff --git a/scripts/windowManager/windowManager.gml b/scripts/windowManager/windowManager.gml index dc4a968d4..107b60e85 100644 --- a/scripts/windowManager/windowManager.gml +++ b/scripts/windowManager/windowManager.gml @@ -181,6 +181,11 @@ function winManStep() { window_drag_sh = window_minimize_size[1]; __winman_to_ref = true; + var _rx = mx / _sw; + var _nx = _rx * (_sw - window_drag_sw); + window_drag_sx = _nx; + DISPLAY_REFRESH + } else { sx = _sx + (mx - _mx); sy = _sy + (my - _my);