mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2024-11-15 11:22:55 +00:00
welcome fallback note styles!
This commit is contained in:
parent
d3209e57b7
commit
82a6ca5916
|
@ -38,6 +38,8 @@ class Countdown
|
||||||
|
|
||||||
static var noteStyle:NoteStyle;
|
static var noteStyle:NoteStyle;
|
||||||
|
|
||||||
|
static var fallbackNoteStyle:Null<NoteStyle>;
|
||||||
|
|
||||||
static var isPixel:Bool = false;
|
static var isPixel:Bool = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -69,11 +71,7 @@ class Countdown
|
||||||
// @:privateAccess
|
// @:privateAccess
|
||||||
// PlayState.instance.dispatchEvent(new SongTimeScriptEvent(SONG_BEAT_HIT, 0, 0));
|
// PlayState.instance.dispatchEvent(new SongTimeScriptEvent(SONG_BEAT_HIT, 0, 0));
|
||||||
|
|
||||||
var fetchedNoteStyle:NoteStyle = NoteStyleRegistry.instance.fetchEntry(PlayState.instance.currentChart.noteStyle);
|
fetchNoteStyle();
|
||||||
if (fetchedNoteStyle == null) noteStyle = NoteStyleRegistry.instance.fetchDefault();
|
|
||||||
else
|
|
||||||
noteStyle = fetchedNoteStyle;
|
|
||||||
if (noteStyle._data.assets.note.isPixel) isPixel = true;
|
|
||||||
|
|
||||||
// The timer function gets called based on the beat of the song.
|
// The timer function gets called based on the beat of the song.
|
||||||
countdownTimer = new FlxTimer();
|
countdownTimer = new FlxTimer();
|
||||||
|
@ -92,7 +90,7 @@ class Countdown
|
||||||
// PlayState.instance.dispatchEvent(new SongTimeScriptEvent(SONG_BEAT_HIT, 0, 0));
|
// PlayState.instance.dispatchEvent(new SongTimeScriptEvent(SONG_BEAT_HIT, 0, 0));
|
||||||
|
|
||||||
// Countdown graphic.
|
// Countdown graphic.
|
||||||
showCountdownGraphic(countdownStep, noteStyle, isPixel);
|
showCountdownGraphic(countdownStep, noteStyle);
|
||||||
|
|
||||||
// Countdown sound.
|
// Countdown sound.
|
||||||
playCountdownSound(countdownStep, noteStyle);
|
playCountdownSound(countdownStep, noteStyle);
|
||||||
|
@ -212,10 +210,20 @@ class Countdown
|
||||||
isPixel = false;
|
isPixel = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static function fetchNoteStyle():Void
|
||||||
|
{
|
||||||
|
var fetchedNoteStyle:NoteStyle = NoteStyleRegistry.instance.fetchEntry(PlayState.instance.currentChart.noteStyle);
|
||||||
|
if (fetchedNoteStyle == null) noteStyle = NoteStyleRegistry.instance.fetchDefault();
|
||||||
|
else
|
||||||
|
noteStyle = fetchedNoteStyle;
|
||||||
|
fallbackNoteStyle = NoteStyleRegistry.instance.fetchEntry(noteStyle.getFallbackID());
|
||||||
|
isPixel = false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the graphic to use for this step of the countdown.
|
* Retrieves the graphic to use for this step of the countdown.
|
||||||
*/
|
*/
|
||||||
public static function showCountdownGraphic(index:CountdownStep, noteStyle:NoteStyle, isGraphicPixel:Bool):Void
|
public static function showCountdownGraphic(index:CountdownStep, noteStyle:NoteStyle):Void
|
||||||
{
|
{
|
||||||
var indexString:String = null;
|
var indexString:String = null;
|
||||||
switch (index)
|
switch (index)
|
||||||
|
@ -246,13 +254,13 @@ class Countdown
|
||||||
var fadeEase = FlxEase.cubeInOut;
|
var fadeEase = FlxEase.cubeInOut;
|
||||||
if (isGraphicPixel) fadeEase = EaseUtil.stepped(8);
|
if (isGraphicPixel) fadeEase = EaseUtil.stepped(8);
|
||||||
|
|
||||||
countdownSprite.antialiasing = !isGraphicPixel;
|
countdownSprite.antialiasing = !isPixel;
|
||||||
|
|
||||||
|
countdownSprite.cameras = [PlayState.instance.camHUD];
|
||||||
|
|
||||||
countdownSprite.updateHitbox();
|
countdownSprite.updateHitbox();
|
||||||
countdownSprite.screenCenter();
|
countdownSprite.screenCenter();
|
||||||
|
|
||||||
countdownSprite.cameras = [PlayState.instance.camHUD];
|
|
||||||
|
|
||||||
// Fade sprite in, then out, then destroy it.
|
// Fade sprite in, then out, then destroy it.
|
||||||
FlxTween.tween(countdownSprite, {y: countdownSprite.y += 100}, Conductor.instance.beatLengthMs / 1000,
|
FlxTween.tween(countdownSprite, {y: countdownSprite.y += 100}, Conductor.instance.beatLengthMs / 1000,
|
||||||
{
|
{
|
||||||
|
@ -272,10 +280,19 @@ class Countdown
|
||||||
|
|
||||||
static function resolveGraphicPath(noteStyle:NoteStyle, index:String):Null<String>
|
static function resolveGraphicPath(noteStyle:NoteStyle, index:String):Null<String>
|
||||||
{
|
{
|
||||||
|
fetchNoteStyle();
|
||||||
var basePath:String = 'ui/countdown/';
|
var basePath:String = 'ui/countdown/';
|
||||||
|
|
||||||
var spritePath:String = basePath + noteStyle.id + '/$index';
|
var spritePath:String = basePath + noteStyle.id + '/$index';
|
||||||
// If nothing is found, revert it to default notestyle skin
|
|
||||||
|
while (!Assets.exists(Paths.image(spritePath)) && fallbackNoteStyle != null)
|
||||||
|
{
|
||||||
|
noteStyle = fallbackNoteStyle;
|
||||||
|
fallbackNoteStyle = NoteStyleRegistry.instance.fetchEntry(noteStyle.getFallbackID());
|
||||||
|
spritePath = basePath + noteStyle.id + '/$index';
|
||||||
|
}
|
||||||
|
if (noteStyle.isHoldNotePixel()) isPixel = true;
|
||||||
|
|
||||||
|
// If ABSOLUTELY nothing is found, revert it to default notestyle skin
|
||||||
if (!Assets.exists(Paths.image(spritePath)))
|
if (!Assets.exists(Paths.image(spritePath)))
|
||||||
{
|
{
|
||||||
if (!isPixel) spritePath = basePath + Constants.DEFAULT_NOTE_STYLE + '/$index';
|
if (!isPixel) spritePath = basePath + Constants.DEFAULT_NOTE_STYLE + '/$index';
|
||||||
|
@ -298,10 +315,19 @@ class Countdown
|
||||||
static function resolveSoundPath(noteStyle:NoteStyle, step:CountdownStep):Null<String>
|
static function resolveSoundPath(noteStyle:NoteStyle, step:CountdownStep):Null<String>
|
||||||
{
|
{
|
||||||
if (step == CountdownStep.BEFORE || step == CountdownStep.AFTER) return null;
|
if (step == CountdownStep.BEFORE || step == CountdownStep.AFTER) return null;
|
||||||
|
fetchNoteStyle();
|
||||||
var basePath:String = 'gameplay/countdown/';
|
var basePath:String = 'gameplay/countdown/';
|
||||||
|
|
||||||
var soundPath:String = basePath + noteStyle.id + '/intro$step';
|
var soundPath:String = basePath + noteStyle.id + '/intro$step';
|
||||||
// If nothing is found, revert it to default notestyle sound
|
|
||||||
|
while (!Assets.exists(Paths.sound(soundPath)) && fallbackNoteStyle != null)
|
||||||
|
{
|
||||||
|
noteStyle = fallbackNoteStyle;
|
||||||
|
fallbackNoteStyle = NoteStyleRegistry.instance.fetchEntry(noteStyle.getFallbackID());
|
||||||
|
soundPath = basePath + noteStyle.id + '/intro$step';
|
||||||
|
}
|
||||||
|
if (noteStyle.isHoldNotePixel()) isPixel = true;
|
||||||
|
|
||||||
|
// If ABSOLUTELY nothing is found, revert it to default notestyle sound
|
||||||
if (!Assets.exists(Paths.sound(soundPath)))
|
if (!Assets.exists(Paths.sound(soundPath)))
|
||||||
{
|
{
|
||||||
if (!isPixel) soundPath = basePath + Constants.DEFAULT_NOTE_STYLE + '/intro$step';
|
if (!isPixel) soundPath = basePath + Constants.DEFAULT_NOTE_STYLE + '/intro$step';
|
||||||
|
|
|
@ -23,24 +23,41 @@ class PopUpStuff extends FlxTypedGroup<FunkinSprite>
|
||||||
*/
|
*/
|
||||||
static var noteStyle:NoteStyle;
|
static var noteStyle:NoteStyle;
|
||||||
|
|
||||||
|
static var fallbackNoteStyle:Null<NoteStyle>;
|
||||||
|
|
||||||
static var isPixel:Bool = false;
|
static var isPixel:Bool = false;
|
||||||
|
|
||||||
override public function new()
|
override public function new()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
fetchNoteStyle();
|
||||||
|
}
|
||||||
|
|
||||||
|
static function fetchNoteStyle():Void
|
||||||
|
{
|
||||||
var fetchedNoteStyle:NoteStyle = NoteStyleRegistry.instance.fetchEntry(PlayState.instance.currentChart.noteStyle);
|
var fetchedNoteStyle:NoteStyle = NoteStyleRegistry.instance.fetchEntry(PlayState.instance.currentChart.noteStyle);
|
||||||
if (fetchedNoteStyle == null) noteStyle = NoteStyleRegistry.instance.fetchDefault();
|
if (fetchedNoteStyle == null) noteStyle = NoteStyleRegistry.instance.fetchDefault();
|
||||||
else
|
else
|
||||||
noteStyle = fetchedNoteStyle;
|
noteStyle = fetchedNoteStyle;
|
||||||
if (noteStyle._data.assets.note.isPixel) isPixel = true;
|
fallbackNoteStyle = NoteStyleRegistry.instance.fetchEntry(noteStyle.getFallbackID());
|
||||||
|
isPixel = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function resolveGraphicPath(noteStyle:NoteStyle, index:String):Null<String>
|
static function resolveGraphicPath(noteStyle:NoteStyle, index:String):Null<String>
|
||||||
{
|
{
|
||||||
|
fetchNoteStyle();
|
||||||
var basePath:String = 'ui/popup/';
|
var basePath:String = 'ui/popup/';
|
||||||
|
|
||||||
var spritePath:String = basePath + noteStyle.id + '/$index';
|
var spritePath:String = basePath + noteStyle.id + '/$index';
|
||||||
|
|
||||||
|
while (!Assets.exists(Paths.image(spritePath)) && fallbackNoteStyle != null)
|
||||||
|
{
|
||||||
|
noteStyle = fallbackNoteStyle;
|
||||||
|
fallbackNoteStyle = NoteStyleRegistry.instance.fetchEntry(noteStyle.getFallbackID());
|
||||||
|
spritePath = basePath + noteStyle.id + '/$index';
|
||||||
|
}
|
||||||
|
if (noteStyle.isHoldNotePixel()) isPixel = true;
|
||||||
|
|
||||||
// If nothing is found, revert it to default notestyle skin
|
// If nothing is found, revert it to default notestyle skin
|
||||||
if (!Assets.exists(Paths.image(spritePath)))
|
if (!Assets.exists(Paths.image(spritePath)))
|
||||||
{
|
{
|
||||||
|
|
|
@ -72,7 +72,7 @@ class NoteStyle implements IRegistryEntry<NoteStyleData>
|
||||||
* Get the note style ID of the parent note style.
|
* Get the note style ID of the parent note style.
|
||||||
* @return The string ID, or `null` if there is no parent.
|
* @return The string ID, or `null` if there is no parent.
|
||||||
*/
|
*/
|
||||||
function getFallbackID():Null<String>
|
public function getFallbackID():Null<String>
|
||||||
{
|
{
|
||||||
return _data.fallback;
|
return _data.fallback;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue