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);
}
if(IS_PLAYING || RENDERING) {
if(IS_PLAYING || IS_RENDERING) {
if(PROJECT.animator.frame_progress) {
__addon_preAnim();

View File

@ -11,6 +11,7 @@
#macro CURRENT_FRAME PROJECT.animator.current_frame
#macro TOTAL_FRAMES PROJECT.animator.frames_total
#macro RENDERING PROJECT.animator.rendering
#macro IS_RENDERING array_length(PROJECT.animator.rendering)
#endregion
#region animation class
@ -24,7 +25,7 @@
frame_progress = false;
play_freeze = 0;
rendering = 0;
rendering = [];
playback = ANIMATOR_END.loop;
static setFrame = function(frame, resetTime = true) {
@ -36,7 +37,7 @@
current_frame = round(frame);
if(current_frame == frames_total) {
if(rendering) {
if(array_length(rendering)) {
is_playing = false;
setFrame(0);
} else if(playback == ANIMATOR_END.stop)
@ -68,7 +69,6 @@
static render = function() {
setFrame(0);
is_playing = true;
rendering = true;
frame_progress = true;
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;
updatedOutTrigger.tags = VALUE_TAG.updateOutTrigger;
insp1UpdateActive = true;
insp1UpdateTooltip = __txtx("panel_inspector_execute", "Execute node");
insp1UpdateIcon = [ THEME.sequence_control, 1, COLORS._main_value_positive ];
insp2UpdateActive = true;
insp2UpdateTooltip = __txtx("panel_inspector_execute", "Execute node");
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;
} #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)
if(!active) return false;

View File

@ -20,7 +20,7 @@ MPEG-4 (.mp4)|*.mp4",
}
function exportAll() {
if(RENDERING) return;
if(IS_RENDERING) return;
Render();
@ -207,7 +207,7 @@ function Node_Export(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
["Quality", false], 6, 7, 10, 13,
];
render_process_id = undefined;
render_process_id = 0;
render_type = "";
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 += "-o " + string_quote(target_path);
array_remove(RENDERING, node_id);
render_process_id = shell_execute_async(webp, cmd, self);
render_type = "webp";
render_target = target_path;
if(render_process_id != 0) array_push(RENDERING, node_id);
} #endregion
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 use_gifski = false;
array_remove(RENDERING, node_id);
if(use_gifski) {
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_target = target_path;
if(render_process_id != 0) array_push(RENDERING, node_id);
} #endregion
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)}";
print($"{ffmpeg} {shell_cmd}")
array_remove(RENDERING, node_id);
render_process_id = shell_execute_async(ffmpeg, shell_cmd, self);
render_type = "mp4";
render_target = target_path;
if(render_process_id != 0) array_push(RENDERING, node_id);
} #endregion
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 temp_path, target_path;
update_on_frame = false;
if(is_array(surf)) {
for(var i = 0; i < array_length(surf); i++) {
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 ];
static onInspector1Update = function() { #region
if(RENDERING) return;
if(IS_RENDERING) return;
if(isInLoop()) RENDER_ALL
else doInspectorAction();
} #endregion
static onInspector2Update = function() {
if(RENDERING) return;
static onInspector2Update = function() { #region
if(IS_RENDERING) return;
exportAll();
}
} #endregion
static doInspectorAction = function() { #region
if(LOADING || APPENDING) return;
@ -663,21 +675,22 @@ function Node_Export(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
var form = getInputData(3);
if(form == NODE_EXPORT_FORMAT.single) {
RENDERING++;
array_push(RENDERING, node_id);
Render();
RENDERING--;
array_remove(RENDERING, node_id);
export();
updatedOutTrigger.setValue(true);
return;
}
playing = true;
played = 0;
update_on_frame = true;
playing = true;
played = 0;
PROJECT.animator.real_frame = -1;
CURRENT_FRAME = -1;
IS_PLAYING = true;
RENDERING++;
array_push(RENDERING, node_id);
if(directory_exists(directory))
directory_destroy(directory);
@ -685,8 +698,8 @@ function Node_Export(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
} #endregion
static step = function() { #region
insp1UpdateIcon[2] = RENDERING? COLORS._main_icon_dark : COLORS._main_value_positive;
insp2UpdateIcon[2] = RENDERING? COLORS._main_icon_dark : COLORS._main_value_positive;
insp1UpdateActive = !IS_RENDERING;
insp2UpdateActive = !IS_RENDERING;
var surf = getInputData( 0);
var pngf = getInputData(13);
@ -726,16 +739,16 @@ function Node_Export(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
outputs[| 0].visible = isInLoop();
if(render_process_id != undefined) {
if(render_process_id != 0) {
var res = ProcIdExists(render_process_id);
if(res == 0) {
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.setOnClick(function() { shellOpenExplorer(self.path); }, "Open in explorer", THEME.explorer);
PANEL_MENU.setNotiIcon(THEME.noti_icon_tick);
render_process_id = undefined;
render_process_id = 0;
RENDERING--;
array_remove(RENDERING, node_id);
}
}
} #endregion
@ -752,8 +765,7 @@ function Node_Export(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
return;
}
if(!PROJECT.animator.frame_progress || !playing || CURRENT_FRAME <= -1)
return;
if(!playing) return;
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
graph_preview_alpha = 1;
if(render_process_id != undefined) {
if(render_process_id != 0) {
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);
}

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) {
initRender();
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 arr = is_array(inpt);

View File

@ -135,50 +135,50 @@ function Panel_Animation() : PanelContent() constructor {
[
function() { return __txt("Stop"); },
function() { return 4; },
function() { if(RENDERING) return COLORS._main_icon_dark; return PROJECT.animator.is_playing? COLORS._main_accent : COLORS._main_icon; },
function() { if(RENDERING) return; PROJECT.animator.stop(); }
function() { return PROJECT.animator.is_playing? COLORS._main_accent : COLORS._main_icon; },
function() { return; PROJECT.animator.stop(); }
],
[
function() { return PROJECT.animator.is_playing? __txt("Pause") : __txt("Play"); },
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() { if(RENDERING) return; if(PROJECT.animator.is_playing) PROJECT.animator.pause(); else PROJECT.animator.resume(); }
function() { return PROJECT.animator.is_playing? COLORS._main_accent : COLORS._main_icon; },
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 3; },
function() { if(RENDERING) return COLORS._main_icon_dark; return COLORS._main_icon; },
function() { if(RENDERING) return; PROJECT.animator.setFrame(0); }
function() { return COLORS._main_icon; },
function() { return; PROJECT.animator.setFrame(0); }
],
[
function() { return __txtx("panel_animation_go_to_last_frame", "Go to last frame"); },
function() { return 2; },
function() { if(RENDERING) return COLORS._main_icon_dark; return COLORS._main_icon; },
function() { if(RENDERING) return; PROJECT.animator.setFrame(TOTAL_FRAMES - 1); }
function() { return COLORS._main_icon; },
function() { return; PROJECT.animator.setFrame(TOTAL_FRAMES - 1); }
],
[
function() { return __txtx("panel_animation_previous_frame", "Previous frame"); },
function() { return 5; },
function() { if(RENDERING) return COLORS._main_icon_dark; return COLORS._main_icon; },
function() { if(RENDERING) return; PROJECT.animator.setFrame(PROJECT.animator.real_frame - 1); }
function() { return COLORS._main_icon; },
function() { return; PROJECT.animator.setFrame(PROJECT.animator.real_frame - 1); }
],
[
function() { return __txtx("panel_animation_next_frame", "Next frame"); },
function() { return 6; },
function() { if(RENDERING) return COLORS._main_icon_dark; return COLORS._main_icon; },
function() { if(RENDERING) return; PROJECT.animator.setFrame(PROJECT.animator.real_frame + 1); }
function() { return COLORS._main_icon; },
function() { return; PROJECT.animator.setFrame(PROJECT.animator.real_frame + 1); }
],
];
#endregion
#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("", "Resume/Pause", vk_space, MOD_KEY.shift,function() { if(RENDERING) return; if(PROJECT.animator.is_playing) PROJECT.animator.pause() else PROJECT.animator.resume(); });
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(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("", "Last frame", vk_end, MOD_KEY.none, function() { if(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("", "Previous frame", vk_left, MOD_KEY.none, function() { if(RENDERING) return; PROJECT.animator.setFrame(max(PROJECT.animator.real_frame - 1, 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(IS_RENDERING) return; PROJECT.animator.setFrame(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(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", "Duplicate", "D", MOD_KEY.ctrl, function() { PANEL_ANIMATION.doDuplicate(); });
@ -1838,6 +1838,8 @@ function Panel_Animation() : PanelContent() constructor {
var row = ceil(amo / col);
if(col < 1) return;
var _act = !IS_RENDERING;
for( var i = 0; i < row; i++ ) {
var colAmo = min(amo - i * col, col);
if(mini)
@ -1849,10 +1851,10 @@ function Panel_Animation() : PanelContent() constructor {
var but = control_buttons[ind];
var txt = but[0]();
var ind = but[1]();
var cc = but[2]();
var cc = _act? but[2]() : COLORS._main_icon_dark;
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();
bx += ui(36);

View File

@ -757,7 +757,10 @@ function Panel_Inspector() : PanelContent() constructor {
if(inspecting.hasInspector1Update(true)) {
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();
} else
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()) {
by += ui(36);
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();
}
} #endregion