From 352c88af5d20c3368622a1d48ea51caa23f47a77 Mon Sep 17 00:00:00 2001 From: Tanasart Date: Mon, 3 Feb 2025 14:51:17 +0700 Subject: [PATCH] Add raw input capture for different input methods (e.g. Microsoft Pinyin). --- datafiles/data/Nodes/Internal.zip | Bin 9100580 -> 9100580 bytes objects/o_dialog_add_node/Create_0.gml | 3 +- objects/o_main/KeyPress_1.gml | 8 ++- objects/o_main/Keyboard_1.gml | 6 +- objects/o_main/Step_1.gml | 7 ++ scripts/node_data/node_data.gml | 8 +-- scripts/node_text/node_text.gml | 7 +- scripts/node_value/node_value.gml | 7 +- scripts/panel_graph/panel_graph.gml | 67 +++++++++++++++--- scripts/panel_inspector/panel_inspector.gml | 32 ++++++--- scripts/panel_menu/panel_menu.gml | 2 +- scripts/panel_preference/panel_preference.gml | 6 ++ scripts/preferences/preferences.gml | 6 +- 13 files changed, 121 insertions(+), 38 deletions(-) diff --git a/datafiles/data/Nodes/Internal.zip b/datafiles/data/Nodes/Internal.zip index ee06e53523ffd6aeaf479860ceab7b3892c825a3..69192e19c2ada041a2f2af15592b649cd0cfac23 100644 GIT binary patch delta 1310 zcmY+?TTEP46b9f*2Zk9bprTdhv_#Q3@GPpa2Q{cg9qQpl0~*nUX6!}F zcY2F2rE)<1?bki3+ox}m;KSoobhNE$^VP+2(@#O`#^ii&XV?{X zcj@#T?W0zDo?f8+)J6yBAhpwr)Il%N%k&BzqQlflKJrt5g49K?(ra{tj#4+hPH)hg zbc~METl6-apm*pbouYTChu)*pbcTAVkIvFL>ZbuZPZwyAhG>{B(j~e~SLiCePan{= zn7a$nzLcr~_2nFDC2!54niufjU_pO`w4p z<{27^EhIvBQe|OgF;pSRpE_T4M@-l1kH%){QmA}&@sDpzr}}6qVA8-sXO@M2gmavy~b9wBM|ENMnA`JYetIFL`3fY?J(c$ZWUQwOHP;`AeQu|9o!l zmE;>+B=5;vMy)fZ7~G5b1?-HMupvV(s>)pGq~Rk>#WbX2I%XgPA7dtF!3_%jim?cbu>?!83?*2OQk0<_6{tiNs!@YltU%o@z0Tvf z>Q^tlx?8n)^eIvt@aTn-Jsy35SDEZc-7f4?4bMv}OO-|M5)m_r@d-Wp8^ImHQ zPrB7(ubw7N&d!yr_OV&u(^KtYzT_UCo+sHe8gQ#)!$?tgeAZ0f=2ri{Mv{6pvEv?N zC)023;Y;1>$$*jUii=PGKz=wX)*RW_=}O+vFrm#?=gUoh`>h*e^DCQzNkLb$PAh2@ z)zfPFoYqhSt)+F;Nb6|>eL-K+SG1A7rY7=`mwe=>X4*uXX$x(o7TQMN(01BE-_m#V zJ?*4jw43(OUfM_d=>Q$1R%)X|beP)d2l|nIq9fEnN9kueM#t#{oupHAn$Cn>%?PzQ ze(|dtLnxDcK7qP_iT)!T$a0{sA2|rhC0I! zqk%UGj%$83FdSGU$xofFTDr}o@sGx4;Ygr(eDUe;rc<383Am)g6>d)rCaBwXCpO?< z==}k)=GKVmobW21-Yu8iE(s>8Eu+>vc9w8%kOwFj?ioFs_e}mV#v+EMUfeY_DS8K3 zWc3+yrC8NxluMrJGb$yEWpT96$d(6z8|`&1oORT^pCw=6pUdV7 zNxrd8@}0c3tJ|DsH#POB+sv_7Y9(tz*3Q^(bv0xyrd{E&=OHs!cCgU@KOSzoV&1I$ E4-vHc>Hq)$ diff --git a/objects/o_dialog_add_node/Create_0.gml b/objects/o_dialog_add_node/Create_0.gml index 23ad5f930..acdae9f98 100644 --- a/objects/o_dialog_add_node/Create_0.gml +++ b/objects/o_dialog_add_node/Create_0.gml @@ -243,7 +243,8 @@ event_inherited(); for( var i = 0, n = array_length(_new_node.outputs); i < n; i++ ) array_push(_outputs, _new_node.outputs[i]); - PANEL_INSPECTOR.setInspecting(_new_node); + if(PANEL_INSPECTOR) PANEL_INSPECTOR.setInspecting(_new_node); + if(PANEL_GRAPH) PANEL_GRAPH.selectDragNode(_new_node, PREFERENCES.node_add_select); } else if(is_instanceof(_node, NodeAction)) { // NOT IMPLEMENTED var _dat = _node.build(node_target_x, node_target_y,, _param); diff --git a/objects/o_main/KeyPress_1.gml b/objects/o_main/KeyPress_1.gml index fcda8644f..af7394135 100644 --- a/objects/o_main/KeyPress_1.gml +++ b/objects/o_main/KeyPress_1.gml @@ -3,14 +3,16 @@ kb_hkey = vk_nokey; if(kb_hkey < 0 && keyboard_key > 0) kb_hkey = keyboard_key; if(kb_hkey < 0 && keyboard_lastkey > 0) kb_hkey = keyboard_lastkey; -if(kb_hkey <= 0) for(var i = 2; i < 320; i++) if(keyboard_check_pressed(i)) { kb_hkey = i; break; } +if(kb_hkey <= 0 && PREFERENCES.keyboard_check_sweep) for(var i = 2; i < 320; i++) if(keyboard_check_pressed(i)) { kb_hkey = i; break; } kb_time = 0; kb_hold = false; KEYBOARD_PRESSED = kb_hkey; -if(keyboard_check(vk_backspace)) KEYBOARD_STRING = string_copy(KEYBOARD_STRING, 1, string_length(KEYBOARD_STRING) - 1); -else KEYBOARD_STRING += keyboard_lastchar; +if(!PREFERENCES.keyboard_capture_raw) { + if(keyboard_check(vk_backspace)) KEYBOARD_STRING = string_copy(KEYBOARD_STRING, 1, string_length(KEYBOARD_STRING) - 1); + else KEYBOARD_STRING += keyboard_lastchar; +} if(KEYBOARD_PRESSED == -1) { for( var i = 0, n = array_length(global.KEYS_VK); i < n; i++ ) { diff --git a/objects/o_main/Keyboard_1.gml b/objects/o_main/Keyboard_1.gml index db5f0f73a..5a98f8ab8 100644 --- a/objects/o_main/Keyboard_1.gml +++ b/objects/o_main/Keyboard_1.gml @@ -17,8 +17,10 @@ if(!trigger) exit; KEYBOARD_PRESSED = kb_hkey; -if(keyboard_check(vk_backspace)) KEYBOARD_STRING = string_copy(KEYBOARD_STRING, 1, string_length(KEYBOARD_STRING) - 1); -else KEYBOARD_STRING += keyboard_lastchar; +if(!PREFERENCES.keyboard_capture_raw) { + if(keyboard_check(vk_backspace)) KEYBOARD_STRING = string_copy(KEYBOARD_STRING, 1, string_length(KEYBOARD_STRING) - 1); + else KEYBOARD_STRING += keyboard_lastchar; +} if(WIDGET_CURRENT && is_instanceof(WIDGET_CURRENT, textInput)) WIDGET_CURRENT.onKey(KEYBOARD_PRESSED); \ No newline at end of file diff --git a/objects/o_main/Step_1.gml b/objects/o_main/Step_1.gml index 00ecb1b03..0ea9e75ea 100644 --- a/objects/o_main/Step_1.gml +++ b/objects/o_main/Step_1.gml @@ -13,6 +13,13 @@ _HOVERING_ELEMENT = noone; FILE_DROPPED = _FILE_DROPPED; _FILE_DROPPED = false; +#region keybord captures + if(PREFERENCES.keyboard_capture_raw && keyboard_string != "") { + KEYBOARD_STRING = keyboard_string; + keyboard_string = ""; + } +#endregion + #region minimize if(winMan_isMinimized()) { if(!minimized) game_set_speed(1, gamespeed_fps); diff --git a/scripts/node_data/node_data.gml b/scripts/node_data/node_data.gml index 02a2c5f35..c719ca44c 100644 --- a/scripts/node_data/node_data.gml +++ b/scripts/node_data/node_data.gml @@ -1334,12 +1334,12 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor { } for( var i = 0, n = array_length(inputs); i < n; i++ ) { - var _in = inputs[i]; - if(_in.bypass_junc == noone || !_in.bypass_junc.visible) continue; + var _in = inputs[i].bypass_junc; + if(_in == noone || !_in.visible) continue; for( var j = 0, m = array_length(_in.value_to); j < m; j++ ) { var _jto = _in.value_to[j]; - if(_jto.value_from != _ot || !_jto.node.active) continue; + if(_jto.value_from != _in || !_jto.node.active) continue; array_push(nodes, _jto.node); } } @@ -1373,7 +1373,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor { for(var i = 0; i < array_length(inputs); i++) { var _in = inputs[i]; - if(_in.bypass_junc == noone) continue; + // if(_in.bypass_junc == noone) continue; var _tos = _in.bypass_junc.getJunctionTo(); for( var j = 0; j < array_length(_tos); j++ ) diff --git a/scripts/node_text/node_text.gml b/scripts/node_text/node_text.gml index 7bec0f190..4081585df 100644 --- a/scripts/node_text/node_text.gml +++ b/scripts/node_text/node_text.gml @@ -8,7 +8,8 @@ function Node_Text(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons .setVisible(true, true); newInput(1, nodeValue_Path("Font", self, "")) - .setDisplay(VALUE_DISPLAY.path_font); + .setDisplay(VALUE_DISPLAY.path_font) + .setVisible(true, false); newInput(2, nodeValue_Int("Size", self, 16)); @@ -96,9 +97,7 @@ function Node_Text(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons if(!file_exists_empty(_path)) return; - if(font != f_p0 && font_exists(font)) - font_delete(font); - + if(font != f_p0 && font_exists(font)) font_delete(font); font_add_enable_aa(_aa); font = font_add(_path, _size, false, false, 0, 127); } diff --git a/scripts/node_value/node_value.gml b/scripts/node_value/node_value.gml index c30ff0a5e..be3e4be5f 100644 --- a/scripts/node_value/node_value.gml +++ b/scripts/node_value/node_value.gml @@ -2334,6 +2334,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru if(!globalExtractable()) return noone; var _key = $"{node.getDisplayName()}_{name}"; + _key = string_to_var(_key); var _glb = node.project.globalNode; if(_glb.inputExist(_key)) @@ -2456,7 +2457,7 @@ function checkJuncConnection(from, to, params) { var cx = round((frx + jx) / 2 + shx); var cy = round((fry + jy) / 2 + shy); var th = max(1, PROJECT.graphConnection.line_width * _s); - var hover, hovDist = max(th * 2, 6); + var hover, hovDist = max(th * 2, 12); var _fin = from.draw_line_shift_e > -1? from.draw_line_shift_e : from.drawLineIndex; var _tin = to.draw_line_shift_e > -1? to.draw_line_shift_e : to.drawLineIndex; @@ -2509,7 +2510,7 @@ function checkJuncConnection(from, to, params) { return hover? self : noone; } -function drawJuncConnection(from, to, params, _thick = false) { +function drawJuncConnection(from, to, params, _hover = 0) { if(from == noone || to == noone) return noone; static drawParam = { @@ -2537,7 +2538,7 @@ function drawJuncConnection(from, to, params, _thick = false) { var shy = to.draw_line_shift_y * _s; var cx = round((frx + jx) / 2 + shx); var cy = round((fry + jy) / 2 + shy); - var th = max(1, PROJECT.graphConnection.line_width * _s) * (1 + _thick); + var th = max(1, PROJECT.graphConnection.line_width * _s) * (1 + _hover); #region draw parameters var corner = PROJECT.graphConnection.line_corner * _s; diff --git a/scripts/panel_graph/panel_graph.gml b/scripts/panel_graph/panel_graph.gml index 9d8f75e60..6c44de37e 100644 --- a/scripts/panel_graph/panel_graph.gml +++ b/scripts/panel_graph/panel_graph.gml @@ -382,6 +382,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor { node_drag_sy = 0; node_drag_ox = 0; node_drag_oy = 0; + node_drag_add = false; selection_block = 0; nodes_selecting = []; @@ -1558,9 +1559,10 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor { if(connection_draw_update || pHOVER) { surface_set_target(connection_surface_cc); if(connection_draw_update) { DRAW_CLEAR } - - var hoverable = !bool(node_dragging) && pHOVER; - + + var hoverable = pHOVER; + hoverable &= !node_dragging || node_drag_add; + connection_param.active = hoverable; connection_param.setPos(gr_x, gr_y, graph_s, mx, my); connection_param.setBoundary(-64, -64, w + 64, h + 64); @@ -1580,8 +1582,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor { DRAW_CLEAR draw_surface(connection_surface_cc, 0, 0); - - if(hov) drawJuncConnection(hov.value_from, hov, connection_param, true); + if(hov) drawJuncConnection(hov.value_from, hov, connection_param, 1 + (node_drag_add && node_dragging)); if(value_dragging && connection_draw_mouse != noone && !key_mod_press(SHIFT)) { var _cmx = connection_draw_mouse[0]; @@ -1675,14 +1676,46 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor { printIf(log, $"Draw node: {get_timer() - t}"); t = get_timer(); // dragging - if(mouse_press(mb_left)) - node_dragging = noone; + if(mouse_press(mb_left)) { + + if(node_drag_add && node_dragging && junction_hovering != noone) { + var _jfr = junction_hovering.value_from; + var _jto = junction_hovering; + var _shy = undefined; + + for( var i = 0, n = array_length(node_dragging.inputs); i < n; i++ ) { + var _inp = node_dragging.inputs[i]; + if((value_bit(_inp.type) & value_bit(_jfr.type) != 0) && _inp.setFrom(_jfr)) { + _shy = _jfr.node.y; + break; + } + } + + for( var i = 0, n = array_length(node_dragging.outputs); i < n; i++ ) { + if(_jto.setFrom(node_dragging.outputs[i])) { + _shy = _shy == undefined? _jto.node.y : (_shy + _jto.node.y) / 2; + break; + } + } + + if(_shy != undefined) { + node_dragging.x -= node_dragging.w / 2; + node_dragging.y = _shy; + } + } + + if(node_dragging) nodes_selecting = [ node_dragging ]; + node_dragging = noone; + node_drag_add = false; + } for(var i = 0; i < array_length(nodes_list); i++) nodes_list[i].groupCheck(gr_x, gr_y, graph_s, mx, my); if(node_dragging && !key_mod_press(ALT)) { addKeyOverlay("Dragging node(s)", [[ "Ctrl", "Disable snapping" ]]); + connection_draw_update = true; + node_surface_update = true; var _mgx = mouse_graph_x; var _mgy = mouse_graph_y; @@ -1742,7 +1775,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor { } } - if(mouse_release(mb_left)) + if(!node_drag_add && mouse_release(mb_left)) node_dragging = noone; printIf(log, $"Drag node time : {get_timer() - t}"); t = get_timer(); @@ -1847,7 +1880,6 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor { drag_locking = false; } - printIf(log, $"Draw selection frame : {get_timer() - t}"); t = get_timer(); } @@ -3255,6 +3287,23 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor { return false; } + function selectDragNode(_node, _add = false) { + nodes_selecting = [ _node ]; + node_dragging = _node; + + _node.x = mouse_graph_x + _node.y = mouse_graph_y + + node_drag_mx = mouse_graph_x; + node_drag_my = mouse_graph_y; + node_drag_sx = _node.x; + node_drag_sy = _node.y; + node_drag_ox = -1; + node_drag_oy = -1; + + node_drag_add = _add; + } + static checkDropItem = function() { // var node = noone; diff --git a/scripts/panel_inspector/panel_inspector.gml b/scripts/panel_inspector/panel_inspector.gml index 2bd0c2594..43253cd16 100644 --- a/scripts/panel_inspector/panel_inspector.gml +++ b/scripts/panel_inspector/panel_inspector.gml @@ -1133,29 +1133,41 @@ function Panel_Inspector() : PanelContent() constructor { array_push(_menuItem, -1); } - array_push(_menuItem, jun.expUse? menu_junc_expression_dis : menu_junc_expression_ena); - if(jun.globalExtractable()) array_push(_menuItem, menu_junc_extract_global); if(_inp) array_push(_menuItem, menu_junc_bypass_toggle); + array_push(_menuItem, jun.expUse? menu_junc_expression_dis : menu_junc_expression_ena); + if(jun.globalExtractable()) { + + array_push(_menuItem, menuItemShelf(__txtx("panel_inspector_use_global", "Use Globalvar"), function(_dat) /*=>*/ { + var arr = []; + for( var i = 0, n = array_length(PROJECT.globalNode.inputs); i < n; i++ ) { + var _glInp = PROJECT.globalNode.inputs[i]; + if(!typeCompatible(_glInp.type, __dialog_junction.type)) continue; + array_push(arr, menuItem(_glInp.name, function(d) /*=>*/ { __dialog_junction.setExpression(d.name); }, noone, noone, noone, { name : _glInp.name })); + } + return submenuCall(_dat, arr); + })); + + array_push(_menuItem, menu_junc_extract_global); + } + array_push(_menuItem, -1, menu_junc_copy); if(_inp) array_push(_menuItem, menu_junc_paste); if(_inp && jun.extract_node != "") { if(is_array(jun.extract_node)) { - var ext = menuItemShelf(__txtx("panel_inspector_extract_multiple", "Extract to..."), function(_dat) { + array_push(_menuItem, menuItemShelf(__txtx("panel_inspector_extract_multiple", "Extract to..."), function(_dat) /*=>*/ { var arr = []; for(var i = 0; i < array_length(__dialog_junction.extract_node); i++) { var _rec = __dialog_junction.extract_node[i]; - var _nod = ALL_NODES[$ _rec]; - - array_push(arr, menuItem(_nod.name, function(_dat) /*=>*/ { __dialog_junction.extractNode(_dat.name); }, noone, noone, noone, { name : _rec })); + array_push(arr, menuItem(ALL_NODES[$ _rec].name, + function(d) /*=>*/ { __dialog_junction.extractNode(d.name); }, noone, noone, noone, { name : _rec })); } return submenuCall(_dat, arr); - }); - array_push(_menuItem, ext); - } else - array_push(_menuItem, menu_junc_extract); + })); + + } else array_push(_menuItem, menu_junc_extract); } var dia = menuCall("inspector_value_menu", _menuItem); diff --git a/scripts/panel_menu/panel_menu.gml b/scripts/panel_menu/panel_menu.gml index 999adfbea..2f2b24ca6 100644 --- a/scripts/panel_menu/panel_menu.gml +++ b/scripts/panel_menu/panel_menu.gml @@ -72,7 +72,7 @@ registerFunction("", "Reload theme", vk_f10, MOD_KEY.ctrl | MOD_KEY.shift, global_theme_reload ).setMenu("reload_theme", ) - registerFunction("", "Addons Menu", "", MOD_KEY.none, function(_dat) /*=>*/ { + registerFunction("", "Addons", "", MOD_KEY.none, function(_dat) /*=>*/ { var arr = [ MENU_ITEMS.addons, menuItem(__txtx("panel_menu_addons_key", "Key displayer"), function() /*=>*/ { if(instance_exists(addon_key_displayer)) return; instance_create_depth(0, 0, 0, addon_key_displayer); }), diff --git a/scripts/panel_preference/panel_preference.gml b/scripts/panel_preference/panel_preference.gml index e629ee2a7..df73e7e4d 100644 --- a/scripts/panel_preference/panel_preference.gml +++ b/scripts/panel_preference/panel_preference.gml @@ -123,6 +123,12 @@ function Panel_Preference() : PanelContent() constructor { slider(0, 1, 0.01, function(val) /*=>*/ { PREFERENCES.keyboard_repeat_speed = val; PREF_SAVE(); }) )); + ds_list_add(pref_global, new __Panel_Linear_Setting_Item_Preference( + __txtx("pref_keyboard_check_sweep", "Keyboard check sweep"), + "keyboard_check_sweep", + new checkBox(function() /*=>*/ { PREFERENCES.keyboard_check_sweep = !PREFERENCES.keyboard_check_sweep; PREF_SAVE(); }) + )); + ds_list_add(pref_global, new __Panel_Linear_Setting_Item_Preference( __txtx("pref_expand_hovering_panel", "Expand hovering panel"), "expand_hover", diff --git a/scripts/preferences/preferences.gml b/scripts/preferences/preferences.gml index 087cff1ec..0e23471a1 100644 --- a/scripts/preferences/preferences.gml +++ b/scripts/preferences/preferences.gml @@ -50,6 +50,8 @@ PREFERENCES.keyboard_repeat_start = 0.50; PREFERENCES.keyboard_repeat_speed = 0.10; PREFERENCES.keyboard_double_delay = 0.25; + PREFERENCES.keyboard_check_sweep = true; + PREFERENCES.keyboard_capture_raw = true; PREFERENCES.file_watcher_delay = 0.1; @@ -121,7 +123,9 @@ #endregion #region //////////////////////////////////////////////////////////////////////// NODES ///////////////////////////////////////////////////////////////////////// - + + PREFERENCES.node_add_select = true; + PREFERENCES.node_param_show = false; PREFERENCES.node_param_width = 192; PREFERENCES.node_3d_preview_size = 256;