diff options
Diffstat (limited to 'editor/animation_track_editor.cpp')
-rw-r--r-- | editor/animation_track_editor.cpp | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 9f6fa74dd3..def55d6057 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -544,7 +544,7 @@ public: if (use_fps && animation->get_step() > 0) { float max_frame = animation->get_length() / animation->get_step(); - p_list->push_back(PropertyInfo(Variant::REAL, "frame", PROPERTY_HINT_RANGE, "0," + rtos(max_frame) + ",0.01")); + p_list->push_back(PropertyInfo(Variant::REAL, "frame", PROPERTY_HINT_RANGE, "0," + rtos(max_frame) + ",1")); } else { p_list->push_back(PropertyInfo(Variant::REAL, "time", PROPERTY_HINT_RANGE, "0," + rtos(animation->get_length()) + ",0.01")); } @@ -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; @@ -4116,6 +4122,7 @@ void AnimationTrackEditor::_update_key_edit() { key_edit = memnew(AnimationTrackKeyEdit); key_edit->animation = animation; key_edit->track = selection.front()->key().track; + key_edit->use_fps = timeline->is_using_fps(); float ofs = animation->track_get_key_time(key_edit->track, selection.front()->key().key); key_edit->key_ofs = ofs; @@ -4889,7 +4896,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; @@ -5021,7 +5035,7 @@ AnimationTrackEditor::AnimationTrackEditor() { bottom_hb->add_child(memnew(VSeparator)); snap = memnew(ToolButton); - snap->set_text(TTR("Snap: ")); + snap->set_text(TTR("Snap:") + " "); bottom_hb->add_child(snap); snap->set_disabled(true); snap->set_toggle_mode(true); |