This commit is contained in:
Tanasart 2024-12-12 10:49:09 +07:00
parent 2621102373
commit 08621ae6be
6 changed files with 218 additions and 12 deletions

View file

@ -41,13 +41,16 @@
globalvar VERSION, SAVE_VERSION, VERSION_STRING, BUILD_NUMBER, LATEST_VERSION, NIGHTLY; globalvar VERSION, SAVE_VERSION, VERSION_STRING, BUILD_NUMBER, LATEST_VERSION, NIGHTLY;
globalvar HOTKEYS, HOTKEY_CONTEXT; globalvar HOTKEYS, HOTKEY_CONTEXT;
NIGHTLY = false;
LATEST_VERSION = 1_18_00_0; LATEST_VERSION = 1_18_00_0;
VERSION = 1_18_05_1; VERSION = 1_18_05_1;
SAVE_VERSION = 1_18_05_0; 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; 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(); HOTKEYS = ds_map_create();
HOTKEY_CONTEXT = ds_list_create(); HOTKEY_CONTEXT = ds_list_create();
HOTKEY_CONTEXT[| 0] = ""; HOTKEY_CONTEXT[| 0] = "";

View file

@ -305,6 +305,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
tools = -1; tools = -1;
rightTools = -1; rightTools = -1;
isTool = false; isTool = false;
isGizmoGlobal = false;
tool_settings = []; tool_settings = [];
tool_attribute = {}; tool_attribute = {};
#endregion #endregion

View file

@ -94,3 +94,53 @@ function Node_GMRoom(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
} }
} }
} }

View file

@ -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(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)); newOutput(0, nodeValue_Output("Number", self, VALUE_TYPE.float, 0));
input_display_list = [ 0, 1, input_display_list = [ 0, 1,
["Editor", false], 2, 6, 3, 5, 4, 7, ["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) { static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
var _val = getInputData(0); var _val = getInputData(0);
var _dsp = getInputData(2); 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; if(_dsp == 0 || _dsp == 1) inputs[0].display_type = VALUE_DISPLAY._default;
else if(_dsp == 2) inputs[0].display_type = VALUE_DISPLAY.rotation; 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; inputs[0].display_type = VALUE_DISPLAY._default;
return _h; return _h;
@ -113,9 +205,21 @@ function Node_Number(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
doUpdate = doUpdateLite; doUpdate = doUpdateLite;
static update = function() { static update = function() {
setType(); 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 _dat = getInputData(0);
var _int = getInputData(1); var _int = getInputData(1);
var _res = processNumber(_dat, _int); var _res = processNumber(_dat, _int);
outputs[0].setValue(_res); outputs[0].setValue(_res);

View file

@ -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; } static d3_view_action_top = function() /*=>*/ { d3_camLerp = 1; d3_camLerp_x = 0; d3_camLerp_y = 89; }
#endregion #endregion
////============ DATA ============ ////- DATA
function setNodePreview(node) { function setNodePreview(node) {
if(locked) return; if(locked) return;
@ -597,7 +597,7 @@ function Panel_Preview() : PanelContent() constructor {
function onFocusBegin() { PANEL_PREVIEW = self; } function onFocusBegin() { PANEL_PREVIEW = self; }
////============ VIEW ============ ////- VIEW
function dragCanvas() { function dragCanvas() {
if(canvas_dragging) { if(canvas_dragging) {
@ -858,7 +858,7 @@ function Panel_Preview() : PanelContent() constructor {
static onFullScreen = function() { run_in(1, fullView); } static onFullScreen = function() { run_in(1, fullView); }
////============ DRAW ============ ////- DRAW
function drawOnionSkin(node, psx, psy, ss) { function drawOnionSkin(node, psx, psy, ss) {
var _surf = preview_surfaces[0]; 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) { function drawNodeTools(active, _node) {
var _mx = mx; var _mx = mx;
var _my = my; var _my = my;
@ -1751,7 +1794,6 @@ function Panel_Preview() : PanelContent() constructor {
overHover &= point_in_rectangle(mx, my, (_node.tools != -1) * toolbar_width, toolbar_height, w, h - toolbar_height); 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 }; var params = { w, h, toolbar_height };
params.panel = self; params.panel = self;
@ -2311,6 +2353,7 @@ function Panel_Preview() : PanelContent() constructor {
} else { } else {
tool_current = noone; 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); 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() { function copyCurrentFrame() {
var prevS = getNodePreviewSurface(); var prevS = getNodePreviewSurface();
@ -2561,7 +2604,7 @@ function Panel_Preview() : PanelContent() constructor {
} }
} }
//// =========== Serialize =========== ////- Serialize
static serialize = function() { static serialize = function() {
return { return {

View file

@ -181,6 +181,11 @@ function winManStep() {
window_drag_sh = window_minimize_size[1]; window_drag_sh = window_minimize_size[1];
__winman_to_ref = true; __winman_to_ref = true;
var _rx = mx / _sw;
var _nx = _rx * (_sw - window_drag_sw);
window_drag_sx = _nx;
DISPLAY_REFRESH
} else { } else {
sx = _sx + (mx - _mx); sx = _sx + (mx - _mx);
sy = _sy + (my - _my); sy = _sy + (my - _my);