From 2993e17278f0162b3b86e9c7cf26d8d22cabf93c Mon Sep 17 00:00:00 2001 From: anysad Date: Sat, 13 Jul 2024 22:45:58 +0300 Subject: [PATCH 1/8] custom popups and countdowns yay!!! --- assets | 2 +- source/funkin/play/Countdown.hx | 152 ++++++++++---------- source/funkin/play/PlayState.hx | 6 +- source/funkin/play/components/PopUpStuff.hx | 58 ++++++-- 4 files changed, 123 insertions(+), 95 deletions(-) diff --git a/assets b/assets index 2e1594ee4c..514a987ee5 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 2e1594ee4c04c7148628bae471bdd061c9deb6b7 +Subproject commit 514a987ee57827b097ed035a1c2fdd1377a53b17 diff --git a/source/funkin/play/Countdown.hx b/source/funkin/play/Countdown.hx index 10636afdf9..7686e5b75e 100644 --- a/source/funkin/play/Countdown.hx +++ b/source/funkin/play/Countdown.hx @@ -10,6 +10,7 @@ import funkin.modding.events.ScriptEvent; import funkin.modding.events.ScriptEvent.CountdownScriptEvent; import flixel.util.FlxTimer; import funkin.audio.FunkinSound; +import openfl.utils.Assets; class Countdown { @@ -18,6 +19,22 @@ class Countdown */ public static var countdownStep(default, null):CountdownStep = BEFORE; + /** + * Which alternate countdown sound effect to use. + * You can set this via script. + * For example, in Week 6 it is `-pixel`. + */ + public static var soundSuffix:String = ''; + + /** + * Which alternate graphic on countdown to use. + * You can set this via script. + * For example, in Week 6 it is `-pixel`. + */ + public static var graphicSuffix:String = ''; + + + /** * The currently running countdown. This will be null if there is no countdown running. */ @@ -29,7 +46,7 @@ class Countdown * This will automatically stop and restart the countdown if it is already running. * @returns `false` if the countdown was cancelled by a script. */ - public static function performCountdown(isPixelStyle:Bool):Bool + public static function performCountdown():Bool { countdownStep = BEFORE; var cancelled:Bool = propagateCountdownEvent(countdownStep); @@ -64,10 +81,10 @@ class Countdown // PlayState.instance.dispatchEvent(new SongTimeScriptEvent(SONG_BEAT_HIT, 0, 0)); // Countdown graphic. - showCountdownGraphic(countdownStep, isPixelStyle); + showCountdownGraphic(countdownStep, graphicSuffix.toLowerCase().contains('pixel')); // Countdown sound. - playCountdownSound(countdownStep, isPixelStyle); + playCountdownSound(countdownStep); // Event handling bullshit. var cancelled:Bool = propagateCountdownEvent(countdownStep); @@ -175,53 +192,31 @@ class Countdown } } + /** + * Reset the countdown configuration to the default. + */ + public static function reset() + { + soundSuffix = ''; + graphicSuffix = ''; + } + /** * Retrieves the graphic to use for this step of the countdown. - * TODO: Make this less dumb. Unhardcode it? Use modules? Use notestyles? - * - * This is public so modules can do lol funny shit. */ - public static function showCountdownGraphic(index:CountdownStep, isPixelStyle:Bool):Void + public static function showCountdownGraphic(index:CountdownStep, isGraphicPixel:Bool):Void { var spritePath:String = null; - - if (isPixelStyle) - { - switch (index) - { - case TWO: - spritePath = 'weeb/pixelUI/ready-pixel'; - case ONE: - spritePath = 'weeb/pixelUI/set-pixel'; - case GO: - spritePath = 'weeb/pixelUI/date-pixel'; - default: - // null - } - } - else - { - switch (index) - { - case TWO: - spritePath = 'ready'; - case ONE: - spritePath = 'set'; - case GO: - spritePath = 'go'; - default: - // null - } - } + spritePath = resolveGraphicPath(graphicSuffix, index); if (spritePath == null) return; var countdownSprite:FunkinSprite = FunkinSprite.create(spritePath); countdownSprite.scrollFactor.set(0, 0); - if (isPixelStyle) countdownSprite.setGraphicSize(Std.int(countdownSprite.width * Constants.PIXEL_ART_SCALE)); + if (isGraphicPixel) countdownSprite.setGraphicSize(Std.int(countdownSprite.width * Constants.PIXEL_ART_SCALE)); - countdownSprite.antialiasing = !isPixelStyle; + countdownSprite.antialiasing = !isGraphicPixel; countdownSprite.updateHitbox(); countdownSprite.screenCenter(); @@ -238,52 +233,55 @@ class Countdown PlayState.instance.add(countdownSprite); } - /** - * Retrieves the sound file to use for this step of the countdown. - * TODO: Make this less dumb. Unhardcode it? Use modules? Use notestyles? - * - * This is public so modules can do lol funny shit. - */ - public static function playCountdownSound(index:CountdownStep, isPixelStyle:Bool):Void + static function resolveGraphicPath(suffix:String, index:CountdownStep):Null { - var soundPath:String = null; - - if (isPixelStyle) + var basePath:String = 'ui/countdown/'; + var indexString:String = null; + switch (index) { - switch (index) - { - case THREE: - soundPath = 'intro3-pixel'; - case TWO: - soundPath = 'intro2-pixel'; - case ONE: - soundPath = 'intro1-pixel'; - case GO: - soundPath = 'introGo-pixel'; - default: - // null - } + case TWO: + indexString = 'ready'; + case ONE: + indexString = 'set'; + case GO: + indexString = 'go'; + default: + // null } - else + basePath += indexString; + var spritePath:String = basePath + suffix; + while (!Assets.exists(Paths.image(spritePath)) && suffix.length > 0) { - switch (index) - { - case THREE: - soundPath = 'intro3'; - case TWO: - soundPath = 'intro2'; - case ONE: - soundPath = 'intro1'; - case GO: - soundPath = 'introGo'; - default: - // null - } + suffix = suffix.split('-').slice(0, -1).join('-'); + spritePath = basePath + suffix; } + if (!Assets.exists(Paths.image(spritePath))) return null; + trace('Resolved sprite path: ' + Paths.image(spritePath)); + return spritePath; + } - if (soundPath == null) return; + /** + * Retrieves the sound file to use for this step of the countdown. + */ + public static function playCountdownSound(index:CountdownStep):Void + { + FunkinSound.playOnce(resolveSoundPath(soundSuffix, index), Constants.COUNTDOWN_VOLUME); + } + + static function resolveSoundPath(suffix:String, step:CountdownStep):Null + { + var basePath:String = 'gameplay/countdown/intro'; + if (step != CountdownStep.BEFORE || step != CountdownStep.AFTER) basePath += step; - FunkinSound.playOnce(Paths.sound(soundPath), Constants.COUNTDOWN_VOLUME); + var soundPath:String = Paths.sound(basePath + suffix); + while (!Assets.exists(soundPath) && suffix.length > 0) + { + suffix = suffix.split('-').slice(0, -1).join('-'); + soundPath = Paths.sound(basePath + suffix); + } + if (!Assets.exists(soundPath)) return null; + trace('Resolved sound path: ' + soundPath); + return soundPath; } public static function decrement(step:CountdownStep):CountdownStep diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index f55cef3888..bf401ece2b 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -899,7 +899,7 @@ class PlayState extends MusicBeatSubState health = Constants.HEALTH_STARTING; songScore = 0; Highscore.tallies.combo = 0; - Countdown.performCountdown(currentStageId.startsWith('school')); + Countdown.performCountdown(); needsReset = false; } @@ -1920,7 +1920,7 @@ class PlayState extends MusicBeatSubState public function startCountdown():Void { // If Countdown.performCountdown returns false, then the countdown was canceled by a script. - var result:Bool = Countdown.performCountdown(currentStageId.startsWith('school')); + var result:Bool = Countdown.performCountdown(); if (!result) return; isInCutscene = false; @@ -3061,6 +3061,8 @@ class PlayState extends MusicBeatSubState GameOverSubState.reset(); PauseSubState.reset(); + Countdown.reset(); + PopUpStuff.reset(); // Clear the static reference to this state. instance = null; diff --git a/source/funkin/play/components/PopUpStuff.hx b/source/funkin/play/components/PopUpStuff.hx index b7e206e977..ddf24d24bc 100644 --- a/source/funkin/play/components/PopUpStuff.hx +++ b/source/funkin/play/components/PopUpStuff.hx @@ -7,25 +7,52 @@ import flixel.util.FlxDirection; import funkin.graphics.FunkinSprite; import funkin.play.PlayState; import funkin.util.TimerUtil; +import openfl.utils.Assets; class PopUpStuff extends FlxTypedGroup { public var offsets:Array = [0, 0]; + /** + * Which alternate graphic on popup to use. + * You can set this via script. + * For example, in Week 6 it is `-pixel`. + */ + public static var graphicSuffix:String = ''; + override public function new() { super(); } + static function resolveGraphicPath(suffix:String, index:String):Null + { + var folder:String; + if (suffix != '') + folder = suffix.substring(0, suffix.indexOf("-")) + suffix.substring(suffix.indexOf("-") + 1); + else + folder = 'normal'; + var basePath:String = 'gameplay/popup/$folder/$index'; + var spritePath:String = basePath + suffix; + trace(spritePath); + while (!Assets.exists(Paths.image(spritePath)) && suffix.length > 0) + { + suffix = suffix.split('-').slice(0, -1).join('-'); + spritePath = basePath + suffix; + } + if (!Assets.exists(Paths.image(spritePath))) return null; + return spritePath; + } + public function displayRating(daRating:String) { var perfStart:Float = TimerUtil.start(); if (daRating == null) daRating = "good"; - var ratingPath:String = daRating; + var ratingPath:String = resolveGraphicPath(graphicSuffix, daRating); - if (PlayState.instance.currentStageId.startsWith('school')) ratingPath = "weeb/pixelUI/" + ratingPath + "-pixel"; + //if (PlayState.instance.currentStageId.startsWith('school')) ratingPath = "weeb/pixelUI/" + ratingPath + "-pixel"; var rating:FunkinSprite = FunkinSprite.create(0, 0, ratingPath); rating.scrollFactor.set(0.2, 0.2); @@ -40,7 +67,7 @@ class PopUpStuff extends FlxTypedGroup add(rating); - if (PlayState.instance.currentStageId.startsWith('school')) + if (graphicSuffix.toLowerCase().contains('pixel')) { rating.setGraphicSize(Std.int(rating.width * Constants.PIXEL_ART_SCALE * 0.7)); rating.antialiasing = false; @@ -73,15 +100,8 @@ class PopUpStuff extends FlxTypedGroup if (combo == null) combo = 0; - var pixelShitPart1:String = ""; - var pixelShitPart2:String = ''; - - if (PlayState.instance.currentStageId.startsWith('school')) - { - pixelShitPart1 = 'weeb/pixelUI/'; - pixelShitPart2 = '-pixel'; - } - var comboSpr:FunkinSprite = FunkinSprite.create(pixelShitPart1 + 'combo' + pixelShitPart2); + var comboPath:String = resolveGraphicPath(graphicSuffix, Std.string(combo)); + var comboSpr:FunkinSprite = FunkinSprite.create(comboPath); comboSpr.y = (FlxG.camera.height * 0.44) + offsets[1]; comboSpr.x = (FlxG.width * 0.507) + offsets[0]; // comboSpr.x -= FlxG.camera.scroll.x * 0.2; @@ -92,7 +112,7 @@ class PopUpStuff extends FlxTypedGroup // add(comboSpr); - if (PlayState.instance.currentStageId.startsWith('school')) + if (graphicSuffix.toLowerCase().contains('pixel')) { comboSpr.setGraphicSize(Std.int(comboSpr.width * Constants.PIXEL_ART_SCALE * 0.7)); comboSpr.antialiasing = false; @@ -129,9 +149,9 @@ class PopUpStuff extends FlxTypedGroup var daLoop:Int = 1; for (i in seperatedScore) { - var numScore:FunkinSprite = FunkinSprite.create(0, comboSpr.y, pixelShitPart1 + 'num' + Std.int(i) + pixelShitPart2); + var numScore:FunkinSprite = FunkinSprite.create(0, comboSpr.y, resolveGraphicPath(graphicSuffix, 'num' + Std.int(i))); - if (PlayState.instance.currentStageId.startsWith('school')) + if (graphicSuffix.toLowerCase().contains('pixel')) { numScore.setGraphicSize(Std.int(numScore.width * Constants.PIXEL_ART_SCALE * 0.7)); numScore.antialiasing = false; @@ -166,4 +186,12 @@ class PopUpStuff extends FlxTypedGroup return combo; } + + /** + * Reset the popup configuration to the default. + */ + public static function reset() + { + graphicSuffix = ''; + } } From 2547fbb8f4033f815d3d8d5cef9eb9ddc02c2832 Mon Sep 17 00:00:00 2001 From: anysad Date: Sat, 13 Jul 2024 23:08:16 +0300 Subject: [PATCH 2/8] remove trace --- assets | 2 +- source/funkin/play/components/PopUpStuff.hx | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/assets b/assets index 514a987ee5..e414ee618b 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 514a987ee57827b097ed035a1c2fdd1377a53b17 +Subproject commit e414ee618b4fa577dc3c3df4e156488e91c6348d diff --git a/source/funkin/play/components/PopUpStuff.hx b/source/funkin/play/components/PopUpStuff.hx index ddf24d24bc..0a4d6b0193 100644 --- a/source/funkin/play/components/PopUpStuff.hx +++ b/source/funkin/play/components/PopUpStuff.hx @@ -34,7 +34,6 @@ class PopUpStuff extends FlxTypedGroup folder = 'normal'; var basePath:String = 'gameplay/popup/$folder/$index'; var spritePath:String = basePath + suffix; - trace(spritePath); while (!Assets.exists(Paths.image(spritePath)) && suffix.length > 0) { suffix = suffix.split('-').slice(0, -1).join('-'); From 9d3c043f8ab462973a1e760336581dee89326e42 Mon Sep 17 00:00:00 2001 From: anysad Date: Sat, 13 Jul 2024 23:29:26 +0300 Subject: [PATCH 3/8] cache textures at their new locations! --- source/funkin/ui/transition/LoadingState.hx | 33 ++++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/source/funkin/ui/transition/LoadingState.hx b/source/funkin/ui/transition/LoadingState.hx index bc26ad97a1..d0b8cfbe88 100644 --- a/source/funkin/ui/transition/LoadingState.hx +++ b/source/funkin/ui/transition/LoadingState.hx @@ -291,17 +291,28 @@ class LoadingState extends MusicBeatSubState FunkinSprite.preparePurgeCache(); FunkinSprite.cacheTexture(Paths.image('healthBar')); FunkinSprite.cacheTexture(Paths.image('menuDesat')); - FunkinSprite.cacheTexture(Paths.image('combo')); - FunkinSprite.cacheTexture(Paths.image('num0')); - FunkinSprite.cacheTexture(Paths.image('num1')); - FunkinSprite.cacheTexture(Paths.image('num2')); - FunkinSprite.cacheTexture(Paths.image('num3')); - FunkinSprite.cacheTexture(Paths.image('num4')); - FunkinSprite.cacheTexture(Paths.image('num5')); - FunkinSprite.cacheTexture(Paths.image('num6')); - FunkinSprite.cacheTexture(Paths.image('num7')); - FunkinSprite.cacheTexture(Paths.image('num8')); - FunkinSprite.cacheTexture(Paths.image('num9')); + FunkinSprite.cacheTexture(Paths.image('gameplay/popup/normal/combo')); + FunkinSprite.cacheTexture(Paths.image('gameplay/popup/normal/num0')); + FunkinSprite.cacheTexture(Paths.image('gameplay/popup/normal/num1')); + FunkinSprite.cacheTexture(Paths.image('gameplay/popup/normal/num2')); + FunkinSprite.cacheTexture(Paths.image('gameplay/popup/normal/num3')); + FunkinSprite.cacheTexture(Paths.image('gameplay/popup/normal/num4')); + FunkinSprite.cacheTexture(Paths.image('gameplay/popup/normal/num5')); + FunkinSprite.cacheTexture(Paths.image('gameplay/popup/normal/num6')); + FunkinSprite.cacheTexture(Paths.image('gameplay/popup/normal/num7')); + FunkinSprite.cacheTexture(Paths.image('gameplay/popup/normal/num8')); + FunkinSprite.cacheTexture(Paths.image('gameplay/popup/normal/num9')); + FunkinSprite.cacheTexture(Paths.image('gameplay/popup/pixel/combo-pixel')); + FunkinSprite.cacheTexture(Paths.image('gameplay/popup/pixel/num0-pixel')); + FunkinSprite.cacheTexture(Paths.image('gameplay/popup/pixel/num1-pixel')); + FunkinSprite.cacheTexture(Paths.image('gameplay/popup/pixel/num2-pixel')); + FunkinSprite.cacheTexture(Paths.image('gameplay/popup/pixel/num3-pixel')); + FunkinSprite.cacheTexture(Paths.image('gameplay/popup/pixel/num4-pixel')); + FunkinSprite.cacheTexture(Paths.image('gameplay/popup/pixel/num5-pixel')); + FunkinSprite.cacheTexture(Paths.image('gameplay/popup/pixel/num6-pixel')); + FunkinSprite.cacheTexture(Paths.image('gameplay/popup/pixel/num7-pixel')); + FunkinSprite.cacheTexture(Paths.image('gameplay/popup/pixel/num8-pixel')); + FunkinSprite.cacheTexture(Paths.image('gameplay/popup/pixel/num9-pixel')); FunkinSprite.cacheTexture(Paths.image('notes', 'shared')); FunkinSprite.cacheTexture(Paths.image('noteSplashes', 'shared')); FunkinSprite.cacheTexture(Paths.image('noteStrumline', 'shared')); From aed100df476df55d38e820cc86f643ed62117284 Mon Sep 17 00:00:00 2001 From: anysad Date: Sat, 13 Jul 2024 23:39:56 +0300 Subject: [PATCH 4/8] how the hell did I miss these? --- source/funkin/ui/transition/LoadingState.hx | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/source/funkin/ui/transition/LoadingState.hx b/source/funkin/ui/transition/LoadingState.hx index d0b8cfbe88..a571126fea 100644 --- a/source/funkin/ui/transition/LoadingState.hx +++ b/source/funkin/ui/transition/LoadingState.hx @@ -317,13 +317,20 @@ class LoadingState extends MusicBeatSubState FunkinSprite.cacheTexture(Paths.image('noteSplashes', 'shared')); FunkinSprite.cacheTexture(Paths.image('noteStrumline', 'shared')); FunkinSprite.cacheTexture(Paths.image('NOTE_hold_assets')); - FunkinSprite.cacheTexture(Paths.image('ready', 'shared')); - FunkinSprite.cacheTexture(Paths.image('set', 'shared')); - FunkinSprite.cacheTexture(Paths.image('go', 'shared')); - FunkinSprite.cacheTexture(Paths.image('sick', 'shared')); - FunkinSprite.cacheTexture(Paths.image('good', 'shared')); - FunkinSprite.cacheTexture(Paths.image('bad', 'shared')); - FunkinSprite.cacheTexture(Paths.image('shit', 'shared')); + FunkinSprite.cacheTexture(Paths.image('ui/countdown/ready', 'shared')); + FunkinSprite.cacheTexture(Paths.image('ui/countdown/set', 'shared')); + FunkinSprite.cacheTexture(Paths.image('ui/countdown/go', 'shared')); + FunkinSprite.cacheTexture(Paths.image('ui/countdown/ready-pixel', 'shared')); + FunkinSprite.cacheTexture(Paths.image('ui/countdown/set-pixel', 'shared')); + FunkinSprite.cacheTexture(Paths.image('ui/countdown/go-pixel', 'shared')); + FunkinSprite.cacheTexture(Paths.image('gameplay/popup/normal/sick')); + FunkinSprite.cacheTexture(Paths.image('gameplay/popup/normal/good')); + FunkinSprite.cacheTexture(Paths.image('gameplay/popup/normal/bad')); + FunkinSprite.cacheTexture(Paths.image('gameplay/popup/normal/shit')); + FunkinSprite.cacheTexture(Paths.image('gameplay/popup/pixel/sick-pixel')); + FunkinSprite.cacheTexture(Paths.image('gameplay/popup/pixel/good-pixel')); + FunkinSprite.cacheTexture(Paths.image('gameplay/popup/pixel/bad-pixel')); + FunkinSprite.cacheTexture(Paths.image('gameplay/popup/pixel/shit-pixel')); FunkinSprite.cacheTexture(Paths.image('miss', 'shared')); // TODO: remove this // List all image assets in the level's library. From f8a0627fd270745ba102e8c6a4b0a223e8cf9d3e Mon Sep 17 00:00:00 2001 From: anysad Date: Tue, 16 Jul 2024 20:53:12 +0300 Subject: [PATCH 5/8] goodbye scripts, hello notestyles! --- assets | 2 +- source/funkin/play/Countdown.hx | 101 +++++++++++--------- source/funkin/play/components/PopUpStuff.hx | 75 +++++++-------- source/funkin/ui/transition/LoadingState.hx | 73 +++++++------- source/funkin/util/Constants.hx | 5 + 5 files changed, 132 insertions(+), 124 deletions(-) diff --git a/assets b/assets index e414ee618b..ca4d97554f 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit e414ee618b4fa577dc3c3df4e156488e91c6348d +Subproject commit ca4d97554f9e3853fda25733f21a5fa108c0b902 diff --git a/source/funkin/play/Countdown.hx b/source/funkin/play/Countdown.hx index 7686e5b75e..b97451fa1b 100644 --- a/source/funkin/play/Countdown.hx +++ b/source/funkin/play/Countdown.hx @@ -11,6 +11,8 @@ import funkin.modding.events.ScriptEvent.CountdownScriptEvent; import flixel.util.FlxTimer; import funkin.audio.FunkinSound; import openfl.utils.Assets; +import funkin.data.notestyle.NoteStyleRegistry; +import funkin.play.notes.notestyle.NoteStyle; class Countdown { @@ -20,20 +22,13 @@ class Countdown public static var countdownStep(default, null):CountdownStep = BEFORE; /** - * Which alternate countdown sound effect to use. - * You can set this via script. - * For example, in Week 6 it is `-pixel`. + * Which alternate graphic/sound on countdown to use. + * This is set via the current notestyle. + * For example, in Week 6 it is `pixel`. */ - public static var soundSuffix:String = ''; - - /** - * Which alternate graphic on countdown to use. - * You can set this via script. - * For example, in Week 6 it is `-pixel`. - */ - public static var graphicSuffix:String = ''; - + static var noteStyle:NoteStyle; + static var isPixel:Bool = false; /** * The currently running countdown. This will be null if there is no countdown running. @@ -64,6 +59,11 @@ class Countdown // @:privateAccess // PlayState.instance.dispatchEvent(new SongTimeScriptEvent(SONG_BEAT_HIT, 0, 0)); + var fetchedNoteStyle:NoteStyle = NoteStyleRegistry.instance.fetchEntry(PlayState.instance.currentChart.noteStyle); + 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. countdownTimer = new FlxTimer(); @@ -81,10 +81,10 @@ class Countdown // PlayState.instance.dispatchEvent(new SongTimeScriptEvent(SONG_BEAT_HIT, 0, 0)); // Countdown graphic. - showCountdownGraphic(countdownStep, graphicSuffix.toLowerCase().contains('pixel')); + showCountdownGraphic(countdownStep, noteStyle, isPixel); // Countdown sound. - playCountdownSound(countdownStep); + playCountdownSound(countdownStep, noteStyle); // Event handling bullshit. var cancelled:Bool = propagateCountdownEvent(countdownStep); @@ -197,17 +197,31 @@ class Countdown */ public static function reset() { - soundSuffix = ''; - graphicSuffix = ''; + noteStyle = NoteStyleRegistry.instance.fetchDefault(); + isPixel = false; } /** * Retrieves the graphic to use for this step of the countdown. */ - public static function showCountdownGraphic(index:CountdownStep, isGraphicPixel:Bool):Void + public static function showCountdownGraphic(index:CountdownStep, noteStyle:NoteStyle, isGraphicPixel:Bool):Void { + var indexString:String = null; + switch (index) + { + case TWO: + indexString = 'ready'; + case ONE: + indexString = 'set'; + case GO: + indexString = 'go'; + default: + // null + } + if (indexString == null) return; + var spritePath:String = null; - spritePath = resolveGraphicPath(graphicSuffix, index); + spritePath = resolveGraphicPath(noteStyle, indexString); if (spritePath == null) return; @@ -215,12 +229,15 @@ class Countdown countdownSprite.scrollFactor.set(0, 0); if (isGraphicPixel) countdownSprite.setGraphicSize(Std.int(countdownSprite.width * Constants.PIXEL_ART_SCALE)); + else countdownSprite.setGraphicSize(Std.int(countdownSprite.width * 0.7)); countdownSprite.antialiasing = !isGraphicPixel; countdownSprite.updateHitbox(); countdownSprite.screenCenter(); + countdownSprite.cameras = [PlayState.instance.camHUD]; + // Fade sprite in, then out, then destroy it. FlxTween.tween(countdownSprite, {y: countdownSprite.y += 100, alpha: 0}, Conductor.instance.beatLengthMs / 1000, { @@ -233,29 +250,18 @@ class Countdown PlayState.instance.add(countdownSprite); } - static function resolveGraphicPath(suffix:String, index:CountdownStep):Null + static function resolveGraphicPath(noteStyle:NoteStyle, index:String):Null { var basePath:String = 'ui/countdown/'; - var indexString:String = null; - switch (index) - { - case TWO: - indexString = 'ready'; - case ONE: - indexString = 'set'; - case GO: - indexString = 'go'; - default: - // null - } - basePath += indexString; - var spritePath:String = basePath + suffix; - while (!Assets.exists(Paths.image(spritePath)) && suffix.length > 0) + + var spritePath:String = basePath + noteStyle.id + '/$index'; + // If nothing is found, revert it to default notestyle skin + if (!Assets.exists(Paths.image(spritePath))) { - suffix = suffix.split('-').slice(0, -1).join('-'); - spritePath = basePath + suffix; + if (!isPixel) spritePath = basePath + Constants.DEFAULT_NOTE_STYLE + '/$index'; + else spritePath = basePath + Constants.DEFAULT_PIXEL_NOTE_STYLE + '/$index'; } - if (!Assets.exists(Paths.image(spritePath))) return null; + trace('Resolved sprite path: ' + Paths.image(spritePath)); return spritePath; } @@ -263,23 +269,24 @@ class Countdown /** * Retrieves the sound file to use for this step of the countdown. */ - public static function playCountdownSound(index:CountdownStep):Void + public static function playCountdownSound(step:CountdownStep, noteStyle:NoteStyle):Void { - FunkinSound.playOnce(resolveSoundPath(soundSuffix, index), Constants.COUNTDOWN_VOLUME); + return FunkinSound.playOnce(Paths.sound(resolveSoundPath(noteStyle, step)), Constants.COUNTDOWN_VOLUME); } - static function resolveSoundPath(suffix:String, step:CountdownStep):Null + static function resolveSoundPath(noteStyle:NoteStyle, step:CountdownStep):Null { - var basePath:String = 'gameplay/countdown/intro'; - if (step != CountdownStep.BEFORE || step != CountdownStep.AFTER) basePath += step; + if (step == CountdownStep.BEFORE || step == CountdownStep.AFTER) return null; + var basePath:String = 'gameplay/countdown/'; - var soundPath:String = Paths.sound(basePath + suffix); - while (!Assets.exists(soundPath) && suffix.length > 0) + var soundPath:String = basePath + noteStyle.id + '/intro$step'; + // If nothing is found, revert it to default notestyle sound + if (!Assets.exists(Paths.sound(soundPath))) { - suffix = suffix.split('-').slice(0, -1).join('-'); - soundPath = Paths.sound(basePath + suffix); + if (!isPixel) soundPath = basePath + Constants.DEFAULT_NOTE_STYLE + '/intro$step'; + else soundPath = basePath + Constants.DEFAULT_PIXEL_NOTE_STYLE + '/intro$step'; } - if (!Assets.exists(soundPath)) return null; + trace('Resolved sound path: ' + soundPath); return soundPath; } diff --git a/source/funkin/play/components/PopUpStuff.hx b/source/funkin/play/components/PopUpStuff.hx index 0a4d6b0193..eb59a99224 100644 --- a/source/funkin/play/components/PopUpStuff.hx +++ b/source/funkin/play/components/PopUpStuff.hx @@ -8,6 +8,8 @@ import funkin.graphics.FunkinSprite; import funkin.play.PlayState; import funkin.util.TimerUtil; import openfl.utils.Assets; +import funkin.data.notestyle.NoteStyleRegistry; +import funkin.play.notes.notestyle.NoteStyle; class PopUpStuff extends FlxTypedGroup { @@ -15,31 +17,35 @@ class PopUpStuff extends FlxTypedGroup /** * Which alternate graphic on popup to use. - * You can set this via script. - * For example, in Week 6 it is `-pixel`. + * This is set via the current notestyle. + * For example, in Week 6 it is `pixel`. */ - public static var graphicSuffix:String = ''; + static var noteStyle:NoteStyle; + + static var isPixel:Bool = false; override public function new() { super(); + + var fetchedNoteStyle:NoteStyle = NoteStyleRegistry.instance.fetchEntry(PlayState.instance.currentChart.noteStyle); + if (fetchedNoteStyle == null) noteStyle = NoteStyleRegistry.instance.fetchDefault(); + else noteStyle = fetchedNoteStyle; + if (noteStyle._data.assets.note.isPixel) isPixel = true; } - static function resolveGraphicPath(suffix:String, index:String):Null + static function resolveGraphicPath(noteStyle:NoteStyle, index:String):Null { - var folder:String; - if (suffix != '') - folder = suffix.substring(0, suffix.indexOf("-")) + suffix.substring(suffix.indexOf("-") + 1); - else - folder = 'normal'; - var basePath:String = 'gameplay/popup/$folder/$index'; - var spritePath:String = basePath + suffix; - while (!Assets.exists(Paths.image(spritePath)) && suffix.length > 0) + var basePath:String = 'ui/popup/'; + + var spritePath:String = basePath + noteStyle.id + '/$index'; + // If nothing is found, revert it to default notestyle skin + if (!Assets.exists(Paths.image(spritePath))) { - suffix = suffix.split('-').slice(0, -1).join('-'); - spritePath = basePath + suffix; + if (!isPixel) spritePath = basePath + Constants.DEFAULT_NOTE_STYLE + '/$index'; + else spritePath = basePath + Constants.DEFAULT_PIXEL_NOTE_STYLE + '/$index'; } - if (!Assets.exists(Paths.image(spritePath))) return null; + return spritePath; } @@ -49,7 +55,7 @@ class PopUpStuff extends FlxTypedGroup if (daRating == null) daRating = "good"; - var ratingPath:String = resolveGraphicPath(graphicSuffix, daRating); + var ratingPath:String = resolveGraphicPath(noteStyle, daRating); //if (PlayState.instance.currentStageId.startsWith('school')) ratingPath = "weeb/pixelUI/" + ratingPath + "-pixel"; @@ -66,7 +72,7 @@ class PopUpStuff extends FlxTypedGroup add(rating); - if (graphicSuffix.toLowerCase().contains('pixel')) + if (isPixel) { rating.setGraphicSize(Std.int(rating.width * Constants.PIXEL_ART_SCALE * 0.7)); rating.antialiasing = false; @@ -99,7 +105,7 @@ class PopUpStuff extends FlxTypedGroup if (combo == null) combo = 0; - var comboPath:String = resolveGraphicPath(graphicSuffix, Std.string(combo)); + var comboPath:String = resolveGraphicPath(noteStyle, 'combo'); var comboSpr:FunkinSprite = FunkinSprite.create(comboPath); comboSpr.y = (FlxG.camera.height * 0.44) + offsets[1]; comboSpr.x = (FlxG.width * 0.507) + offsets[0]; @@ -111,16 +117,10 @@ class PopUpStuff extends FlxTypedGroup // add(comboSpr); - if (graphicSuffix.toLowerCase().contains('pixel')) - { - comboSpr.setGraphicSize(Std.int(comboSpr.width * Constants.PIXEL_ART_SCALE * 0.7)); - comboSpr.antialiasing = false; - } - else - { - comboSpr.setGraphicSize(Std.int(comboSpr.width * 0.7)); - comboSpr.antialiasing = true; - } + if (isPixel) comboSpr.setGraphicSize(Std.int(comboSpr.width * Constants.PIXEL_ART_SCALE * 0.7)); + else comboSpr.setGraphicSize(Std.int(comboSpr.width * 0.7)); + + comboSpr.antialiasing = !isPixel; comboSpr.updateHitbox(); FlxTween.tween(comboSpr, {alpha: 0}, 0.2, @@ -148,18 +148,12 @@ class PopUpStuff extends FlxTypedGroup var daLoop:Int = 1; for (i in seperatedScore) { - var numScore:FunkinSprite = FunkinSprite.create(0, comboSpr.y, resolveGraphicPath(graphicSuffix, 'num' + Std.int(i))); + var numScore:FunkinSprite = FunkinSprite.create(0, comboSpr.y, resolveGraphicPath(noteStyle, 'num' + Std.int(i))); - if (graphicSuffix.toLowerCase().contains('pixel')) - { - numScore.setGraphicSize(Std.int(numScore.width * Constants.PIXEL_ART_SCALE * 0.7)); - numScore.antialiasing = false; - } - else - { - numScore.setGraphicSize(Std.int(numScore.width * 0.45)); - numScore.antialiasing = true; - } + if (isPixel) numScore.setGraphicSize(Std.int(numScore.width * Constants.PIXEL_ART_SCALE * 0.7)); + else numScore.setGraphicSize(Std.int(numScore.width * 0.45)); + + numScore.antialiasing = !isPixel; numScore.updateHitbox(); numScore.x = comboSpr.x - (36 * daLoop) - 65; //- 90; @@ -191,6 +185,7 @@ class PopUpStuff extends FlxTypedGroup */ public static function reset() { - graphicSuffix = ''; + noteStyle = NoteStyleRegistry.instance.fetchDefault(); + isPixel = false; } } diff --git a/source/funkin/ui/transition/LoadingState.hx b/source/funkin/ui/transition/LoadingState.hx index a571126fea..e50032d65f 100644 --- a/source/funkin/ui/transition/LoadingState.hx +++ b/source/funkin/ui/transition/LoadingState.hx @@ -291,46 +291,47 @@ class LoadingState extends MusicBeatSubState FunkinSprite.preparePurgeCache(); FunkinSprite.cacheTexture(Paths.image('healthBar')); FunkinSprite.cacheTexture(Paths.image('menuDesat')); - FunkinSprite.cacheTexture(Paths.image('gameplay/popup/normal/combo')); - FunkinSprite.cacheTexture(Paths.image('gameplay/popup/normal/num0')); - FunkinSprite.cacheTexture(Paths.image('gameplay/popup/normal/num1')); - FunkinSprite.cacheTexture(Paths.image('gameplay/popup/normal/num2')); - FunkinSprite.cacheTexture(Paths.image('gameplay/popup/normal/num3')); - FunkinSprite.cacheTexture(Paths.image('gameplay/popup/normal/num4')); - FunkinSprite.cacheTexture(Paths.image('gameplay/popup/normal/num5')); - FunkinSprite.cacheTexture(Paths.image('gameplay/popup/normal/num6')); - FunkinSprite.cacheTexture(Paths.image('gameplay/popup/normal/num7')); - FunkinSprite.cacheTexture(Paths.image('gameplay/popup/normal/num8')); - FunkinSprite.cacheTexture(Paths.image('gameplay/popup/normal/num9')); - FunkinSprite.cacheTexture(Paths.image('gameplay/popup/pixel/combo-pixel')); - FunkinSprite.cacheTexture(Paths.image('gameplay/popup/pixel/num0-pixel')); - FunkinSprite.cacheTexture(Paths.image('gameplay/popup/pixel/num1-pixel')); - FunkinSprite.cacheTexture(Paths.image('gameplay/popup/pixel/num2-pixel')); - FunkinSprite.cacheTexture(Paths.image('gameplay/popup/pixel/num3-pixel')); - FunkinSprite.cacheTexture(Paths.image('gameplay/popup/pixel/num4-pixel')); - FunkinSprite.cacheTexture(Paths.image('gameplay/popup/pixel/num5-pixel')); - FunkinSprite.cacheTexture(Paths.image('gameplay/popup/pixel/num6-pixel')); - FunkinSprite.cacheTexture(Paths.image('gameplay/popup/pixel/num7-pixel')); - FunkinSprite.cacheTexture(Paths.image('gameplay/popup/pixel/num8-pixel')); - FunkinSprite.cacheTexture(Paths.image('gameplay/popup/pixel/num9-pixel')); + // Lord have mercy on me and this caching -anysad + FunkinSprite.cacheTexture(Paths.image('ui/popup/funkin/combo')); + FunkinSprite.cacheTexture(Paths.image('ui/popup/funkin/num0')); + FunkinSprite.cacheTexture(Paths.image('ui/popup/funkin/num1')); + FunkinSprite.cacheTexture(Paths.image('ui/popup/funkin/num2')); + FunkinSprite.cacheTexture(Paths.image('ui/popup/funkin/num3')); + FunkinSprite.cacheTexture(Paths.image('ui/popup/funkin/num4')); + FunkinSprite.cacheTexture(Paths.image('ui/popup/funkin/num5')); + FunkinSprite.cacheTexture(Paths.image('ui/popup/funkin/num6')); + FunkinSprite.cacheTexture(Paths.image('ui/popup/funkin/num7')); + FunkinSprite.cacheTexture(Paths.image('ui/popup/funkin/num8')); + FunkinSprite.cacheTexture(Paths.image('ui/popup/funkin/num9')); + FunkinSprite.cacheTexture(Paths.image('ui/popup/pixel/combo')); + FunkinSprite.cacheTexture(Paths.image('ui/popup/pixel/num0')); + FunkinSprite.cacheTexture(Paths.image('ui/popup/pixel/num1')); + FunkinSprite.cacheTexture(Paths.image('ui/popup/pixel/num2')); + FunkinSprite.cacheTexture(Paths.image('ui/popup/pixel/num3')); + FunkinSprite.cacheTexture(Paths.image('ui/popup/pixel/num4')); + FunkinSprite.cacheTexture(Paths.image('ui/popup/pixel/num5')); + FunkinSprite.cacheTexture(Paths.image('ui/popup/pixel/num6')); + FunkinSprite.cacheTexture(Paths.image('ui/popup/pixel/num7')); + FunkinSprite.cacheTexture(Paths.image('ui/popup/pixel/num8')); + FunkinSprite.cacheTexture(Paths.image('ui/popup/pixel/num9')); FunkinSprite.cacheTexture(Paths.image('notes', 'shared')); FunkinSprite.cacheTexture(Paths.image('noteSplashes', 'shared')); FunkinSprite.cacheTexture(Paths.image('noteStrumline', 'shared')); FunkinSprite.cacheTexture(Paths.image('NOTE_hold_assets')); - FunkinSprite.cacheTexture(Paths.image('ui/countdown/ready', 'shared')); - FunkinSprite.cacheTexture(Paths.image('ui/countdown/set', 'shared')); - FunkinSprite.cacheTexture(Paths.image('ui/countdown/go', 'shared')); - FunkinSprite.cacheTexture(Paths.image('ui/countdown/ready-pixel', 'shared')); - FunkinSprite.cacheTexture(Paths.image('ui/countdown/set-pixel', 'shared')); - FunkinSprite.cacheTexture(Paths.image('ui/countdown/go-pixel', 'shared')); - FunkinSprite.cacheTexture(Paths.image('gameplay/popup/normal/sick')); - FunkinSprite.cacheTexture(Paths.image('gameplay/popup/normal/good')); - FunkinSprite.cacheTexture(Paths.image('gameplay/popup/normal/bad')); - FunkinSprite.cacheTexture(Paths.image('gameplay/popup/normal/shit')); - FunkinSprite.cacheTexture(Paths.image('gameplay/popup/pixel/sick-pixel')); - FunkinSprite.cacheTexture(Paths.image('gameplay/popup/pixel/good-pixel')); - FunkinSprite.cacheTexture(Paths.image('gameplay/popup/pixel/bad-pixel')); - FunkinSprite.cacheTexture(Paths.image('gameplay/popup/pixel/shit-pixel')); + FunkinSprite.cacheTexture(Paths.image('ui/countdown/funkin/ready', 'shared')); + FunkinSprite.cacheTexture(Paths.image('ui/countdown/funkin/set', 'shared')); + FunkinSprite.cacheTexture(Paths.image('ui/countdown/funkin/go', 'shared')); + FunkinSprite.cacheTexture(Paths.image('ui/countdown/pixel/ready', 'shared')); + FunkinSprite.cacheTexture(Paths.image('ui/countdown/pixel/set', 'shared')); + FunkinSprite.cacheTexture(Paths.image('ui/countdown/pixel/go', 'shared')); + FunkinSprite.cacheTexture(Paths.image('ui/popup/normal/sick')); + FunkinSprite.cacheTexture(Paths.image('ui/popup/normal/good')); + FunkinSprite.cacheTexture(Paths.image('ui/popup/normal/bad')); + FunkinSprite.cacheTexture(Paths.image('ui/popup/normal/shit')); + FunkinSprite.cacheTexture(Paths.image('ui/popup/pixel/sick')); + FunkinSprite.cacheTexture(Paths.image('ui/popup/pixel/good')); + FunkinSprite.cacheTexture(Paths.image('ui/popup/pixel/bad')); + FunkinSprite.cacheTexture(Paths.image('ui/popup/pixel/shit')); FunkinSprite.cacheTexture(Paths.image('miss', 'shared')); // TODO: remove this // List all image assets in the level's library. diff --git a/source/funkin/util/Constants.hx b/source/funkin/util/Constants.hx index 1e0978839a..79b0e05c56 100644 --- a/source/funkin/util/Constants.hx +++ b/source/funkin/util/Constants.hx @@ -258,6 +258,11 @@ class Constants */ public static final DEFAULT_NOTE_STYLE:String = 'funkin'; + /** + * The default pixel note style for songs. + */ + public static final DEFAULT_PIXEL_NOTE_STYLE:String = 'pixel'; + /** * The default album for songs in Freeplay. */ From ee449819959ed51b5719f7ebd39493118c307eee Mon Sep 17 00:00:00 2001 From: anysad Date: Tue, 16 Jul 2024 22:02:05 +0300 Subject: [PATCH 6/8] you know what, make countdown sprites a little bigger --- source/funkin/play/Countdown.hx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/funkin/play/Countdown.hx b/source/funkin/play/Countdown.hx index b97451fa1b..ccd4783479 100644 --- a/source/funkin/play/Countdown.hx +++ b/source/funkin/play/Countdown.hx @@ -228,8 +228,8 @@ class Countdown var countdownSprite:FunkinSprite = FunkinSprite.create(spritePath); countdownSprite.scrollFactor.set(0, 0); - if (isGraphicPixel) countdownSprite.setGraphicSize(Std.int(countdownSprite.width * Constants.PIXEL_ART_SCALE)); - else countdownSprite.setGraphicSize(Std.int(countdownSprite.width * 0.7)); + if (isGraphicPixel) countdownSprite.setGraphicSize(Std.int(countdownSprite.width * Constants.PIXEL_ART_SCALE * 1.1)); + else countdownSprite.setGraphicSize(Std.int(countdownSprite.width * 0.8)); countdownSprite.antialiasing = !isGraphicPixel; From ff1ab1eb4245092829701e322c1b4dbe27f80590 Mon Sep 17 00:00:00 2001 From: anysad Date: Wed, 17 Jul 2024 23:19:18 +0300 Subject: [PATCH 7/8] welcome fallback note styles! --- source/funkin/play/Countdown.hx | 53 ++++++++++++++----- source/funkin/play/components/PopUpStuff.hx | 21 +++++++- .../funkin/play/notes/notestyle/NoteStyle.hx | 2 +- 3 files changed, 59 insertions(+), 17 deletions(-) diff --git a/source/funkin/play/Countdown.hx b/source/funkin/play/Countdown.hx index ccd4783479..25a896317b 100644 --- a/source/funkin/play/Countdown.hx +++ b/source/funkin/play/Countdown.hx @@ -28,6 +28,8 @@ class Countdown */ static var noteStyle:NoteStyle; + static var fallbackNoteStyle:Null; + static var isPixel:Bool = false; /** @@ -59,10 +61,7 @@ class Countdown // @:privateAccess // PlayState.instance.dispatchEvent(new SongTimeScriptEvent(SONG_BEAT_HIT, 0, 0)); - var fetchedNoteStyle:NoteStyle = NoteStyleRegistry.instance.fetchEntry(PlayState.instance.currentChart.noteStyle); - if (fetchedNoteStyle == null) noteStyle = NoteStyleRegistry.instance.fetchDefault(); - else noteStyle = fetchedNoteStyle; - if (noteStyle._data.assets.note.isPixel) isPixel = true; + fetchNoteStyle(); // The timer function gets called based on the beat of the song. countdownTimer = new FlxTimer(); @@ -81,7 +80,7 @@ class Countdown // PlayState.instance.dispatchEvent(new SongTimeScriptEvent(SONG_BEAT_HIT, 0, 0)); // Countdown graphic. - showCountdownGraphic(countdownStep, noteStyle, isPixel); + showCountdownGraphic(countdownStep, noteStyle); // Countdown sound. playCountdownSound(countdownStep, noteStyle); @@ -201,10 +200,19 @@ class Countdown 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. */ - public static function showCountdownGraphic(index:CountdownStep, noteStyle:NoteStyle, isGraphicPixel:Bool):Void + public static function showCountdownGraphic(index:CountdownStep, noteStyle:NoteStyle):Void { var indexString:String = null; switch (index) @@ -228,16 +236,16 @@ class Countdown var countdownSprite:FunkinSprite = FunkinSprite.create(spritePath); countdownSprite.scrollFactor.set(0, 0); - if (isGraphicPixel) countdownSprite.setGraphicSize(Std.int(countdownSprite.width * Constants.PIXEL_ART_SCALE * 1.1)); + if (isPixel) countdownSprite.setGraphicSize(Std.int(countdownSprite.width * Constants.PIXEL_ART_SCALE * 1.1)); else countdownSprite.setGraphicSize(Std.int(countdownSprite.width * 0.8)); - countdownSprite.antialiasing = !isGraphicPixel; + countdownSprite.antialiasing = !isPixel; + + countdownSprite.cameras = [PlayState.instance.camHUD]; countdownSprite.updateHitbox(); countdownSprite.screenCenter(); - countdownSprite.cameras = [PlayState.instance.camHUD]; - // Fade sprite in, then out, then destroy it. FlxTween.tween(countdownSprite, {y: countdownSprite.y += 100, alpha: 0}, Conductor.instance.beatLengthMs / 1000, { @@ -252,10 +260,18 @@ class Countdown static function resolveGraphicPath(noteStyle:NoteStyle, index:String):Null { + fetchNoteStyle(); var basePath:String = 'ui/countdown/'; - 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 (!isPixel) spritePath = basePath + Constants.DEFAULT_NOTE_STYLE + '/$index'; @@ -277,10 +293,19 @@ class Countdown static function resolveSoundPath(noteStyle:NoteStyle, step:CountdownStep):Null { if (step == CountdownStep.BEFORE || step == CountdownStep.AFTER) return null; + fetchNoteStyle(); var basePath:String = 'gameplay/countdown/'; - 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 (!isPixel) soundPath = basePath + Constants.DEFAULT_NOTE_STYLE + '/intro$step'; diff --git a/source/funkin/play/components/PopUpStuff.hx b/source/funkin/play/components/PopUpStuff.hx index eb59a99224..6c111c0dbf 100644 --- a/source/funkin/play/components/PopUpStuff.hx +++ b/source/funkin/play/components/PopUpStuff.hx @@ -22,23 +22,40 @@ class PopUpStuff extends FlxTypedGroup */ static var noteStyle:NoteStyle; + static var fallbackNoteStyle:Null; + static var isPixel:Bool = false; override public function new() { super(); + fetchNoteStyle(); + } + + static function fetchNoteStyle():Void + { var fetchedNoteStyle:NoteStyle = NoteStyleRegistry.instance.fetchEntry(PlayState.instance.currentChart.noteStyle); if (fetchedNoteStyle == null) noteStyle = NoteStyleRegistry.instance.fetchDefault(); else 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 { + fetchNoteStyle(); var basePath:String = 'ui/popup/'; - 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 (!Assets.exists(Paths.image(spritePath))) { diff --git a/source/funkin/play/notes/notestyle/NoteStyle.hx b/source/funkin/play/notes/notestyle/NoteStyle.hx index d0cc09f6a8..edfcff2ee1 100644 --- a/source/funkin/play/notes/notestyle/NoteStyle.hx +++ b/source/funkin/play/notes/notestyle/NoteStyle.hx @@ -72,7 +72,7 @@ class NoteStyle implements IRegistryEntry * Get the note style ID of the parent note style. * @return The string ID, or `null` if there is no parent. */ - function getFallbackID():Null + public function getFallbackID():Null { return _data.fallback; } From ba96b111960e2945c14eef0112368a30152d1e7c Mon Sep 17 00:00:00 2001 From: anysad Date: Thu, 18 Jul 2024 17:56:54 +0300 Subject: [PATCH 8/8] hopefully final polish? --- source/funkin/play/Countdown.hx | 26 ++++++++++----------- source/funkin/play/components/PopUpStuff.hx | 10 ++++---- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/source/funkin/play/Countdown.hx b/source/funkin/play/Countdown.hx index 25a896317b..1a9605597f 100644 --- a/source/funkin/play/Countdown.hx +++ b/source/funkin/play/Countdown.hx @@ -61,8 +61,6 @@ class Countdown // @:privateAccess // PlayState.instance.dispatchEvent(new SongTimeScriptEvent(SONG_BEAT_HIT, 0, 0)); - fetchNoteStyle(); - // The timer function gets called based on the beat of the song. countdownTimer = new FlxTimer(); @@ -80,10 +78,10 @@ class Countdown // PlayState.instance.dispatchEvent(new SongTimeScriptEvent(SONG_BEAT_HIT, 0, 0)); // Countdown graphic. - showCountdownGraphic(countdownStep, noteStyle); + showCountdownGraphic(countdownStep); // Countdown sound. - playCountdownSound(countdownStep, noteStyle); + playCountdownSound(countdownStep); // Event handling bullshit. var cancelled:Bool = propagateCountdownEvent(countdownStep); @@ -212,7 +210,7 @@ class Countdown /** * Retrieves the graphic to use for this step of the countdown. */ - public static function showCountdownGraphic(index:CountdownStep, noteStyle:NoteStyle):Void + public static function showCountdownGraphic(index:CountdownStep):Void { var indexString:String = null; switch (index) @@ -229,25 +227,24 @@ class Countdown if (indexString == null) return; var spritePath:String = null; - spritePath = resolveGraphicPath(noteStyle, indexString); + spritePath = resolveGraphicPath(indexString); if (spritePath == null) return; var countdownSprite:FunkinSprite = FunkinSprite.create(spritePath); countdownSprite.scrollFactor.set(0, 0); - if (isPixel) countdownSprite.setGraphicSize(Std.int(countdownSprite.width * Constants.PIXEL_ART_SCALE * 1.1)); - else countdownSprite.setGraphicSize(Std.int(countdownSprite.width * 0.8)); + if (isPixel) countdownSprite.setGraphicSize(Std.int(countdownSprite.width * Constants.PIXEL_ART_SCALE)); + else countdownSprite.setGraphicSize(Std.int(countdownSprite.width * 0.7)); countdownSprite.antialiasing = !isPixel; countdownSprite.cameras = [PlayState.instance.camHUD]; countdownSprite.updateHitbox(); - countdownSprite.screenCenter(); // Fade sprite in, then out, then destroy it. - FlxTween.tween(countdownSprite, {y: countdownSprite.y += 100, alpha: 0}, Conductor.instance.beatLengthMs / 1000, + FlxTween.tween(countdownSprite, {alpha: 0}, Conductor.instance.beatLengthMs / 1000, { ease: FlxEase.cubeInOut, onComplete: function(twn:FlxTween) { @@ -256,9 +253,10 @@ class Countdown }); PlayState.instance.add(countdownSprite); + countdownSprite.screenCenter(); } - static function resolveGraphicPath(noteStyle:NoteStyle, index:String):Null + static function resolveGraphicPath(index:String):Null { fetchNoteStyle(); var basePath:String = 'ui/countdown/'; @@ -285,12 +283,12 @@ class Countdown /** * Retrieves the sound file to use for this step of the countdown. */ - public static function playCountdownSound(step:CountdownStep, noteStyle:NoteStyle):Void + public static function playCountdownSound(step:CountdownStep):Void { - return FunkinSound.playOnce(Paths.sound(resolveSoundPath(noteStyle, step)), Constants.COUNTDOWN_VOLUME); + return FunkinSound.playOnce(Paths.sound(resolveSoundPath(step)), Constants.COUNTDOWN_VOLUME); } - static function resolveSoundPath(noteStyle:NoteStyle, step:CountdownStep):Null + static function resolveSoundPath(step:CountdownStep):Null { if (step == CountdownStep.BEFORE || step == CountdownStep.AFTER) return null; fetchNoteStyle(); diff --git a/source/funkin/play/components/PopUpStuff.hx b/source/funkin/play/components/PopUpStuff.hx index 6c111c0dbf..4025358785 100644 --- a/source/funkin/play/components/PopUpStuff.hx +++ b/source/funkin/play/components/PopUpStuff.hx @@ -29,8 +29,6 @@ class PopUpStuff extends FlxTypedGroup override public function new() { super(); - - fetchNoteStyle(); } static function fetchNoteStyle():Void @@ -42,7 +40,7 @@ class PopUpStuff extends FlxTypedGroup isPixel = false; } - static function resolveGraphicPath(noteStyle:NoteStyle, index:String):Null + static function resolveGraphicPath(index:String):Null { fetchNoteStyle(); var basePath:String = 'ui/popup/'; @@ -72,7 +70,7 @@ class PopUpStuff extends FlxTypedGroup if (daRating == null) daRating = "good"; - var ratingPath:String = resolveGraphicPath(noteStyle, daRating); + var ratingPath:String = resolveGraphicPath(daRating); //if (PlayState.instance.currentStageId.startsWith('school')) ratingPath = "weeb/pixelUI/" + ratingPath + "-pixel"; @@ -122,7 +120,7 @@ class PopUpStuff extends FlxTypedGroup if (combo == null) combo = 0; - var comboPath:String = resolveGraphicPath(noteStyle, 'combo'); + var comboPath:String = resolveGraphicPath('combo'); var comboSpr:FunkinSprite = FunkinSprite.create(comboPath); comboSpr.y = (FlxG.camera.height * 0.44) + offsets[1]; comboSpr.x = (FlxG.width * 0.507) + offsets[0]; @@ -165,7 +163,7 @@ class PopUpStuff extends FlxTypedGroup var daLoop:Int = 1; for (i in seperatedScore) { - var numScore:FunkinSprite = FunkinSprite.create(0, comboSpr.y, resolveGraphicPath(noteStyle, 'num' + Std.int(i))); + var numScore:FunkinSprite = FunkinSprite.create(0, comboSpr.y, resolveGraphicPath('num' + Std.int(i))); if (isPixel) numScore.setGraphicSize(Std.int(numScore.width * Constants.PIXEL_ART_SCALE * 0.7)); else numScore.setGraphicSize(Std.int(numScore.width * 0.45));