diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-09-23 08:43:56 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-23 08:43:56 +0200 |
commit | 2a2f40c45bf29c0dfce9b17c7a3016ca60dfda01 (patch) | |
tree | c9559f55b00432ae43cc6c42c19f43507e2c4de8 /editor/plugins | |
parent | a089057596e881743de0e80908e5930de4536dd5 (diff) | |
parent | a701d4e940d93758279bbbe72633306b3c646781 (diff) |
Merge pull request #32007 from nekomatata/sprite-frames-editor-delete
SpriteFramesEditor improvements around deleting animations
Diffstat (limited to 'editor/plugins')
-rw-r--r-- | editor/plugins/sprite_frames_editor_plugin.cpp | 27 | ||||
-rw-r--r-- | editor/plugins/sprite_frames_editor_plugin.h | 3 |
2 files changed, 25 insertions, 5 deletions
diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp index d91de6cbf6..f065ab3420 100644 --- a/editor/plugins/sprite_frames_editor_plugin.cpp +++ b/editor/plugins/sprite_frames_editor_plugin.cpp @@ -464,9 +464,11 @@ void SpriteFramesEditor::_animation_select() { if (updating) return; - double value = anim_speed->get_line_edit()->get_text().to_double(); - if (!Math::is_equal_approx(value, frames->get_animation_speed(edited_anim))) - _animation_fps_changed(value); + if (frames->has_animation(edited_anim)) { + double value = anim_speed->get_line_edit()->get_text().to_double(); + if (!Math::is_equal_approx(value, frames->get_animation_speed(edited_anim))) + _animation_fps_changed(value); + } TreeItem *selected = animations->get_selected(); ERR_FAIL_COND(!selected); @@ -548,6 +550,7 @@ void SpriteFramesEditor::_animation_name_edited() { undo_redo->commit_action(); } + void SpriteFramesEditor::_animation_add() { String name = "New Anim"; @@ -578,13 +581,21 @@ void SpriteFramesEditor::_animation_add() { undo_redo->commit_action(); animations->grab_focus(); } + void SpriteFramesEditor::_animation_remove() { + if (updating) return; if (!frames->has_animation(edited_anim)) return; + delete_dialog->set_text(TTR("Delete Animation?")); + delete_dialog->popup_centered_minsize(); +} + +void SpriteFramesEditor::_animation_remove_confirmed() { + undo_redo->create_action(TTR("Remove Animation")); undo_redo->add_do_method(frames, "remove_animation", edited_anim); undo_redo->add_undo_method(frames, "add_animation", edited_anim); @@ -598,6 +609,8 @@ void SpriteFramesEditor::_animation_remove() { undo_redo->add_do_method(this, "_update_library"); undo_redo->add_undo_method(this, "_update_library"); + edited_anim = StringName(); + undo_redo->commit_action(); } @@ -840,6 +853,7 @@ void SpriteFramesEditor::_bind_methods() { ClassDB::bind_method(D_METHOD("_animation_name_edited"), &SpriteFramesEditor::_animation_name_edited); ClassDB::bind_method(D_METHOD("_animation_add"), &SpriteFramesEditor::_animation_add); ClassDB::bind_method(D_METHOD("_animation_remove"), &SpriteFramesEditor::_animation_remove); + ClassDB::bind_method(D_METHOD("_animation_remove_confirmed"), &SpriteFramesEditor::_animation_remove_confirmed); ClassDB::bind_method(D_METHOD("_animation_loop_changed"), &SpriteFramesEditor::_animation_loop_changed); ClassDB::bind_method(D_METHOD("_animation_fps_changed"), &SpriteFramesEditor::_animation_fps_changed); ClassDB::bind_method(D_METHOD("get_drag_data_fw"), &SpriteFramesEditor::get_drag_data_fw); @@ -870,7 +884,6 @@ SpriteFramesEditor::SpriteFramesEditor() { new_anim = memnew(ToolButton); new_anim->set_tooltip(TTR("New Animation")); hbc_animlist->add_child(new_anim); - new_anim->set_h_size_flags(SIZE_EXPAND_FILL); new_anim->connect("pressed", this, "_animation_add"); remove_anim = memnew(ToolButton); @@ -926,7 +939,7 @@ SpriteFramesEditor::SpriteFramesEditor() { paste->set_tooltip(TTR("Paste")); hbc->add_child(paste); - hbc->add_spacer(false); + hbc->add_child(memnew(VSeparator)); empty = memnew(ToolButton); empty->set_tooltip(TTR("Insert Empty (Before)")); @@ -987,6 +1000,10 @@ SpriteFramesEditor::SpriteFramesEditor() { edited_anim = "default"; + delete_dialog = memnew(ConfirmationDialog); + add_child(delete_dialog); + delete_dialog->connect("confirmed", this, "_animation_remove_confirmed"); + split_sheet_dialog = memnew(ConfirmationDialog); add_child(split_sheet_dialog); VBoxContainer *split_sheet_vb = memnew(VBoxContainer); diff --git a/editor/plugins/sprite_frames_editor_plugin.h b/editor/plugins/sprite_frames_editor_plugin.h index d64431cde7..f20b54f910 100644 --- a/editor/plugins/sprite_frames_editor_plugin.h +++ b/editor/plugins/sprite_frames_editor_plugin.h @@ -73,6 +73,8 @@ class SpriteFramesEditor : public HSplitContainer { StringName edited_anim; + ConfirmationDialog *delete_dialog; + ConfirmationDialog *split_sheet_dialog; ScrollContainer *splite_sheet_scroll; TextureRect *split_sheet_preview; @@ -98,6 +100,7 @@ class SpriteFramesEditor : public HSplitContainer { void _animation_name_edited(); void _animation_add(); void _animation_remove(); + void _animation_remove_confirmed(); void _animation_loop_changed(); void _animation_fps_changed(double p_value); |