Skip to content

Commit

Permalink
getCharPixelIcon function to minimize duplicates.
Browse files Browse the repository at this point in the history
  • Loading branch information
TechnikTil authored Sep 18, 2024
1 parent 5f563f0 commit a6dbbef
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 49 deletions.
53 changes: 34 additions & 19 deletions source/funkin/play/character/CharacterData.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> = getCharPixelIcon(char);
if(convertChar != null)
return null;

charPath += convertChar;

var isAnimated = Assets.exists(Paths.file('images/$charPath.xml'));
var frame:FlxFrame = null;

Expand Down
35 changes: 5 additions & 30 deletions source/funkin/ui/PixelatedIcon.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<String> = 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'));

Expand Down

0 comments on commit a6dbbef

Please sign in to comment.