From 34a6d6a29b72cfa82879c1df455f5b54e92f2103 Mon Sep 17 00:00:00 2001 From: lunarcleint <88809950+lunarcleint@users.noreply.github.com> Date: Mon, 22 Jul 2024 17:28:30 -0700 Subject: [PATCH] creating anims --- .../editors/character/CharacterAnimButton.hx | 5 ++ .../editors/character/CharacterAnimsWindow.hx | 50 +++++++++++++------ 2 files changed, 40 insertions(+), 15 deletions(-) diff --git a/source/funkin/editors/character/CharacterAnimButton.hx b/source/funkin/editors/character/CharacterAnimButton.hx index 8e36642a..6e8f30e0 100644 --- a/source/funkin/editors/character/CharacterAnimButton.hx +++ b/source/funkin/editors/character/CharacterAnimButton.hx @@ -215,6 +215,11 @@ class CharacterAnimButton extends UIButton { public function changeName(newName:String) @:privateAccess { if (newName == anim) return; + if (parent.character.getNameList().indexOf(newName) != -1) { + nameTextBox.label.text = anim; + return; + } + if (parent.character.animateAtlas != null) { var animSymbol:SymbolStuff = parent.character.animateAtlas.anim.animsMap[anim]; diff --git a/source/funkin/editors/character/CharacterAnimsWindow.hx b/source/funkin/editors/character/CharacterAnimsWindow.hx index 0a2a52c4..af9be287 100644 --- a/source/funkin/editors/character/CharacterAnimsWindow.hx +++ b/source/funkin/editors/character/CharacterAnimsWindow.hx @@ -21,6 +21,7 @@ class CharacterAnimsWindow extends UIButtonList { public function new(x:Float, y:Float, character:CharacterGhost) { super(x, y, Std.int(500-16), 419, "", FlxPoint.get(Std.int(500-16-32), 208)); + this.character = character; cameraSpacing = 0; frames = Paths.getFrames('editors/ui/inputbox'); @@ -37,15 +38,9 @@ class CharacterAnimsWindow extends UIButtonList { alpha = 0.7; - @:privateAccess - for (name => anim in displayWindowSprite.animation._animations) - buildAnimDisplay(name, anim); - - for (anim in character.getAnimOrder()) { - var button:CharacterAnimButton = new CharacterAnimButton(0, 0, character.animDatas.get(anim), this); - add(button); animButtons.set(anim, button); - } - this.character = character; + for (anim in character.getAnimOrder()) + addAnimation(character.animDatas.get(anim)); + addButton.callback = generateAnimation; } public var ghosts:Array = []; @@ -78,10 +73,35 @@ class CharacterAnimsWindow extends UIButtonList { remove(button); button.destroy(); } - // public function createAnimation() { - // var animData:AnimData = { - // name: "New Animation" - // x: 0, y: 0, - // } - // } + public function generateAnimation() { + var animName:String = "New Anim"; + var animNames:Array = character.getNameList(); + + var newAnimCount:Int = 0; + while (animNames.indexOf(animName) != -1) { + newAnimCount++; + animName = 'New Anim - $newAnimCount'; + } + + var animData:AnimData = { + name: animName, + anim: character.frames.getByIndex(0).name, + fps: 24, loop: false, + x: 0, y: 0, + indices: [], + animType: NONE, + }; + addAnimation(animData); + } + + public function addAnimation(animData:AnimData, animID:Int = -1) @:privateAccess { + XMLUtil.addAnimToSprite(character, animData); + buildAnimDisplay(animData.name, character.animation._animations[animData.name]); + + var newButton:CharacterAnimButton = new CharacterAnimButton(0, 0, animData, this); + newButton.alpha = 0.25; animButtons.set(animData.name, newButton); + + if (animID == -1) add(newButton); + else insert(newButton, animID); + } } \ No newline at end of file