Fix animation button color.

This commit is contained in:
Tanasart 2023-11-04 19:22:52 +07:00
parent 3dade4c58f
commit faf6cce3ad
7 changed files with 69 additions and 48 deletions

View file

@ -95,7 +95,7 @@ _HOVERING_ELEMENT = noone;
_k = ds_map_find_next(PROJECT.nodeMap, _k); _k = ds_map_find_next(PROJECT.nodeMap, _k);
} }
if(IS_PLAYING || RENDERING) { if(IS_PLAYING || IS_RENDERING) {
if(PROJECT.animator.frame_progress) { if(PROJECT.animator.frame_progress) {
__addon_preAnim(); __addon_preAnim();

View file

@ -11,6 +11,7 @@
#macro CURRENT_FRAME PROJECT.animator.current_frame #macro CURRENT_FRAME PROJECT.animator.current_frame
#macro TOTAL_FRAMES PROJECT.animator.frames_total #macro TOTAL_FRAMES PROJECT.animator.frames_total
#macro RENDERING PROJECT.animator.rendering #macro RENDERING PROJECT.animator.rendering
#macro IS_RENDERING array_length(PROJECT.animator.rendering)
#endregion #endregion
#region animation class #region animation class
@ -24,7 +25,7 @@
frame_progress = false; frame_progress = false;
play_freeze = 0; play_freeze = 0;
rendering = 0; rendering = [];
playback = ANIMATOR_END.loop; playback = ANIMATOR_END.loop;
static setFrame = function(frame, resetTime = true) { static setFrame = function(frame, resetTime = true) {
@ -36,7 +37,7 @@
current_frame = round(frame); current_frame = round(frame);
if(current_frame == frames_total) { if(current_frame == frames_total) {
if(rendering) { if(array_length(rendering)) {
is_playing = false; is_playing = false;
setFrame(0); setFrame(0);
} else if(playback == ANIMATOR_END.stop) } else if(playback == ANIMATOR_END.stop)
@ -68,7 +69,6 @@
static render = function() { static render = function() {
setFrame(0); setFrame(0);
is_playing = true; is_playing = true;
rendering = true;
frame_progress = true; frame_progress = true;
time_since_last_frame = 0; time_since_last_frame = 0;
} }

View file

@ -123,9 +123,11 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x
updatedInTrigger.tags = VALUE_TAG.updateInTrigger; updatedInTrigger.tags = VALUE_TAG.updateInTrigger;
updatedOutTrigger.tags = VALUE_TAG.updateOutTrigger; updatedOutTrigger.tags = VALUE_TAG.updateOutTrigger;
insp1UpdateActive = true;
insp1UpdateTooltip = __txtx("panel_inspector_execute", "Execute node"); insp1UpdateTooltip = __txtx("panel_inspector_execute", "Execute node");
insp1UpdateIcon = [ THEME.sequence_control, 1, COLORS._main_value_positive ]; insp1UpdateIcon = [ THEME.sequence_control, 1, COLORS._main_value_positive ];
insp2UpdateActive = true;
insp2UpdateTooltip = __txtx("panel_inspector_execute", "Execute node"); insp2UpdateTooltip = __txtx("panel_inspector_execute", "Execute node");
insp2UpdateIcon = [ THEME.sequence_control, 1, COLORS._main_value_positive ]; insp2UpdateIcon = [ THEME.sequence_control, 1, COLORS._main_value_positive ];
@ -645,7 +647,7 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x
return true; return true;
} #endregion } #endregion
static isRenderActive = function() { return renderActive || (PREFERENCES.render_all_export && PROJECT.animator.rendering); } static isRenderActive = function() { return renderActive || (PREFERENCES.render_all_export && IS_RENDERING); }
static isRenderable = function(log = false) { #region //Check if every input is ready (updated) static isRenderable = function(log = false) { #region //Check if every input is ready (updated)
if(!active) return false; if(!active) return false;

View file

@ -20,7 +20,7 @@ MPEG-4 (.mp4)|*.mp4",
} }
function exportAll() { function exportAll() {
if(RENDERING) return; if(IS_RENDERING) return;
Render(); Render();
@ -207,7 +207,7 @@ function Node_Export(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
["Quality", false], 6, 7, 10, 13, ["Quality", false], 6, 7, 10, 13,
]; ];
render_process_id = undefined; render_process_id = 0;
render_type = ""; render_type = "";
render_target = ""; render_target = "";
@ -309,9 +309,12 @@ function Node_Export(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
cmd += "-bgcolor 0,0,0,0 "; cmd += "-bgcolor 0,0,0,0 ";
cmd += "-o " + string_quote(target_path); cmd += "-o " + string_quote(target_path);
array_remove(RENDERING, node_id);
render_process_id = shell_execute_async(webp, cmd, self); render_process_id = shell_execute_async(webp, cmd, self);
render_type = "webp"; render_type = "webp";
render_target = target_path; render_target = target_path;
if(render_process_id != 0) array_push(RENDERING, node_id);
} #endregion } #endregion
static renderGif = function(temp_path, target_path) { #region static renderGif = function(temp_path, target_path) { #region
@ -327,6 +330,8 @@ function Node_Export(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
var loop_str = loop? 0 : 1; var loop_str = loop? 0 : 1;
var use_gifski = false; var use_gifski = false;
array_remove(RENDERING, node_id);
if(use_gifski) { if(use_gifski) {
var shell_cmd = $"-o {string_quote(target_path)} -r {rate} --repeat {loop_str} -Q {qual} {string_quote(temp_path)}"; var shell_cmd = $"-o {string_quote(target_path)} -r {rate} --repeat {loop_str} -Q {qual} {string_quote(temp_path)}";
@ -343,6 +348,8 @@ function Node_Export(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
render_type = "gif"; render_type = "gif";
render_target = target_path; render_target = target_path;
if(render_process_id != 0) array_push(RENDERING, node_id);
} #endregion } #endregion
static renderMp4 = function(temp_path, target_path) { #region static renderMp4 = function(temp_path, target_path) { #region
@ -357,9 +364,12 @@ function Node_Export(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
var shell_cmd = $"-hide_banner -loglevel quiet -framerate {rate} -i \"{temp_path}%05d.png\" -c:v libx264 -r {rate} -pix_fmt yuv420p {string_quote(target_path)}"; var shell_cmd = $"-hide_banner -loglevel quiet -framerate {rate} -i \"{temp_path}%05d.png\" -c:v libx264 -r {rate} -pix_fmt yuv420p {string_quote(target_path)}";
print($"{ffmpeg} {shell_cmd}") print($"{ffmpeg} {shell_cmd}")
array_remove(RENDERING, node_id);
render_process_id = shell_execute_async(ffmpeg, shell_cmd, self); render_process_id = shell_execute_async(ffmpeg, shell_cmd, self);
render_type = "mp4"; render_type = "mp4";
render_target = target_path; render_target = target_path;
if(render_process_id != 0) array_push(RENDERING, node_id);
} #endregion } #endregion
static pathString = function(path, index = 0, _array = false) { #region static pathString = function(path, index = 0, _array = false) { #region
@ -594,6 +604,8 @@ function Node_Export(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
var extd = getInputData( 9); var extd = getInputData( 9);
var temp_path, target_path; var temp_path, target_path;
update_on_frame = false;
if(is_array(surf)) { if(is_array(surf)) {
for(var i = 0; i < array_length(surf); i++) { for(var i = 0; i < array_length(surf); i++) {
temp_path = $"{directory}/{i}/*.png"; temp_path = $"{directory}/{i}/*.png";
@ -644,16 +656,16 @@ function Node_Export(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
insp2UpdateIcon = [ THEME.play_all, 0, COLORS._main_value_positive ]; insp2UpdateIcon = [ THEME.play_all, 0, COLORS._main_value_positive ];
static onInspector1Update = function() { #region static onInspector1Update = function() { #region
if(RENDERING) return; if(IS_RENDERING) return;
if(isInLoop()) RENDER_ALL if(isInLoop()) RENDER_ALL
else doInspectorAction(); else doInspectorAction();
} #endregion } #endregion
static onInspector2Update = function() { static onInspector2Update = function() { #region
if(RENDERING) return; if(IS_RENDERING) return;
exportAll(); exportAll();
} } #endregion
static doInspectorAction = function() { #region static doInspectorAction = function() { #region
if(LOADING || APPENDING) return; if(LOADING || APPENDING) return;
@ -663,21 +675,22 @@ function Node_Export(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
var form = getInputData(3); var form = getInputData(3);
if(form == NODE_EXPORT_FORMAT.single) { if(form == NODE_EXPORT_FORMAT.single) {
RENDERING++; array_push(RENDERING, node_id);
Render(); Render();
RENDERING--; array_remove(RENDERING, node_id);
export(); export();
updatedOutTrigger.setValue(true); updatedOutTrigger.setValue(true);
return; return;
} }
playing = true; update_on_frame = true;
played = 0; playing = true;
played = 0;
PROJECT.animator.real_frame = -1; PROJECT.animator.real_frame = -1;
CURRENT_FRAME = -1; CURRENT_FRAME = -1;
IS_PLAYING = true; IS_PLAYING = true;
RENDERING++; array_push(RENDERING, node_id);
if(directory_exists(directory)) if(directory_exists(directory))
directory_destroy(directory); directory_destroy(directory);
@ -685,8 +698,8 @@ function Node_Export(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
} #endregion } #endregion
static step = function() { #region static step = function() { #region
insp1UpdateIcon[2] = RENDERING? COLORS._main_icon_dark : COLORS._main_value_positive; insp1UpdateActive = !IS_RENDERING;
insp2UpdateIcon[2] = RENDERING? COLORS._main_icon_dark : COLORS._main_value_positive; insp2UpdateActive = !IS_RENDERING;
var surf = getInputData( 0); var surf = getInputData( 0);
var pngf = getInputData(13); var pngf = getInputData(13);
@ -726,16 +739,16 @@ function Node_Export(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
outputs[| 0].visible = isInLoop(); outputs[| 0].visible = isInLoop();
if(render_process_id != undefined) { if(render_process_id != 0) {
var res = ProcIdExists(render_process_id); var res = ProcIdExists(render_process_id);
if(res == 0) { if(res == 0) {
var noti = log_message("EXPORT", $"Export {render_type} as {render_target}", THEME.noti_icon_tick, COLORS._main_value_positive, false); var noti = log_message("EXPORT", $"Export {render_type} as {render_target}", THEME.noti_icon_tick, COLORS._main_value_positive, false);
noti.path = filename_dir(render_target); noti.path = filename_dir(render_target);
noti.setOnClick(function() { shellOpenExplorer(self.path); }, "Open in explorer", THEME.explorer); noti.setOnClick(function() { shellOpenExplorer(self.path); }, "Open in explorer", THEME.explorer);
PANEL_MENU.setNotiIcon(THEME.noti_icon_tick); PANEL_MENU.setNotiIcon(THEME.noti_icon_tick);
render_process_id = undefined; render_process_id = 0;
RENDERING--; array_remove(RENDERING, node_id);
} }
} }
} #endregion } #endregion
@ -752,8 +765,7 @@ function Node_Export(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
return; return;
} }
if(!PROJECT.animator.frame_progress || !playing || CURRENT_FRAME <= -1) if(!playing) return;
return;
export(); export();
@ -763,7 +775,7 @@ function Node_Export(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region
graph_preview_alpha = 1; graph_preview_alpha = 1;
if(render_process_id != undefined) { if(render_process_id != 0) {
graph_preview_alpha = 0.5; graph_preview_alpha = 0.5;
draw_sprite_ui(THEME.loading, 0, xx + w * _s / 2, yy + h * _s / 2, _s, _s, current_time / 2, COLORS._main_icon, 1); draw_sprite_ui(THEME.loading, 0, xx + w * _s / 2, yy + h * _s / 2, _s, _s, current_time / 2, COLORS._main_icon, 1);
} }

View file

@ -87,7 +87,7 @@ function Node_Render_Sprite_Sheet(_x, _y, _group = noone) : Node(_x, _y, _group)
if(grup != SPRITE_ANIM_GROUP.animation) { if(grup != SPRITE_ANIM_GROUP.animation) {
initRender(); initRender();
return; return;
} else if(RENDERING && PROJECT.animator.frame_progress && CURRENT_FRAME == 0 && !refreshSurface) { } else if(IS_RENDERING && PROJECT.animator.frame_progress && CURRENT_FRAME == 0 && !refreshSurface) {
var skip = getInputData(2); var skip = getInputData(2);
var arr = is_array(inpt); var arr = is_array(inpt);

View file

@ -135,50 +135,50 @@ function Panel_Animation() : PanelContent() constructor {
[ [
function() { return __txt("Stop"); }, function() { return __txt("Stop"); },
function() { return 4; }, function() { return 4; },
function() { if(RENDERING) return COLORS._main_icon_dark; return PROJECT.animator.is_playing? COLORS._main_accent : COLORS._main_icon; }, function() { return PROJECT.animator.is_playing? COLORS._main_accent : COLORS._main_icon; },
function() { if(RENDERING) return; PROJECT.animator.stop(); } function() { return; PROJECT.animator.stop(); }
], ],
[ [
function() { return PROJECT.animator.is_playing? __txt("Pause") : __txt("Play"); }, function() { return PROJECT.animator.is_playing? __txt("Pause") : __txt("Play"); },
function() { return !PROJECT.animator.is_playing; }, function() { return !PROJECT.animator.is_playing; },
function() { if(RENDERING) return COLORS._main_icon_dark; return PROJECT.animator.is_playing? COLORS._main_accent : COLORS._main_icon; }, function() { return PROJECT.animator.is_playing? COLORS._main_accent : COLORS._main_icon; },
function() { if(RENDERING) return; if(PROJECT.animator.is_playing) PROJECT.animator.pause(); else PROJECT.animator.resume(); } function() { return; if(PROJECT.animator.is_playing) PROJECT.animator.pause(); else PROJECT.animator.resume(); }
], ],
[ [
function() { return __txtx("panel_animation_go_to_first_frame", "Go to first frame"); }, function() { return __txtx("panel_animation_go_to_first_frame", "Go to first frame"); },
function() { return 3; }, function() { return 3; },
function() { if(RENDERING) return COLORS._main_icon_dark; return COLORS._main_icon; }, function() { return COLORS._main_icon; },
function() { if(RENDERING) return; PROJECT.animator.setFrame(0); } function() { return; PROJECT.animator.setFrame(0); }
], ],
[ [
function() { return __txtx("panel_animation_go_to_last_frame", "Go to last frame"); }, function() { return __txtx("panel_animation_go_to_last_frame", "Go to last frame"); },
function() { return 2; }, function() { return 2; },
function() { if(RENDERING) return COLORS._main_icon_dark; return COLORS._main_icon; }, function() { return COLORS._main_icon; },
function() { if(RENDERING) return; PROJECT.animator.setFrame(TOTAL_FRAMES - 1); } function() { return; PROJECT.animator.setFrame(TOTAL_FRAMES - 1); }
], ],
[ [
function() { return __txtx("panel_animation_previous_frame", "Previous frame"); }, function() { return __txtx("panel_animation_previous_frame", "Previous frame"); },
function() { return 5; }, function() { return 5; },
function() { if(RENDERING) return COLORS._main_icon_dark; return COLORS._main_icon; }, function() { return COLORS._main_icon; },
function() { if(RENDERING) return; PROJECT.animator.setFrame(PROJECT.animator.real_frame - 1); } function() { return; PROJECT.animator.setFrame(PROJECT.animator.real_frame - 1); }
], ],
[ [
function() { return __txtx("panel_animation_next_frame", "Next frame"); }, function() { return __txtx("panel_animation_next_frame", "Next frame"); },
function() { return 6; }, function() { return 6; },
function() { if(RENDERING) return COLORS._main_icon_dark; return COLORS._main_icon; }, function() { return COLORS._main_icon; },
function() { if(RENDERING) return; PROJECT.animator.setFrame(PROJECT.animator.real_frame + 1); } function() { return; PROJECT.animator.setFrame(PROJECT.animator.real_frame + 1); }
], ],
]; ];
#endregion #endregion
#region ++++ hotkeys ++++ #region ++++ hotkeys ++++
addHotkey("", "Play/Pause", vk_space, MOD_KEY.none, function() { if(RENDERING) return; if(IS_PLAYING) PROJECT.animator.pause() else PROJECT.animator.play(); }); addHotkey("", "Play/Pause", vk_space, MOD_KEY.none, function() { if(IS_RENDERING) return; if(IS_PLAYING) PROJECT.animator.pause() else PROJECT.animator.play(); });
addHotkey("", "Resume/Pause", vk_space, MOD_KEY.shift,function() { if(RENDERING) return; if(PROJECT.animator.is_playing) PROJECT.animator.pause() else PROJECT.animator.resume(); }); addHotkey("", "Resume/Pause", vk_space, MOD_KEY.shift,function() { if(IS_RENDERING) return; if(PROJECT.animator.is_playing) PROJECT.animator.pause() else PROJECT.animator.resume(); });
addHotkey("", "First frame", vk_home, MOD_KEY.none, function() { if(RENDERING) return; PROJECT.animator.setFrame(0); }); addHotkey("", "First frame", vk_home, MOD_KEY.none, function() { if(IS_RENDERING) return; PROJECT.animator.setFrame(0); });
addHotkey("", "Last frame", vk_end, MOD_KEY.none, function() { if(RENDERING) return; PROJECT.animator.setFrame(TOTAL_FRAMES - 1); }); addHotkey("", "Last frame", vk_end, MOD_KEY.none, function() { if(IS_RENDERING) return; PROJECT.animator.setFrame(TOTAL_FRAMES - 1); });
addHotkey("", "Next frame", vk_right, MOD_KEY.none, function() { if(RENDERING) return; PROJECT.animator.setFrame(min(PROJECT.animator.real_frame + 1, TOTAL_FRAMES - 1)); }); addHotkey("", "Next frame", vk_right, MOD_KEY.none, function() { if(IS_RENDERING) return; PROJECT.animator.setFrame(min(PROJECT.animator.real_frame + 1, TOTAL_FRAMES - 1)); });
addHotkey("", "Previous frame", vk_left, MOD_KEY.none, function() { if(RENDERING) return; PROJECT.animator.setFrame(max(PROJECT.animator.real_frame - 1, 0)); }); addHotkey("", "Previous frame", vk_left, MOD_KEY.none, function() { if(IS_RENDERING) return; PROJECT.animator.setFrame(max(PROJECT.animator.real_frame - 1, 0)); });
addHotkey("Animation", "Delete keys", vk_delete, MOD_KEY.none, function() { PANEL_ANIMATION.deleteKeys(); }); addHotkey("Animation", "Delete keys", vk_delete, MOD_KEY.none, function() { PANEL_ANIMATION.deleteKeys(); });
addHotkey("Animation", "Duplicate", "D", MOD_KEY.ctrl, function() { PANEL_ANIMATION.doDuplicate(); }); addHotkey("Animation", "Duplicate", "D", MOD_KEY.ctrl, function() { PANEL_ANIMATION.doDuplicate(); });
@ -1838,6 +1838,8 @@ function Panel_Animation() : PanelContent() constructor {
var row = ceil(amo / col); var row = ceil(amo / col);
if(col < 1) return; if(col < 1) return;
var _act = !IS_RENDERING;
for( var i = 0; i < row; i++ ) { for( var i = 0; i < row; i++ ) {
var colAmo = min(amo - i * col, col); var colAmo = min(amo - i * col, col);
if(mini) if(mini)
@ -1849,10 +1851,10 @@ function Panel_Animation() : PanelContent() constructor {
var but = control_buttons[ind]; var but = control_buttons[ind];
var txt = but[0](); var txt = but[0]();
var ind = but[1](); var ind = but[1]();
var cc = but[2](); var cc = _act? but[2]() : COLORS._main_icon_dark;
var fnc = but[3]; var fnc = but[3];
if(buttonInstant(THEME.button_hide, bx, by, ui(32), ui(32), [mx, my], pFOCUS, pHOVER, txt, THEME.sequence_control, ind, cc) == 2) if(buttonInstant(THEME.button_hide, bx, by, ui(32), ui(32), [mx, my], pFOCUS && _act, pHOVER && _act, txt, THEME.sequence_control, ind, cc) == 2)
fnc(); fnc();
bx += ui(36); bx += ui(36);

View file

@ -757,7 +757,10 @@ function Panel_Inspector() : PanelContent() constructor {
if(inspecting.hasInspector1Update(true)) { if(inspecting.hasInspector1Update(true)) {
var icon = inspecting.insp1UpdateIcon; var icon = inspecting.insp1UpdateIcon;
if(buttonInstant(THEME.button_hide, bx, by, ui(32), ui(32), [mx, my], pFOCUS, pHOVER, inspecting.insp1UpdateTooltip, icon[0], icon[1], icon[2]) == 2) var ac = inspecting.insp1UpdateActive;
var cc = ac? icon[2] : COLORS._main_icon_dark;
if(buttonInstant(THEME.button_hide, bx, by, ui(32), ui(32), [mx, my], pFOCUS && ac, pHOVER && ac, inspecting.insp1UpdateTooltip, icon[0], icon[1], cc) == 2)
inspecting.inspector1Update(); inspecting.inspector1Update();
} else } else
draw_sprite_ui(THEME.sequence_control, 1, bx + ui(16), by + ui(16),,,, COLORS._main_icon_dark); draw_sprite_ui(THEME.sequence_control, 1, bx + ui(16), by + ui(16),,,, COLORS._main_icon_dark);
@ -765,8 +768,10 @@ function Panel_Inspector() : PanelContent() constructor {
if(inspecting.hasInspector2Update()) { if(inspecting.hasInspector2Update()) {
by += ui(36); by += ui(36);
var icon = inspecting.insp2UpdateIcon; var icon = inspecting.insp2UpdateIcon;
var ac = inspecting.insp2UpdateActive;
var cc = ac? icon[2] : COLORS._main_icon_dark;
if(buttonInstant(THEME.button_hide, bx, by, ui(32), ui(32), [mx, my], pFOCUS, pHOVER, inspecting.insp2UpdateTooltip, icon[0], icon[1], icon[2]) = 2) if(buttonInstant(THEME.button_hide, bx, by, ui(32), ui(32), [mx, my], pFOCUS && ac, pHOVER && ac, inspecting.insp2UpdateTooltip, icon[0], icon[1], cc) = 2)
inspecting.inspector2Update(); inspecting.inspector2Update();
} }
} #endregion } #endregion