Skip to content

Commit

Permalink
remove animation implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
lemz1 committed Nov 3, 2024
1 parent fd5cd6a commit 1096b87
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
16 changes: 16 additions & 0 deletions source/funkin/ui/debug/char/CharCreatorCharacter.hx
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,22 @@ class CharCreatorCharacter extends Bopper
return true;
}

public function removeAnimation(name:String):Bool
{
if (getAnimationData(name) == null) return false;

for (animation in animations)
{
if (animation.name == name)
{
animations.remove(animation);
return true;
}
}

return false;
}

override public function setAnimationOffsets(name:String, xOffset:Float, yOffset:Float)
{
super.setAnimationOffsets(name, xOffset, yOffset);
Expand Down
21 changes: 21 additions & 0 deletions source/funkin/ui/debug/char/components/dialogs/AddAnimDialog.hx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,27 @@ class AddAnimDialog extends DefaultPageDialog
updateDropdown();
charAnimDropdown.selectedIndex = charAnimDropdown.dataSource.size - 1;
}

charAnimDelete.onClick = function(_) {
if ((charAnimName.text ?? "") == "") return;

if (!char.removeAnimation(charAnimName.text)) return;
cast(page, CharCreatorGameplayPage).ghostCharacter.removeAnimation(charAnimName.text);

updateDropdown();
charAnimDropdown.selectedIndex = charAnimDropdown.dataSource.size - 1;

if (charAnimDropdown.selectedIndex == -1)
{
@:privateAccess
cast(page, CharCreatorGameplayPage).labelAnimName.text = "None";
return;
}

var anim:String = charAnimDropdown.value.text;
char.playAnimation(anim);
cast(page, CharCreatorGameplayPage).ghostCharacter.playAnimation(anim);
}
}

function updateDropdown()
Expand Down

0 comments on commit 1096b87

Please sign in to comment.