Skip to content

Commit

Permalink
animlist.d: Add duplicate animation option to animlist panel (#405)
Browse files Browse the repository at this point in the history
solved #369
  • Loading branch information
r888800009 authored Sep 13, 2024
1 parent da1b49a commit 7791183
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions source/creator/panels/animlist.d
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,21 @@ protected:
foreach(name, ref anim; incActivePuppet().getAnimations()) {
igPushID(name.ptr, name.ptr+name.length);
if (igBeginPopup("###OPTIONS")) {
if (igMenuItem(__("Duplicate"))) {
import inochi2d.fmt.serialize : inToJson, inLoadJsonDataFromMemory;

// maybe we can just serialize and deserialize, without deep copy implementation
auto newAnim = inLoadJsonDataFromMemory!Animation(inToJson(anim));
auto newName = name ~ "_copy";
while (newName in incActivePuppet().getAnimations()) {
newName ~= "_copy";
}

incActivePuppet().getAnimations()[newName] = newAnim;
newAnim.finalize(incActivePuppet());
incAnimationChange(newName);
}

if (igMenuItem(__("Edit..."))) {
incPushWindow(new EditAnimationWindow(anim, name));
}
Expand Down

0 comments on commit 7791183

Please sign in to comment.