diff --git a/source/funkin/play/character/CharacterData.hx b/source/funkin/play/character/CharacterData.hx index 052310a7e2..1818f009bb 100644 --- a/source/funkin/play/character/CharacterData.hx +++ b/source/funkin/play/character/CharacterData.hx @@ -282,47 +282,62 @@ class CharacterDataParser } /** - * Returns the idle frame of a character. + * Returns the Freeplay Icon version of a character. + * This was made to avoid copy and pasting. */ - public static function getCharPixelIconAsset(char:String):FlxFrame + public static function getCharPixelIcon(char:String):String { - var charPath:String = "freeplay/icons/"; - - // FunkinCrew please dont skin me alive for copying pixelated icon and changing it a tiny bit - switch (char) + var charPath = switch (char) { case "bf-christmas" | "bf-car" | "bf-pixel" | "bf-holding-gf" | "bf-dark": - charPath += "bfpixel"; + "bfpixel"; case "monster-christmas": - charPath += "monsterpixel"; + "monsterpixel"; case "mom" | "mom-car": - charPath += "mommypixel"; + "mommypixel"; case "pico-blazin" | "pico-playable" | "pico-speaker": - charPath += "picopixel"; + "picopixel"; case "gf-christmas" | "gf-car" | "gf-pixel" | "gf-tankmen" | "gf-dark": - charPath += "gfpixel"; + "gfpixel"; case "dad": - charPath += "dadpixel"; + "dadpixel"; case "darnell-blazin": - charPath += "darnellpixel"; + "darnellpixel"; case "senpai-angry": - charPath += "senpaipixel"; + "senpaipixel"; case "spooky-dark": - charPath += "spookypixel"; + "spookypixel"; case "tankman-atlas": - charPath += "tankmanpixel"; + "tankmanpixel"; case "pico-christmas" | "pico-dark": - charPath += "picopixel"; + "picopixel"; default: - charPath += '${char}pixel'; + '${char}pixel'; } - if (!Assets.exists(Paths.image(charPath))) + if (!Assets.exists(Paths.image("freeplay/icons/" + charPath))) { trace('[WARN] Character ${char} has no freeplay icon.'); return null; } + return charPath; + } + + /** + * Returns the idle frame of a character. + * @author TechnikTil + */ + public static function getCharPixelIconAsset(char:String):FlxFrame + { + var charPath:String = "freeplay/icons/"; + + var convertChar:Null = getCharPixelIcon(char); + if(convertChar != null) + return null; + + charPath += convertChar; + var isAnimated = Assets.exists(Paths.file('images/$charPath.xml')); var frame:FlxFrame = null; diff --git a/source/funkin/ui/PixelatedIcon.hx b/source/funkin/ui/PixelatedIcon.hx index 4252c96958..17c4ad9cfa 100644 --- a/source/funkin/ui/PixelatedIcon.hx +++ b/source/funkin/ui/PixelatedIcon.hx @@ -2,6 +2,7 @@ package funkin.ui; import flixel.FlxSprite; import funkin.graphics.FlxFilteredSprite; +import funkin.play.character.CharacterData.CharacterDataParser; /** * The icon that gets used for Freeplay capsules and char select @@ -21,37 +22,11 @@ class PixelatedIcon extends FlxFilteredSprite { var charPath:String = "freeplay/icons/"; - switch (char) - { - case "bf-christmas" | "bf-car" | "bf-pixel" | "bf-holding-gf": - charPath += "bfpixel"; - case "monster-christmas": - charPath += "monsterpixel"; - case "mom" | "mom-car": - charPath += "mommypixel"; - case "pico-blazin" | "pico-playable" | "pico-speaker": - charPath += "picopixel"; - case "gf-christmas" | "gf-car" | "gf-pixel" | "gf-tankmen": - charPath += "gfpixel"; - case "dad": - charPath += "dadpixel"; - case "darnell-blazin": - charPath += "darnellpixel"; - case "senpai-angry": - charPath += "senpaipixel"; - case "spooky-dark": - charPath += "spookypixel"; - case "tankman-atlas": - charPath += "tankmanpixel"; - default: - charPath += '${char}pixel'; - } + var convertChar:Null = CharacterDataParser.getCharPixelIcon(char); + if(convertChar != null) + return null; - if (!openfl.utils.Assets.exists(Paths.image(charPath))) - { - trace('[WARN] Character ${char} has no freeplay icon.'); - return; - } + charPath += convertChar; var isAnimated = openfl.utils.Assets.exists(Paths.file('images/$charPath.xml'));