AnimationPlayer FPS mode fixes

This commit is contained in:
homer666 2019-04-15 13:33:04 +10:00
parent 325f6c6581
commit e3b7f9e1ca
1 changed files with 17 additions and 4 deletions

View File

@ -1022,8 +1022,14 @@ void AnimationTimelineEdit::update_values() {
editing = true;
if (use_fps && animation->get_step() > 0) {
length->set_value(animation->get_length() / animation->get_step());
length->set_step(1);
length->set_tooltip(TTR("Animation length (frames)"));
time_icon->set_tooltip(TTR("Animation length (frames)"));
} else {
length->set_value(animation->get_length());
length->set_step(0.01);
length->set_tooltip(TTR("Animation length (seconds)"));
time_icon->set_tooltip(TTR("Animation length (seconds)"));
}
loop->set_pressed(animation->has_loop());
editing = false;
@ -1168,7 +1174,7 @@ AnimationTimelineEdit::AnimationTimelineEdit() {
len_hb->add_child(expander);
time_icon = memnew(TextureRect);
time_icon->set_v_size_flags(SIZE_SHRINK_CENTER);
time_icon->set_tooltip(TTR("Animation Length Time (seconds)"));
time_icon->set_tooltip(TTR("Animation length (seconds)"));
len_hb->add_child(time_icon);
length = memnew(EditorSpinSlider);
length->set_min(0.001);
@ -1177,7 +1183,7 @@ AnimationTimelineEdit::AnimationTimelineEdit() {
length->set_allow_greater(true);
length->set_custom_minimum_size(Vector2(70 * EDSCALE, 0));
length->set_hide_slider(true);
length->set_tooltip(TTR("Animation Length Time (seconds)"));
length->set_tooltip(TTR("Animation length (seconds)"));
length->connect("value_changed", this, "_anim_length_changed");
len_hb->add_child(length);
loop = memnew(ToolButton);
@ -3857,7 +3863,7 @@ void AnimationTrackEditor::_insert_key_from_track(float p_ofs, int p_track) {
ERR_FAIL_INDEX(p_track, animation->get_track_count());
if (snap->is_pressed() && step->get_value() != 0) {
p_ofs = Math::stepify(p_ofs, step->get_value());
p_ofs = snap_time(p_ofs);
}
while (animation->track_find_key(p_track, p_ofs, true) != -1) { //make sure insertion point is valid
p_ofs += 0.001;
@ -4889,7 +4895,14 @@ void AnimationTrackEditor::_selection_changed() {
float AnimationTrackEditor::snap_time(float p_value) {
if (snap->is_pressed()) {
p_value = Math::stepify(p_value, step->get_value());
double snap_increment;
if (timeline->is_using_fps() && step->get_value() > 0)
snap_increment = 1.0 / step->get_value();
else
snap_increment = step->get_value();
p_value = Math::stepify(p_value, snap_increment);
}
return p_value;