From c440edec6bbd4c27bf38c3d46bde0b151eda9a0e Mon Sep 17 00:00:00 2001 From: Tanasart Date: Wed, 14 Aug 2024 10:28:46 +0700 Subject: [PATCH] hotkey fix --- objects/o_dialog_command_palette/Create_0.gml | 8 +- objects/o_dialog_preference/Create_0.gml | 4 +- .../function_register/function_register.gml | 9 +- scripts/globals/globals.gml | 8 +- scripts/hotkey_data/hotkey_data.gml | 218 +++++++++++------- .../node_align_functions.gml | 9 + scripts/node_slideshow/node_slideshow.gml | 4 + scripts/node_value/node_value.gml | 61 +++-- scripts/panel_function/panel_function.gml | 2 +- scripts/panel_graph/panel_graph.gml | 59 +++-- scripts/panel_history/panel_history.gml | 7 +- scripts/panel_nodes/panel_nodes.gml | 7 +- scripts/preferences/preferences.gml | 30 +-- scripts/string_functions/string_functions.gml | 22 ++ 14 files changed, 258 insertions(+), 190 deletions(-) diff --git a/objects/o_dialog_command_palette/Create_0.gml b/objects/o_dialog_command_palette/Create_0.gml index 6dd36f8fd..8daca5d1a 100644 --- a/objects/o_dialog_command_palette/Create_0.gml +++ b/objects/o_dialog_command_palette/Create_0.gml @@ -14,7 +14,7 @@ event_inherited(); setFocus(self.id); - data = []; + data = array_clone(RECENT_COMMANDS, 1); keys = variable_struct_get_names(FUNCTIONS); hk_editing = noone; @@ -41,6 +41,11 @@ event_inherited(); keyboard_trigger = false; function searchMenu() { + if(search_string == "") { + data = array_clone(RECENT_COMMANDS, 1); + return; + } + data = []; var pr_list = ds_priority_create(); var search_lower = string_lower(search_string); @@ -97,6 +102,7 @@ event_inherited(); if(sc_content.active) { if((!keyboard_trigger && mouse_press(mb_left)) || keyboard_check_pressed(vk_enter)) { _menu.action(); + array_push(RECENT_COMMANDS, _menu); instance_destroy(); } diff --git a/objects/o_dialog_preference/Create_0.gml b/objects/o_dialog_preference/Create_0.gml index a18e5e122..8606bd266 100644 --- a/objects/o_dialog_preference/Create_0.gml +++ b/objects/o_dialog_preference/Create_0.gml @@ -658,6 +658,7 @@ event_inherited(); for(var i = 0; i < ds_list_size(ll); i++) array_push(_lst, ll[| i]); + array_sort(_lst, function(s1, s2) /*=>*/ {return string_compare(s1.name, s2.name)}); array_push(hotkeyContext, { context: ctx, list: _lst }); var _title = ctx == ""? "Global" : ctx; @@ -683,8 +684,9 @@ event_inherited(); array_push(_lst, _k); } + array_sort(_lst, function(s1, s2) /*=>*/ {return string_compare(s1.name, s2.name)}); array_push(hotkeyContext, { context: ctx, list: _lst }); - array_push(hotkeyArray, $" - {ctx}"); + array_push(hotkeyArray, $" {ctx}"); } hk_page = 0; diff --git a/scripts/function_register/function_register.gml b/scripts/function_register/function_register.gml index 38ec291a8..fcd4a90d3 100644 --- a/scripts/function_register/function_register.gml +++ b/scripts/function_register/function_register.gml @@ -11,11 +11,12 @@ } function __fnInit() { - globalvar CMD_FUNCTIONS, MENU_ITEMS, FUNCTIONS; + globalvar CMD_FUNCTIONS, MENU_ITEMS, FUNCTIONS, RECENT_COMMANDS; - FUNCTIONS = {}; - CMD_FUNCTIONS = {}; - MENU_ITEMS = {}; + FUNCTIONS = {}; + CMD_FUNCTIONS = {}; + MENU_ITEMS = {}; + RECENT_COMMANDS = []; __fnInit_Global(); __fnInit_Panels(); diff --git a/scripts/globals/globals.gml b/scripts/globals/globals.gml index 0ee3306fc..6a8a62af1 100644 --- a/scripts/globals/globals.gml +++ b/scripts/globals/globals.gml @@ -36,11 +36,11 @@ globalvar VERSION, SAVE_VERSION, VERSION_STRING, BUILD_NUMBER, LATEST_VERSION; globalvar HOTKEYS, HOTKEY_CONTEXT; - LATEST_VERSION = 11700; - VERSION = 11790; - SAVE_VERSION = 11700; + LATEST_VERSION = 1_17_00_0; + VERSION = 1_17_10_0; + SAVE_VERSION = 1_17_10_0; VERSION_STRING = "1.17.10.006"; - BUILD_NUMBER = 11790; + BUILD_NUMBER = 1_17_10_0; HOTKEYS = ds_map_create(); HOTKEY_CONTEXT = ds_list_create(); diff --git a/scripts/hotkey_data/hotkey_data.gml b/scripts/hotkey_data/hotkey_data.gml index 42cd5165f..5d08761aa 100644 --- a/scripts/hotkey_data/hotkey_data.gml +++ b/scripts/hotkey_data/hotkey_data.gml @@ -1,79 +1,59 @@ globalvar HOTKEYS_CUSTOM; function __initHotKey() { - HOTKEYS_CUSTOM = { - "Node_Canvas": { - "Selection": new hotkeySimple("S"), - "Magic Selection": new hotkeySimple("W"), - "Pencil": new hotkeySimple("B"), - "Eraser": new hotkeySimple("E"), - "Rectangle": new hotkeySimple("N"), - "Ellipse": new hotkeySimple("M"), - "Iso Cube": new hotkeySimple(""), - "Curve": new hotkeySimple(""), - "Freeform": new hotkeySimple("Q"), - "Fill": new hotkeySimple("G"), - - "Outline": new hotkeySimple("O", MOD_KEY.alt), - "Extrude": new hotkeySimple("E", MOD_KEY.alt), - "Inset": new hotkeySimple("I", MOD_KEY.alt), - "Skew": new hotkeySimple("S", MOD_KEY.alt), - "Corner": new hotkeySimple("C", MOD_KEY.alt), - }, - - "Node_Mesh_Warp": { - "Edit control point": new hotkeySimple("V"), - "Pin mesh": new hotkeySimple("P"), - "Mesh edit": new hotkeySimple("M"), - "Anchor remove": new hotkeySimple("E"), - }, - - "Node_Armature": { - "Move": new hotkeySimple("V"), - "Scale": new hotkeySimple("S"), - "Add bones": new hotkeySimple("A"), - "Remove bones": new hotkeySimple("E"), - "Detach bones": new hotkeySimple("D"), - "IK": new hotkeySimple("K"), - }, - - "Node_Path": { - "Transform": new hotkeySimple("T"), - "Anchor add / remove": new hotkeySimple("A"), - "Edit Control point": new hotkeySimple("C"), - "Draw path": new hotkeySimple("B"), - "Rectangle path": new hotkeySimple("N"), - "Circle path": new hotkeySimple("M"), - }, - - "Node_Rigid_Object": { - "Mesh edit": new hotkeySimple("A"), - "Anchor remove": new hotkeySimple("E"), - }, - - "Node_Strand_Create": { - "Push": new hotkeySimple("P"), - "Comb": new hotkeySimple("C"), - "Stretch": new hotkeySimple("S"), - "Shorten": new hotkeySimple("D"), - "Grab": new hotkeySimple("G"), - }, - - "Node_Path_Anchor": { - "Adjust control point": new hotkeySimple("A"), - }, - - "Node_3D_Object": { - "Transform": new hotkeySimple("G"), - "Rotate": new hotkeySimple("R"), - "Scale": new hotkeySimple("S"), - }, - - "Node_3D_Camera": { - "Move Target": new hotkeySimple("T"), - }, - - }; + HOTKEYS_CUSTOM = {}; + + hotkeySimple("Node_Canvas", "Selection", "S"); + hotkeySimple("Node_Canvas", "Magic Selection", "W"); + hotkeySimple("Node_Canvas", "Pencil", "B"); + hotkeySimple("Node_Canvas", "Eraser", "E"); + hotkeySimple("Node_Canvas", "Rectangle", "N"); + hotkeySimple("Node_Canvas", "Ellipse", "M"); + hotkeySimple("Node_Canvas", "Iso Cube", ""); + hotkeySimple("Node_Canvas", "Curve", ""); + hotkeySimple("Node_Canvas", "Freeform", "Q"); + hotkeySimple("Node_Canvas", "Fill", "G"); + hotkeySimple("Node_Canvas", "Outline", "O", MOD_KEY.alt); + hotkeySimple("Node_Canvas", "Extrude", "E", MOD_KEY.alt); + hotkeySimple("Node_Canvas", "Inset", "I", MOD_KEY.alt); + hotkeySimple("Node_Canvas", "Skew", "S", MOD_KEY.alt); + hotkeySimple("Node_Canvas", "Corner", "C", MOD_KEY.alt); + + hotkeySimple("Node_Mesh_Warp", "Edit control point", "V"); + hotkeySimple("Node_Mesh_Warp", "Pin mesh", "P"); + hotkeySimple("Node_Mesh_Warp", "Mesh edit", "M"); + hotkeySimple("Node_Mesh_Warp", "Anchor remove", "E"); + + hotkeySimple("Node_Armature", "Move", "V"); + hotkeySimple("Node_Armature", "Scale", "S"); + hotkeySimple("Node_Armature", "Add bones", "A"); + hotkeySimple("Node_Armature", "Remove bones", "E"); + hotkeySimple("Node_Armature", "Detach bones", "D"); + hotkeySimple("Node_Armature", "IK", "K"); + + hotkeySimple("Node_Path", "Transform", "T"); + hotkeySimple("Node_Path", "Anchor add / remove", "A"); + hotkeySimple("Node_Path", "Edit Control point", "C"); + hotkeySimple("Node_Path", "Draw path", "B"); + hotkeySimple("Node_Path", "Rectangle path", "N"); + hotkeySimple("Node_Path", "Circle path", "M"); + + hotkeySimple("Node_Rigid_Object", "Mesh edit", "A"); + hotkeySimple("Node_Rigid_Object", "Anchor remove", "E"); + + hotkeySimple("Node_Strand_Create", "Push", "P"); + hotkeySimple("Node_Strand_Create", "Comb", "C"); + hotkeySimple("Node_Strand_Create", "Stretch", "S"); + hotkeySimple("Node_Strand_Create", "Shorten", "D"); + hotkeySimple("Node_Strand_Create", "Grab", "G"); + + hotkeySimple("Node_Path_Anchor", "Adjust control point", "A"); + + hotkeySimple("Node_3D_Object", "Transform", "G"); + hotkeySimple("Node_3D_Object", "Rotate", "R"); + hotkeySimple("Node_3D_Object", "Scale", "S"); + + hotkeySimple("Node_3D_Camera", "Move Target", "T"); } function getToolHotkey(_group, _key) { @@ -86,14 +66,21 @@ function getToolHotkey(_group, _key) { return _grp[$ _key]; } + +function hotkeySimple(_context, _name, _key, modi = MOD_KEY.none) { return new HotkeySimple(_context, _name, _key, modi); } +function HotkeySimple(_context, _name, _key, modi = MOD_KEY.none) constructor { + context = _context; + name = _name; -function hotkeySimple(_key, modi = MOD_KEY.none) constructor { self.key = key_get_index(_key); self.modi = modi; dKey = key; dModi = modi; + if(!struct_has(HOTKEYS_CUSTOM, context)) HOTKEYS_CUSTOM[$ context] = {}; + HOTKEYS_CUSTOM[$ context][$ name] = self; + static isPressing = function() { if(is_string(key)) key = key_get_index(key); return key == noone? false : key_press(key, modi); @@ -103,6 +90,12 @@ function hotkeySimple(_key, modi = MOD_KEY.none) constructor { if(is_string(key)) key = key_get_index(key); return key_get_name(key, modi); } + + static serialize = function() { return { context, name, key, modi } } + static deserialize = function(ll) { if(!is_struct(ll)) return; key = ll.key; modi = ll.modi; } + + var _loadKey = $"{context}_{name}"; + if(struct_has(HOTKEYS_DATA, _loadKey)) deserialize(HOTKEYS_DATA[$ _loadKey]); } function hotkeyObject(_context, _name, _key, _mod = MOD_KEY.none, _action = noone) constructor { @@ -115,18 +108,13 @@ function hotkeyObject(_context, _name, _key, _mod = MOD_KEY.none, _action = noon dKey = _key; dModi = _mod; - static serialize = function() { return { context, name, key, modi }; } - - static deserialize = function(ll) { - key = is_struct(ll)? ll.key : ll[2]; - modi = is_struct(ll)? ll.modi : ll[3]; - } - static full_name = function() { return string_to_var(context == ""? $"global.{name}" : $"{context}.{name}"); } + static serialize = function() { return { context, name, key, modi } } + static deserialize = function(ll) { if(!is_struct(ll)) return; key = ll.key; modi = ll.modi; } + var _loadKey = $"{context}_{name}"; - if(struct_has(HOTKEYS_DATA, _loadKey)) - deserialize(HOTKEYS_DATA[$ _loadKey]); + if(struct_has(HOTKEYS_DATA, _loadKey)) deserialize(HOTKEYS_DATA[$ _loadKey]); } function addHotkey(_context, _name, _key, _mod, _action) { @@ -245,4 +233,68 @@ function hotkey_draw(keyStr, _x, _y, _status = 0) { draw_sprite_stretched_ext(THEME.ui_panel, 1, _x - _tw - ui(4), _y - _th / 2 - ui(3), _tw + ui(8), _th + ui(3), bc); draw_text(_x, _y, keyStr); +} + +function hotkey_serialize() { + + var _context = []; + for(var i = 0, n = ds_list_size(HOTKEY_CONTEXT); i < n; i++) { + var ll = HOTKEYS[? HOTKEY_CONTEXT[| i]]; + + for(var j = 0, m = ds_list_size(ll); j < m; j++) { + var _hk = ll[| j]; + if(_hk.dKey == _hk.key && _hk.dModi == _hk.modi) continue; + array_push(_context, _hk.serialize()); + } + } + + var _node = []; + var _cust = variable_struct_get_names(HOTKEYS_CUSTOM); + for(var i = 0, n = array_length(_cust); i < n; i++) { + + var nd = _cust[i]; + var nl = HOTKEYS_CUSTOM[$ nd]; + var kk = variable_struct_get_names(nl); + + for (var j = 0, m = array_length(kk); j < m; j++) { + var _nm = kk[j]; + var _hk = nl[$ _nm]; + + if(_hk.dKey == _hk.key && _hk.dModi == _hk.modi) continue; + array_push(_node, _hk.serialize()); + } + } + + json_save_struct(DIRECTORY + "hotkeys.json", { context: _context, node: _node }); +} + +function hotkey_deserialize() { + HOTKEYS_DATA = {}; + var path = DIRECTORY + "hotkeys.json"; + if(!file_exists(path)) return; + + var map = json_load_struct(path); + if(!is_struct(map)) return; + + if(struct_has(map, "context")) { + var _ctx = map.context; + for(var i = 0; i < array_length(_ctx); i++) { + var key_list = _ctx[i]; + var _context = key_list.context; + var name = key_list.name; + + HOTKEYS_DATA[$ $"{_context}_{name}"] = key_list; + } + } + + if(struct_has(map, "node")) { + var _ctx = map.node; + for(var i = 0; i < array_length(_ctx); i++) { + var key_list = _ctx[i]; + var _context = key_list.context; + var name = key_list.name; + + HOTKEYS_DATA[$ $"{_context}_{name}"] = key_list; + } + } } \ No newline at end of file diff --git a/scripts/node_align_functions/node_align_functions.gml b/scripts/node_align_functions/node_align_functions.gml index 55599b616..07c48c9f3 100644 --- a/scripts/node_align_functions/node_align_functions.gml +++ b/scripts/node_align_functions/node_align_functions.gml @@ -209,4 +209,13 @@ function node_auto_align(nodeList) { if(h_var < v_var) { node_halign(nodeList); node_vdistribute(nodeList); } else if(v_var < h_var) { node_valign(nodeList); node_hdistribute(nodeList); } +} + +function node_snap_grid(nodeList, spacing = 16) { + for (var i = 0, n = array_length(nodeList); i < n; i++) { + var _node = nodeList[i]; + + _node.x = value_snap(_node.x, spacing); + _node.y = value_snap(_node.y, spacing); + } } \ No newline at end of file diff --git a/scripts/node_slideshow/node_slideshow.gml b/scripts/node_slideshow/node_slideshow.gml index ab0c79186..66ebaad39 100644 --- a/scripts/node_slideshow/node_slideshow.gml +++ b/scripts/node_slideshow/node_slideshow.gml @@ -12,8 +12,11 @@ function Node_Slideshow(_x, _y, _group = noone) : Node(_x, _y, _group) construct inputs[2] = nodeValue_Enum_Scroll("Anchor", self, 0, [ "Center", "Top left" ]); + inputs[3] = nodeValue_Float("Arrival Speed", self, 4); + slide_title = ""; slide_anchor = 0; + slide_speed = 32; static step = function() { var _ord = inputs[0].getValue(); @@ -21,6 +24,7 @@ function Node_Slideshow(_x, _y, _group = noone) : Node(_x, _y, _group) construct slide_title = inputs[1].getValue(); slide_anchor = inputs[2].getValue(); + slide_speed = max(1, 100 / inputs[3].getValue()); setDisplayName($"Slide-{slide_title}"); } diff --git a/scripts/node_value/node_value.gml b/scripts/node_value/node_value.gml index 35d60974a..fac910f22 100644 --- a/scripts/node_value/node_value.gml +++ b/scripts/node_value/node_value.gml @@ -104,37 +104,35 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru #region ---- value ---- - def_val = array_clone(_value); - def_length = is_array(def_val)? array_length(def_val) : 0; - def_depth = array_get_depth(def_val); - unit = new nodeValueUnit(self); - def_unit = VALUE_UNIT.constant; - dyna_depo = ds_list_create(); - value_tag = ""; + def_val = array_clone(_value); + def_length = is_array(def_val)? array_length(def_val) : 0; + def_depth = array_get_depth(def_val); + unit = new nodeValueUnit(self); + def_unit = VALUE_UNIT.constant; + dyna_depo = ds_list_create(); + value_tag = ""; - type_array = 0; + type_array = 0; - is_modified = false; - cache_value = [ false, false, undefined, undefined ]; - cache_array = [ false, false ]; - use_cache = true; - record_value = true; + is_modified = false; + cache_value = [ false, false, undefined, undefined ]; + cache_array = [ false, false ]; + use_cache = true; + record_value = true; process_array = true; dynamic_array = false; validateValue = true; runInUI = false; - fullUpdate = false; + fullUpdate = false; + attributes = {}; - attributes = {}; - - node.inputs_data[index] = _value; + node.inputs_data[index] = _value; node.input_value_map[$ internalName] = _value; __curr_get_val = [ 0, 0 ]; - - validator = noone; + validator = noone; #endregion #region ---- draw ---- @@ -1474,7 +1472,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru } } #endregion - static setValueInspector = function(_val = 0, index = noone, time = CURRENT_FRAME) { #region + static setValueInspector = function(_val = 0, index = noone, time = CURRENT_FRAME) { INLINE var res = false; @@ -1487,30 +1485,29 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru var _node = PANEL_INSPECTOR.inspectings[i]; if(ind >= array_length(_node.inputs)) continue; - var r = _node.inputs[ind].setValueDirect(val, index); + var r = _node.inputs[ind].setValueDirect(val, index, true, time); if(_node == node) res = r; } - } else { - res = setValueDirect(val, index, time); - } - + } else + res = setValueDirect(val, index, true, time); + return res; - } #endregion + } static setValueDirect = function(val = 0, index = noone, record = true, time = CURRENT_FRAME, _update = true) { is_modified = true; var updated = false; var _val = val; var _inp = connect_type == JUNCTION_CONNECT.input; - - record &= record_value; - + + record &= record_value & _inp; + if(sep_axis) { if(index == noone) { for( var i = 0, n = array_length(animators); i < n; i++ ) - updated |= animators[i].setValue(val[i], _inp && record, time); + updated |= animators[i].setValue(val[i], record, time); } else - updated = animators[index].setValue(val, _inp && record, time); + updated = animators[index].setValue(val, record, time); } else { if(index != noone) { @@ -1520,7 +1517,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru _val[index] = val; } - updated = animator.setValue(_val, _inp && record, time); + updated = animator.setValue(_val, record, time); } if(type == VALUE_TYPE.gradient) updated = true; diff --git a/scripts/panel_function/panel_function.gml b/scripts/panel_function/panel_function.gml index dec527a39..eeecb2fd1 100644 --- a/scripts/panel_function/panel_function.gml +++ b/scripts/panel_function/panel_function.gml @@ -482,7 +482,7 @@ registerFunction("", "Preferences", "", MOD_KEY.none, call_dialog_preference ).setMenu("preference", THEME.gear) registerFunction("", "Splash screen", "", MOD_KEY.none, call_dialog_splash ).setMenu("splash_screen") registerFunction("", "Release note", "", MOD_KEY.none, call_dialog_release_note ).setMenu("release_note") - registerFunction("", "Command Palette", "T", MOD_KEY.ctrl | MOD_KEY.shift, call_dialog_command_palette).setMenu("command_palette") + registerFunction("", "Command Palette", vk_space, MOD_KEY.ctrl, call_dialog_command_palette ).setMenu("command_palette") registerFunction("", "Open Autosave Folder", "", MOD_KEY.none, open_autosave_folder ).setMenu("autosave_folder", THEME.save_auto) registerFunction("", "Addons", "", MOD_KEY.none, call_panel_addon ).setMenu("addons") diff --git a/scripts/panel_graph/panel_graph.gml b/scripts/panel_graph/panel_graph.gml index 9ba87cdac..c856fcaa6 100644 --- a/scripts/panel_graph/panel_graph.gml +++ b/scripts/panel_graph/panel_graph.gml @@ -40,6 +40,7 @@ function panel_graph_paste() { CALL("graph_paste"); PANEL_GRAPH.doPaste(); } function panel_graph_auto_align() { CALL("graph_auto_align"); node_auto_align(PANEL_GRAPH.nodes_selecting); } + function panel_graph_snap_nodes() { CALL("graph_snap_nodes"); node_snap_grid(PANEL_GRAPH.nodes_selecting, PANEL_GRAPH.project.graphGrid.size); } function panel_graph_search() { CALL("graph_search"); PANEL_GRAPH.toggleSearch(); } function panel_graph_toggle_minimap() { CALL("graph_toggle_minimap"); PANEL_GRAPH.minimap_show = !PANEL_GRAPH.minimap_show; } @@ -92,12 +93,11 @@ registerFunction("Graph", "Array", "A", MOD_KEY.ctrl | MOD_KEY.shift, panel_graph_array ).setMenu("graph_array") registerFunction("Graph", "Frame", "F", MOD_KEY.shift, panel_graph_frame ).setMenu("graph_frame") - registerFunction("Graph", "Canvas", "", MOD_KEY.none, - function(_dat) { return submenuCall(_dat, [ MENU_ITEMS.graph_canvas_copy, MENU_ITEMS.graph_canvas_blend ]); } ).setMenu("graph_canvas",, true) registerFunction("Graph", "Copy to Canvas", "C", MOD_KEY.ctrl | MOD_KEY.shift, panel_graph_canvas_copy ).setMenu("graph_canvas_copy") registerFunction("Graph", "Blend Canvas", "C", MOD_KEY.ctrl | MOD_KEY.alt, panel_graph_canvas_blend ).setMenu("graph_canvas_blend") - - + registerFunction("Graph", "Canvas", "", MOD_KEY.none, + function(_dat) { return submenuCall(_dat, [ MENU_ITEMS.graph_canvas_copy, MENU_ITEMS.graph_canvas_blend ]); } ).setMenu("graph_canvas",, true) + registerFunction("Graph", "Delete (break)", vk_delete, MOD_KEY.shift, panel_graph_delete_break ).setMenu("graph_delete_break", THEME.cross) registerFunction("Graph", "Delete (merge)", vk_delete, MOD_KEY.none, panel_graph_delete_merge ).setMenu("graph_delete_merge", THEME.cross) @@ -109,6 +109,7 @@ registerFunction("Graph", "Zoom", "", MOD_KEY.alt | MOD_KEY.ctrl, panel_graph_zoom ).setMenu("graph_zoom") registerFunction("Graph", "Auto Align", "L", MOD_KEY.none, panel_graph_auto_align ).setMenu("graph_auto_align") + registerFunction("Graph", "Snap Nodes", "", MOD_KEY.none, panel_graph_snap_nodes ).setMenu("graph_snap_nodes") registerFunction("Graph", "Search", "F", MOD_KEY.ctrl, panel_graph_search ).setMenu("graph_search") registerFunction("Graph", "Toggle Minimap", "M", MOD_KEY.ctrl, panel_graph_toggle_minimap ).setMenu("graph_toggle_minimap") @@ -291,9 +292,10 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor { graph_cx = 0; graph_cy = 0; - graph_autopan = false; - graph_pan_x_to = 0; - graph_pan_y_to = 0; + graph_autopan = false; + graph_pan_x_to = 0; + graph_pan_y_to = 0; + graph_pan_speed = 32; scale = [ 0.01, 0.02, 0.05, 0.10, 0.15, 0.20, 0.25, 0.33, 0.50, 0.65, 0.80, 1, 1.2, 1.35, 1.5, 2.0 ]; graph_s = 1; @@ -735,7 +737,11 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor { menu_connection_tunnel = MENU_ITEMS.graph_create_tunnel; - // node color + #region colors setters + __junction_hovering = noone; + menu_node_color = MENU_ITEMS.graph_group_node_color; + menu_junc_color = MENU_ITEMS.graph_group_junction_color; + function setSelectingNodeColor(color) { __temp_color = color; @@ -743,12 +749,6 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor { array_foreach(nodes_selecting, function(node) { node.attributes.color = __temp_color; }); } - menu_node_color = MENU_ITEMS.graph_group_node_color; - - - // junction color - __junction_hovering = noone; - function setSelectingJuncColor(color) { if(__junction_hovering == noone) return; __junction_hovering.setColor(color); @@ -763,9 +763,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor { } } } - - menu_junc_color = MENU_ITEMS.graph_group_junction_color; - + #endregion //// ============ Project ============ @@ -782,14 +780,14 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor { //// ============ Views ============ - function onFocusBegin() { // + function onFocusBegin() { PANEL_GRAPH = self; PROJECT = project; nodes_select_drag = 0; } - function focusNode(_node) { // + function focusNode(_node) { if(_node == noone) { nodes_selecting = []; return; @@ -799,15 +797,12 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor { fullView(); } - function fullView() { - INLINE - toCenterNode(array_empty(nodes_selecting)? nodes_list : nodes_selecting); - } + function fullView() { INLINE toCenterNode(array_empty(nodes_selecting)? nodes_list : nodes_selecting); } function dragGraph() { if(graph_autopan) { - graph_x = lerp_float(graph_x, graph_pan_x_to, 32, 1); - graph_y = lerp_float(graph_y, graph_pan_y_to, 32, 1); + graph_x = lerp_float(graph_x, graph_pan_x_to, graph_pan_speed, 1); + graph_y = lerp_float(graph_y, graph_pan_y_to, graph_pan_speed, 1); if(graph_x == graph_pan_x_to && graph_y == graph_pan_y_to) graph_autopan = false; @@ -937,10 +932,11 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor { graph_y = round(graph_y); } - function autoPanTo(_x, _y) { - graph_autopan = true; - graph_pan_x_to = _x; - graph_pan_y_to = _y; + function autoPanTo(_x, _y, _speed = 32) { + graph_autopan = true; + graph_pan_x_to = _x; + graph_pan_y_to = _y; + graph_pan_speed = _speed; } function setSlideShow(index, skip = false) { @@ -973,7 +969,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor { graph_y = _ty; } else - autoPanTo(_tx, _ty, skip); + autoPanTo(_tx, _ty, _targ.slide_speed); } //// =========== Context ========== @@ -3119,6 +3115,9 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor { _ti.inputs[1].setFrom(_jo); _ji.setFrom(_to.outputs[0]); + + _to.inputs[0].updateColor(); + _ti.inputs[1].updateColor(); } function createAction() { diff --git a/scripts/panel_history/panel_history.gml b/scripts/panel_history/panel_history.gml index fe27faf59..04ac56e5f 100644 --- a/scripts/panel_history/panel_history.gml +++ b/scripts/panel_history/panel_history.gml @@ -1,7 +1,8 @@ function Panel_History() : PanelContent() constructor { - title = __txt("History"); - w = ui(400); - h = ui(480); + title = __txt("History"); + padding = ui(8); + w = ui(400); + h = ui(480); anchor = ANCHOR.left | ANCHOR.top; hold = false; diff --git a/scripts/panel_nodes/panel_nodes.gml b/scripts/panel_nodes/panel_nodes.gml index 8bba16045..1c180441a 100644 --- a/scripts/panel_nodes/panel_nodes.gml +++ b/scripts/panel_nodes/panel_nodes.gml @@ -1,9 +1,8 @@ function Panel_Nodes() : PanelContent() constructor { title = __txt("Nodes"); - padding = 8; - - w = ui(320); - h = ui(480); + padding = ui(8); + w = ui(320); + h = ui(480); search_string = ""; diff --git a/scripts/preferences/preferences.gml b/scripts/preferences/preferences.gml index c489e608c..14621444c 100644 --- a/scripts/preferences/preferences.gml +++ b/scripts/preferences/preferences.gml @@ -249,24 +249,13 @@ PREFERENCES.window_height = max(600, window_minimize_size[1]); PREFERENCES.window_monitor = window_monitor; - var _hotkey = []; - for(var j = 0; j < ds_list_size(HOTKEY_CONTEXT); j++) { - var ll = HOTKEYS[? HOTKEY_CONTEXT[| j]]; - - for(var i = 0; i < ds_list_size(ll); i++) { - var _hk = ll[| i]; - if(_hk.dKey == _hk.key && _hk.dModi == _hk.modi) continue; - - array_push(_hotkey, _hk.serialize()); - } - } - json_save_struct(DIRECTORY + "keys.json", PREFERENCES); - json_save_struct(DIRECTORY + "hotkeys.json", _hotkey); json_save_struct(DIRECTORY + "Nodes/fav.json", global.FAV_NODES); json_save_struct(DIRECTORY + "Nodes/recent.json", global.RECENT_NODES); json_save_struct(DIRECTORY + "key_nodes.json", HOTKEYS_CUSTOM); json_save_struct(DIRECTORY + "default_project.json", PROJECT_ATTRIBUTES); + + hotkey_serialize(); } function PREF_LOAD() { @@ -277,20 +266,6 @@ else struct_override(PREFERENCES, map); } - var path = DIRECTORY + "hotkeys.json"; - if(file_exists(path)) { - var map = json_load_struct(path); - HOTKEYS_DATA = {}; - - for(var i = 0; i < array_length(map); i++) { - var key_list = map[i]; - var _context = is_struct(key_list)? key_list.context : key_list[0]; - var name = is_struct(key_list)? key_list.name : key_list[1]; - - HOTKEYS_DATA[$ $"{_context}_{name}"] = key_list; - } - } - if(!directory_exists($"{DIRECTORY}Themes/{PREFERENCES.theme}")) PREFERENCES.theme = "default"; @@ -308,6 +283,7 @@ var f = json_load_struct(DIRECTORY + "default_project.json"); struct_override(PROJECT_ATTRIBUTES, f); + hotkey_deserialize(); } function PREF_APPLY() { diff --git a/scripts/string_functions/string_functions.gml b/scripts/string_functions/string_functions.gml index f0b1b9bcc..548d00763 100644 --- a/scripts/string_functions/string_functions.gml +++ b/scripts/string_functions/string_functions.gml @@ -44,6 +44,28 @@ function string_to_var(str) { INLINE return string_replace_all(string function string_to_var2(context, name) { INLINE return string_to_var(context == ""? name : $"{context} {name}"); } function string_quote(str) { INLINE return $"\"{str}\""; } +function string_compare(s1, s2) { + var l1 = string_length(s1); + var l2 = string_length(s2); + + var i = 0; + var c1, c2; + + repeat(min(l1, l2)) { + c1 = string_lower(string_char_at(s1, i)); + c2 = string_lower(string_char_at(s2, i)); + + if(c1 == c2) { + i++; + continue; + } + + return ord(c1) - ord(c2); + } + + return l1 - l2; +} + function array_to_string(arr) { if(!is_array(arr)) return string(arr); if(array_empty(arr)) return "[]";