-
-
Notifications
You must be signed in to change notification settings - Fork 19.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[AnimatedSprite] Implement duplicate animations #57949
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* [32m3942[m | ||
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -321,6 +321,7 @@ void SpriteFramesEditor::_notification(int p_what) { | |||||
zoom_reset->set_icon(get_theme_icon(SNAME("ZoomReset"), SNAME("EditorIcons"))); | ||||||
zoom_in->set_icon(get_theme_icon(SNAME("ZoomMore"), SNAME("EditorIcons"))); | ||||||
new_anim->set_icon(get_theme_icon(SNAME("New"), SNAME("EditorIcons"))); | ||||||
duplicate_anim->set_icon(get_theme_icon(SNAME("Duplicate"), SNAME("EditorIcons"))); | ||||||
remove_anim->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); | ||||||
split_sheet_zoom_out->set_icon(get_theme_icon(SNAME("ZoomLess"), SNAME("EditorIcons"))); | ||||||
split_sheet_zoom_reset->set_icon(get_theme_icon(SNAME("ZoomReset"), SNAME("EditorIcons"))); | ||||||
|
@@ -662,13 +663,43 @@ void SpriteFramesEditor::_animation_add() { | |||||
undo_redo->add_do_method(E, "set_animation", name); | ||||||
undo_redo->add_undo_method(E, "set_animation", current); | ||||||
} | ||||||
|
||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These trailing spaces have to be removed. |
||||||
edited_anim = name; | ||||||
|
||||||
undo_redo->commit_action(); | ||||||
animations->grab_focus(); | ||||||
} | ||||||
|
||||||
void SpriteFramesEditor::_animation_duplicate() { | ||||||
if ( !frames->has_animation(edited_anim) ) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I wonder why CI did not detect this :( |
||||||
print_line("Current animation has no frames"); | ||||||
return; | ||||||
} | ||||||
|
||||||
StringName anim_to_duplicate = edited_anim; | ||||||
int duplicate_frame_count = frames->get_frame_count(anim_to_duplicate); | ||||||
String new_name = String(edited_anim); //Get the animation name to duplicate, cant use the anim_to_duplicate since its a StringName and cannot be modified | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For comments, it's prefered to start with |
||||||
|
||||||
_animation_add(); | ||||||
|
||||||
for (int i = 0; i < duplicate_frame_count; i++) { | ||||||
frames->add_frame(edited_anim, frames->get_frame(anim_to_duplicate, i)); | ||||||
} | ||||||
|
||||||
//Rename the duplicated animation | ||||||
int counter = 1; | ||||||
while(frames->has_animation(new_name + "_" + itos(counter))) { | ||||||
counter++; | ||||||
} | ||||||
new_name = new_name + "_" + itos(counter); | ||||||
frames->rename_animation(edited_anim,new_name); | ||||||
Comment on lines
+690
to
+695
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is inconsistent with how Also, there should be a space between |
||||||
|
||||||
//Update the UI | ||||||
edited_anim = new_name; | ||||||
_update_library(); | ||||||
animations->grab_focus(); | ||||||
} | ||||||
|
||||||
void SpriteFramesEditor::_animation_remove() { | ||||||
if (updating) { | ||||||
return; | ||||||
|
@@ -1036,6 +1067,12 @@ SpriteFramesEditor::SpriteFramesEditor() { | |||||
hbc_animlist->add_child(new_anim); | ||||||
new_anim->connect("pressed", callable_mp(this, &SpriteFramesEditor::_animation_add)); | ||||||
|
||||||
duplicate_anim = memnew(Button); | ||||||
duplicate_anim->set_flat(true); | ||||||
duplicate_anim->set_tooltip(TTR("Duplicate Animation")); | ||||||
hbc_animlist->add_child(duplicate_anim); | ||||||
duplicate_anim->connect("pressed", callable_mp(this, &SpriteFramesEditor::_animation_duplicate)); | ||||||
|
||||||
remove_anim = memnew(Button); | ||||||
remove_anim->set_flat(true); | ||||||
remove_anim->set_tooltip(TTR("Remove Animation")); | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file has to be removed :)