mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-12-25 14:36:13 +01:00
cache group
This commit is contained in:
parent
cb39f44bab
commit
6e336452c5
9 changed files with 84 additions and 32 deletions
|
@ -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",},
|
||||
|
|
Binary file not shown.
|
@ -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
|
||||
}
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -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) {}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -1021,6 +1021,9 @@ 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" ]);
|
||||
|
@ -1058,6 +1061,14 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
|
|||
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;
|
||||
|
|
Loading…
Reference in a new issue