Skip to content

Commit

Permalink
Merge pull request #79600 from Rindbee/fix-rename-animation-in-Sprite…
Browse files Browse the repository at this point in the history
…FramesEditor

Fix rename animation in SpriteFramesEditor
  • Loading branch information
YuriSizov committed Jul 21, 2023
2 parents ce92f05 + e9cd29c commit 7573a45
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions editor/plugins/animation_state_machine_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1508,6 +1508,10 @@ void AnimationNodeStateMachineEditor::_name_edited(const String &p_text) {
int base = 1;
String name = base_name;
while (state_machine->has_node(name)) {
if (name == prev_name) {
name_edit_popup->hide(); // The old name wins, the name doesn't change, just hide the popup.
return;
}
base++;
name = base_name + " " + itos(base);
}
Expand Down
5 changes: 4 additions & 1 deletion editor/plugins/sprite_frames_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -949,13 +949,16 @@ void SpriteFramesEditor::_animation_name_edited() {
String name = new_name;
int counter = 0;
while (frames->has_animation(name)) {
if (name == String(edited_anim)) {
edited->set_text(0, name); // The name didn't change, just updated the column text to name.
return;
}
counter++;
name = new_name + "_" + itos(counter);
}

EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
undo_redo->create_action(TTR("Rename Animation"), UndoRedo::MERGE_DISABLE, EditorNode::get_singleton()->get_edited_scene());
_rename_node_animation(undo_redo, false, edited_anim, "", "");
undo_redo->add_do_method(frames.ptr(), "rename_animation", edited_anim, name);
undo_redo->add_undo_method(frames.ptr(), "rename_animation", name, edited_anim);
_rename_node_animation(undo_redo, false, edited_anim, name, name);
Expand Down

0 comments on commit 7573a45

Please sign in to comment.