mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2025-01-09 13:47:25 +00:00
spritesheet fixins for char select
This commit is contained in:
parent
3fa9b2a635
commit
105e3dccba
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -13,3 +13,4 @@ shitAudio/
|
|||
node_modules/
|
||||
package.json
|
||||
package-lock.json
|
||||
.aider*
|
||||
|
|
79
source/funkin/ui/PixelatedIcon.hx
Normal file
79
source/funkin/ui/PixelatedIcon.hx
Normal file
|
@ -0,0 +1,79 @@
|
|||
package funkin.ui;
|
||||
|
||||
import flixel.FlxSprite;
|
||||
|
||||
/**
|
||||
* The icon that gets used for Freeplay capsules and char select
|
||||
* NOT to be confused with the CharIcon class, which is for the in-game icons
|
||||
*/
|
||||
class PixelatedIcon extends FlxSprite
|
||||
{
|
||||
public function new(x:Float, y:Float)
|
||||
{
|
||||
super(x, y);
|
||||
this.makeGraphic(32, 32, 0x00000000);
|
||||
this.antialiasing = false;
|
||||
this.active = false;
|
||||
}
|
||||
|
||||
public function setCharacter(char:String):Void
|
||||
{
|
||||
var charPath:String = "freeplay/icons/";
|
||||
|
||||
switch (char)
|
||||
{
|
||||
case 'monster-christmas':
|
||||
charPath += 'monsterpixel';
|
||||
case 'mom-car':
|
||||
charPath += 'mommypixel';
|
||||
case 'darnell-blazin':
|
||||
charPath += 'darnellpixel';
|
||||
case 'senpai-angry':
|
||||
charPath += 'senpaipixel';
|
||||
default:
|
||||
charPath += '${char}pixel';
|
||||
}
|
||||
|
||||
if (!openfl.utils.Assets.exists(Paths.image(charPath)))
|
||||
{
|
||||
trace('[WARN] Character ${char} has no freeplay icon.');
|
||||
return;
|
||||
}
|
||||
|
||||
var isAnimated = openfl.utils.Assets.exists(Paths.file('images/$charPath.xml'));
|
||||
|
||||
if (isAnimated)
|
||||
{
|
||||
this.frames = Paths.getSparrowAtlas(charPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.loadGraphic(Paths.image(charPath));
|
||||
}
|
||||
|
||||
this.scale.x = this.scale.y = 2;
|
||||
|
||||
switch (char)
|
||||
{
|
||||
case 'parents-christmas':
|
||||
this.origin.x = 140;
|
||||
default:
|
||||
this.origin.x = 100;
|
||||
}
|
||||
|
||||
if (isAnimated)
|
||||
{
|
||||
this.active = true;
|
||||
this.animation.addByPrefix('idle', 'idle0', 10, true);
|
||||
this.animation.addByPrefix('confirm', 'confirm0', 10, false);
|
||||
this.animation.addByPrefix('confirm-hold', 'confirm-hold0', 10, true);
|
||||
|
||||
this.animation.finishCallback = function(name:String):Void {
|
||||
trace('Finish pixel animation: ${name}');
|
||||
if (name == 'confirm') this.animation.play('confirm-hold');
|
||||
};
|
||||
|
||||
this.animation.play('idle');
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,12 +1,13 @@
|
|||
package funkin.ui.charSelect;
|
||||
|
||||
import flixel.text.FlxText;
|
||||
import flixel.FlxSprite;
|
||||
import funkin.ui.PixelatedIcon;
|
||||
import flixel.system.debug.watch.Tracker.TrackerProfile;
|
||||
import flixel.math.FlxPoint;
|
||||
import flixel.tweens.FlxTween;
|
||||
import openfl.display.BlendMode;
|
||||
import flixel.group.FlxGroup.FlxTypedGroup;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.group.FlxSpriteGroup;
|
||||
import funkin.play.stage.Stage;
|
||||
import funkin.modding.events.ScriptEvent;
|
||||
|
@ -284,21 +285,11 @@ class CharSelectSubState extends MusicBeatSubState
|
|||
if (availableChars.exists(i))
|
||||
{
|
||||
var path:String = availableChars.get(i);
|
||||
var temp:CharIconCharacter = new CharIconCharacter(path);
|
||||
var temp:PixelatedIcon = new PixelatedIcon(0, 0);
|
||||
temp.setCharacter(path);
|
||||
temp.setGraphicSize(128, 128);
|
||||
temp.updateHitbox();
|
||||
temp.ID = 0;
|
||||
|
||||
var idleAnimPrefix:String = switch (path)
|
||||
{
|
||||
case "pico":
|
||||
"Pico Icon";
|
||||
case "bf":
|
||||
"boyfriend icon instance 1";
|
||||
case _:
|
||||
"Pico Icon";
|
||||
};
|
||||
|
||||
// temp.animation.addByPrefix("idle", idleAnimPrefix, 0, false);
|
||||
// temp.animation.play("idle");
|
||||
grpIcons.add(temp);
|
||||
}
|
||||
else
|
||||
|
@ -567,17 +558,19 @@ class CharSelectSubState extends MusicBeatSubState
|
|||
member.animation.play("idle");
|
||||
}
|
||||
case 0:
|
||||
var memb:CharIconCharacter = cast member;
|
||||
var memb:PixelatedIcon = cast member;
|
||||
|
||||
if (index == getCurrentSelected())
|
||||
{
|
||||
// memb.pixels = memb.withDropShadow.clone();
|
||||
memb.setGraphicSize(128 * 1.3);
|
||||
memb.scale.set(2.6, 2.6);
|
||||
|
||||
if (controls.ACCEPT) memb.animation.play("confirm");
|
||||
}
|
||||
else
|
||||
{
|
||||
// memb.pixels = memb.noDropShadow.clone();
|
||||
memb.setGraphicSize(128);
|
||||
memb.scale.set(2, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,12 +24,13 @@ import funkin.play.scoring.Scoring.ScoringRank;
|
|||
import funkin.save.Save;
|
||||
import funkin.save.Save.SaveScoreData;
|
||||
import flixel.util.FlxColor;
|
||||
import funkin.ui.PixelatedIcon;
|
||||
|
||||
class SongMenuItem extends FlxSpriteGroup
|
||||
{
|
||||
public var capsule:FlxSprite;
|
||||
|
||||
var pixelIcon:FlxSprite;
|
||||
var pixelIcon:PixelatedIcon;
|
||||
|
||||
/**
|
||||
* Modify this by calling `init()`
|
||||
|
@ -201,11 +202,7 @@ class SongMenuItem extends FlxSpriteGroup
|
|||
// TODO: Use value from metadata instead of random.
|
||||
updateDifficultyRating(FlxG.random.int(0, 20));
|
||||
|
||||
pixelIcon = new FlxSprite(160, 35);
|
||||
|
||||
pixelIcon.makeGraphic(32, 32, 0x00000000);
|
||||
pixelIcon.antialiasing = false;
|
||||
pixelIcon.active = false;
|
||||
pixelIcon = new PixelatedIcon(160, 35);
|
||||
add(pixelIcon);
|
||||
grpHide.add(pixelIcon);
|
||||
|
||||
|
@ -512,7 +509,7 @@ class SongMenuItem extends FlxSpriteGroup
|
|||
// Update capsule text.
|
||||
songText.text = songData?.songName ?? 'Random';
|
||||
// Update capsule character.
|
||||
if (songData?.songCharacter != null) setCharacter(songData.songCharacter);
|
||||
if (songData?.songCharacter != null) pixelIcon.setCharacter(songData.songCharacter);
|
||||
updateBPM(Std.int(songData?.songStartingBpm) ?? 0);
|
||||
updateDifficultyRating(songData?.difficultyRating ?? 0);
|
||||
updateScoringRank(songData?.scoringRank);
|
||||
|
@ -526,76 +523,6 @@ class SongMenuItem extends FlxSpriteGroup
|
|||
checkWeek(songData?.songId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the character displayed next to this song in the freeplay menu.
|
||||
* @param char The character ID used by this song.
|
||||
* If the character has no freeplay icon, a warning will be thrown and nothing will display.
|
||||
*/
|
||||
public function setCharacter(char:String):Void
|
||||
{
|
||||
var charPath:String = "freeplay/icons/";
|
||||
|
||||
// TODO: Put this in the character metadata where it belongs.
|
||||
// TODO: Also, can use CharacterDataParser.getCharPixelIconAsset()
|
||||
switch (char)
|
||||
{
|
||||
case 'monster-christmas':
|
||||
charPath += 'monsterpixel';
|
||||
case 'mom-car':
|
||||
charPath += 'mommypixel';
|
||||
case 'darnell-blazin':
|
||||
charPath += 'darnellpixel';
|
||||
case 'senpai-angry':
|
||||
charPath += 'senpaipixel';
|
||||
default:
|
||||
charPath += '${char}pixel';
|
||||
}
|
||||
|
||||
if (!openfl.utils.Assets.exists(Paths.image(charPath)))
|
||||
{
|
||||
trace('[WARN] Character ${char} has no freeplay icon.');
|
||||
return;
|
||||
}
|
||||
|
||||
var isAnimated = openfl.utils.Assets.exists(Paths.file('images/$charPath.xml'));
|
||||
|
||||
if (isAnimated)
|
||||
{
|
||||
pixelIcon.frames = Paths.getSparrowAtlas(charPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
pixelIcon.loadGraphic(Paths.image(charPath));
|
||||
}
|
||||
|
||||
pixelIcon.scale.x = pixelIcon.scale.y = 2;
|
||||
|
||||
switch (char)
|
||||
{
|
||||
case 'parents-christmas':
|
||||
pixelIcon.origin.x = 140;
|
||||
default:
|
||||
pixelIcon.origin.x = 100;
|
||||
}
|
||||
// pixelIcon.origin.x = capsule.origin.x;
|
||||
// pixelIcon.offset.x -= pixelIcon.origin.x;
|
||||
|
||||
if (isAnimated)
|
||||
{
|
||||
pixelIcon.active = true;
|
||||
|
||||
pixelIcon.animation.addByPrefix('idle', 'idle0', 10, true);
|
||||
pixelIcon.animation.addByPrefix('confirm', 'confirm0', 10, false);
|
||||
pixelIcon.animation.addByPrefix('confirm-hold', 'confirm-hold0', 10, true);
|
||||
|
||||
pixelIcon.animation.finishCallback = function(name:String):Void {
|
||||
trace('Finish pixel animation: ${name}');
|
||||
if (name == 'confirm') pixelIcon.animation.play('confirm-hold');
|
||||
};
|
||||
|
||||
pixelIcon.animation.play('idle');
|
||||
}
|
||||
}
|
||||
|
||||
var frameInTicker:Float = 0;
|
||||
var frameInTypeBeat:Int = 0;
|
||||
|
|
Loading…
Reference in a new issue