diff --git a/source/funkin/ui/debug/char/CharCreatorCharacter.hx b/source/funkin/ui/debug/char/CharCreatorCharacter.hx index 9bf7fca41a..4f35b0313b 100644 --- a/source/funkin/ui/debug/char/CharCreatorCharacter.hx +++ b/source/funkin/ui/debug/char/CharCreatorCharacter.hx @@ -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); diff --git a/source/funkin/ui/debug/char/components/dialogs/AddAnimDialog.hx b/source/funkin/ui/debug/char/components/dialogs/AddAnimDialog.hx index e143ad5682..245f525019 100644 --- a/source/funkin/ui/debug/char/components/dialogs/AddAnimDialog.hx +++ b/source/funkin/ui/debug/char/components/dialogs/AddAnimDialog.hx @@ -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()