mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2025-01-12 15:17:57 +00:00
Merge pull request #767 from FunkinCrew/techniktil/chart-editor-icons
[PUBLIC PR] [FUNK-717] Fix pixel icons in the chart editor
This commit is contained in:
commit
c46483722e
|
@ -12,6 +12,7 @@ import funkin.util.assets.DataAssets;
|
||||||
import funkin.util.VersionUtil;
|
import funkin.util.VersionUtil;
|
||||||
import haxe.Json;
|
import haxe.Json;
|
||||||
import openfl.utils.Assets;
|
import openfl.utils.Assets;
|
||||||
|
import flixel.graphics.frames.FlxFrame;
|
||||||
|
|
||||||
class CharacterDataParser
|
class CharacterDataParser
|
||||||
{
|
{
|
||||||
|
@ -281,41 +282,78 @@ class CharacterDataParser
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: Hardcode this.
|
* Returns the idle frame of a character.
|
||||||
*/
|
*/
|
||||||
public static function getCharPixelIconAsset(char:String):String
|
public static function getCharPixelIconAsset(char:String):FlxFrame
|
||||||
{
|
{
|
||||||
var icon:String = char;
|
var charPath:String = "freeplay/icons/";
|
||||||
|
|
||||||
switch (icon)
|
// FunkinCrew please dont skin me alive for copying pixelated icon and changing it a tiny bit
|
||||||
|
switch (char)
|
||||||
{
|
{
|
||||||
case "bf-christmas" | "bf-car" | "bf-pixel" | "bf-holding-gf":
|
case "bf-christmas" | "bf-car" | "bf-pixel" | "bf-holding-gf" | "bf-dark":
|
||||||
icon = "bf";
|
charPath += "bfpixel";
|
||||||
case "monster-christmas":
|
case "monster-christmas":
|
||||||
icon = "monster";
|
charPath += "monsterpixel";
|
||||||
case "mom" | "mom-car":
|
case "mom" | "mom-car":
|
||||||
icon = "mommy";
|
charPath += "mommypixel";
|
||||||
case "pico-blazin" | "pico-playable" | "pico-speaker":
|
case "pico-blazin" | "pico-playable" | "pico-speaker":
|
||||||
icon = "pico";
|
charPath += "picopixel";
|
||||||
case "gf-christmas" | "gf-car" | "gf-pixel" | "gf-tankmen":
|
case "gf-christmas" | "gf-car" | "gf-pixel" | "gf-tankmen" | "gf-dark":
|
||||||
icon = "gf";
|
charPath += "gfpixel";
|
||||||
case "dad":
|
case "dad":
|
||||||
icon = "daddy";
|
charPath += "dadpixel";
|
||||||
case "darnell-blazin":
|
case "darnell-blazin":
|
||||||
icon = "darnell";
|
charPath += "darnellpixel";
|
||||||
case "senpai-angry":
|
case "senpai-angry":
|
||||||
icon = "senpai";
|
charPath += "senpaipixel";
|
||||||
case "spooky-dark":
|
case "spooky-dark":
|
||||||
icon = "spooky";
|
charPath += "spookypixel";
|
||||||
case "tankman-atlas":
|
case "tankman-atlas":
|
||||||
icon = "tankman";
|
charPath += "tankmanpixel";
|
||||||
|
case "pico-christmas" | "pico-dark":
|
||||||
|
charPath += "picopixel";
|
||||||
|
default:
|
||||||
|
charPath += '${char}pixel';
|
||||||
}
|
}
|
||||||
|
|
||||||
var path = Paths.image("freeplay/icons/" + icon + "pixel");
|
if (!Assets.exists(Paths.image(charPath)))
|
||||||
if (Assets.exists(path)) return path;
|
{
|
||||||
|
trace('[WARN] Character ${char} has no freeplay icon.');
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Hardcode some additional behavior or a fallback.
|
var isAnimated = Assets.exists(Paths.file('images/$charPath.xml'));
|
||||||
return null;
|
var frame:FlxFrame = null;
|
||||||
|
|
||||||
|
if (isAnimated)
|
||||||
|
{
|
||||||
|
var frames = Paths.getSparrowAtlas(charPath);
|
||||||
|
|
||||||
|
var idleFrame:FlxFrame = frames.frames.find(function(frame:FlxFrame):Bool {
|
||||||
|
return frame.name.startsWith('idle');
|
||||||
|
});
|
||||||
|
|
||||||
|
if (idleFrame == null)
|
||||||
|
{
|
||||||
|
trace('[WARN] Character ${char} has no idle in their freeplay icon.');
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// so, haxe.ui.backend.AssetsImpl uses the parent width and height, which makes the image go crazy when rendered
|
||||||
|
// so this is a work around so that it uses the actual width and height
|
||||||
|
var imageGraphic = flixel.graphics.FlxGraphic.fromFrame(idleFrame);
|
||||||
|
|
||||||
|
var imageFrame = flixel.graphics.frames.FlxImageFrame.fromImage(imageGraphic);
|
||||||
|
frame = imageFrame.frame;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var imageFrame = flixel.graphics.frames.FlxImageFrame.fromImage(Paths.image(charPath));
|
||||||
|
frame = imageFrame.frame;
|
||||||
|
}
|
||||||
|
|
||||||
|
return frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -95,7 +95,7 @@ class ChartEditorCharacterIconSelectorMenu extends ChartEditorBaseMenu
|
||||||
}
|
}
|
||||||
|
|
||||||
var LIMIT = 6;
|
var LIMIT = 6;
|
||||||
charButton.icon = CharacterDataParser.getCharPixelIconAsset(charId);
|
charButton.icon = haxe.ui.util.Variant.fromImageData(CharacterDataParser.getCharPixelIconAsset(charId));
|
||||||
charButton.text = charData.name.length > LIMIT ? '${charData.name.substr(0, LIMIT)}.' : '${charData.name}';
|
charButton.text = charData.name.length > LIMIT ? '${charData.name.substr(0, LIMIT)}.' : '${charData.name}';
|
||||||
|
|
||||||
charButton.onClick = _ -> {
|
charButton.onClick = _ -> {
|
||||||
|
|
|
@ -221,7 +221,7 @@ class ChartEditorMetadataToolbox extends ChartEditorBaseToolbox
|
||||||
var charDataOpponent:Null<CharacterData> = CharacterDataParser.fetchCharacterData(chartEditorState.currentSongMetadata.playData.characters.opponent);
|
var charDataOpponent:Null<CharacterData> = CharacterDataParser.fetchCharacterData(chartEditorState.currentSongMetadata.playData.characters.opponent);
|
||||||
if (charDataOpponent != null)
|
if (charDataOpponent != null)
|
||||||
{
|
{
|
||||||
buttonCharacterOpponent.icon = CharacterDataParser.getCharPixelIconAsset(chartEditorState.currentSongMetadata.playData.characters.opponent);
|
buttonCharacterOpponent.icon = haxe.ui.util.Variant.fromImageData(CharacterDataParser.getCharPixelIconAsset(chartEditorState.currentSongMetadata.playData.characters.opponent));
|
||||||
buttonCharacterOpponent.text = charDataOpponent.name.length > LIMIT ? '${charDataOpponent.name.substr(0, LIMIT)}.' : '${charDataOpponent.name}';
|
buttonCharacterOpponent.text = charDataOpponent.name.length > LIMIT ? '${charDataOpponent.name.substr(0, LIMIT)}.' : '${charDataOpponent.name}';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -233,7 +233,7 @@ class ChartEditorMetadataToolbox extends ChartEditorBaseToolbox
|
||||||
var charDataGirlfriend:Null<CharacterData> = CharacterDataParser.fetchCharacterData(chartEditorState.currentSongMetadata.playData.characters.girlfriend);
|
var charDataGirlfriend:Null<CharacterData> = CharacterDataParser.fetchCharacterData(chartEditorState.currentSongMetadata.playData.characters.girlfriend);
|
||||||
if (charDataGirlfriend != null)
|
if (charDataGirlfriend != null)
|
||||||
{
|
{
|
||||||
buttonCharacterGirlfriend.icon = CharacterDataParser.getCharPixelIconAsset(chartEditorState.currentSongMetadata.playData.characters.girlfriend);
|
buttonCharacterGirlfriend.icon = haxe.ui.util.Variant.fromImageData(CharacterDataParser.getCharPixelIconAsset(chartEditorState.currentSongMetadata.playData.characters.girlfriend));
|
||||||
buttonCharacterGirlfriend.text = charDataGirlfriend.name.length > LIMIT ? '${charDataGirlfriend.name.substr(0, LIMIT)}.' : '${charDataGirlfriend.name}';
|
buttonCharacterGirlfriend.text = charDataGirlfriend.name.length > LIMIT ? '${charDataGirlfriend.name.substr(0, LIMIT)}.' : '${charDataGirlfriend.name}';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -245,7 +245,7 @@ class ChartEditorMetadataToolbox extends ChartEditorBaseToolbox
|
||||||
var charDataPlayer:Null<CharacterData> = CharacterDataParser.fetchCharacterData(chartEditorState.currentSongMetadata.playData.characters.player);
|
var charDataPlayer:Null<CharacterData> = CharacterDataParser.fetchCharacterData(chartEditorState.currentSongMetadata.playData.characters.player);
|
||||||
if (charDataPlayer != null)
|
if (charDataPlayer != null)
|
||||||
{
|
{
|
||||||
buttonCharacterPlayer.icon = CharacterDataParser.getCharPixelIconAsset(chartEditorState.currentSongMetadata.playData.characters.player);
|
buttonCharacterPlayer.icon = haxe.ui.util.Variant.fromImageData(CharacterDataParser.getCharPixelIconAsset(chartEditorState.currentSongMetadata.playData.characters.player));
|
||||||
buttonCharacterPlayer.text = charDataPlayer.name.length > LIMIT ? '${charDataPlayer.name.substr(0, LIMIT)}.' : '${charDataPlayer.name}';
|
buttonCharacterPlayer.text = charDataPlayer.name.length > LIMIT ? '${charDataPlayer.name.substr(0, LIMIT)}.' : '${charDataPlayer.name}';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue