diff --git a/source/funkin/editors/character/CharacterAnimButton.hx b/source/funkin/editors/character/CharacterAnimButton.hx index 79985a30..254e97d5 100644 --- a/source/funkin/editors/character/CharacterAnimButton.hx +++ b/source/funkin/editors/character/CharacterAnimButton.hx @@ -264,9 +264,7 @@ class CharacterAnimButton extends UIButton { if (parent.character.animateAtlas != null) __refreshAnimation(); else { - trace(parent.character.animation._animations); var flxAnimation:FlxAnimation = __getFlxAnimation(); - trace(parent.character.animation._animations); flxAnimation.prefix = newAnim; refreshFlxAnimationFrames(flxAnimation, animData); @@ -343,12 +341,9 @@ class CharacterAnimButton extends UIButton { flxAnimation.frames = frameIndices; } else { - trace(flxAnimation.prefix); final animFrames:Array = new Array(); parent.character.animation.findByPrefix(animFrames, flxAnimation.prefix); - trace(animFrames); - final frameIndices:Array = []; parent.character.animation.byPrefixHelper(frameIndices, animFrames, flxAnimation.prefix); @@ -358,7 +353,7 @@ class CharacterAnimButton extends UIButton { if (flxAnimation.frames.length <= 0) invalidate(); else validate(); } catch (e) { - trace('$e ${e.details}'); + trace('ERROR REFRESHING FLXANIMATION FRAMES: $e'); invalidate(); } @@ -375,19 +370,15 @@ class CharacterAnimButton extends UIButton { var wasRefreshed:Bool = false; try { - if (animData.indices.length > 0) { + parent.character.animateAtlas.anim.animsMap.remove(animData.name); + if (animData.indices.length > 0) parent.character.animateAtlas.anim.addBySymbolIndices(animData.name, animData.anim, animData.indices, animData.fps, animData.loop); - wasRefreshed = true; - } else { - for (name in parent.character.animateAtlas.anim.symbolDictionary.keys()) - if (parent.character.animateAtlas.anim.startsWith(name, animData.anim)) { - symbol.instance.symbol.name = name; - wasRefreshed = true; - break; - } - } + else + parent.character.animateAtlas.anim.addBySymbol(animData.name, animData.anim, animData.fps, animData.loop); + wasRefreshed = parent.character.animateAtlas.anim.animsMap.exists(animData.name); + if (!wasRefreshed) __getAnimationSymbol(); } catch (e) { - trace('$e'); + trace('ERROR REFRESHING SYMBOL FRAMES: $e'); } validate(wasRefreshed); diff --git a/source/funkin/editors/character/CharacterEditor.hx b/source/funkin/editors/character/CharacterEditor.hx index a1cbefce..a0d38458 100644 --- a/source/funkin/editors/character/CharacterEditor.hx +++ b/source/funkin/editors/character/CharacterEditor.hx @@ -513,7 +513,6 @@ class CharacterEditor extends UIState { } function _set_offset(x:Float, y:Float) { - trace(character.getAnimName(), characterAnimsWindow.animButtons); if (character.getAnimName() == null) return; characterAnimsWindow.animButtons.get(character.getAnimName()).changeOffset( FlxMath.roundDecimal(x, 2), FlxMath.roundDecimal(y, 2) @@ -627,16 +626,19 @@ class CharacterEditor extends UIState { stage.characterPoses[stagePosition].revertCharacter(character); changeCharacterIsPlayer(player); - remove(character); - - if (stage.characterPoses.exists(stagePosition)) - stage.applyCharStuff(character, stagePosition, 0); + updateCharacterStagePosition(); _animation_play(null); characterPropertiesWindow.designedAsDropDown.index = characterPropertiesWindow.designedAsDropDown.options.indexOf(player ? "BOYFRIEND" : "DAD"); characterPropertiesWindow.designedAsDropDown.label.text = player ? "BOYFRIEND" : "DAD"; } + public inline function updateCharacterStagePosition() { + remove(character); + if (stage.characterPoses.exists(stagePosition)) + stage.applyCharStuff(character, stagePosition, 0); + } + public function changeCharacterIsPlayer(player:Bool) @:privateAccess { if (character.__swappedLeftRightAnims) character.swapLeftRightAnimations(); diff --git a/source/funkin/editors/character/CharacterPropertiesWindow.hx b/source/funkin/editors/character/CharacterPropertiesWindow.hx index 85fc0f38..ed329d74 100644 --- a/source/funkin/editors/character/CharacterPropertiesWindow.hx +++ b/source/funkin/editors/character/CharacterPropertiesWindow.hx @@ -1,5 +1,6 @@ package funkin.editors.character; +import funkin.backend.FlxAnimate; import haxe.io.Path; import funkin.editors.character.CharacterInfoScreen.CharacterExtraInfo; import funkin.game.Character; @@ -156,21 +157,27 @@ class CharacterPropertiesWindow extends UISliceSprite { character.sprite = sprite; + animsWindow.displayWindowSprite.animation.reset(); + animsWindow.displayAnimsFramesList.clear(); + if (animsWindow.displayWindowGraphic != null) + animsWindow.displayWindowGraphic.destroy(); + if (Assets.exists('$noExt/Animation.json')) { + if (character.animateAtlas == null) { + character.animation.reset(); + character.animateAtlas = new FlxAnimate(character.x, character.y); + } else + character.animateAtlas.anim.stop(); + character.atlasPath = noExt; character.animateAtlas.loadAtlas(noExt); - - character.animateAtlas.anim.animsMap.clear(); - character.animateAtlas.anim.symbolDictionary.clear(); - - character.animateAtlas.anim.stop(); } else { + if (character.animateAtlas != null) { + character.animateAtlas.destroy(); + character.animateAtlas = null; + character.atlasPlayingAnim = character.atlasPath = null; + } character.frames = Paths.getFrames(path, true); - character.animation.reset(); - - animsWindow.displayWindowSprite.animation.reset(); - if (animsWindow.displayWindowGraphic != null) - animsWindow.displayWindowGraphic.destroy(); animsWindow.displayWindowSprite.loadGraphicFromSprite(character); if (Assets.exists(Paths.image('characters/${character.sprite}'))) @@ -178,8 +185,9 @@ class CharacterPropertiesWindow extends UISliceSprite { } character.animDatas.clear(); - for (anim in animsWindow.buttons) - anim.checkValid(); // Re-add all animations + for (anim in animsWindow.buttons) anim.checkValid(); // Re-add all animations + + CharacterEditor.instance.playAnimation(animsWindow.findValid().getDefault(animsWindow.buttons.members[0].anim)); } public function changeFlipX(newFlipX:Bool) @:privateAccess {