diff --git a/PixelComposer.yyp b/PixelComposer.yyp index d803f3bea..69b482abf 100644 --- a/PixelComposer.yyp +++ b/PixelComposer.yyp @@ -334,6 +334,7 @@ {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_bone.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_button_path_icon.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_button_path_not_found_icon.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",}, + {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_cache_group.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_cache.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_chat.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_checkbox_on_start.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",}, diff --git a/datafiles/data/themes/default.zip b/datafiles/data/themes/default.zip index 467e4b538..1f245e88c 100644 Binary files a/datafiles/data/themes/default.zip and b/datafiles/data/themes/default.zip differ diff --git a/scripts/node_cache/node_cache.gml b/scripts/node_cache/node_cache.gml index ad9fadbfc..7bc1346c6 100644 --- a/scripts/node_cache/node_cache.gml +++ b/scripts/node_cache/node_cache.gml @@ -1,6 +1,6 @@ function Node_Cache(_x, _y, _group = noone) : __Node_Cache(_x, _y, _group) constructor { - name = "Cache"; - use_cache = CACHE_USE.auto; + name = "Cache"; + use_cache = CACHE_USE.auto; inputs[| 0] = nodeValue("Surface in", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, 0); @@ -38,6 +38,8 @@ function Node_Cache(_x, _y, _group = noone) : __Node_Cache(_x, _y, _group) const var _surf = getInputData(0); cacheCurrentFrame(_surf); + + disableNodeGroup(); } #endregion static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region @@ -55,17 +57,4 @@ function Node_Cache(_x, _y, _group = noone) : __Node_Cache(_x, _y, _group) const cache_loading_progress = 0; cache_loading = true; } #endregion - - static attributeDeserialize = function(attr) { #region - struct_override(attributes, attr); - cache_group_members = []; - - if(struct_has(attributes, "cache_group")) { - for( var i = 0, n = array_length(attributes.cache_group); i < n; i++ ) { - var _node = attributes.cache_group[i]; - if(ds_map_exists(PROJECT.nodeMap, _node)) - array_push(cache_group_members, PROJECT.nodeMap[? _node]); - } - } - } #endregion } \ No newline at end of file diff --git a/scripts/node_cache_array/node_cache_array.gml b/scripts/node_cache_array/node_cache_array.gml index 3fb9c832b..ec63576e3 100644 --- a/scripts/node_cache_array/node_cache_array.gml +++ b/scripts/node_cache_array/node_cache_array.gml @@ -1,6 +1,6 @@ function Node_Cache_Array(_x, _y, _group = noone) : __Node_Cache(_x, _y, _group) constructor { - name = "Cache Array"; - use_cache = CACHE_USE.manual; + name = "Cache Array"; + use_cache = CACHE_USE.manual; inputs[| 0] = nodeValue("Surface in", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, 0); @@ -19,7 +19,7 @@ function Node_Cache_Array(_x, _y, _group = noone) : __Node_Cache(_x, _y, _group) cache_loading = false; cache_content = ""; - cache_loading_progress = 0; + cache_loading_progress = 0; insp2UpdateTooltip = "Clear cache"; insp2UpdateIcon = [ THEME.cache, 0, COLORS._main_icon ]; @@ -63,6 +63,8 @@ function Node_Cache_Array(_x, _y, _group = noone) : __Node_Cache(_x, _y, _group) if(cacheExist(i)) array_push(ss, cached_output[i]); outputs[| 0].setValue(ss); + + disableNodeGroup(); } #endregion static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region diff --git a/scripts/node_cache_base/node_cache_base.gml b/scripts/node_cache_base/node_cache_base.gml index f10ae6ffd..5ec9a2183 100644 --- a/scripts/node_cache_base/node_cache_base.gml +++ b/scripts/node_cache_base/node_cache_base.gml @@ -1,5 +1,5 @@ function __Node_Cache(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { - name = "Cache"; + name = "Cache"; clearCacheOnChange = false; update_on_frame = true; @@ -9,13 +9,46 @@ function __Node_Cache(_x, _y, _group = noone) : Node(_x, _y, _group) constructor vertex_hash = ""; insp1UpdateTooltip = "Generate cache group"; - insp1UpdateIcon = [ THEME.cache, 0, COLORS._main_icon ]; + insp1UpdateIcon = [ THEME.cache_group, 0, COLORS._main_icon ]; + + if(NOT_LOAD) run_in(1, function() { onInspector1Update(); }); + + static removeNode = function(node) { #region + if(node.cache_group == noone) return; + + array_remove(attributes.cache_group, node.node_id); + node.cache_group = noone; + refreshCacheGroup(); + } #endregion + + static addNode = function(node) { #region + array_push_unique(attributes.cache_group, node.node_id); + refreshCacheGroup(); + } #endregion + + static enableNodeGroup = function() { #region + for( var i = 0, n = array_length(cache_group_members); i < n; i++ ) + cache_group_members[i].renderActive = true; + clearCache(true); + } #endregion + + static disableNodeGroup = function() { #region + if(IS_PLAYING && CURRENT_FRAME == TOTAL_FRAMES - 1) + for( var i = 0, n = array_length(cache_group_members); i < n; i++ ) + cache_group_members[i].renderActive = false; + } #endregion + + static refreshCacheGroup = function() { #region + cache_group_members = array_create(array_length(attributes.cache_group)); + for( var i = 0, n = array_length(attributes.cache_group); i < n; i++ ) { + cache_group_members[i] = PROJECT.nodeMap[? attributes.cache_group[i]]; + cache_group_members[i].cache_group = self; + } + } #endregion static getCacheGroup = function(node) { #region - if(node != self) { + if(node != self) array_push(attributes.cache_group, node.node_id); - array_push(cache_group_members, node); - } for( var i = 0, n = ds_list_size(node.inputs); i < n; i++ ) { var _from = node.inputs[| i].value_from; @@ -32,6 +65,7 @@ function __Node_Cache(_x, _y, _group = noone) : Node(_x, _y, _group) constructor cache_group_members = []; getCacheGroup(self); + refreshCacheGroup(); } #endregion static ccw = function(a, b, c) { return (b[0] - a[0]) * (c[1] - a[1]) - (c[0] - a[0]) * (b[1] - a[1]); } @@ -149,4 +183,9 @@ function __Node_Cache(_x, _y, _group = noone) : Node(_x, _y, _group) constructor draw_set_alpha(1); } #endregion + + static attributeDeserialize = function(attr) { #region + struct_override(attributes, attr); + refreshCacheGroup(); + } #endregion } \ No newline at end of file diff --git a/scripts/node_collection/node_collection.gml b/scripts/node_collection/node_collection.gml index 05432ab70..96701c974 100644 --- a/scripts/node_collection/node_collection.gml +++ b/scripts/node_collection/node_collection.gml @@ -70,8 +70,8 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc instanceBase = noone; input_display_list_def = []; - custom_input_index = 0; - custom_output_index = 0; + custom_input_index = 0; + custom_output_index = 0; metadata = new MetaDataManager(); @@ -79,11 +79,11 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc attributes.w = 128; attributes.h = 128; + managedRenderOrder = false; + input_dummy = nodeValue("Add to group", self, JUNCTION_CONNECT.input, VALUE_TYPE.any, 0); draw_dummy = false; - managedRenderOrder = false; - input_dummy.onSetFrom = function(juncFrom) { ds_list_remove(juncFrom.value_to, input_dummy); input_dummy.value_from = noone; diff --git a/scripts/node_data/node_data.gml b/scripts/node_data/node_data.gml index 5b6caf523..75d2eaafb 100644 --- a/scripts/node_data/node_data.gml +++ b/scripts/node_data/node_data.gml @@ -222,6 +222,10 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x is_3D = false; #endregion + #region ---- cache ---- + cache_group = noone; + #endregion + static createNewInput = noone; static initTooltip = function() { #region @@ -581,6 +585,12 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x error_noti_update = noti_error(getFullName() + " node require manual execution.",, self); onValueUpdate(index); + if(cache_group) cache_group.enableNodeGroup(); + } #endregion + + static valueFromUpdate = function(index) { #region + onValueFromUpdate(index); + if(cache_group) cache_group.enableNodeGroup(); } #endregion static onValueUpdate = function(index = 0) {} diff --git a/scripts/node_value/node_value.gml b/scripts/node_value/node_value.gml index e0f83ab66..4a66a84a8 100644 --- a/scripts/node_value/node_value.gml +++ b/scripts/node_value/node_value.gml @@ -1840,7 +1840,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru node.valueUpdate(index, _o); if(_update && connect_type == JUNCTION_CONNECT.input) { - node.onValueFromUpdate(index); + node.valueFromUpdate(index); node.triggerRender(); node.clearCacheForward(); @@ -1871,7 +1871,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru value_from = noone; if(connect_type == JUNCTION_CONNECT.input) - node.onValueFromUpdate(index); + node.valueFromUpdate(index); node.clearCacheForward(); PROJECT.modified = true; diff --git a/scripts/panel_graph/panel_graph.gml b/scripts/panel_graph/panel_graph.gml index 7f1dbbee2..1784caff7 100644 --- a/scripts/panel_graph/panel_graph.gml +++ b/scripts/panel_graph/panel_graph.gml @@ -1020,7 +1020,10 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor { } node_dragging.move(nx, ny, graph_s); - + + if(key_mod_press(SHIFT) && node_dragging.cache_group != noone) + node_dragging.cache_group.removeNode(node_dragging); + if(mouse_release(mb_left) && (nx != node_drag_sx || ny != node_drag_sy)) { recordAction(ACTION_TYPE.var_modify, node_dragging, [ node_drag_sx, "x", "node x position" ]); recordAction(ACTION_TYPE.var_modify, node_dragging, [ node_drag_sy, "y", "node y position" ]); @@ -1053,11 +1056,19 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor { _node.move(_nx, _ny, graph_s); } - + node_drag_ox = nx; node_drag_oy = ny; } + if(key_mod_press(SHIFT)) { + for(var i = 0; i < ds_list_size(nodes_select_list); i++) { + var _node = nodes_select_list[| i]; + if(_node.cache_group != noone) + _node.cache_group.removeNode(_node); + } + } + if(mouse_release(mb_left) && (nx != node_drag_sx || ny != node_drag_sy)) { var shfx = node_drag_sx - nx; var shfy = node_drag_sy - ny; @@ -2069,7 +2080,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor { ds_list_add(nodes_list, node); } #endregion - function close() { #region + function close() { #region var panels = findPanels("Panel_Graph"); for( var i = 0, n = array_length(panels); i < n; i++ ) { if(panels[i] == self) continue;