mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-12-24 14:06:23 +01:00
undo data refresh
This commit is contained in:
parent
ef2d8aaa2f
commit
b422fdcf65
7 changed files with 41 additions and 26 deletions
|
@ -444,6 +444,8 @@ function valueAnimator(_val, _prop, _sep_axis = false) constructor {
|
|||
|
||||
static insertKey = function(_key, _index) { ds_list_insert(values, _index, _key); }
|
||||
|
||||
function onUndo() { updateKeyMap(); prop.triggerSetFrom(); }
|
||||
|
||||
static setKeyTime = function(_key, _time, _replace = true, record = false) { #region
|
||||
if(!ds_list_exist(values, _key)) return 0;
|
||||
if(_key.time == _time && !_replace) return 0;
|
||||
|
@ -482,7 +484,7 @@ function valueAnimator(_val, _prop, _sep_axis = false) constructor {
|
|||
setKeyTime(data.key, data.time, false);
|
||||
|
||||
data.time = _prevTime;
|
||||
}, { key : _key, time : _prevTime });
|
||||
}, { key : _key, time : _prevTime }, onUndo);
|
||||
|
||||
ds_list_insert(values, i, _key);
|
||||
if(_replace) updateKeyMap();
|
||||
|
@ -494,7 +496,7 @@ function valueAnimator(_val, _prop, _sep_axis = false) constructor {
|
|||
setKeyTime(data.key, data.time, false);
|
||||
|
||||
data.time = _prevTime;
|
||||
}, { key : _key, time : _prevTime });
|
||||
}, { key : _key, time : _prevTime }, onUndo);
|
||||
|
||||
ds_list_add(values, _key);
|
||||
if(_replace) updateKeyMap();
|
||||
|
@ -536,7 +538,7 @@ function valueAnimator(_val, _prop, _sep_axis = false) constructor {
|
|||
if(isEqual(values[| 0].value, _val))
|
||||
return false;
|
||||
|
||||
if(_record) recordAction(ACTION_TYPE.var_modify, values[| 0], [ values[| 0].value, "value", prop.name ]);
|
||||
if(_record) recordAction(ACTION_TYPE.var_modify, values[| 0], [ values[| 0].value, "value", prop.name ], onUndo);
|
||||
|
||||
values[| 0].value = _val;
|
||||
return true;
|
||||
|
@ -545,7 +547,7 @@ function valueAnimator(_val, _prop, _sep_axis = false) constructor {
|
|||
if(ds_list_size(values) == 0) { // Should not be called normally
|
||||
var k = new valueKey(_time, _val, self, ease_in, ease_out);
|
||||
ds_list_add(values, k);
|
||||
if(_record) recordAction(ACTION_TYPE.list_insert, values, [ k, ds_list_size(values) - 1, $"add {prop.name} keyframe" ], function() { updateKeyMap(); });
|
||||
if(_record) recordAction(ACTION_TYPE.list_insert, values, [ k, ds_list_size(values) - 1, $"add {prop.name} keyframe" ], onUndo);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -555,7 +557,7 @@ function valueAnimator(_val, _prop, _sep_axis = false) constructor {
|
|||
if(!global.FLAG.keyframe_override) return false;
|
||||
|
||||
if(_key.value != _val) {
|
||||
if(_record) recordAction(ACTION_TYPE.var_modify, _key, [ _key.value, "value", prop.name ]);
|
||||
if(_record) recordAction(ACTION_TYPE.var_modify, _key, [ _key.value, "value", prop.name ], onUndo);
|
||||
_key.value = _val;
|
||||
return true;
|
||||
}
|
||||
|
@ -563,14 +565,14 @@ function valueAnimator(_val, _prop, _sep_axis = false) constructor {
|
|||
} else if(_key.time > _time) {
|
||||
var k = new valueKey(_time, _val, self, ease_in, ease_out);
|
||||
ds_list_insert(values, i, k);
|
||||
if(_record) recordAction(ACTION_TYPE.list_insert, values, [k, i, $"add {prop.name} keyframe" ], function() { updateKeyMap(); });
|
||||
if(_record) recordAction(ACTION_TYPE.list_insert, values, [k, i, $"add {prop.name} keyframe" ], onUndo);
|
||||
updateKeyMap();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
var k = new valueKey(_time, _val, self, ease_in, ease_out);
|
||||
if(_record) recordAction(ACTION_TYPE.list_insert, values, [ k, ds_list_size(values), $"add {prop.name} keyframe" ], function() { updateKeyMap(); });
|
||||
if(_record) recordAction(ACTION_TYPE.list_insert, values, [ k, ds_list_size(values), $"add {prop.name} keyframe" ], onUndo);
|
||||
ds_list_add(values, k);
|
||||
updateKeyMap();
|
||||
return true;
|
||||
|
|
|
@ -191,7 +191,11 @@ function Node_Lua_Compute(_x, _y, _group = noone) : Node(_x, _y, _group) constru
|
|||
doCompile();
|
||||
} #endregion
|
||||
|
||||
static onDestroy = function() { #region
|
||||
static onDestroy = function() {
|
||||
lua_state_destroy(lua_state);
|
||||
} #endregion
|
||||
}
|
||||
|
||||
static onRestore = function() {
|
||||
lua_state = lua_create();
|
||||
}
|
||||
}
|
|
@ -36,7 +36,11 @@ function Node_Lua_Global(_x, _y, _group = noone) : Node(_x, _y, _group) construc
|
|||
catch(e) { noti_warning(exception_print(e),, self); }
|
||||
} #endregion
|
||||
|
||||
static onDestroy = function() { #region
|
||||
static onDestroy = function() {
|
||||
lua_state_destroy(lua_state);
|
||||
} #endregion
|
||||
}
|
||||
|
||||
static onRestore = function() {
|
||||
lua_state = lua_create();
|
||||
}
|
||||
}
|
|
@ -191,7 +191,11 @@ function Node_Lua_Surface(_x, _y, _group = noone) : Node(_x, _y, _group) constru
|
|||
doCompile();
|
||||
} #endregion
|
||||
|
||||
static onDestroy = function() { #region
|
||||
static onDestroy = function() {
|
||||
lua_state_destroy(lua_state);
|
||||
} #endregion
|
||||
}
|
||||
|
||||
static onRestore = function() {
|
||||
lua_state = lua_create();
|
||||
}
|
||||
}
|
|
@ -24,12 +24,11 @@ function Node_Struct(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
|||
ds_list_add(_in, inputs[| i]);
|
||||
|
||||
for( var i = input_fix_len; i < ds_list_size(inputs); i += data_length ) {
|
||||
if(getInputData(i) != "") {
|
||||
var _val = inputs[| i].getValue();
|
||||
|
||||
if(_val != "") {
|
||||
ds_list_add(_in, inputs[| i + 0]);
|
||||
ds_list_add(_in, inputs[| i + 1].setVisible(false, true));
|
||||
} else {
|
||||
delete inputs[| i + 0];
|
||||
delete inputs[| i + 1];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,12 +43,12 @@ function Node_Struct(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
|||
|
||||
static onValueUpdate = function(index = 0) {
|
||||
if(LOADING || APPENDING) return;
|
||||
|
||||
refreshDynamicInput();
|
||||
|
||||
if(index < 0) return;
|
||||
|
||||
if(safe_mod(index - input_fix_len, data_length) == 0)
|
||||
inputs[| index + 1].name = getInputData(index) + " value";
|
||||
inputs[| index + 1].name = $"{getInputData(index)} value";
|
||||
|
||||
refreshDynamicInput();
|
||||
}
|
||||
|
||||
static step = function() {
|
||||
|
@ -68,6 +67,8 @@ function Node_Struct(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
|||
var val = getInputData(i + 1);
|
||||
var frm = inputs[| i + 1].value_from;
|
||||
|
||||
if(key == "") continue;
|
||||
|
||||
if(frm != noone && frm.type == VALUE_TYPE.surface)
|
||||
str[$ key] = new Surface(val);
|
||||
else if(frm != noone && frm.type == VALUE_TYPE.buffer)
|
||||
|
|
|
@ -40,16 +40,13 @@ function Node_Switch(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
|||
array_resize(input_display_list, input_display_len);
|
||||
|
||||
for( var i = input_fix_len; i < ds_list_size(inputs); i += data_length ) {
|
||||
if(getInputData(i) != "") {
|
||||
if(inputs[| i].getValue() != "") {
|
||||
ds_list_add(_in, inputs[| i + 0]);
|
||||
ds_list_add(_in, inputs[| i + 1]);
|
||||
inputs[| i + 1].setVisible(false, true);
|
||||
|
||||
array_push(input_display_list, i + 0);
|
||||
array_push(input_display_list, i + 1);
|
||||
} else {
|
||||
delete inputs[| i + 0];
|
||||
delete inputs[| i + 1];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,6 +61,7 @@ function Node_Switch(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
|||
|
||||
static onValueFromUpdate = function(index) { #region
|
||||
if(LOADING || APPENDING) return;
|
||||
if(index < 0) return;
|
||||
|
||||
inputs[| 1].setType(inputs[| 1].value_from? inputs[| 1].value_from.type : VALUE_TYPE.any);
|
||||
|
||||
|
@ -79,7 +77,7 @@ function Node_Switch(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
|||
if(LOADING || APPENDING) return;
|
||||
|
||||
if(safe_mod(index - input_fix_len, data_length) == 0) //Variable name
|
||||
inputs[| index + 1].name = getInputData(index) + " value";
|
||||
inputs[| index + 1].name = $"{getInputData(index)} value";
|
||||
|
||||
refreshDynamicInput();
|
||||
} #endregion
|
||||
|
|
|
@ -2163,6 +2163,8 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
|
|||
return controlNode.rendered;
|
||||
} #endregion
|
||||
|
||||
static triggerSetFrom = function() { node.valueUpdate(index); }
|
||||
|
||||
static setFrom = function(_valueFrom, _update = true, checkRecur = true, log = false) { #region ////Set from
|
||||
//print($"Connecting {_valueFrom.name} to {name}");
|
||||
|
||||
|
|
Loading…
Reference in a new issue