From 414b356f4bf609cf591253c862355989dc806b9c Mon Sep 17 00:00:00 2001 From: Tanasart Date: Fri, 5 Jul 2024 10:18:46 +0700 Subject: [PATCH] - [Graph Panel] Add double shift kets to select all junctions of the same io type in the same node as the dragging junction. --- objects/o_main/Create_0.gml | 6 ++- objects/o_main/Step_1.gml | 47 +++++++++---------- objects/o_main/o_main.yy | 38 +++++++-------- scripts/control_function/control_function.gml | 38 ++++++++------- scripts/node_collection/node_collection.gml | 4 +- scripts/node_data/node_data.gml | 4 +- scripts/panel_graph/panel_graph.gml | 16 ++++++- scripts/preferences/preferences.gml | 3 +- scripts/preferences/preferences.yy | 2 +- 9 files changed, 88 insertions(+), 70 deletions(-) diff --git a/objects/o_main/Create_0.gml b/objects/o_main/Create_0.gml index b3a87a9f9..e5d23cd20 100644 --- a/objects/o_main/Create_0.gml +++ b/objects/o_main/Create_0.gml @@ -10,7 +10,7 @@ gc_target_frame_time(100); #endregion -#region window +#region window & IO window_set_min_width(960); window_set_min_height(600); draw_set_circle_precision(64); @@ -47,6 +47,10 @@ kb_hold = false; kb_hkey = 0; + kd_ctrl = 0; + kd_shift = 0; + kd_alt = 0; + fpss = array_create(10); fpsr = 0; diff --git a/objects/o_main/Step_1.gml b/objects/o_main/Step_1.gml index 08b0a59fb..f6ad1665e 100644 --- a/objects/o_main/Step_1.gml +++ b/objects/o_main/Step_1.gml @@ -197,35 +197,34 @@ FILE_DROPPED = false; #endregion #region modifiers - if(CTRL == KEYBOARD_STATUS.up) CTRL = KEYBOARD_STATUS.idle; - if(SHIFT == KEYBOARD_STATUS.up) SHIFT = KEYBOARD_STATUS.idle; - if(ALT == KEYBOARD_STATUS.up) ALT = KEYBOARD_STATUS.idle; + var _d = PREFERENCES.double_click_delay; - if(CTRL == KEYBOARD_STATUS.pressing && !keyboard_check(vk_control)) - CTRL = KEYBOARD_STATUS.up; + kd_ctrl += DELTA_TIME; + if(CTRL == KEY_STAT.up) CTRL = KEY_STAT.idle; + if(CTRL == KEY_STAT.pressing && !keyboard_check(vk_control)) CTRL = KEY_STAT.up; + if(CTRL == KEY_STAT.down || CTRL == KEY_STAT.double) CTRL = KEY_STAT.pressing; + if(keyboard_check_pressed(vk_control)) { CTRL = kd_ctrl < _d? KEY_STAT.double : KEY_STAT.down; kd_ctrl = 0; } + if(keyboard_check_released(vk_control)) CTRL = KEY_STAT.up; - if(SHIFT == KEYBOARD_STATUS.pressing && !keyboard_check(vk_shift)) - SHIFT = KEYBOARD_STATUS.up; + kd_shift += DELTA_TIME; + if(SHIFT == KEY_STAT.up) SHIFT = KEY_STAT.idle; + if(SHIFT == KEY_STAT.pressing && !keyboard_check(vk_shift)) SHIFT = KEY_STAT.up; + if(SHIFT == KEY_STAT.down || SHIFT == KEY_STAT.double) SHIFT = KEY_STAT.pressing; + if(keyboard_check_pressed(vk_shift)) { SHIFT = kd_shift < _d? KEY_STAT.double : KEY_STAT.down; kd_shift = 0; } + if(keyboard_check_released(vk_shift)) SHIFT = KEY_STAT.up; - if(ALT == KEYBOARD_STATUS.pressing && !keyboard_check(vk_alt)) - ALT = KEYBOARD_STATUS.up; - - if(CTRL == KEYBOARD_STATUS.down) CTRL = KEYBOARD_STATUS.pressing; - if(SHIFT == KEYBOARD_STATUS.down) SHIFT = KEYBOARD_STATUS.pressing; - if(ALT == KEYBOARD_STATUS.down) ALT = KEYBOARD_STATUS.pressing; - - if(keyboard_check_pressed(vk_control)) CTRL = KEYBOARD_STATUS.down; - if(keyboard_check_pressed(vk_shift)) SHIFT = KEYBOARD_STATUS.down; - if(keyboard_check_pressed(vk_alt)) ALT = KEYBOARD_STATUS.down; - - if(keyboard_check_released(vk_control)) CTRL = KEYBOARD_STATUS.up; - if(keyboard_check_released(vk_shift)) SHIFT = KEYBOARD_STATUS.up; - if(keyboard_check_released(vk_alt)) ALT = KEYBOARD_STATUS.up; + kd_alt += DELTA_TIME; + if(ALT == KEY_STAT.up) ALT = KEY_STAT.idle; + if(ALT == KEY_STAT.pressing && !keyboard_check(vk_alt)) ALT = KEY_STAT.up; + if(ALT == KEY_STAT.down || ALT == KEY_STAT.double) ALT = KEY_STAT.pressing; + if(keyboard_check_pressed(vk_alt)) { ALT = kd_alt < _d? KEY_STAT.double : KEY_STAT.down; kd_alt = 0; } + if(keyboard_check_released(vk_alt)) ALT = KEY_STAT.up; HOTKEY_MOD = 0; - if(CTRL == KEYBOARD_STATUS.pressing) HOTKEY_MOD |= MOD_KEY.ctrl; - if(SHIFT == KEYBOARD_STATUS.pressing) HOTKEY_MOD |= MOD_KEY.shift; - if(ALT == KEYBOARD_STATUS.pressing) HOTKEY_MOD |= MOD_KEY.alt; + if(CTRL == KEY_STAT.pressing) HOTKEY_MOD |= MOD_KEY.ctrl; + if(SHIFT == KEY_STAT.pressing) HOTKEY_MOD |= MOD_KEY.shift; + if(ALT == KEY_STAT.pressing) HOTKEY_MOD |= MOD_KEY.alt; + #endregion #region mouse wrap diff --git a/objects/o_main/o_main.yy b/objects/o_main/o_main.yy index fa6e466ef..c26819bb9 100644 --- a/objects/o_main/o_main.yy +++ b/objects/o_main/o_main.yy @@ -2,25 +2,25 @@ "$GMObject":"", "%Name":"o_main", "eventList":[ - {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":0,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, - {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":1,"eventType":2,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, - {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":3,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, - {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":1,"eventType":3,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, - {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":1,"eventType":5,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, - {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":2,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, - {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":3,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, - {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":4,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, - {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":20,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, - {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":60,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, - {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":62,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, - {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":68,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, - {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":69,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, - {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":70,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, - {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":75,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, - {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":64,"eventType":8,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, - {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":75,"eventType":8,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, - {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":1,"eventType":9,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, - {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":1,"eventType":10,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":0,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":1,"eventType":2,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":3,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":1,"eventType":3,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":1,"eventType":5,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":2,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":3,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":4,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":20,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":60,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":62,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":68,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":69,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":70,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":75,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":64,"eventType":8,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":75,"eventType":8,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":1,"eventType":9,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":1,"eventType":10,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, ], "managed":true, "name":"o_main", diff --git a/scripts/control_function/control_function.gml b/scripts/control_function/control_function.gml index 072f2354e..a3b02fe29 100644 --- a/scripts/control_function/control_function.gml +++ b/scripts/control_function/control_function.gml @@ -7,11 +7,13 @@ #endregion #region keyboard - enum KEYBOARD_STATUS { + enum KEY_STAT { idle, down, pressing, - up + up, + + double } globalvar KEYBOARD_STRING, KEYBOARD_PRESSED; @@ -19,16 +21,16 @@ WIDGET_ACTIVE = []; KEYBOARD_PRESSED = vk_nokey; - CTRL = KEYBOARD_STATUS.idle; - ALT = KEYBOARD_STATUS.idle; - SHIFT = KEYBOARD_STATUS.idle; + CTRL = KEY_STAT.idle; + ALT = KEY_STAT.idle; + SHIFT = KEY_STAT.idle; function key_release() { INLINE - CTRL = KEYBOARD_STATUS.up; - ALT = KEYBOARD_STATUS.up; - SHIFT = KEYBOARD_STATUS.up; + CTRL = KEY_STAT.up; + ALT = KEY_STAT.up; + SHIFT = KEY_STAT.up; keyboard_key_release(vk_control); keyboard_key_release(vk_shift); @@ -37,18 +39,18 @@ function key_mod_press_any() { INLINE - return CTRL == KEYBOARD_STATUS.pressing || ALT == KEYBOARD_STATUS.pressing || SHIFT == KEYBOARD_STATUS.pressing; + return CTRL == KEY_STAT.pressing || ALT == KEY_STAT.pressing || SHIFT == KEY_STAT.pressing; } - function key_mod_down(key) { INLINE return key == KEYBOARD_STATUS.down; } - - function key_mod_press(key) { INLINE return key == KEYBOARD_STATUS.pressing; } + function key_mod_down(key) { INLINE return key == KEY_STAT.down; } + function key_mod_double(key) { INLINE return key == KEY_STAT.double; } + function key_mod_press(key) { INLINE return key == KEY_STAT.pressing; } function key_mod_presses(keys) { INLINE switch(argument_count) { - case 1 : return argument[0] == KEYBOARD_STATUS.pressing; - case 2 : return argument[0] == KEYBOARD_STATUS.pressing && argument[1] == KEYBOARD_STATUS.pressing; - case 3 : return argument[0] == KEYBOARD_STATUS.pressing && argument[1] == KEYBOARD_STATUS.pressing && argument[2] == KEYBOARD_STATUS.pressing; + case 1 : return argument[0] == KEY_STAT.pressing; + case 2 : return argument[0] == KEY_STAT.pressing && argument[1] == KEY_STAT.pressing; + case 3 : return argument[0] == KEY_STAT.pressing && argument[1] == KEY_STAT.pressing && argument[2] == KEY_STAT.pressing; } return false; } @@ -57,9 +59,9 @@ INLINE switch(keyindex) { - case MOD_KEY.alt : return ALT == KEYBOARD_STATUS.pressing; - case MOD_KEY.shift : return SHIFT == KEYBOARD_STATUS.pressing; - case MOD_KEY.ctrl : return CTRL == KEYBOARD_STATUS.pressing; + case MOD_KEY.alt : return ALT == KEY_STAT.pressing; + case MOD_KEY.shift : return SHIFT == KEY_STAT.pressing; + case MOD_KEY.ctrl : return CTRL == KEY_STAT.pressing; } return false; diff --git a/scripts/node_collection/node_collection.gml b/scripts/node_collection/node_collection.gml index 9371e89f6..5e7495229 100644 --- a/scripts/node_collection/node_collection.gml +++ b/scripts/node_collection/node_collection.gml @@ -540,8 +540,8 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc static drawNodeOverlay = function(xx, yy, _mx, _my, _s) { if(_s < 0.75) return; - var _bx = xx + w * _s - 10; - var _by = yy + h * _s - 10; + var _bx = (xx + w / 2 * _s); + var _by = (yy + h * _s) - 10; var _hv = PANEL_GRAPH.pHOVER && PANEL_GRAPH.node_hovering == self; _hv &= point_in_circle(_mx, _my, _bx, _by, 8); diff --git a/scripts/node_data/node_data.gml b/scripts/node_data/node_data.gml index 43b694c63..96ce8f171 100644 --- a/scripts/node_data/node_data.gml +++ b/scripts/node_data/node_data.gml @@ -1200,7 +1200,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor { return __draw_bbox.fromPoints(x0, y0, x1, y1); } #endregion - static drawNodeName = function(xx, yy, _s) { #region + static drawNodeName = function(xx, yy, _s) { var _name = renamed? display_name : name; if(_name == "") return; @@ -1224,7 +1224,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor { var _xpd = ui(8 + (icon != noone) * 16); draw_text_cut(round(xx + _xpd), round(yy + ui(10)), _name, w * _s - _xpd, ts); draw_set_alpha(1); - } #endregion + } static drawJunctionWidget = function(_x, _y, _mx, _my, _s, _hover, _focus) { #region diff --git a/scripts/panel_graph/panel_graph.gml b/scripts/panel_graph/panel_graph.gml index 85073cfa5..5859e07c2 100644 --- a/scripts/panel_graph/panel_graph.gml +++ b/scripts/panel_graph/panel_graph.gml @@ -1668,9 +1668,21 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor { value_dragging = noone; return; } + + if(key_mod_double(SHIFT)) { + var _n = value_dragging.node; + var _l = value_dragging.connect_type == JUNCTION_CONNECT.input? _n.inputs : _n.outputs; + var _i = value_dragging.connect_type == JUNCTION_CONNECT.input? _n.inputs_index : _n.outputs_index; - if(key_mod_press(SHIFT)) { - array_push_unique(value_draggings, value_dragging) + array_push_unique(value_draggings, value_dragging); + + for (var i = 0, n = array_length(_i); i < n; i++) { + var _j = _l[| _i[i]]; + array_push_unique(value_draggings, _j); + } + + } else if(key_mod_press(SHIFT)) { + array_push_unique(value_draggings, value_dragging); if(value_focus) array_push_unique(value_draggings, value_focus); diff --git a/scripts/preferences/preferences.gml b/scripts/preferences/preferences.gml index c4d0ac6f7..4c8f21bac 100644 --- a/scripts/preferences/preferences.gml +++ b/scripts/preferences/preferences.gml @@ -38,9 +38,10 @@ PREFERENCES.double_click_delay = 0.25; PREFERENCES.mouse_wheel_speed = 1.00; - + PREFERENCES.keyboard_repeat_start = 0.50; PREFERENCES.keyboard_repeat_speed = 0.10; + PREFERENCES.keyboard_double_delay = 0.25; #endregion diff --git a/scripts/preferences/preferences.yy b/scripts/preferences/preferences.yy index 1471d3d7d..ef8dc4ab7 100644 --- a/scripts/preferences/preferences.yy +++ b/scripts/preferences/preferences.yy @@ -1,5 +1,5 @@ { - "$GMScript":"v1", + "$GMScript":"", "%Name":"preferences", "isCompatibility":false, "isDnD":false,