Warn when opening imported anim in AnimationPlayer

This commit is contained in:
homer666 2019-04-23 15:02:34 +10:00
parent 886afa9b76
commit e5c8e4019b
2 changed files with 30 additions and 0 deletions

View File

@ -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);

View File

@ -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;