1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-06 12:20:30 +00:00

Add animation reset track feature

As a bonus, to have consistency between use Beziers and create insert tracks, use Beziers also gets a default via editor settings that is used when the confirmation dialog is disabled, instead of just falling back to creating non-Bezier tracks.
This commit is contained in:
Pedro J. Estébanez
2020-12-20 11:46:44 +01:00
parent 90f13520dd
commit 4da9a501f6
11 changed files with 301 additions and 84 deletions

View File

@@ -116,6 +116,21 @@ void AnimationPlayerEditor::_notification(int p_what) {
play_bw_from->set_icon(get_icon("PlayBackwards", "EditorIcons"));
autoplay_icon = get_icon("AutoPlay", "EditorIcons");
reset_icon = get_icon("Reload", "EditorIcons");
{
Ref<Image> autoplay_img = autoplay_icon->get_data();
Ref<Image> reset_img = reset_icon->get_data();
Ref<Image> autoplay_reset_img;
Size2 icon_size = Size2(autoplay_img->get_width(), autoplay_img->get_height());
autoplay_reset_img.instance();
autoplay_reset_img->create(icon_size.x * 2, icon_size.y, false, autoplay_img->get_format());
autoplay_reset_img->blit_rect(autoplay_img, Rect2(Point2(), icon_size), Point2());
autoplay_reset_img->blit_rect(reset_img, Rect2(Point2(), icon_size), Point2(icon_size.x, 0));
Ref<ImageTexture> temp_icon;
temp_icon.instance();
temp_icon->create_from_image(autoplay_reset_img);
autoplay_reset_icon = temp_icon;
}
stop->set_icon(get_icon("Stop", "EditorIcons"));
onion_toggle->set_icon(get_icon("Onion", "EditorIcons"));
@@ -816,11 +831,17 @@ void AnimationPlayerEditor::_update_player() {
int active_idx = -1;
for (List<StringName>::Element *E = animlist.front(); E; E = E->next()) {
if (player->get_autoplay() == E->get()) {
animation->add_icon_item(autoplay_icon, E->get());
} else {
animation->add_item(E->get());
Ref<Texture> icon;
if (E->get() == player->get_autoplay()) {
if (E->get() == "RESET") {
icon = autoplay_reset_icon;
} else {
icon = autoplay_icon;
}
} else if (E->get() == "RESET") {
icon = reset_icon;
}
animation->add_icon_item(icon, E->get());
if (player->get_assigned_animation() == E->get()) {
active_idx = animation->get_item_count() - 1;
@@ -1368,7 +1389,7 @@ void AnimationPlayerEditor::_prepare_onion_layers_2() {
}
// Backup current animation state.
AnimatedValuesBackup values_backup = player->backup_animated_values();
Ref<AnimatedValuesBackup> values_backup = player->backup_animated_values();
float cpos = player->get_current_animation_position();
// Render every past/future step with the capture shader.
@@ -1397,8 +1418,8 @@ void AnimationPlayerEditor::_prepare_onion_layers_2() {
onion.captures_valid.write[cidx] = valid;
if (valid) {
player->seek(pos, true);
get_tree()->flush_transform_notifications(); // Needed for transforms of Spatials.
values_backup.update_skeletons(); // Needed for Skeletons (2D & 3D).
get_tree()->flush_transform_notifications(); // Needed for transforms of Node3Ds.
values_backup->update_skeletons(); // Needed for Skeletons (2D & 3D).
VS::get_singleton()->viewport_set_active(onion.captures[cidx], true);
VS::get_singleton()->viewport_set_parent_viewport(root_vp, onion.captures[cidx]);
@@ -1418,7 +1439,7 @@ void AnimationPlayerEditor::_prepare_onion_layers_2() {
// (Seeking with update=true wouldn't do the trick because the current value of the properties
// may not match their value for the current point in the animation).
player->seek(cpos, false);
player->restore_animated_values(values_backup);
values_backup->restore();
// Restore state of main editors.
if (SpatialEditor::get_singleton()->is_visible()) {