From 4defc11762b204f63f5d719024b454ce398d9693 Mon Sep 17 00:00:00 2001 From: lemz1 Date: Thu, 31 Oct 2024 23:10:29 +0100 Subject: [PATCH] yay finished multisparrow i think --- .../ui/debug/char/CharCreatorCharacter.hx | 33 ++++++++----------- .../char/components/dialogs/AddAnimDialog.hx | 4 +-- .../char/pages/CharCreatorGameplayPage.hx | 4 ++- 3 files changed, 18 insertions(+), 23 deletions(-) diff --git a/source/funkin/ui/debug/char/CharCreatorCharacter.hx b/source/funkin/ui/debug/char/CharCreatorCharacter.hx index 90909f89fb..dbe5137058 100644 --- a/source/funkin/ui/debug/char/CharCreatorCharacter.hx +++ b/source/funkin/ui/debug/char/CharCreatorCharacter.hx @@ -49,11 +49,19 @@ class CharCreatorCharacter extends Bopper switch (generatedParams.renderType) { case "sparrow" | "multisparrow": - if (generatedParams.files.length != 2) return; // img and data - - var img = BitmapData.fromBytes(generatedParams.files[0].bytes); - var data = generatedParams.files[1].bytes.toString(); - this.frames = FlxAtlasFrames.fromSparrow(img, data); + if (generatedParams.files.length < 2) return; // img and data + + var combinedFrames = null; + for (i in 0...Math.floor(generatedParams.files.length / 2)) + { + var img = BitmapData.fromBytes(generatedParams.files[i * 2].bytes); + var data = generatedParams.files[i * 2 + 1].bytes.toString(); + var sparrow = FlxAtlasFrames.fromSparrow(img, data); + if (combinedFrames == null) combinedFrames = sparrow; + else + combinedFrames.addAtlas(sparrow); + } + this.frames = combinedFrames; case "packer": if (generatedParams.files.length != 2) return; // img and data @@ -113,26 +121,11 @@ class CharCreatorCharacter extends Bopper } } - var multiSparrowFrames:Map = []; - public function addAnimation(name:String, prefix:String, offsets:Array, indices:Array, animPath:String = "", frameRate:Int = 24, looped:Bool = false, flipX:Bool = false, flipY:Bool = false) { if (getAnimationData(name) != null) return true; // i mean i guess??? - if (renderType == "multisparrow" && !multiSparrowFrames.exists(animPath)) - { - var daFrames:FlxAtlasFrames = Paths.getSparrowAtlas(animPath); - if (daFrames == null) return false; - - multiSparrowFrames.set(animPath, daFrames); - - for (frame in daFrames.frames) - { - this.frames.pushFrame(frame); - } - } - if (renderType != "atlas") { if (indices.length > 0) animation.addByIndices(name, prefix, indices, "", frameRate, looped, flipX, flipY); diff --git a/source/funkin/ui/debug/char/components/dialogs/AddAnimDialog.hx b/source/funkin/ui/debug/char/components/dialogs/AddAnimDialog.hx index 336197618a..12d42dbb37 100644 --- a/source/funkin/ui/debug/char/components/dialogs/AddAnimDialog.hx +++ b/source/funkin/ui/debug/char/components/dialogs/AddAnimDialog.hx @@ -19,7 +19,7 @@ class AddAnimDialog extends DefaultPageDialog charAnimFrames.disabled = charAnimPath.disabled = charAnimFlipX.disabled = charAnimFlipY.disabled = charAnimFramerate.disabled = (char.renderType == "atlas"); charAnimFrames.tooltip = charAnimPath.tooltip = charAnimFlipX.tooltip = charAnimFlipY.tooltip = charAnimFramerate.tooltip = (char.renderType == "atlas" ? "Unavailable for Atlas Characters." : null); - if (char.renderType != "multisparrow") + if (char.renderType != "atlas") { charAnimFrameList.dataSource = new ArrayDataSource(); for (fname in char.frames.frames) @@ -78,7 +78,7 @@ class AddAnimDialog extends DefaultPageDialog if (!animAdded) return; char.setAnimationOffsets(charAnimName.text, charAnimOffsetX.pos, charAnimOffsetY.pos); - char.playAnimation(charAnimName.text, true, true); + char.playAnimation(charAnimName.text); updateDropdown(); charAnimDropdown.selectedIndex = charAnimDropdown.dataSource.size - 1; diff --git a/source/funkin/ui/debug/char/pages/CharCreatorGameplayPage.hx b/source/funkin/ui/debug/char/pages/CharCreatorGameplayPage.hx index c7c3aed117..94ae5bfbcf 100644 --- a/source/funkin/ui/debug/char/pages/CharCreatorGameplayPage.hx +++ b/source/funkin/ui/debug/char/pages/CharCreatorGameplayPage.hx @@ -156,6 +156,7 @@ class CharCreatorGameplayPage extends CharCreatorDefaultPage var id = drop.selectedIndex + 1; if (id >= drop.dataSource.size) id = 0; drop.selectedIndex = id; + currentCharacter.playAnimation(currentCharacter.animations[drop.selectedIndex].name); } labelAnimName.onRightClick = function(_) { @@ -165,6 +166,7 @@ class CharCreatorGameplayPage extends CharCreatorDefaultPage var id = drop.selectedIndex - 1; if (id < 0) id = drop.dataSource.size - 1; drop.selectedIndex = id; + currentCharacter.playAnimation(currentCharacter.animations[drop.selectedIndex].name); } labelAnimOffsetX.onClick = _ -> changeCharAnimOffset(5); @@ -203,7 +205,7 @@ class CharCreatorGameplayPage extends CharCreatorDefaultPage currentCharacter.animations[drop.selectedIndex].offsets = newOffsets; currentCharacter.setAnimationOffsets(currentCharacter.animations[drop.selectedIndex].name, newOffsets[0], newOffsets[1]); // todo: probs merge there two lol - currentCharacter.playAnimation(currentCharacter.animations[drop.selectedIndex].name, true, true); + currentCharacter.playAnimation(currentCharacter.animations[drop.selectedIndex].name); // GhostUtil.copyFromCharacter(ghostCharacter, currentCharacter); very costly for memory! we're just gonna update the offsets ghostCharacter.animations[drop.selectedIndex].offsets = newOffsets;