diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-04-30 10:15:30 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-30 10:15:30 +0200 |
commit | e98ccaefe8bfe636cb7fc43667a41e7fce69ec45 (patch) | |
tree | e0ec13e1bf2f4cf96d80094d1504c7b8d1b6cec6 | |
parent | d0e628fa55da50bd4841f1865b47bb6b283fb886 (diff) | |
parent | e5c8e4019bc83a893c1b09a3671ffae8d493d77a (diff) |
Merge pull request #28323 from homer666/animationplayer-imported-anim-warning
Warn when opening imported anim in Animation editor
-rw-r--r-- | editor/animation_track_editor.cpp | 27 | ||||
-rw-r--r-- | editor/animation_track_editor.h | 3 |
2 files changed, 30 insertions, 0 deletions
diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index def55d6057..4dff7d5b69 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -2547,6 +2547,15 @@ void AnimationTrackEditor::set_animation(const Ref<Animation> &p_anim) { step->set_read_only(false); snap->set_disabled(false); snap_mode->set_disabled(false); + + imported_anim_warning->hide(); + for (int i = 0; i < animation->get_track_count(); i++) { + if (animation->track_is_imported(i)) { + imported_anim_warning->show(); + break; + } + } + } else { hscroll->hide(); edit->set_disabled(true); @@ -3616,6 +3625,7 @@ void AnimationTrackEditor::_notification(int p_what) { snap->set_icon(get_icon("Snap", "EditorIcons")); view_group->set_icon(get_icon(view_group->is_pressed() ? "AnimationTrackList" : "AnimationTrackGroup", "EditorIcons")); selected_filter->set_icon(get_icon("AnimationFilter", "EditorIcons")); + imported_anim_warning->set_icon(get_icon("NodeWarning", "EditorIcons")); main_panel->add_style_override("panel", get_stylebox("bg", "Tree")); } @@ -4909,6 +4919,15 @@ float AnimationTrackEditor::snap_time(float p_value) { return p_value; } +void AnimationTrackEditor::_show_imported_anim_warning() const { + + EditorNode::get_singleton()->show_warning(TTR("This animation belongs to an imported scene, so changes to imported tracks will not be saved.\n\n" + "To enable the ability to add custom tracks, navigate to the scene's import settings and set\n" + "\"Animation > Storage\" to \"Files\", enable \"Animation > Keep Custom Tracks\", then re-import.\n" + "Alternatively, use an import preset that imports animations to separate files."), + TTR("Warning: Editing imported animation")); +} + void AnimationTrackEditor::_bind_methods() { ClassDB::bind_method("_animation_changed", &AnimationTrackEditor::_animation_changed); @@ -4947,6 +4966,7 @@ void AnimationTrackEditor::_bind_methods() { ClassDB::bind_method("_view_group_toggle", &AnimationTrackEditor::_view_group_toggle); ClassDB::bind_method("_selection_changed", &AnimationTrackEditor::_selection_changed); ClassDB::bind_method("_snap_mode_changed", &AnimationTrackEditor::_snap_mode_changed); + ClassDB::bind_method("_show_imported_anim_warning", &AnimationTrackEditor::_show_imported_anim_warning); ADD_SIGNAL(MethodInfo("timeline_changed", PropertyInfo(Variant::REAL, "position"), PropertyInfo(Variant::BOOL, "drag"))); ADD_SIGNAL(MethodInfo("keying_changed")); @@ -5017,6 +5037,13 @@ AnimationTrackEditor::AnimationTrackEditor() { //timeline_vbox->add_child(memnew(HSeparator)); HBoxContainer *bottom_hb = memnew(HBoxContainer); add_child(bottom_hb); + + imported_anim_warning = memnew(Button); + imported_anim_warning->hide(); + imported_anim_warning->set_tooltip(TTR("Warning: Editing imported animation")); + imported_anim_warning->connect("pressed", this, "_show_imported_anim_warning"); + bottom_hb->add_child(imported_anim_warning); + bottom_hb->add_spacer(); selected_filter = memnew(ToolButton); diff --git a/editor/animation_track_editor.h b/editor/animation_track_editor.h index 5ac5999b68..a69659642c 100644 --- a/editor/animation_track_editor.h +++ b/editor/animation_track_editor.h @@ -309,6 +309,9 @@ class AnimationTrackEditor : public VBoxContainer { ToolButton *snap; OptionButton *snap_mode; + Button *imported_anim_warning; + void _show_imported_anim_warning() const; + void _snap_mode_changed(int p_mode); Vector<AnimationTrackEdit *> track_edits; Vector<AnimationTrackEditGroup *> groups; |