From 1deb42ad8dd6429cde94f437675c0cff3f8dcb60 Mon Sep 17 00:00:00 2001 From: Saracen Date: Sun, 1 Sep 2024 01:32:56 +0100 Subject: [PATCH] Improve behaviour of AnimationPlayer warnings. --- editor/animation_track_editor.cpp | 24 +++++++++++++++++++----- editor/editor_node.cpp | 9 ++++++--- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 8c07cefc194..e83d6cb31df 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -1378,12 +1378,26 @@ void AnimationTimelineEdit::_anim_loop_pressed() { undo_redo->add_undo_method(this, "update_values"); undo_redo->commit_action(); } else { - String base_path = animation->get_path(); - if (FileAccess::exists(base_path + ".import")) { - EditorNode::get_singleton()->show_warning(TTR("Can't change loop mode on animation instanced from imported scene.")); - } else { - EditorNode::get_singleton()->show_warning(TTR("Can't change loop mode on animation embedded in another scene.")); + String base = animation->get_path(); + int srpos = base.find("::"); + if (srpos != -1) { + base = animation->get_path().substr(0, srpos); } + + if (FileAccess::exists(base + ".import")) { + if (ResourceLoader::get_resource_type(base) == "PackedScene") { + EditorNode::get_singleton()->show_warning(TTR("Can't change loop mode on animation instanced from an imported scene.\n\nTo change this animation's loop mode, navigate to the scene's Advanced Import settings and select the animation.\nYou can then change the loop mode from the inspector menu.")); + } else { + EditorNode::get_singleton()->show_warning(TTR("Can't change loop mode on animation instanced from an imported resource.")); + } + } else { + if (ResourceLoader::get_resource_type(base) == "PackedScene") { + EditorNode::get_singleton()->show_warning(TTR("Can't change loop mode on animation embedded in another scene.\n\nYou must open this scene and change the animation's loop mode from there.")); + } else { + EditorNode::get_singleton()->show_warning(TTR("Can't change loop mode on animation embedded in another resource.")); + } + } + update_values(); } } diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index d3fa2ed716f..5fd02b2881f 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -5200,7 +5200,8 @@ void EditorNode::show_accept(const String &p_text, const String &p_title) { _close_save_scene_progress(); accept->set_ok_button_text(p_title); accept->set_text(p_text); - EditorInterface::get_singleton()->popup_dialog_centered(accept); + accept->reset_size(); + EditorInterface::get_singleton()->popup_dialog_centered_clamped(accept, Size2i(), 0.0); } } @@ -5210,7 +5211,8 @@ void EditorNode::show_save_accept(const String &p_text, const String &p_title) { _close_save_scene_progress(); save_accept->set_ok_button_text(p_title); save_accept->set_text(p_text); - EditorInterface::get_singleton()->popup_dialog_centered(save_accept); + save_accept->reset_size(); + EditorInterface::get_singleton()->popup_dialog_centered_clamped(save_accept, Size2i(), 0.0); } } @@ -5219,7 +5221,8 @@ void EditorNode::show_warning(const String &p_text, const String &p_title) { _close_save_scene_progress(); warning->set_text(p_text); warning->set_title(p_title); - EditorInterface::get_singleton()->popup_dialog_centered(warning); + warning->reset_size(); + EditorInterface::get_singleton()->popup_dialog_centered_clamped(warning, Size2i(), 0.0); } else { WARN_PRINT(p_title + " " + p_text); }