From 1096b87f6e7511881488f314ceb89ab6125c9ed1 Mon Sep 17 00:00:00 2001 From: lemz1 Date: Sun, 3 Nov 2024 13:17:00 +0100 Subject: [PATCH] remove animation implementation --- .../ui/debug/char/CharCreatorCharacter.hx | 16 ++++++++++++++ .../char/components/dialogs/AddAnimDialog.hx | 21 +++++++++++++++++++ 2 files changed, 37 insertions(+) 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()