diff --git a/source/funkin/InitState.hx b/source/funkin/InitState.hx index a0ca741623..60631f5455 100644 --- a/source/funkin/InitState.hx +++ b/source/funkin/InitState.hx @@ -22,7 +22,7 @@ import funkin.data.event.SongEventRegistry; import funkin.data.stage.StageRegistry; import funkin.data.story.level.LevelRegistry; import funkin.modding.module.ModuleHandler; -import funkin.play.character.CharacterData.CharacterDataParser; +import funkin.data.character.CharacterRegistry; import funkin.play.notes.notekind.NoteKindManager; import funkin.play.PlayStatePlaylist; import funkin.ui.debug.charting.ChartEditorState; @@ -177,9 +177,9 @@ class InitState extends FlxState AlbumRegistry.instance.loadEntries(); StageRegistry.instance.loadEntries(); - // TODO: CharacterDataParser doesn't use json2object, so it's way slower than the other parsers and more prone to syntax errors. + // TODO: CharacterRegistry doesn't use json2object, so it's way slower than the other parsers and more prone to syntax errors. // Move it to use a BaseRegistry. - CharacterDataParser.loadCharacterCache(); + CharacterRegistry.loadCharacterCache(); NoteKindManager.loadScripts(); diff --git a/source/funkin/data/animation/AnimationData.hx b/source/funkin/data/animation/AnimationData.hx index a0214096c7..d0a5c6dc1b 100644 --- a/source/funkin/data/animation/AnimationData.hx +++ b/source/funkin/data/animation/AnimationData.hx @@ -7,7 +7,6 @@ class AnimationDataUtil return { name: name, prefix: data.prefix, - assetPath: data.assetPath, offsets: data.offsets, looped: data.looped, flipX: data.flipX, @@ -21,7 +20,6 @@ class AnimationDataUtil { return { prefix: data.prefix, - assetPath: data.assetPath, offsets: data.offsets, looped: data.looped, flipX: data.flipX, @@ -65,14 +63,6 @@ typedef UnnamedAnimationData = @:optional var prefix:String; - /** - * Optionally specify an asset path to use for this specific animation. - * ONLY for use by MultiSparrow characters. - * @default The assetPath of the parent sprite - */ - @:optional - var assetPath:Null; - /** * Offset the character's position by this amount when playing this animation. * @default [0, 0] diff --git a/source/funkin/data/character/CharacterData.hx b/source/funkin/data/character/CharacterData.hx new file mode 100644 index 0000000000..e83d26634c --- /dev/null +++ b/source/funkin/data/character/CharacterData.hx @@ -0,0 +1,194 @@ +package funkin.data.character; + +import funkin.data.animation.AnimationData; + +/** + * Describes the available rendering types for a character. + */ +enum abstract CharacterRenderType(String) from String to String +{ + /** + * Renders the character using a single spritesheet and XML data. + */ + public var Sparrow = 'sparrow'; + + /** + * Renders the character using a single spritesheet and TXT data. + */ + public var Packer = 'packer'; + + /** + * Renders the character using multiple spritesheets and XML data. + */ + public var MultiSparrow = 'multisparrow'; + + /** + * Renders the character using a spritesheet of symbols and JSON data. + */ + public var AnimateAtlas = 'animateatlas'; + + /** + * Renders the character using a custom method. + */ + public var Custom = 'custom'; +} + +/** + * The JSON data schema used to define a character. + */ +typedef CharacterData = +{ + /** + * The sematic version number of the character data JSON format. + */ + var version:String; + + /** + * The readable name of the character. + */ + var name:String; + + /** + * The type of rendering system to use for the character. + * @default sparrow + */ + var renderType:CharacterRenderType; + + /** + * Behavior varies by render type: + * - SPARROW: Path to retrieve both the spritesheet and the XML data from. + * - PACKER: Path to retrieve both the spritsheet and the TXT data from. + */ + var assetPaths:Array; + + /** + * The scale of the graphic as a float. + * Pro tip: On pixel-art levels, save the sprites small and set this value to 6 or so to save memory. + * @default 1 + */ + var scale:Null; + + /** + * Optional data about the health icon for the character. + */ + var healthIcon:Null; + + var death:Null; + + /** + * The global offset to the character's position, in pixels. + * @default [0, 0] + */ + var offsets:Null>; + + /** + * The amount to offset the camera by while focusing on this character. + * Default value focuses on the character directly. + * @default [0, 0] + */ + var cameraOffsets:Array; + + /** + * Setting this to true disables anti-aliasing for the character. + * @default false + */ + var isPixel:Null; + + /** + * The frequency at which the character will play its idle animation, in beats. + * Increasing this number will make the character dance less often. + * Supports up to `0.25` precision. + * @default `1.0` on characters + */ + @:optional + @:default(1.0) + var danceEvery:Null; + + /** + * The minimum duration that a character will play a note animation for, in beats. + * If this number is too low, you may see the character start playing the idle animation between notes. + * If this number is too high, you may see the the character play the sing animation for too long after the notes are gone. + * + * Examples: + * - Daddy Dearest uses a value of `1.525`. + * @default 1.0 + */ + var singTime:Null; + + /** + * An optional array of animations which the character can play. + */ + var animations:Array; + + /** + * If animations are used, this is the name of the animation to play first. + * @default idle + */ + var startingAnimation:Null; + + /** + * Whether or not the whole ass sprite is flipped by default. + * Useful for characters that could also be played (Pico) + * + * @default false + */ + var flipX:Null; +}; + +/** + * The JSON data schema used to define the health icon for a character. + */ +typedef HealthIconData = +{ + /** + * The ID to use for the health icon. + * @default The character's ID + */ + var id:Null; + + /** + * The scale of the health icon. + */ + var scale:Null; + + /** + * Whether to flip the health icon horizontally. + * @default false + */ + var flipX:Null; + + /** + * Multiply scale by 6 and disable antialiasing + * @default false + */ + var isPixel:Null; + + /** + * The offset of the health icon, in pixels. + * @default [0, 25] + */ + var offsets:Null>; +} + +typedef DeathData = +{ + /** + * The amount to offset the camera by while focusing on this character as they die. + * Default value focuses on the character's graphic midpoint. + * @default [0, 0] + */ + var ?cameraOffsets:Array; + + /** + * The amount to zoom the camera by while focusing on this character as they die. + * Value is a multiplier of the default camera zoom for the stage. + * @default 1.0 + */ + var ?cameraZoom:Float; + + /** + * Impose a delay between when the character reaches `0` health and when the death animation plays. + * @default 0.0 + */ + var ?preTransitionDelay:Float; +} diff --git a/source/funkin/play/character/CharacterData.hx b/source/funkin/data/character/CharacterRegistry.hx similarity index 75% rename from source/funkin/play/character/CharacterData.hx rename to source/funkin/data/character/CharacterRegistry.hx index 54e7a6afb6..00065ef520 100644 --- a/source/funkin/play/character/CharacterData.hx +++ b/source/funkin/data/character/CharacterRegistry.hx @@ -1,8 +1,14 @@ -package funkin.play.character; +package funkin.data.character; import funkin.data.animation.AnimationData; +import funkin.data.character.CharacterData; import funkin.modding.events.ScriptEvent; import funkin.modding.events.ScriptEventDispatcher; +import funkin.play.character.AnimateAtlasCharacter; +import funkin.play.character.BaseCharacter; +import funkin.play.character.MultiSparrowCharacter; +import funkin.play.character.PackerCharacter; +import funkin.play.character.SparrowCharacter; import funkin.play.character.ScriptedCharacter.ScriptedAnimateAtlasCharacter; import funkin.play.character.ScriptedCharacter.ScriptedBaseCharacter; import funkin.play.character.ScriptedCharacter.ScriptedMultiSparrowCharacter; @@ -13,21 +19,23 @@ import funkin.util.VersionUtil; import haxe.Json; import flixel.graphics.frames.FlxFrame; -class CharacterDataParser +/** + * NOTE: This doesn't act the same as the other registries. + * It doesn't implement `BaseRegistry` and fetching produces a new instance rather than reusing them. + */ +class CharacterRegistry { /** - * The current version string for the stage data format. + * The current version string for the character data format. * Handle breaking changes by incrementing this value - * and adding migration to the `migrateStageData()` function. - * - * - Version 1.0.1 adds `death.cameraOffsets` + * and adding migration to the `migrateCharacterData()` function. */ - public static final CHARACTER_DATA_VERSION:String = '1.0.1'; + public static final CHARACTER_DATA_VERSION:String = '1.1.0'; /** * The current version rule check for the stage data format. */ - public static final CHARACTER_DATA_VERSION_RULE:String = '1.0.x'; + public static final CHARACTER_DATA_VERSION_RULE:String = '1.1.x'; static final characterCache:Map = new Map(); static final characterScriptedClass:Map = new Map(); @@ -378,14 +386,31 @@ class CharacterDataParser */ public static function parseCharacterData(charId:String):Null { - var rawJson:String = loadCharacterFile(charId); + var rawJson:JsonFile = loadCharacterFile(charId); - var charData:CharacterData = migrateCharacterData(rawJson, charId); + var charData:CharacterData = buildCharacterData(rawJson, charId); - return validateCharacterData(charId, charData); + if (charData == null) + { + // trace('[CHARACTER] Could not load character data for "$charId", check above for potential errors'); + return null; + } + if (CHARACTER_DATA_VERSION_RULE == null || VersionUtil.validateVersionStr(charData.version, CHARACTER_DATA_VERSION_RULE)) + { + return charData; + } + // else if (VersionUtil.validateVersion(charData.version, "1.0.x")) + // { + // return migrateCharacterData_v1_0_0(charData, charId); + // } + else + { + trace('[CHARACTER] Could not load character data for "$charId": bad version (got ${charData.version}, expected ${CHARACTER_DATA_VERSION_RULE})'); + return null; + } } - static function loadCharacterFile(charPath:String):String + static function loadCharacterFile(charPath:String):JsonFile { var charFilePath:String = Paths.json('characters/${charPath}'); var rawJson = Assets.getText(charFilePath).trim(); @@ -395,25 +420,32 @@ class CharacterDataParser rawJson = rawJson.substr(0, rawJson.length - 1); } - return rawJson; + return { + fileName: charFilePath, + contents: rawJson + }; } - static function migrateCharacterData(rawJson:String, charId:String):Null + static function buildCharacterData(rawJson:JsonFile, charId:String):Null { - // If you update the character data format in a breaking way, - // handle migration here by checking the `version` value. + var parser = new json2object.JsonParser(); + parser.ignoreUnknownVariables = false; - try + switch (rawJson) { - var charData:CharacterData = cast Json.parse(rawJson); - return charData; + case {fileName: fileName, contents: contents}: + parser.fromJson(contents, fileName); + default: + return null; } - catch (e) + + if (parser.errors.length > 0) { - trace(' Error parsing data for character: ${charId}'); - trace(' ${e}'); + trace(parser.errors, charId); return null; } + + return parser.value; } /** @@ -476,7 +508,7 @@ class CharacterDataParser input.renderType = DEFAULT_RENDERTYPE; } - if (input.assetPath == null) + if (input.assetPaths == null) { trace('ERROR: Could not load character data for "$id": missing assetPath'); return null; @@ -608,194 +640,3 @@ class CharacterDataParser return input; } } - -/** - * Describes the available rendering types for a character. - */ -enum abstract CharacterRenderType(String) from String to String -{ - /** - * Renders the character using a single spritesheet and XML data. - */ - public var Sparrow = 'sparrow'; - - /** - * Renders the character using a single spritesheet and TXT data. - */ - public var Packer = 'packer'; - - /** - * Renders the character using multiple spritesheets and XML data. - */ - public var MultiSparrow = 'multisparrow'; - - /** - * Renders the character using a spritesheet of symbols and JSON data. - */ - public var AnimateAtlas = 'animateatlas'; - - /** - * Renders the character using a custom method. - */ - public var Custom = 'custom'; -} - -/** - * The JSON data schema used to define a character. - */ -typedef CharacterData = -{ - /** - * The sematic version number of the character data JSON format. - */ - var version:String; - - /** - * The readable name of the character. - */ - var name:String; - - /** - * The type of rendering system to use for the character. - * @default sparrow - */ - var renderType:CharacterRenderType; - - /** - * Behavior varies by render type: - * - SPARROW: Path to retrieve both the spritesheet and the XML data from. - * - PACKER: Path to retrieve both the spritsheet and the TXT data from. - */ - var assetPath:String; - - /** - * The scale of the graphic as a float. - * Pro tip: On pixel-art levels, save the sprites small and set this value to 6 or so to save memory. - * @default 1 - */ - var scale:Null; - - /** - * Optional data about the health icon for the character. - */ - var healthIcon:Null; - - var death:Null; - - /** - * The global offset to the character's position, in pixels. - * @default [0, 0] - */ - var offsets:Null>; - - /** - * The amount to offset the camera by while focusing on this character. - * Default value focuses on the character directly. - * @default [0, 0] - */ - var cameraOffsets:Array; - - /** - * Setting this to true disables anti-aliasing for the character. - * @default false - */ - var isPixel:Null; - - /** - * The frequency at which the character will play its idle animation, in beats. - * Increasing this number will make the character dance less often. - * Supports up to `0.25` precision. - * @default `1.0` on characters - */ - @:optional - @:default(1.0) - var danceEvery:Null; - - /** - * The minimum duration that a character will play a note animation for, in beats. - * If this number is too low, you may see the character start playing the idle animation between notes. - * If this number is too high, you may see the the character play the sing animation for too long after the notes are gone. - * - * Examples: - * - Daddy Dearest uses a value of `1.525`. - * @default 1.0 - */ - var singTime:Null; - - /** - * An optional array of animations which the character can play. - */ - var animations:Array; - - /** - * If animations are used, this is the name of the animation to play first. - * @default idle - */ - var startingAnimation:Null; - - /** - * Whether or not the whole ass sprite is flipped by default. - * Useful for characters that could also be played (Pico) - * - * @default false - */ - var flipX:Null; -}; - -/** - * The JSON data schema used to define the health icon for a character. - */ -typedef HealthIconData = -{ - /** - * The ID to use for the health icon. - * @default The character's ID - */ - var id:Null; - - /** - * The scale of the health icon. - */ - var scale:Null; - - /** - * Whether to flip the health icon horizontally. - * @default false - */ - var flipX:Null; - - /** - * Multiply scale by 6 and disable antialiasing - * @default false - */ - var isPixel:Null; - - /** - * The offset of the health icon, in pixels. - * @default [0, 25] - */ - var offsets:Null>; -} - -typedef DeathData = -{ - /** - * The amount to offset the camera by while focusing on this character as they die. - * Default value focuses on the character's graphic midpoint. - * @default [0, 0] - */ - var ?cameraOffsets:Array; - - /** - * The amount to zoom the camera by while focusing on this character as they die. - * Value is a multiplier of the default camera zoom for the stage. - * @default 1.0 - */ - var ?cameraZoom:Float; - - /** - * Impose a delay between when the character reaches `0` health and when the death animation plays. - * @default 0.0 - */ - var ?preTransitionDelay:Float; -} diff --git a/source/funkin/data/character/migrator/CharacterDataMigrator.hx b/source/funkin/data/character/migrator/CharacterDataMigrator.hx new file mode 100644 index 0000000000..324ef14d02 --- /dev/null +++ b/source/funkin/data/character/migrator/CharacterDataMigrator.hx @@ -0,0 +1,55 @@ +package funkin.data.character.migrator; + +import funkin.data.character.CharacterData; +import funkin.data.character.CharacterRegistry; +import funkin.data.animation.AnimationData; + +class CharacterDataMigrator +{ + public static inline function migrate(input:CharacterData_v1_0_0.CharacterData_v1_0_0):CharacterData + { + return migrate_CharacterData_v1_0_0(input); + } + + public static function migrate_CharacterData_v1_0_0(input:CharacterData_v1_0_0.CharacterData_v1_0_0):CharacterData + { + return { + version: CharacterRegistry.CHARACTER_DATA_VERSION, + name: input.name, + renderType: input.renderType, + assetPaths: [input.assetPath], + scale: input.scale, + healthIcon: input.healthIcon, + death: input.death, + offsets: input.offsets, + cameraOffsets: input.cameraOffsets, + isPixel: input.isPixel, + danceEvery: input.danceEvery, + singTime: input.singTime, + animations: migrate_AnimationData_v1_0_0(input.animations), + startingAnimation: input.startingAnimation, + flipX: input.flipX, + }; + } + + static function migrate_AnimationData_v1_0_0(input:Array):Array + { + var animations:Array = []; + for (animation in input) + { + // no more assetPath + animations.push( + { + prefix: animation.prefix, + offsets: animation.offsets, + looped: animation.looped, + flipX: animation.flipX, + flipY: animation.flipY, + frameRate: animation.frameRate, + frameIndices: animation.frameIndices, + name: animation.name + }); + } + return animations; + } +} diff --git a/source/funkin/data/character/migrator/CharacterData_v1_0_0.hx b/source/funkin/data/character/migrator/CharacterData_v1_0_0.hx new file mode 100644 index 0000000000..0f1317bf51 --- /dev/null +++ b/source/funkin/data/character/migrator/CharacterData_v1_0_0.hx @@ -0,0 +1,188 @@ +package funkin.data.character.migrator; + +import funkin.data.character.CharacterData; + +/** + * The JSON data schema used to define a character. + */ +typedef CharacterData_v1_0_0 = +{ + /** + * The sematic version number of the character data JSON format. + */ + var version:String; + + /** + * The readable name of the character. + */ + var name:String; + + /** + * The type of rendering system to use for the character. + * @default sparrow + */ + var renderType:CharacterRenderType; + + /** + * Behavior varies by render type: + * - SPARROW: Path to retrieve both the spritesheet and the XML data from. + * - PACKER: Path to retrieve both the spritsheet and the TXT data from. + */ + var assetPath:String; + + /** + * The scale of the graphic as a float. + * Pro tip: On pixel-art levels, save the sprites small and set this value to 6 or so to save memory. + * @default 1 + */ + var scale:Null; + + /** + * Optional data about the health icon for the character. + */ + var healthIcon:Null; + + var death:Null; + + /** + * The global offset to the character's position, in pixels. + * @default [0, 0] + */ + var offsets:Null>; + + /** + * The amount to offset the camera by while focusing on this character. + * Default value focuses on the character directly. + * @default [0, 0] + */ + var cameraOffsets:Array; + + /** + * Setting this to true disables anti-aliasing for the character. + * @default false + */ + var isPixel:Null; + + /** + * The frequency at which the character will play its idle animation, in beats. + * Increasing this number will make the character dance less often. + * Supports up to `0.25` precision. + * @default `1.0` on characters + */ + @:optional + @:default(1.0) + var danceEvery:Null; + + /** + * The minimum duration that a character will play a note animation for, in beats. + * If this number is too low, you may see the character start playing the idle animation between notes. + * If this number is too high, you may see the the character play the sing animation for too long after the notes are gone. + * + * Examples: + * - Daddy Dearest uses a value of `1.525`. + * @default 1.0 + */ + var singTime:Null; + + /** + * An optional array of animations which the character can play. + */ + var animations:Array; + + /** + * If animations are used, this is the name of the animation to play first. + * @default idle + */ + var startingAnimation:Null; + + /** + * Whether or not the whole ass sprite is flipped by default. + * Useful for characters that could also be played (Pico) + * + * @default false + */ + var flipX:Null; +}; + +/** + * A data structure representing an animation in a spritesheet. + * This is a generic data structure used by characters, stage props, and more! + * BE CAREFUL when changing it. + */ +typedef AnimationData_v1_0_0 = +{ + /** + * The prefix for the frames of the animation as defined by the XML file. + * This will may or may not differ from the `name` of the animation, + * depending on how your animator organized their FLA or whatever. + * + * NOTE: For Sparrow animations, this is not optional, but for Packer animations it is. + */ + @:optional + var prefix:String; + + /** + * Optionally specify an asset path to use for this specific animation. + * ONLY for use by MultiSparrow characters. + * @default The assetPath of the parent sprite + */ + @:optional + var assetPath:Null; + + /** + * Offset the character's position by this amount when playing this animation. + * @default [0, 0] + */ + @:default([0, 0]) + @:optional + var offsets:Null>; + + /** + * Whether the animation should loop when it finishes. + * @default false + */ + @:default(false) + @:optional + var looped:Bool; + + /** + * Whether the animation's sprites should be flipped horizontally. + * @default false + */ + @:default(false) + @:optional + var flipX:Null; + + /** + * Whether the animation's sprites should be flipped vertically. + * @default false + */ + @:default(false) + @:optional + var flipY:Null; + + /** + * The frame rate of the animation. + * @default 24 + */ + @:default(24) + @:optional + var frameRate:Null; + + /** + * If you want this animation to use only certain frames of an animation with a given prefix, + * select them here. + * @example [0, 1, 2, 3] (use only the first four frames) + * @default [] (all frames) + */ + @:default([]) + @:optional + var frameIndices:Null>; + + /** + * The name for the animation. + * This should match the animation name queried by the game; + * for example, characters need animations with names `idle`, `singDOWN`, `singUPmiss`, etc. + */ + var name:String; +} diff --git a/source/funkin/modding/PolymodHandler.hx b/source/funkin/modding/PolymodHandler.hx index eb0e77fc55..eac8eba214 100644 --- a/source/funkin/modding/PolymodHandler.hx +++ b/source/funkin/modding/PolymodHandler.hx @@ -13,7 +13,7 @@ import funkin.data.freeplay.player.PlayerRegistry; import funkin.data.stage.StageRegistry; import funkin.data.freeplay.album.AlbumRegistry; import funkin.modding.module.ModuleHandler; -import funkin.play.character.CharacterData.CharacterDataParser; +import funkin.data.character.CharacterRegistry; import funkin.save.Save; import funkin.util.FileUtil; import funkin.util.macro.ClassMacro; @@ -333,8 +333,19 @@ class PolymodHandler { return { assetLibraryPaths: [ - 'default' => 'preload', 'shared' => 'shared', 'songs' => 'songs', 'videos' => 'videos', 'tutorial' => 'tutorial', 'week1' => 'week1', - 'week2' => 'week2', 'week3' => 'week3', 'week4' => 'week4', 'week5' => 'week5', 'week6' => 'week6', 'week7' => 'week7', 'weekend1' => 'weekend1', + 'default' => 'preload', + 'shared' => 'shared', + 'songs' => 'songs', + 'videos' => 'videos', + 'tutorial' => 'tutorial', + 'week1' => 'week1', + 'week2' => 'week2', + 'week3' => 'week3', + 'week4' => 'week4', + 'week5' => 'week5', + 'week6' => 'week6', + 'week7' => 'week7', + 'weekend1' => 'weekend1', ], coreAssetRedirect: CORE_FOLDER, } @@ -426,7 +437,7 @@ class PolymodHandler AlbumRegistry.instance.loadEntries(); StageRegistry.instance.loadEntries(); - CharacterDataParser.loadCharacterCache(); // TODO: Migrate characters to BaseRegistry. + CharacterRegistry.loadCharacterCache(); // TODO: Migrate characters to BaseRegistry. NoteKindManager.loadScripts(); ModuleHandler.loadModuleCache(); } diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index dbacf3fa96..2280686400 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -36,7 +36,7 @@ import funkin.input.PreciseInputManager; import funkin.modding.events.ScriptEvent; import funkin.modding.events.ScriptEventDispatcher; import funkin.play.character.BaseCharacter; -import funkin.play.character.CharacterData.CharacterDataParser; +import funkin.data.character.CharacterRegistry; import funkin.play.components.ComboMilestone; import funkin.play.components.HealthIcon; import funkin.play.components.PopUpStuff; @@ -1697,7 +1697,7 @@ class PlayState extends MusicBeatSubState // // GIRLFRIEND // - var girlfriend:BaseCharacter = CharacterDataParser.fetchCharacter(currentCharacterData.girlfriend); + var girlfriend:BaseCharacter = CharacterRegistry.fetchCharacter(currentCharacterData.girlfriend); if (girlfriend != null) { @@ -1715,7 +1715,7 @@ class PlayState extends MusicBeatSubState // // DAD // - var dad:BaseCharacter = CharacterDataParser.fetchCharacter(currentCharacterData.opponent); + var dad:BaseCharacter = CharacterRegistry.fetchCharacter(currentCharacterData.opponent); if (dad != null) { @@ -1738,7 +1738,7 @@ class PlayState extends MusicBeatSubState // // BOYFRIEND // - var boyfriend:BaseCharacter = CharacterDataParser.fetchCharacter(currentCharacterData.player); + var boyfriend:BaseCharacter = CharacterRegistry.fetchCharacter(currentCharacterData.player); if (boyfriend != null) { diff --git a/source/funkin/play/character/AnimateAtlasCharacter.hx b/source/funkin/play/character/AnimateAtlasCharacter.hx index 22af05b242..c8d86e4f83 100644 --- a/source/funkin/play/character/AnimateAtlasCharacter.hx +++ b/source/funkin/play/character/AnimateAtlasCharacter.hx @@ -15,7 +15,7 @@ import flixel.util.FlxColor; import flixel.util.FlxDestroyUtil; import funkin.graphics.adobeanimate.FlxAtlasSprite; import funkin.modding.events.ScriptEvent; -import funkin.play.character.CharacterData.CharacterRenderType; +import funkin.data.character.CharacterData.CharacterRenderType; import openfl.display.BitmapData; import openfl.display.BlendMode; @@ -129,8 +129,8 @@ class AnimateAtlasCharacter extends BaseCharacter { trace('[ATLASCHAR] Loading sprite atlas for ${characterId}.'); - var animLibrary:String = Paths.getLibrary(_data.assetPath); - var animPath:String = Paths.stripLibrary(_data.assetPath); + var animLibrary:String = Paths.getLibrary(_data.assetPaths[0]); + var animPath:String = Paths.stripLibrary(_data.assetPaths[0]); var assetPath:String = Paths.animateAtlas(animPath, animLibrary); var sprite:FlxAtlasSprite = new FlxAtlasSprite(0, 0, assetPath); @@ -199,8 +199,8 @@ class AnimateAtlasCharacter extends BaseCharacter var prefix = anim.prefix; if (!this.mainSprite.hasAnimation(prefix)) { - FlxG.log.warn('[ATLASCHAR] Animation ${prefix} not found in Animate Atlas ${_data.assetPath}'); - trace('[ATLASCHAR] Animation ${prefix} not found in Animate Atlas ${_data.assetPath}'); + FlxG.log.warn('[ATLASCHAR] Animation ${prefix} not found in Animate Atlas ${_data.assetPaths[0]}'); + trace('[ATLASCHAR] Animation ${prefix} not found in Animate Atlas ${_data.assetPaths[0]}'); continue; } animations.set(anim.name, anim); diff --git a/source/funkin/play/character/BaseCharacter.hx b/source/funkin/play/character/BaseCharacter.hx index a7fdee3fba..ebc894375a 100644 --- a/source/funkin/play/character/BaseCharacter.hx +++ b/source/funkin/play/character/BaseCharacter.hx @@ -2,8 +2,8 @@ package funkin.play.character; import flixel.math.FlxPoint; import funkin.modding.events.ScriptEvent; -import funkin.play.character.CharacterData.CharacterDataParser; -import funkin.play.character.CharacterData.CharacterRenderType; +import funkin.data.character.CharacterRegistry; +import funkin.data.character.CharacterData; import funkin.play.stage.Bopper; import funkin.play.notes.NoteDirection; @@ -148,12 +148,12 @@ class BaseCharacter extends Bopper public function new(id:String, renderType:CharacterRenderType) { - super(CharacterDataParser.DEFAULT_DANCEEVERY); + super(CharacterRegistry.DEFAULT_DANCEEVERY); this.characterId = id; ignoreExclusionPref = ["sing"]; - _data = CharacterDataParser.fetchCharacterData(this.characterId); + _data = CharacterRegistry.fetchCharacterData(this.characterId); if (_data == null) { throw 'Could not find character data for characterId: $characterId'; diff --git a/source/funkin/play/character/MultiSparrowCharacter.hx b/source/funkin/play/character/MultiSparrowCharacter.hx index 63935a5327..84d2ee20f5 100644 --- a/source/funkin/play/character/MultiSparrowCharacter.hx +++ b/source/funkin/play/character/MultiSparrowCharacter.hx @@ -4,9 +4,7 @@ import flixel.graphics.frames.FlxAtlasFrames; import flixel.graphics.frames.FlxFramesCollection; import funkin.modding.events.ScriptEvent; import funkin.util.assets.FlxAnimationUtil; -import funkin.play.character.CharacterData.CharacterRenderType; - -// TODO: no more assetPath per animation, rather make `assetPath` an array +import funkin.data.character.CharacterData.CharacterRenderType; /** * For some characters which use Sparrow atlases, the spritesheets need to be split @@ -56,25 +54,18 @@ class MultiSparrowCharacter extends BaseCharacter function buildSpritesheet():Void { var assetList = []; - for (anim in _data.animations) - { - if (anim.assetPath != null && !assetList.contains(anim.assetPath)) - { - assetList.push(anim.assetPath); - } - } - var texture:FlxAtlasFrames = Paths.getSparrowAtlas(_data.assetPath); + var texture:FlxAtlasFrames = Paths.getSparrowAtlas(_data.assetPaths[0]); if (texture == null) { - trace('Multi-Sparrow atlas could not load PRIMARY texture: ${_data.assetPath}'); - FlxG.log.error('Multi-Sparrow atlas could not load PRIMARY texture: ${_data.assetPath}'); + trace('Multi-Sparrow atlas could not load PRIMARY texture: ${_data.assetPaths[0]}'); + FlxG.log.error('Multi-Sparrow atlas could not load PRIMARY texture: ${_data.assetPaths[0]}'); return; } else { - trace('Creating multi-sparrow atlas: ${_data.assetPath}'); + trace('Creating multi-sparrow atlas: ${_data.assetPaths[0]}'); texture.parent.destroyOnNoUse = false; } diff --git a/source/funkin/play/character/PackerCharacter.hx b/source/funkin/play/character/PackerCharacter.hx index 5d004606ca..863a85da66 100644 --- a/source/funkin/play/character/PackerCharacter.hx +++ b/source/funkin/play/character/PackerCharacter.hx @@ -2,7 +2,7 @@ package funkin.play.character; import flixel.graphics.frames.FlxFramesCollection; import funkin.modding.events.ScriptEvent; -import funkin.play.character.CharacterData.CharacterRenderType; +import funkin.data.character.CharacterData.CharacterRenderType; import funkin.util.assets.FlxAnimationUtil; /** @@ -28,12 +28,12 @@ class PackerCharacter extends BaseCharacter function loadSpritesheet():Void { - trace('[PACKERCHAR] Loading spritesheet ${_data.assetPath} for ${characterId}'); + trace('[PACKERCHAR] Loading spritesheet ${_data.assetPaths[0]} for ${characterId}'); - var tex:FlxFramesCollection = Paths.getPackerAtlas(_data.assetPath); + var tex:FlxFramesCollection = Paths.getPackerAtlas(_data.assetPaths[0]); if (tex == null) { - trace('Could not load Packer sprite: ${_data.assetPath}'); + trace('Could not load Packer sprite: ${_data.assetPaths[0]}'); return; } diff --git a/source/funkin/play/character/SparrowCharacter.hx b/source/funkin/play/character/SparrowCharacter.hx index eacf799d8a..70d9e55203 100644 --- a/source/funkin/play/character/SparrowCharacter.hx +++ b/source/funkin/play/character/SparrowCharacter.hx @@ -3,7 +3,7 @@ package funkin.play.character; import funkin.modding.events.ScriptEvent; import funkin.util.assets.FlxAnimationUtil; import flixel.graphics.frames.FlxFramesCollection; -import funkin.play.character.CharacterData.CharacterRenderType; +import funkin.data.character.CharacterData.CharacterRenderType; /** * A SparrowCharacter is a Character which is rendered by @@ -31,12 +31,12 @@ class SparrowCharacter extends BaseCharacter function loadSpritesheet() { - trace('[SPARROWCHAR] Loading spritesheet ${_data.assetPath} for ${characterId}'); + trace('[SPARROWCHAR] Loading spritesheet ${_data.assetPaths[0]} for ${characterId}'); - var tex:FlxFramesCollection = Paths.getSparrowAtlas(_data.assetPath); + var tex:FlxFramesCollection = Paths.getSparrowAtlas(_data.assetPaths[0]); if (tex == null) { - trace('Could not load Sparrow sprite: ${_data.assetPath}'); + trace('Could not load Sparrow sprite: ${_data.assetPaths[0]}'); return; } diff --git a/source/funkin/play/components/HealthIcon.hx b/source/funkin/play/components/HealthIcon.hx index f6430457f5..62853d9769 100644 --- a/source/funkin/play/components/HealthIcon.hx +++ b/source/funkin/play/components/HealthIcon.hx @@ -1,10 +1,9 @@ package funkin.play.components; -import funkin.play.character.CharacterData; import flixel.FlxSprite; import flixel.math.FlxMath; import flixel.math.FlxPoint; -import funkin.play.character.CharacterData.CharacterDataParser; +import funkin.data.character.CharacterData; import funkin.graphics.FunkinSprite; import funkin.util.MathUtil; diff --git a/source/funkin/ui/charSelect/CharacterUnlockState.hx b/source/funkin/ui/charSelect/CharacterUnlockState.hx index b32a35145c..0fc2ee0ce9 100644 --- a/source/funkin/ui/charSelect/CharacterUnlockState.hx +++ b/source/funkin/ui/charSelect/CharacterUnlockState.hx @@ -7,12 +7,11 @@ import flixel.text.FlxText; import flixel.tweens.FlxEase; import flixel.tweens.FlxTween; import flixel.util.FlxColor; -import funkin.play.character.CharacterData; -import funkin.play.character.CharacterData.CharacterDataParser; import funkin.play.components.HealthIcon; import funkin.ui.freeplay.charselect.PlayableCharacter; import funkin.data.freeplay.player.PlayerData; import funkin.data.freeplay.player.PlayerRegistry; +import funkin.data.character.CharacterRegistry; import funkin.ui.mainmenu.MainMenuState; using flixel.util.FlxSpriteUtil; @@ -76,7 +75,7 @@ class CharacterUnlockState extends MusicBeatState // HealthIcon handles getting the right frames for us, // but it has a bunch of overhead in it that makes it gross to work with outside the health bar. var healthIconCharacterId = targetCharacterData.getOwnedCharacterIds()[0]; - var baseCharacter = CharacterDataParser.fetchCharacter(healthIconCharacterId); + var baseCharacter = CharacterRegistry.fetchCharacter(healthIconCharacterId); var healthIcon:HealthIcon = new HealthIcon(healthIconCharacterId); @:privateAccess healthIcon.configure(baseCharacter._data.healthIcon); diff --git a/source/funkin/ui/debug/anim/DebugBoundingState.hx b/source/funkin/ui/debug/anim/DebugBoundingState.hx index 157d20aa1b..8f9cac37dd 100644 --- a/source/funkin/ui/debug/anim/DebugBoundingState.hx +++ b/source/funkin/ui/debug/anim/DebugBoundingState.hx @@ -12,8 +12,8 @@ import flixel.text.FlxText; import flixel.util.FlxColor; import funkin.input.Cursor; import funkin.play.character.BaseCharacter; -import funkin.play.character.CharacterData; -import funkin.play.character.CharacterData.CharacterDataParser; +import funkin.data.character.CharacterData; +import funkin.data.character.CharacterRegistry; import funkin.ui.mainmenu.MainMenuState; import funkin.util.MouseUtil; import funkin.util.SerializerUtil; @@ -192,9 +192,9 @@ class DebugBoundingState extends FlxState txtOffsetShit.y = FlxG.height - 20 - txtOffsetShit.height; offsetView.add(txtOffsetShit); - var characters:Array = CharacterDataParser.listCharacterIds(); + var characters:Array = CharacterRegistry.listCharacterIds(); characters = characters.filter(function(charId:String) { - var char = CharacterDataParser.fetchCharacterData(charId); + var char = CharacterRegistry.fetchCharacterData(charId); return char.renderType != AnimateAtlas; }); characters.sort(SortUtil.alphabetically); @@ -489,7 +489,7 @@ class DebugBoundingState extends FlxState swagChar.destroy(); } - swagChar = CharacterDataParser.fetchCharacter(char); + swagChar = CharacterRegistry.fetchCharacter(char); swagChar.x = 100; swagChar.y = 100; swagChar.debug = true; @@ -504,7 +504,7 @@ class DebugBoundingState extends FlxState bf.pixels = swagChar.pixels; clearInfo(); - addInfo(swagChar._data.assetPath, ""); + addInfo(swagChar._data.assetPaths[0], ""); addInfo('Width', bf.width); addInfo('Height', bf.height); diff --git a/source/funkin/ui/debug/char/CharCreatorCharacter.hx b/source/funkin/ui/debug/char/CharCreatorCharacter.hx index dbe5137058..472e977362 100644 --- a/source/funkin/ui/debug/char/CharCreatorCharacter.hx +++ b/source/funkin/ui/debug/char/CharCreatorCharacter.hx @@ -4,7 +4,7 @@ import flixel.graphics.frames.FlxAtlasFrames; import openfl.display.BitmapData; import funkin.data.animation.AnimationData; import funkin.play.character.BaseCharacter.CharacterType; -import funkin.play.character.CharacterData.CharacterDataParser; +import funkin.data.character.CharacterRegistry; import funkin.ui.debug.char.animate.CharSelectAtlasSprite; import funkin.play.stage.Bopper; import flixel.math.FlxPoint; @@ -40,7 +40,7 @@ class CharCreatorCharacter extends Bopper override public function new(wizardParams:WizardGenerateParams) { - super(CharacterDataParser.DEFAULT_DANCEEVERY); + super(CharacterRegistry.DEFAULT_DANCEEVERY); ignoreExclusionPref = ["sing"]; shouldBop = false; @@ -140,7 +140,6 @@ class CharCreatorCharacter extends Bopper name: name, prefix: prefix, frameIndices: indices, - assetPath: animPath, frameRate: frameRate, flipX: flipX, flipY: flipY, diff --git a/source/funkin/ui/debug/char/components/dialogs/AddAnimDialog.hx b/source/funkin/ui/debug/char/components/dialogs/AddAnimDialog.hx index 12d42dbb37..6a7ee54d27 100644 --- a/source/funkin/ui/debug/char/components/dialogs/AddAnimDialog.hx +++ b/source/funkin/ui/debug/char/components/dialogs/AddAnimDialog.hx @@ -42,7 +42,6 @@ class AddAnimDialog extends DefaultPageDialog charAnimName.text = animData.name; charAnimPrefix.text = animData.prefix; - charAnimPath.text = animData.assetPath; charAnimFrames.text = (animData.frameIndices != null && animData.frameIndices.length > 0 ? animData.frameIndices.join(", ") : ""); charAnimLooped.selected = animData.looped ?? false; diff --git a/source/funkin/ui/debug/char/components/dialogs/GhostSettingsDialog.hx b/source/funkin/ui/debug/char/components/dialogs/GhostSettingsDialog.hx index 82e5556308..52c0f04dcb 100644 --- a/source/funkin/ui/debug/char/components/dialogs/GhostSettingsDialog.hx +++ b/source/funkin/ui/debug/char/components/dialogs/GhostSettingsDialog.hx @@ -3,8 +3,8 @@ package funkin.ui.debug.char.components.dialogs; import haxe.ui.core.Screen; import haxe.ui.containers.Grid; import haxe.ui.containers.menus.Menu; -import funkin.play.character.CharacterData; -import funkin.play.character.CharacterData.CharacterDataParser; +import funkin.data.character.CharacterData; +import funkin.data.character.CharacterRegistry; import funkin.util.SortUtil; import flixel.tweens.FlxEase; import flixel.tweens.FlxTween; @@ -18,8 +18,8 @@ class GhostSettingsDialog extends DefaultPageDialog { super(daPage); - var charData = CharacterDataParser.fetchCharacterData(Constants.DEFAULT_CHARACTER); - ghostTypeButton.icon = (charData == null ? null : CharacterDataParser.getCharPixelIconAsset(Constants.DEFAULT_CHARACTER)); + var charData = CharacterRegistry.fetchCharacterData(Constants.DEFAULT_CHARACTER); + ghostTypeButton.icon = (charData == null ? null : CharacterRegistry.getCharPixelIconAsset(Constants.DEFAULT_CHARACTER)); ghostTypeButton.text = (charData == null ? "None" : charData.name.length > 6 ? '${charData.name.substr(0, 6)}.' : '${charData.name}'); // callbacks @@ -70,14 +70,14 @@ class GhostCharacterMenu extends Menu charGrid.width = this.width; ghostSelectScroll.addComponent(charGrid); - var charIds = CharacterDataParser.listCharacterIds(); + var charIds = CharacterRegistry.listCharacterIds(); charIds.sort(SortUtil.alphabetically); var defaultText:String = '(choose a character)'; for (charIndex => charId in charIds) { - var charData:CharacterData = CharacterDataParser.fetchCharacterData(charId); + var charData:CharacterData = CharacterRegistry.fetchCharacterData(charId); var charButton = new haxe.ui.components.Button(); charButton.width = 70; @@ -95,7 +95,7 @@ class GhostCharacterMenu extends Menu }*/ var LIMIT = 6; - charButton.icon = CharacterDataParser.getCharPixelIconAsset(charId); + charButton.icon = CharacterRegistry.getCharPixelIconAsset(charId); charButton.text = charData.name.length > LIMIT ? '${charData.name.substr(0, LIMIT)}.' : '${charData.name}'; charButton.onClick = _ -> diff --git a/source/funkin/ui/debug/char/util/GhostUtil.hx b/source/funkin/ui/debug/char/util/GhostUtil.hx index 63c800d5ff..a954d63798 100644 --- a/source/funkin/ui/debug/char/util/GhostUtil.hx +++ b/source/funkin/ui/debug/char/util/GhostUtil.hx @@ -52,7 +52,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); ghost.setAnimationOffsets(anim.name, anim.offsets[0], anim.offsets[1]); } } diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx index 3fb63a4f1e..0810bae303 100644 --- a/source/funkin/ui/debug/charting/ChartEditorState.hx +++ b/source/funkin/ui/debug/charting/ChartEditorState.hx @@ -48,8 +48,8 @@ import funkin.input.TurboKeyHandler; import funkin.modding.events.ScriptEvent; import funkin.play.notes.notekind.NoteKindManager; import funkin.play.character.BaseCharacter.CharacterType; -import funkin.play.character.CharacterData; -import funkin.play.character.CharacterData.CharacterDataParser; +import funkin.data.character.CharacterData; +import funkin.data.character.CharacterRegistry; import funkin.play.components.HealthIcon; import funkin.play.notes.NoteSprite; import funkin.play.PlayState; @@ -5382,8 +5382,8 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState { if (healthIconsDirty) { - var charDataBF = CharacterDataParser.fetchCharacterData(currentSongMetadata.playData.characters.player); - var charDataDad = CharacterDataParser.fetchCharacterData(currentSongMetadata.playData.characters.opponent); + var charDataBF = CharacterRegistry.fetchCharacterData(currentSongMetadata.playData.characters.player); + var charDataDad = CharacterRegistry.fetchCharacterData(currentSongMetadata.playData.characters.opponent); if (healthIconBF != null) { healthIconBF.configure(charDataBF?.healthIcon); @@ -5654,7 +5654,8 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState function handleHelpKeybinds():Void { // F1 = Open Help - if (FlxG.keys.justPressed.F1 && !isHaxeUIDialogOpen) { + if (FlxG.keys.justPressed.F1 && !isHaxeUIDialogOpen) + { this.openUserGuideDialog(); } } diff --git a/source/funkin/ui/debug/charting/dialogs/ChartEditorCharacterIconSelectorMenu.hx b/source/funkin/ui/debug/charting/dialogs/ChartEditorCharacterIconSelectorMenu.hx index 90d998a027..ecf61b8a06 100644 --- a/source/funkin/ui/debug/charting/dialogs/ChartEditorCharacterIconSelectorMenu.hx +++ b/source/funkin/ui/debug/charting/dialogs/ChartEditorCharacterIconSelectorMenu.hx @@ -2,8 +2,8 @@ package funkin.ui.debug.charting.dialogs; import flixel.math.FlxPoint; import funkin.play.character.BaseCharacter.CharacterType; -import funkin.play.character.CharacterData; -import funkin.play.character.CharacterData.CharacterDataParser; +import funkin.data.character.CharacterData; +import funkin.data.character.CharacterRegistry; import funkin.play.components.HealthIcon; import funkin.ui.debug.charting.dialogs.ChartEditorBaseDialog.DialogParams; import funkin.util.SortUtil; @@ -70,14 +70,14 @@ class ChartEditorCharacterIconSelectorMenu extends ChartEditorBaseMenu charGrid.width = this.width; charSelectScroll.addComponent(charGrid); - var charIds:Array = CharacterDataParser.listCharacterIds(); + var charIds:Array = CharacterRegistry.listCharacterIds(); charIds.sort(SortUtil.alphabetically); var defaultText:String = '(choose a character)'; for (charIndex => charId in charIds) { - var charData:CharacterData = CharacterDataParser.fetchCharacterData(charId); + var charData:CharacterData = CharacterRegistry.fetchCharacterData(charId); var charButton = new haxe.ui.components.Button(); charButton.width = 70; @@ -95,7 +95,7 @@ class ChartEditorCharacterIconSelectorMenu extends ChartEditorBaseMenu } var LIMIT = 6; - charButton.icon = haxe.ui.util.Variant.fromImageData(CharacterDataParser.getCharPixelIconAsset(charId)); + charButton.icon = haxe.ui.util.Variant.fromImageData(CharacterRegistry.getCharPixelIconAsset(charId)); charButton.text = charData.name.length > LIMIT ? '${charData.name.substr(0, LIMIT)}.' : '${charData.name}'; charButton.onClick = _ -> { diff --git a/source/funkin/ui/debug/charting/dialogs/ChartEditorUploadVocalsDialog.hx b/source/funkin/ui/debug/charting/dialogs/ChartEditorUploadVocalsDialog.hx index 537c7c36ed..c9db151b50 100644 --- a/source/funkin/ui/debug/charting/dialogs/ChartEditorUploadVocalsDialog.hx +++ b/source/funkin/ui/debug/charting/dialogs/ChartEditorUploadVocalsDialog.hx @@ -4,7 +4,8 @@ import funkin.input.Cursor; import funkin.ui.debug.charting.dialogs.ChartEditorBaseDialog.DialogDropTarget; import funkin.ui.debug.charting.dialogs.ChartEditorBaseDialog.DialogParams; import funkin.util.FileUtil; -import funkin.play.character.CharacterData; +import funkin.data.character.CharacterData; +import funkin.data.character.CharacterRegistry; import haxe.io.Path; import haxe.ui.components.Button; import haxe.ui.components.Label; @@ -64,7 +65,7 @@ class ChartEditorUploadVocalsDialog extends ChartEditorBaseDialog { trace('Adding vocal upload for character ${charKey}'); - var charMetadata:Null = CharacterDataParser.fetchCharacterData(charKey); + var charMetadata:Null = CharacterRegistry.fetchCharacterData(charKey); var charName:String = charMetadata?.name ?? charKey; var vocalsEntry = new ChartEditorUploadVocalsEntry(charName); diff --git a/source/funkin/ui/debug/charting/handlers/ChartEditorDialogHandler.hx b/source/funkin/ui/debug/charting/handlers/ChartEditorDialogHandler.hx index ab13da1d92..1dc37630ca 100644 --- a/source/funkin/ui/debug/charting/handlers/ChartEditorDialogHandler.hx +++ b/source/funkin/ui/debug/charting/handlers/ChartEditorDialogHandler.hx @@ -10,8 +10,6 @@ import funkin.data.song.SongData.SongTimeChange; import funkin.data.song.SongRegistry; import funkin.input.Cursor; import funkin.play.character.BaseCharacter; -import funkin.play.character.CharacterData; -import funkin.play.character.CharacterData.CharacterDataParser; import funkin.play.song.Song; import funkin.data.stage.StageData; import funkin.ui.debug.charting.dialogs.ChartEditorAboutDialog; diff --git a/source/funkin/ui/debug/charting/handlers/ChartEditorToolboxHandler.hx b/source/funkin/ui/debug/charting/handlers/ChartEditorToolboxHandler.hx index f82bc3c1fc..092633a869 100644 --- a/source/funkin/ui/debug/charting/handlers/ChartEditorToolboxHandler.hx +++ b/source/funkin/ui/debug/charting/handlers/ChartEditorToolboxHandler.hx @@ -1,8 +1,6 @@ package funkin.ui.debug.charting.handlers; import funkin.data.stage.StageData; -import funkin.play.character.CharacterData; -import funkin.play.character.CharacterData.CharacterDataParser; import haxe.ui.components.HorizontalSlider; import haxe.ui.containers.TreeView; import haxe.ui.containers.TreeViewNode; @@ -11,8 +9,6 @@ import funkin.play.event.SongEvent; import funkin.data.event.SongEventSchema; import funkin.data.song.SongData.SongTimeChange; import funkin.play.character.BaseCharacter.CharacterType; -import funkin.play.character.CharacterData; -import funkin.play.character.CharacterData.CharacterDataParser; import funkin.play.event.SongEvent; import funkin.play.song.SongSerializer; import funkin.data.stage.StageData; diff --git a/source/funkin/ui/debug/charting/toolboxes/ChartEditorDifficultyToolbox.hx b/source/funkin/ui/debug/charting/toolboxes/ChartEditorDifficultyToolbox.hx index 1163c1b96f..dd6cef4054 100644 --- a/source/funkin/ui/debug/charting/toolboxes/ChartEditorDifficultyToolbox.hx +++ b/source/funkin/ui/debug/charting/toolboxes/ChartEditorDifficultyToolbox.hx @@ -1,7 +1,6 @@ package funkin.ui.debug.charting.toolboxes; import funkin.play.character.BaseCharacter.CharacterType; -import funkin.play.character.CharacterData; import funkin.data.stage.StageData; import funkin.data.stage.StageRegistry; import funkin.ui.debug.charting.commands.ChangeStartingBPMCommand; diff --git a/source/funkin/ui/debug/charting/toolboxes/ChartEditorEventDataToolbox.hx b/source/funkin/ui/debug/charting/toolboxes/ChartEditorEventDataToolbox.hx index 70580300ea..cdbc2ed1f2 100644 --- a/source/funkin/ui/debug/charting/toolboxes/ChartEditorEventDataToolbox.hx +++ b/source/funkin/ui/debug/charting/toolboxes/ChartEditorEventDataToolbox.hx @@ -1,7 +1,6 @@ package funkin.ui.debug.charting.toolboxes; import funkin.play.character.BaseCharacter.CharacterType; -import funkin.play.character.CharacterData; import funkin.data.stage.StageData; import funkin.play.event.SongEvent; import funkin.data.event.SongEventSchema; diff --git a/source/funkin/ui/debug/charting/toolboxes/ChartEditorMetadataToolbox.hx b/source/funkin/ui/debug/charting/toolboxes/ChartEditorMetadataToolbox.hx index f68776cabf..c65dfbc208 100644 --- a/source/funkin/ui/debug/charting/toolboxes/ChartEditorMetadataToolbox.hx +++ b/source/funkin/ui/debug/charting/toolboxes/ChartEditorMetadataToolbox.hx @@ -1,7 +1,8 @@ package funkin.ui.debug.charting.toolboxes; import funkin.play.character.BaseCharacter.CharacterType; -import funkin.play.character.CharacterData; +import funkin.data.character.CharacterData; +import funkin.data.character.CharacterRegistry; import funkin.data.stage.StageData; import funkin.data.stage.StageRegistry; import funkin.ui.debug.charting.commands.ChangeStartingBPMCommand; @@ -218,10 +219,10 @@ class ChartEditorMetadataToolbox extends ChartEditorBaseToolbox var LIMIT = 6; - var charDataOpponent:Null = CharacterDataParser.fetchCharacterData(chartEditorState.currentSongMetadata.playData.characters.opponent); + var charDataOpponent:Null = CharacterRegistry.fetchCharacterData(chartEditorState.currentSongMetadata.playData.characters.opponent); if (charDataOpponent != null) { - buttonCharacterOpponent.icon = haxe.ui.util.Variant.fromImageData(CharacterDataParser.getCharPixelIconAsset(chartEditorState.currentSongMetadata.playData.characters.opponent)); + buttonCharacterOpponent.icon = haxe.ui.util.Variant.fromImageData(CharacterRegistry.getCharPixelIconAsset(chartEditorState.currentSongMetadata.playData.characters.opponent)); buttonCharacterOpponent.text = charDataOpponent.name.length > LIMIT ? '${charDataOpponent.name.substr(0, LIMIT)}.' : '${charDataOpponent.name}'; } else @@ -230,10 +231,10 @@ class ChartEditorMetadataToolbox extends ChartEditorBaseToolbox buttonCharacterOpponent.text = "None"; } - var charDataGirlfriend:Null = CharacterDataParser.fetchCharacterData(chartEditorState.currentSongMetadata.playData.characters.girlfriend); + var charDataGirlfriend:Null = CharacterRegistry.fetchCharacterData(chartEditorState.currentSongMetadata.playData.characters.girlfriend); if (charDataGirlfriend != null) { - buttonCharacterGirlfriend.icon = haxe.ui.util.Variant.fromImageData(CharacterDataParser.getCharPixelIconAsset(chartEditorState.currentSongMetadata.playData.characters.girlfriend)); + buttonCharacterGirlfriend.icon = haxe.ui.util.Variant.fromImageData(CharacterRegistry.getCharPixelIconAsset(chartEditorState.currentSongMetadata.playData.characters.girlfriend)); buttonCharacterGirlfriend.text = charDataGirlfriend.name.length > LIMIT ? '${charDataGirlfriend.name.substr(0, LIMIT)}.' : '${charDataGirlfriend.name}'; } else @@ -242,10 +243,10 @@ class ChartEditorMetadataToolbox extends ChartEditorBaseToolbox buttonCharacterGirlfriend.text = "None"; } - var charDataPlayer:Null = CharacterDataParser.fetchCharacterData(chartEditorState.currentSongMetadata.playData.characters.player); + var charDataPlayer:Null = CharacterRegistry.fetchCharacterData(chartEditorState.currentSongMetadata.playData.characters.player); if (charDataPlayer != null) { - buttonCharacterPlayer.icon = haxe.ui.util.Variant.fromImageData(CharacterDataParser.getCharPixelIconAsset(chartEditorState.currentSongMetadata.playData.characters.player)); + buttonCharacterPlayer.icon = haxe.ui.util.Variant.fromImageData(CharacterRegistry.getCharPixelIconAsset(chartEditorState.currentSongMetadata.playData.characters.player)); buttonCharacterPlayer.text = charDataPlayer.name.length > LIMIT ? '${charDataPlayer.name.substr(0, LIMIT)}.' : '${charDataPlayer.name}'; } else diff --git a/source/funkin/ui/debug/charting/util/ChartEditorDropdowns.hx b/source/funkin/ui/debug/charting/util/ChartEditorDropdowns.hx index 21938b0057..aebb5b3808 100644 --- a/source/funkin/ui/debug/charting/util/ChartEditorDropdowns.hx +++ b/source/funkin/ui/debug/charting/util/ChartEditorDropdowns.hx @@ -5,12 +5,12 @@ import funkin.play.notes.notestyle.NoteStyle; import funkin.data.stage.StageData; import funkin.play.event.SongEvent; import funkin.data.stage.StageRegistry; -import funkin.play.character.CharacterData; import haxe.ui.components.DropDown; import funkin.play.stage.Stage; import funkin.play.character.BaseCharacter.CharacterType; import funkin.data.event.SongEventRegistry; -import funkin.play.character.CharacterData.CharacterDataParser; +import funkin.data.character.CharacterData; +import funkin.data.character.CharacterRegistry; /** * Functions for populating dropdowns based on game data. @@ -28,7 +28,7 @@ class ChartEditorDropdowns dropDown.dataSource.clear(); // TODO: Filter based on charType. - var charIds:Array = CharacterDataParser.listCharacterIds(); + var charIds:Array = CharacterRegistry.listCharacterIds(); var returnValue:DropDownEntry = switch (charType) { @@ -42,7 +42,7 @@ class ChartEditorDropdowns for (charId in charIds) { - var character:Null = CharacterDataParser.fetchCharacterData(charId); + var character:Null = CharacterRegistry.fetchCharacterData(charId); if (character == null) continue; var value = {id: charId, text: character.name}; diff --git a/source/funkin/ui/debug/stageeditor/StageEditorState.hx b/source/funkin/ui/debug/stageeditor/StageEditorState.hx index 98190498fa..a928e78959 100644 --- a/source/funkin/ui/debug/stageeditor/StageEditorState.hx +++ b/source/funkin/ui/debug/stageeditor/StageEditorState.hx @@ -13,7 +13,7 @@ import flixel.group.FlxGroup.FlxTypedGroup; import flixel.addons.display.FlxGridOverlay; import funkin.play.character.BaseCharacter; import funkin.play.character.BaseCharacter.CharacterType; -import funkin.play.character.CharacterData.CharacterDataParser; +import funkin.data.character.CharacterRegistry; import funkin.save.Save; import funkin.input.Cursor; import haxe.ui.backend.flixel.UIState; @@ -328,11 +328,11 @@ class StageEditorState extends UIState Screen.instance.addComponent(root); // group shit + assets - var gf = CharacterDataParser.fetchCharacter("gf", true); + var gf = CharacterRegistry.fetchCharacter("gf", true); gf.characterType = CharacterType.GF; - var dad = CharacterDataParser.fetchCharacter("dad", true); + var dad = CharacterRegistry.fetchCharacter("dad", true); dad.characterType = CharacterType.DAD; - var bf = CharacterDataParser.fetchCharacter("bf", true); + var bf = CharacterRegistry.fetchCharacter("bf", true); bf.characterType = CharacterType.BF; bf.flipX = !bf.getDataFlipX(); diff --git a/source/funkin/ui/debug/stageeditor/toolboxes/StageEditorCharacterToolbox.hx b/source/funkin/ui/debug/stageeditor/toolboxes/StageEditorCharacterToolbox.hx index cd01f1fca4..c405f0419c 100644 --- a/source/funkin/ui/debug/stageeditor/toolboxes/StageEditorCharacterToolbox.hx +++ b/source/funkin/ui/debug/stageeditor/toolboxes/StageEditorCharacterToolbox.hx @@ -3,7 +3,7 @@ package funkin.ui.debug.stageeditor.toolboxes; import haxe.ui.components.NumberStepper; import funkin.play.character.BaseCharacter; import funkin.play.character.BaseCharacter.CharacterType; -import funkin.play.character.CharacterData.CharacterDataParser; +import funkin.data.character.CharacterRegistry; import funkin.util.SortUtil; import haxe.ui.data.ArrayDataSource; import haxe.ui.components.DropDown; @@ -17,7 +17,7 @@ import haxe.ui.core.Screen; import flixel.tweens.FlxTween; import flixel.tweens.FlxEase; import haxe.ui.containers.Grid; -import funkin.play.character.CharacterData; +import funkin.data.character.CharacterData; using StringTools; @@ -122,8 +122,8 @@ class StageEditorCharacterToolbox extends StageEditorDefaultToolbox var prevText = characterTypeButton.text; - var charData = CharacterDataParser.fetchCharacterData(stageEditorState.selectedChar.characterId); - characterTypeButton.icon = (charData == null ? null : CharacterDataParser.getCharPixelIconAsset(stageEditorState.selectedChar.characterId)); + var charData = CharacterRegistry.fetchCharacterData(stageEditorState.selectedChar.characterId); + characterTypeButton.icon = (charData == null ? null : CharacterRegistry.getCharPixelIconAsset(stageEditorState.selectedChar.characterId)); characterTypeButton.text = (charData == null ? "None" : charData.name.length > 6 ? '${charData.name.substr(0, 6)}.' : '${charData.name}'); if (prevText != characterTypeButton.text) @@ -167,14 +167,14 @@ class StageEditorCharacterMenu extends Menu // copied from chart editor charGrid.width = this.width; charSelectScroll.addComponent(charGrid); - var charIds = CharacterDataParser.listCharacterIds(); + var charIds = CharacterRegistry.listCharacterIds(); charIds.sort(SortUtil.alphabetically); var defaultText:String = '(choose a character)'; for (charIndex => charId in charIds) { - var charData:CharacterData = CharacterDataParser.fetchCharacterData(charId); + var charData:CharacterData = CharacterRegistry.fetchCharacterData(charId); var charButton = new haxe.ui.components.Button(); charButton.width = 70; @@ -192,7 +192,7 @@ class StageEditorCharacterMenu extends Menu // copied from chart editor } var LIMIT = 6; - charButton.icon = CharacterDataParser.getCharPixelIconAsset(charId); + charButton.icon = CharacterRegistry.getCharPixelIconAsset(charId); charButton.text = charData.name.length > LIMIT ? '${charData.name.substr(0, LIMIT)}.' : '${charData.name}'; charButton.onClick = _ -> { @@ -212,7 +212,7 @@ class StageEditorCharacterMenu extends Menu // copied from chart editor // okay i think that was enough cleaning phew you can see how clean this group is now!!! // anyways new character!!!! - var newChar = CharacterDataParser.fetchCharacter(charId, true); + var newChar = CharacterRegistry.fetchCharacter(charId, true); newChar.characterType = type; newChar.resetCharacter(true); diff --git a/source/funkin/ui/haxeui/components/CharacterPlayer.hx b/source/funkin/ui/haxeui/components/CharacterPlayer.hx index 77b23d68a7..bcb5c1bf7d 100644 --- a/source/funkin/ui/haxeui/components/CharacterPlayer.hx +++ b/source/funkin/ui/haxeui/components/CharacterPlayer.hx @@ -7,7 +7,7 @@ import funkin.modding.events.ScriptEvent.SongTimeScriptEvent; import funkin.modding.events.ScriptEvent.UpdateScriptEvent; import haxe.ui.core.IDataComponent; import funkin.play.character.BaseCharacter; -import funkin.play.character.CharacterData.CharacterDataParser; +import funkin.data.character.CharacterRegistry; import haxe.ui.containers.Box; import haxe.ui.core.Component; import haxe.ui.events.AnimationEvent; @@ -86,7 +86,7 @@ class CharacterPlayer extends Box } // Prevent script issues by fetching with debug=true. - var newCharacter:BaseCharacter = CharacterDataParser.fetchCharacter(id, true); + var newCharacter:BaseCharacter = CharacterRegistry.fetchCharacter(id, true); if (newCharacter == null) { character = null; diff --git a/source/funkin/ui/transition/preload/FunkinPreloader.hx b/source/funkin/ui/transition/preload/FunkinPreloader.hx index 1b39a34827..41ad3f479f 100644 --- a/source/funkin/ui/transition/preload/FunkinPreloader.hx +++ b/source/funkin/ui/transition/preload/FunkinPreloader.hx @@ -13,7 +13,7 @@ import flash.display.Sprite; import flash.Lib; import flixel.system.FlxBasePreloader; import funkin.modding.PolymodHandler; -import funkin.play.character.CharacterData.CharacterDataParser; +import funkin.data.character.CharacterRegistry; import funkin.util.MathUtil; import lime.app.Future; import lime.math.Rectangle; @@ -705,7 +705,7 @@ class FunkinPreloader extends FlxBasePreloader /* // TODO: Reimplement this. - var future:Future> = []; // CharacterDataParser.loadCharacterCacheAsync(); + var future:Future> = []; // CharacterRegistry.loadCharacterCacheAsync(); future.onProgress((loaded:Int, total:Int) -> { parsingCharactersPercent = loaded / total;