aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Koopa2017-01-25 21:22:16 +0100
committerRémi Verschelde2017-03-18 19:52:08 +0100
commit3f8ce209b7a64c38364fe3a9def12e33b7a13db6 (patch)
treefb9240a23f0f5107e04c2fb5a75ad4c4edf9eba3
parent8015ab0db39c4e89a2f956af217e4195a67804e9 (diff)
downloadgodot-3f8ce209b7a64c38364fe3a9def12e33b7a13db6.tar.gz
godot-3f8ce209b7a64c38364fe3a9def12e33b7a13db6.tar.zst
godot-3f8ce209b7a64c38364fe3a9def12e33b7a13db6.zip
Added warning when removing animations
(cherry picked from commit f279df265448da476c6cdb0806bdcc1db5f128fd)
-rw-r--r--tools/editor/plugins/animation_player_editor_plugin.cpp27
-rw-r--r--tools/editor/plugins/animation_player_editor_plugin.h2
2 files changed, 20 insertions, 9 deletions
diff --git a/tools/editor/plugins/animation_player_editor_plugin.cpp b/tools/editor/plugins/animation_player_editor_plugin.cpp
index 18a3e98b2..bf16e57fb 100644
--- a/tools/editor/plugins/animation_player_editor_plugin.cpp
+++ b/tools/editor/plugins/animation_player_editor_plugin.cpp
@@ -440,22 +440,27 @@ void AnimationPlayerEditor::_animation_save_as(const Ref<Resource>& p_resource)
file->set_title(TTR("Save Resource As.."));
current_option = RESOURCE_SAVE;
}
+
void AnimationPlayerEditor::_animation_remove() {
- if (animation->get_item_count()==0)
+ if (animation->get_item_count() == 0)
return;
- String current = animation->get_item_text(animation->get_selected());
- Ref<Animation> anim = player->get_animation(current);
+ delete_dialog->set_text(TTR("Delete Animation?"));
+ delete_dialog->popup_centered_minsize();
+}
+
+void AnimationPlayerEditor::_animation_remove_confirmed() {
+ String current = animation->get_item_text(animation->get_selected());
+ Ref<Animation> anim = player->get_animation(current);
undo_redo->create_action(TTR("Remove Animation"));
- undo_redo->add_do_method(player,"remove_animation",current);
- undo_redo->add_undo_method(player,"add_animation",current,anim);
- undo_redo->add_do_method(this,"_animation_player_changed",player);
- undo_redo->add_undo_method(this,"_animation_player_changed",player);
+ undo_redo->add_do_method(player, "remove_animation", current);
+ undo_redo->add_undo_method(player, "add_animation", current, anim);
+ undo_redo->add_do_method(this, "_animation_player_changed", player);
+ undo_redo->add_undo_method(this, "_animation_player_changed", player);
undo_redo->commit_action();
-
}
void AnimationPlayerEditor::_select_anim_by_name(const String& p_anim) {
@@ -1260,6 +1265,7 @@ void AnimationPlayerEditor::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_animation_rename"),&AnimationPlayerEditor::_animation_rename);
ObjectTypeDB::bind_method(_MD("_animation_load"),&AnimationPlayerEditor::_animation_load);
ObjectTypeDB::bind_method(_MD("_animation_remove"),&AnimationPlayerEditor::_animation_remove);
+ ObjectTypeDB::bind_method(_MD("_animation_remove_confirmed"),&AnimationPlayerEditor::_animation_remove_confirmed);
ObjectTypeDB::bind_method(_MD("_animation_blend"),&AnimationPlayerEditor::_animation_blend);
ObjectTypeDB::bind_method(_MD("_animation_edit"),&AnimationPlayerEditor::_animation_edit);
ObjectTypeDB::bind_method(_MD("_animation_resource_edit"),&AnimationPlayerEditor::_animation_resource_edit);
@@ -1384,6 +1390,10 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor) {
add_child(accept);
accept->connect("confirmed", this, "_menu_confirm_current");
+ delete_dialog = memnew(ConfirmationDialog);
+ add_child(delete_dialog);
+ delete_dialog->connect("confirmed", this, "_animation_remove_confirmed");
+
duplicate_anim = memnew( ToolButton );
hb->add_child(duplicate_anim);
ED_SHORTCUT("animation_player_editor/duplicate_animation", TTR("Duplicate Animation"));
@@ -1397,7 +1407,6 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor) {
rename_anim->set_tooltip(TTR("Rename Animation"));
remove_anim = memnew( ToolButton );
-
hb->add_child(remove_anim);
ED_SHORTCUT("animation_player_editor/remove_animation", TTR("Remove Animation"));
remove_anim->set_shortcut(ED_GET_SHORTCUT("animation_player_editor/remove_animation"));
diff --git a/tools/editor/plugins/animation_player_editor_plugin.h b/tools/editor/plugins/animation_player_editor_plugin.h
index ecd0c65cb..006c1efdd 100644
--- a/tools/editor/plugins/animation_player_editor_plugin.h
+++ b/tools/editor/plugins/animation_player_editor_plugin.h
@@ -97,6 +97,7 @@ class AnimationPlayerEditor : public VBoxContainer {
EditorFileDialog *file;
AcceptDialog *accept;
+ ConfirmationDialog* delete_dialog;
int current_option;
struct BlendEditor {
@@ -138,6 +139,7 @@ class AnimationPlayerEditor : public VBoxContainer {
void _animation_save_as(const Ref<Resource>& p_resource);
void _animation_remove();
+ void _animation_remove_confirmed();
void _animation_blend();
void _animation_edit();
void _animation_duplicate();