diff --git a/source/funkin/ui/debug/char/CharCreatorCharacter.hx b/source/funkin/ui/debug/char/CharCreatorCharacter.hx index 3e0d86870f..d00c9e4347 100644 --- a/source/funkin/ui/debug/char/CharCreatorCharacter.hx +++ b/source/funkin/ui/debug/char/CharCreatorCharacter.hx @@ -121,8 +121,8 @@ class CharCreatorCharacter extends Bopper } } - 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) + public function addAnimation(name:String, prefix:String, offsets:Array, indices:Array, frameRate:Int = 24, looped:Bool = false, + flipX:Bool = false, flipY:Bool = false) { if (getAnimationData(name) != null) return true; // i mean i guess??? diff --git a/source/funkin/ui/debug/char/components/dialogs/AddAnimDialog.hx b/source/funkin/ui/debug/char/components/dialogs/AddAnimDialog.hx index 0b48f9282c..d6e5151eea 100644 --- a/source/funkin/ui/debug/char/components/dialogs/AddAnimDialog.hx +++ b/source/funkin/ui/debug/char/components/dialogs/AddAnimDialog.hx @@ -72,15 +72,13 @@ class AddAnimDialog extends DefaultPageDialog var shouldDoIndices:Bool = (indices.length > 0 && !indices.contains(null)); var animAdded:Bool = char.addAnimation(charAnimName.text, charAnimPrefix.text, [charAnimOffsetX.pos, charAnimOffsetY.pos], - (shouldDoIndices ? indices : []), charAnimPath.text, Std.int(charAnimFramerate.pos), charAnimLooped.selected, charAnimFlipX.selected, - charAnimFlipY.selected); + (shouldDoIndices ? indices : []), Std.int(charAnimFramerate.pos), charAnimLooped.selected, charAnimFlipX.selected, charAnimFlipY.selected); if (!animAdded) return; char.playAnimation(charAnimName.text); cast(page, CharCreatorGameplayPage).ghostCharacter.addAnimation(charAnimName.text, charAnimPrefix.text, [charAnimOffsetX.pos, charAnimOffsetY.pos], - (shouldDoIndices ? indices : []), charAnimPath.text, Std.int(charAnimFramerate.pos), charAnimLooped.selected, charAnimFlipX.selected, - charAnimFlipY.selected); + (shouldDoIndices ? indices : []), Std.int(charAnimFramerate.pos), charAnimLooped.selected, charAnimFlipX.selected, charAnimFlipY.selected); updateDropdown(); charAnimDropdown.selectedIndex = charAnimDropdown.dataSource.size - 1; diff --git a/source/funkin/ui/debug/char/components/wizard/AddCharFilesDialog.hx b/source/funkin/ui/debug/char/components/wizard/AddCharFilesDialog.hx index 1ccb665a99..dc62561112 100644 --- a/source/funkin/ui/debug/char/components/wizard/AddCharFilesDialog.hx +++ b/source/funkin/ui/debug/char/components/wizard/AddCharFilesDialog.hx @@ -38,9 +38,10 @@ class AddCharFilesDialog extends DefaultWizardDialog switch (params.renderType) { - case "sparrow" | "multisparrow": + case "sparrow": addAssetsBox.addComponent(new UploadAssetsBox("Put the path to the Spritesheet Image here.", FileUtil.FILE_EXTENSION_INFO_PNG)); - + case "multisparrow": + recursiveUploadBox(); case "packer": addAssetsBox.addComponent(new UploadAssetsBox("Put the path to the Spritesheet Image here.", FileUtil.FILE_EXTENSION_INFO_PNG)); @@ -57,9 +58,18 @@ class AddCharFilesDialog extends DefaultWizardDialog if (addAssetsBox.disabled) return true; var uploadBoxes:Array = []; - for (box in addAssetsBox.childComponents) + for (unsafeBox in addAssetsBox.childComponents) { - if (Std.isOfType(box, UploadAssetsBox)) uploadBoxes.push(cast box); + if (!Std.isOfType(unsafeBox, UploadAssetsBox)) + { + continue; + } + var box:UploadAssetsBox = cast unsafeBox; + if (box.daField.text == null || box.daField.text.length == 0) + { + continue; + } + uploadBoxes.push(box); } // check if the files even exist @@ -77,31 +87,44 @@ class AddCharFilesDialog extends DefaultWizardDialog switch (params.renderType) { case "sparrow" | "multisparrow": - var imgPath = uploadBoxes[0].daField.text; - var xmlPath = uploadBoxes[0].daField.text.replace(".png", ".xml"); + var files = []; + for (uploadBox in uploadBoxes) + { + var imgPath = uploadBox.daField.text; + var xmlPath = uploadBox.daField.text.replace(".png", ".xml"); - // checking if we even have the correct file types in the correct places - if (Path.extension(imgPath) != "png" || Path.extension(xmlPath) != "xml") return false; + // checking if we even have the correct file types in the correct places + if (Path.extension(imgPath) != "png" || Path.extension(xmlPath) != "xml") return false; - // testing if we could actually use these - var imgBytes = CharCreatorUtil.gimmeTheBytes(imgPath); - var xmlBytes = CharCreatorUtil.gimmeTheBytes(xmlPath); + // testing if we could actually use these + var imgBytes = CharCreatorUtil.gimmeTheBytes(imgPath); + var xmlBytes = CharCreatorUtil.gimmeTheBytes(xmlPath); - var tempSprite = new FlxSprite(); - try - { - var bitmap = BitmapData.fromBytes(imgBytes); - tempSprite.frames = FlxAtlasFrames.fromSparrow(bitmap, xmlBytes.toString()); - } - catch (e) - { - tempSprite.destroy(); - return false; - } + var tempSprite = new FlxSprite(); + try + { + var bitmap = BitmapData.fromBytes(imgBytes); + tempSprite.frames = FlxAtlasFrames.fromSparrow(bitmap, xmlBytes.toString()); + } + catch (e) + { + tempSprite.destroy(); + return false; + } - tempSprite.destroy(); // fuck this guy i hate him - params.files = [ - {name: imgPath, bytes: imgBytes}, {name: xmlPath, bytes: xmlBytes}]; + tempSprite.destroy(); // fuck this guy i hate him + files = files.concat([ + { + name: imgPath, + bytes: imgBytes + }, + { + name: xmlPath, + bytes: xmlBytes + } + ]); + } + params.files = files; return true; @@ -186,6 +209,16 @@ class AddCharFilesDialog extends DefaultWizardDialog return false; } + + function recursiveUploadBox():Void + { + var uploadBox = new UploadAssetsBox("Put the path to the Spritesheet Image here.", FileUtil.FILE_EXTENSION_INFO_PNG); + uploadBox.daField.onChange = _ -> { + uploadBox.daField.onChange = null; + recursiveUploadBox(); + }; + addAssetsBox.addComponent(uploadBox); + } } class UploadAssetsBox extends HBox diff --git a/source/funkin/ui/debug/char/pages/CharCreatorGameplayPage.hx b/source/funkin/ui/debug/char/pages/CharCreatorGameplayPage.hx index 479815a907..d5c3587ae8 100644 --- a/source/funkin/ui/debug/char/pages/CharCreatorGameplayPage.hx +++ b/source/funkin/ui/debug/char/pages/CharCreatorGameplayPage.hx @@ -9,8 +9,8 @@ import haxe.ui.components.VerticalRule; import funkin.data.stage.StageData; import funkin.play.stage.Bopper; import funkin.data.stage.StageData.StageDataCharacter; -import funkin.play.character.CharacterData; -import funkin.play.character.CharacterData.CharacterDataParser; +import funkin.data.character.CharacterData; +import funkin.data.character.CharacterRegistry; import funkin.play.character.BaseCharacter.CharacterType; import funkin.play.stage.StageProp; import funkin.data.stage.StageRegistry; @@ -251,7 +251,7 @@ class CharCreatorGameplayPage extends CharCreatorDefaultPage } else { - var data:CharacterData = CharacterDataParser.fetchCharacterData(ghostId); + var data:CharacterData = CharacterRegistry.fetchCharacterData(ghostId); if (data == null) return ghostId; GhostUtil.copyFromCharacterData(ghostCharacter, data); diff --git a/source/funkin/ui/debug/char/util/GhostUtil.hx b/source/funkin/ui/debug/char/util/GhostUtil.hx index d3f09f462b..d96db14d23 100644 --- a/source/funkin/ui/debug/char/util/GhostUtil.hx +++ b/source/funkin/ui/debug/char/util/GhostUtil.hx @@ -1,6 +1,6 @@ package funkin.ui.debug.char.util; -import funkin.play.character.CharacterData; +import funkin.data.character.CharacterData; import funkin.ui.debug.char.animate.CharSelectAtlasSprite; import funkin.ui.debug.char.pages.CharCreatorGameplayPage; import flixel.graphics.frames.FlxAtlasFrames; @@ -20,7 +20,7 @@ class GhostUtil switch (player.renderType) { case "sparrow" | "multisparrow": - if (ghost.generatedParams.files.length != 2) return; // img and data + if (ghost.generatedParams.files.length < 2) return; // img and data var combinedFrames = null; for (i in 0...Math.floor(ghost.generatedParams.files.length / 2)) @@ -64,7 +64,7 @@ class GhostUtil for (anim in player.animations) { - ghost.addAnimation(anim.name, anim.prefix, anim.offsets, anim.frameIndices, anim.assetPath, anim.frameRate, anim.looped, anim.flipX, anim.flipY); + ghost.addAnimation(anim.name, anim.prefix, anim.offsets, anim.frameIndices, anim.frameRate, anim.looped, anim.flipX, anim.flipY); } } @@ -77,26 +77,19 @@ class GhostUtil switch (data.renderType) { - case "sparrow": - ghost.frames = Paths.getSparrowAtlas(data.assetPath); - - case "packer": - ghost.frames = Paths.getPackerAtlas(data.assetPath); - - case "multisparrow": // lemz if you're reading this pls don't forget to update this once you're finished reworking multisparrow chars, thanks! - var allAssetPaths:Array = []; - - for (anim in data.animations) + case "sparrow" | "multisparrow": + var combinedFrames = null; + for (i => assetPath in data.assetPaths) { - if (anim.assetPath != null && !allAssetPaths.contains(anim.assetPath)) allAssetPaths.push(anim.assetPath); + if (combinedFrames == null) combinedFrames = Paths.getSparrowAtlas(assetPath); + else + combinedFrames.addAtlas(Paths.getSparrowAtlas(assetPath)); } - - var combinedFrames = Paths.getSparrowAtlas(data.assetPath); - for (path in allAssetPaths) - combinedFrames.addAtlas(Paths.getSparrowAtlas(path)); - ghost.frames = combinedFrames; + case "packer": + ghost.frames = Paths.getPackerAtlas(data.assetPaths[0]); + case "animateatlas": // TODO, gonna think of smth default: // nuthin @@ -108,8 +101,8 @@ class GhostUtil for (anim in data.animations) { - ghost.addAnimation(anim.name, anim.prefix, anim.offsets, anim.frameIndices ?? [], anim.assetPath ?? "", anim.frameRate ?? 24, anim.looped ?? false, - anim.flipX ?? false, anim.flipY ?? false); + ghost.addAnimation(anim.name, anim.prefix, anim.offsets, anim.frameIndices ?? [], anim.frameRate ?? 24, anim.looped ?? false, anim.flipX ?? false, + anim.flipY ?? false); } } }