diff options
author | homer666 <homer666@users.noreply.github.com> | 2019-04-23 15:02:34 +1000 |
---|---|---|
committer | homer666 <homer666@users.noreply.github.com> | 2019-04-30 04:46:45 +1000 |
commit | e5c8e4019bc83a893c1b09a3671ffae8d493d77a (patch) | |
tree | 30302ea2ed5fade5899f8b6dff844a81ff116f09 | |
parent | 886afa9b7692bc263cf96c03882760521b74b942 (diff) |
Warn when opening imported anim in AnimationPlayer
-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 9f6fa74dd3..3dc3884a51 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -2541,6 +2541,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); @@ -3610,6 +3619,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")); } @@ -4895,6 +4905,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); @@ -4933,6 +4952,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")); @@ -5003,6 +5023,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; |