diff --git a/scripts/__node/__node.gml b/scripts/__node/__node.gml index 943c907cb..057081469 100644 --- a/scripts/__node/__node.gml +++ b/scripts/__node/__node.gml @@ -51,15 +51,15 @@ function __Node_Base(x, y) constructor { static step = function() {} static update = function(frame = CURRENT_FRAME) {} - static valueUpdate = function(index) {} + static valueUpdate = function(index) {} static triggerRender = function() {} static onValidate = function() {} - static onDestroy = function() {} + static onDestroy = function() {} static clearCache = function() {} static clearCacheForward = function() {} - static serialize = function() {} + static serialize = function() {} static deserialize = function(_map) {} } \ No newline at end of file diff --git a/scripts/directory_object/directory_object.gml b/scripts/directory_object/directory_object.gml index b3f273b0c..898500d80 100644 --- a/scripts/directory_object/directory_object.gml +++ b/scripts/directory_object/directory_object.gml @@ -48,10 +48,12 @@ function FileObject(_name, _path) constructor { #region } #endregion static getSpr = function() { #region - if(spr != -1) return spr; + if(spr != -1 && sprite_exists(spr)) + return spr; + if(sprFetchID != noone) return -1; - if(array_length(spr_path) == 0) { + if(array_empty(spr_path)) { if(loadThumbnailAsync) { sprFetchID = sprite_add_ext(self.path, 0, 0, 0, true); IMAGE_FETCH_MAP[? sprFetchID] = function(load_result) { @@ -62,6 +64,7 @@ function FileObject(_name, _path) constructor { #region spr = sprite_add(self.path, 0, 0, 0, 0, 0); if(spr) sprite_set_offset(spr, sprite_get_width(spr) / 2, sprite_get_height(spr) / 2); } + return spr; } diff --git a/scripts/load_function/load_function.gml b/scripts/load_function/load_function.gml index c2595cf82..a69cf20d0 100644 --- a/scripts/load_function/load_function.gml +++ b/scripts/load_function/load_function.gml @@ -141,7 +141,6 @@ function LOAD_AT(path, readonly = false, override = false) { #region try { var _node_list = _load_content.nodes; for(var i = 0, n = array_length(_node_list); i < n; i++) { - // printIf(log, $" >> Loading nodes : {_node_list[i].type}"); var _node = nodeLoad(_node_list[i]); if(_node) array_push(create_list, _node); } @@ -150,68 +149,7 @@ function LOAD_AT(path, readonly = false, override = false) { #region } } - printIf(log, $" > Load nodes : {(get_timer() - t1) / 1000} ms"); t1 = get_timer(); - - try { - if(struct_has(_load_content, "animator")) { - var _anim_map = _load_content.animator; - PROJECT.animator.frames_total = struct_try_get(_anim_map, "frames_total", 30); - PROJECT.animator.framerate = struct_try_get(_anim_map, "framerate", 30); - PROJECT.animator.frame_range = struct_try_get(_anim_map, "frame_range", noone); - } - } catch(e) { - log_warning("LOAD, animator", exception_print(e)); - } - - if(struct_has(_load_content, "onion_skin")) - struct_override(PROJECT.onion_skin, _load_content.onion_skin); - - if(struct_has(_load_content, "previewGrid")) - struct_override(PROJECT.previewGrid, _load_content.previewGrid); - - if(struct_has(_load_content, "graphGrid")) - struct_override(PROJECT.graphGrid, _load_content.graphGrid); - - if(struct_has(_load_content, "attributes")) { - struct_override(PROJECT.attributes, _load_content.attributes); - } - PROJECT.setPalette(); - - if(struct_has(_load_content, "notes")) { - PROJECT.notes = array_create(array_length(_load_content.notes)); - for( var i = 0, n = array_length(_load_content.notes); i < n; i++ ) - PROJECT.notes[i] = new Note.deserialize(_load_content.notes[i]); - } - - try { - if(struct_has(_load_content, "metadata")) - PROJECT.meta.deserialize(_load_content.metadata); - } catch(e) { - log_warning("LOAD, metadata", exception_print(e)); - } - - PROJECT.globalNode = new Node_Global(); - try { - if(struct_has(_load_content, "global")) - PROJECT.globalNode.deserialize(_load_content.global); - else if(struct_has(_load_content, "global_node")) - PROJECT.globalNode.deserialize(_load_content.global_node); - } catch(e) { - log_warning("LOAD, global", exception_print(e)); - } - - try { - if(struct_has(_load_content, "addon")) { - var _addon = _load_content.addon; - PROJECT.addons = _addon; - struct_foreach(_addon, function(_name, _value) { addonLoad(_name, false); }); - } else - PROJECT.addons = {}; - } catch(e) { - log_warning("LOAD, addon", exception_print(e)); - } - - printIf(log, $" > Load data : {(get_timer() - t1) / 1000} ms"); t1 = get_timer(); + PROJECT.deserialize(_load_content); ds_queue_clear(CONNECTION_CONFLICT); diff --git a/scripts/node_value/node_value.gml b/scripts/node_value/node_value.gml index 6d5103289..fd40fbd8c 100644 --- a/scripts/node_value/node_value.gml +++ b/scripts/node_value/node_value.gml @@ -368,8 +368,13 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru mapButton = button(function() { attributes.mapped = !attributes.mapped; var val = getValue(); - if( attributes.mapped && is_numeric(val)) setValue([0, val]); - if(!attributes.mapped && is_array(val)) setValue(array_safe_get_fast(val, 0)); + + if( attributes.mapped) + setValue([0, 0]); + + if(!attributes.mapped && is_array(def_val)) + setValue(def_val); + setArrayDepth(attributes.mapped); node.triggerRender(); @@ -410,6 +415,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru inp.visible = vis; node.refreshNodeDisplay(); } + } #endregion /////========== ANIMATION ========== diff --git a/scripts/panel_collection/panel_collection.gml b/scripts/panel_collection/panel_collection.gml index 0ab60611f..3873c0b58 100644 --- a/scripts/panel_collection/panel_collection.gml +++ b/scripts/panel_collection/panel_collection.gml @@ -141,6 +141,9 @@ function Panel_Collection() : PanelContent() constructor { }); tb_search.auto_update = true; + grid_size = ui(64); + grid_size_to = grid_size; + contentView = 0; contentPane = new scrollPane(content_w - ui(6), content_h, function(_y, _m) { #region draw_clear_alpha(c_white, 0); @@ -180,9 +183,10 @@ function Panel_Collection() : PanelContent() constructor { updated_prog = lerp_linear(updated_prog, 0, 0.01); if(contentView == 0) { - var grid_size = ui(64); - var grid_width = ui(80); - var grid_space = ui(12); + var grid_width = round(grid_size * 1.25); + if(grid_width > ui(80)) grid_width = grid_size; + + var grid_space = round(grid_size * 0.1875); var col = max(1, floor(_cw / (grid_width + grid_space))); var row = ceil(node_count / col); @@ -277,7 +281,7 @@ function Panel_Collection() : PanelContent() constructor { } draw_set_text(f_p3, fa_center, fa_top, COLORS._main_text_inner); - var _txtH = draw_text_ext_add(_boxx + grid_size / 2, yy + grid_size + ui(4), _node.name, -1, grid_width,, true); + var _txtH = draw_text_ext_add(_boxx + grid_size / 2, yy + grid_size + ui(4), _node.name, -1, grid_width, 1, true); name_height = max(name_height, _txtH + 8); } @@ -286,6 +290,12 @@ function Panel_Collection() : PanelContent() constructor { yy += hght; } + if(pHOVER && key_mod_press(CTRL) && point_in_rectangle(_m[0], _m[1], 0, 0, contentPane.surface_w, contentPane.surface_h)) { + if(mouse_wheel_down()) grid_size_to = clamp(grid_size_to - ui(4), ui(32), ui(160)); + if(mouse_wheel_up()) grid_size_to = clamp(grid_size_to + ui(4), ui(32), ui(160)); + } + grid_size = lerp_float(grid_size, grid_size_to, 5); + } else { var list_width = _cw; var list_height = ui(28); diff --git a/scripts/panel_function/panel_function.gml b/scripts/panel_function/panel_function.gml index 26f0cd16c..65ab792d7 100644 --- a/scripts/panel_function/panel_function.gml +++ b/scripts/panel_function/panel_function.gml @@ -114,13 +114,14 @@ } #endregion function checkPanelValid() { #region - var val = true; - if(!is_instanceof(PANEL_GRAPH.panel, Panel)) val = false; - if(!is_instanceof(PANEL_PREVIEW.panel, Panel)) val = false; - if(!is_instanceof(PANEL_INSPECTOR.panel, Panel)) val = false; + var val = true; + var _mst = ""; + if(!is_instanceof(PANEL_GRAPH.panel, Panel)) { val = false; _mst += "Graph, " }; + if(!is_instanceof(PANEL_PREVIEW.panel, Panel)) { val = false; _mst += "Preview, " }; + if(!is_instanceof(PANEL_INSPECTOR.panel, Panel)) { val = false; _mst += "Inspector, " }; if(!val) { - noti_warning("Invalid Panel Layout, layout and UI scale will be reset to the default value.\n\nRestart recommended."); + noti_warning($"Invalid Panel Layout, missing {_mst} panel(s). Reset to the default layout and restart recommened."); PREFERENCES.panel_layout_file = "Vertical"; PREFERENCES._display_scaling = 1; diff --git a/scripts/panel_graph/panel_graph.gml b/scripts/panel_graph/panel_graph.gml index bb1232a82..7f87b373c 100644 --- a/scripts/panel_graph/panel_graph.gml +++ b/scripts/panel_graph/panel_graph.gml @@ -160,6 +160,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor { self.project = project; nodes_list = project.nodes; + // layer_index = noone; setTitle(); } setProject(project); @@ -1509,100 +1510,100 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor { function connectDraggingValueTo(target) { #region var _connect = [ 0, noone, noone ]; - if(PANEL_INSPECTOR && PANEL_INSPECTOR.attribute_hovering != noone) { - PANEL_INSPECTOR.attribute_hovering(value_dragging); + if(is_instanceof(PANEL_INSPECTOR, Panel_Inspector) && PANEL_INSPECTOR.attribute_hovering != noone) { + PANEL_INSPECTOR.attribute_hovering(value_dragging); + + } else if(target != noone) { + + if(target.connect_type == value_dragging.connect_type) { - } else if(target != noone) { - - if(target.connect_type == value_dragging.connect_type) { - - if(value_dragging.connect_type == JUNCTION_CONNECT.input) { - if(target.value_from) { - value_dragging.setFrom(target.value_from); - target.removeFrom(); - } - - } else if(value_dragging.connect_type == JUNCTION_CONNECT.output) { - var _tos = target.getJunctionTo(); - - for (var i = 0, n = array_length(_tos); i < n; i++) - _tos[i].setFrom(value_dragging); + if(value_dragging.connect_type == JUNCTION_CONNECT.input) { + if(target.value_from) { + value_dragging.setFrom(target.value_from); + target.removeFrom(); } - } else { - var _addInput = target.value_from == noone && target.connect_type == JUNCTION_CONNECT.input && target.node.auto_input; + } else if(value_dragging.connect_type == JUNCTION_CONNECT.output) { + var _tos = target.getJunctionTo(); - if(value_dragging.connect_type == JUNCTION_CONNECT.input) { - if(array_empty(value_draggings)) { - _connect = [ value_dragging.setFrom(target), value_dragging, target ]; - } else { - for( var i = 0, n = array_length(value_draggings); i < n; i++ ) - value_draggings[i].setFrom(target); - } - - } else if(_addInput && !array_empty(value_draggings)) { - for( var i = 0, n = array_length(value_draggings); i < n; i++ ) - target.node.addInput(value_draggings[i]); - - } else { - _connect = [ target.setFrom(value_dragging), target, value_dragging ]; - } + for (var i = 0, n = array_length(_tos); i < n; i++) + _tos[i].setFrom(value_dragging); } } else { - if(value_dragging.connect_type == JUNCTION_CONNECT.input) - value_dragging.removeFrom(); - value_dragging.node.triggerRender(); + var _addInput = target.value_from == noone && target.connect_type == JUNCTION_CONNECT.input && target.node.auto_input; - if(value_focus != value_dragging) { - var ctx = is_instanceof(frame_hovering, Node_Collection_Inline)? frame_hovering : getCurrentContext(); - if(value_dragging.node.inline_context && !key_mod_press(SHIFT)) - ctx = value_dragging.node.inline_context; - - with(dialogCall(o_dialog_add_node, mouse_mx + 8, mouse_my + 8, { context: ctx })) { - node_target_x = other.mouse_grid_x; - node_target_y = other.mouse_grid_y; - node_called = other.value_dragging; - - alarm[0] = 1; + if(value_dragging.connect_type == JUNCTION_CONNECT.input) { + if(array_empty(value_draggings)) { + _connect = [ value_dragging.setFrom(target), value_dragging, target ]; + } else { + for( var i = 0, n = array_length(value_draggings); i < n; i++ ) + value_draggings[i].setFrom(target); } + + } else if(_addInput && !array_empty(value_draggings)) { + for( var i = 0, n = array_length(value_draggings); i < n; i++ ) + target.node.addInput(value_draggings[i]); + + } else { + _connect = [ target.setFrom(value_dragging), target, value_dragging ]; } } - value_dragging = noone; - connection_draw_mouse = noone; + } else { + if(value_dragging.connect_type == JUNCTION_CONNECT.input) + value_dragging.removeFrom(); + value_dragging.node.triggerRender(); - if(_connect[0] == -9) { - if(_connect[1].value_from_loop != noone) - _connect[1].value_from_loop.destroy(); - - var menu = [ - menuItem("Feedback", function(data) { - var junc_in = data.params.junc_in; - var junc_out = data.params.junc_out; - - var feed = nodeBuild("Node_Feedback_Inline", 0, 0); - // feed.connectJunctions(junc_in, junc_out); - feed.attributes.junc_in = [ junc_in .node.node_id, junc_in .index ]; - feed.attributes.junc_out = [ junc_out.node.node_id, junc_out.index ]; - feed.scanJunc(); - - }, THEME.feedback_24,,, { junc_in : _connect[1], junc_out : _connect[2] }), - - menuItem("Loop", function(data) { - var junc_in = data.params.junc_in; - var junc_out = data.params.junc_out; - - var feed = nodeBuild("Node_Iterate_Inline", 0, 0); - feed.attributes.junc_in = [ junc_in .node.node_id, junc_in .index ]; - feed.attributes.junc_out = [ junc_out.node.node_id, junc_out.index ]; - feed.scanJunc(); - - }, THEME.loop_24,,, { junc_in : _connect[1], junc_out : _connect[2] }), - ]; + if(value_focus != value_dragging) { + var ctx = is_instanceof(frame_hovering, Node_Collection_Inline)? frame_hovering : getCurrentContext(); + if(value_dragging.node.inline_context && !key_mod_press(SHIFT)) + ctx = value_dragging.node.inline_context; - menuCall(,,, menu); + with(dialogCall(o_dialog_add_node, mouse_mx + 8, mouse_my + 8, { context: ctx })) { + node_target_x = other.mouse_grid_x; + node_target_y = other.mouse_grid_y; + node_called = other.value_dragging; + + alarm[0] = 1; + } } + } + + value_dragging = noone; + connection_draw_mouse = noone; + + if(_connect[0] == -9) { + if(_connect[1].value_from_loop != noone) + _connect[1].value_from_loop.destroy(); + + var menu = [ + menuItem("Feedback", function(data) { + var junc_in = data.params.junc_in; + var junc_out = data.params.junc_out; + + var feed = nodeBuild("Node_Feedback_Inline", 0, 0); + // feed.connectJunctions(junc_in, junc_out); + feed.attributes.junc_in = [ junc_in .node.node_id, junc_in .index ]; + feed.attributes.junc_out = [ junc_out.node.node_id, junc_out.index ]; + feed.scanJunc(); + + }, THEME.feedback_24,,, { junc_in : _connect[1], junc_out : _connect[2] }), + + menuItem("Loop", function(data) { + var junc_in = data.params.junc_in; + var junc_out = data.params.junc_out; + + var feed = nodeBuild("Node_Iterate_Inline", 0, 0); + feed.attributes.junc_in = [ junc_in .node.node_id, junc_in .index ]; + feed.attributes.junc_out = [ junc_out.node.node_id, junc_out.index ]; + feed.scanJunc(); + + }, THEME.loop_24,,, { junc_in : _connect[1], junc_out : _connect[2] }), + ]; + + menuCall(,,, menu); + } } #endregion function draggingValue() { diff --git a/scripts/panel_inspector/panel_inspector.gml b/scripts/panel_inspector/panel_inspector.gml index 0a62fc6f5..970f20485 100644 --- a/scripts/panel_inspector/panel_inspector.gml +++ b/scripts/panel_inspector/panel_inspector.gml @@ -35,14 +35,14 @@ function Inspector_Spacer(height, line = false) constructor { self.h = height; s function Panel_Inspector() : PanelContent() constructor { #region ---- main ---- - title = __txt("Inspector"); context_str = "Inspector"; + title = __txt("Inspector"); icon = THEME.panel_inspector_icon; - w = ui(400); - h = ui(640); + w = ui(400); + h = ui(640); min_w = ui(160); - + locked = false; inspecting = noone; inspectings = []; @@ -73,6 +73,8 @@ function Panel_Inspector() : PanelContent() constructor { picker_index = 0; picker_change = false; + + attribute_hovering = noone; #endregion globalvar_viewer_init(); diff --git a/scripts/project_data/project_data.gml b/scripts/project_data/project_data.gml index fcd0edc9e..4ca879fd5 100644 --- a/scripts/project_data/project_data.gml +++ b/scripts/project_data/project_data.gml @@ -3,6 +3,13 @@ PROJECT = noone; #endregion +#region layer + function Layer() constructor { + name = "New Layer"; + nodes = []; + } +#endregion + #region project function Project() constructor { active = true; /// @is {bool} @@ -23,6 +30,8 @@ nodeMap = ds_map_create(); nodeNameMap = ds_map_create(); + composer = noone; + animator = new AnimationManager(); globalNode = new Node_Global(); nodeController = new __Node_Controller(self); @@ -144,6 +153,85 @@ } #endregion static toString = function() { return $"ProjectObject [{path}]"; } + + static serialize = function() { + var _map = {}; + _map.version = SAVE_VERSION; + + var _anim_map = {}; + _anim_map.frames_total = animator.frames_total; + _anim_map.framerate = animator.framerate; + _anim_map.frame_range = animator.frame_range; + _map.animator = _anim_map; + + _map.metadata = meta.serialize(); + _map.global_node = globalNode.serialize(); + _map.onion_skin = onion_skin; + + _map.previewGrid = previewGrid; + _map.graphGrid = graphGrid; + _map.attributes = attributes; + + _map.timelines = timelines.serialize(); + _map.notes = array_map(notes, function(note) { return note.serialize(); } ); + + _map.composer = composer == noone? -4 : composer.serialize(); + + __node_list = []; + array_foreach(allNodes, function(node) { if(node.active) array_push(__node_list, node.serialize()); }) + _map.nodes = __node_list; + + + var prev = PANEL_PREVIEW.getNodePreviewSurface(); + if(!is_surface(prev)) _map.preview = ""; + else _map.preview = surface_encode(surface_size_lim(prev, 128, 128)); + + var _addon = {}; + with(_addon_custom) { + var _ser = lua_call(thread, "serialize"); + _addon[$ name] = PREFERENCES.save_file_minify? json_stringify_minify(_ser) : json_stringify(_ser); + } + _map.addon = _addon; + + return _map; + } + + static deserialize = function(_map) { + if(struct_has(_map, "animator")) { + var _anim_map = _map.animator; + animator.frames_total = struct_try_get(_anim_map, "frames_total", 30); + animator.framerate = struct_try_get(_anim_map, "framerate", 30); + animator.frame_range = struct_try_get(_anim_map, "frame_range", noone); + } + + if(struct_has(_map, "onion_skin")) struct_override(onion_skin, _map.onion_skin); + if(struct_has(_map, "previewGrid")) struct_override(previewGrid, _map.previewGrid); + if(struct_has(_map, "graphGrid")) struct_override(graphGrid, _map.graphGrid); + if(struct_has(_map, "attributes")) struct_override(attributes, _map.attributes); + if(struct_has(_map, "metadata")) meta.deserialize(_map.metadata); + + setPalette(); + + if(struct_has(_map, "notes")) { + notes = array_create(array_length(_map.notes)); + for( var i = 0, n = array_length(_map.notes); i < n; i++ ) + notes[i] = new Note.deserialize(_map.notes[i]); + } + + globalNode = new Node_Global(); + if(struct_has(_map, "global")) globalNode.deserialize(_map.global); + else if(struct_has(_map, "global_node")) globalNode.deserialize(_map.global_node); + + if(struct_has(_map, "composer") && _map.composer != -4) + composer.deserialize(_map.composer); + + addons = {}; + if(struct_has(_map, "addon")) { + var _addon = _map.addon; + addons = _addon; + struct_foreach(_addon, function(_name, _value) { addonLoad(_name, false); }); + } + } } function __initProject() { diff --git a/scripts/save_function/save_function.gml b/scripts/save_function/save_function.gml index ca0d790a2..e84804207 100644 --- a/scripts/save_function/save_function.gml +++ b/scripts/save_function/save_function.gml @@ -14,50 +14,9 @@ function NEW() { #region } #endregion function save_serialize(project = PROJECT, _outMap = false) { #region - var _map = {}; - _map.version = SAVE_VERSION; - - var _node_list = []; - var amo = array_length(project.allNodes); - var i = 0; - - repeat(amo) { - var _node = project.allNodes[i++]; - if(_node.active) array_push(_node_list, _node.serialize()); - } - - _map.nodes = _node_list; - - var _anim_map = {}; - _anim_map.frames_total = project.animator.frames_total; - _anim_map.framerate = project.animator.framerate; - _anim_map.frame_range = project.animator.frame_range; - _map.animator = _anim_map; - - _map.metadata = PROJECT.meta.serialize(); - _map.global_node = project.globalNode.serialize(); - _map.onion_skin = project.onion_skin; - - _map.previewGrid = project.previewGrid; - _map.graphGrid = project.graphGrid; - _map.attributes = project.attributes; - - _map.timelines = project.timelines.serialize(); - _map.notes = array_map(project.notes, function(note) { return note.serialize(); } ); - - var prev = PANEL_PREVIEW.getNodePreviewSurface(); - if(!is_surface(prev)) _map.preview = ""; - else _map.preview = surface_encode(surface_size_lim(prev, 128, 128)); - - var _addon = {}; - with(_addon_custom) { - var _ser = lua_call(thread, "serialize"); - _addon[$ name] = PREFERENCES.save_file_minify? json_stringify_minify(_ser) : json_stringify(_ser); - } - _map.addon = _addon; + var _map = project.serialize(); if(_outMap) return _map; - return PREFERENCES.save_file_minify? json_stringify_minify(_map) : json_stringify(_map, true); } #endregion