From 0971a0bb4c0e8f4bf6c5c143bcb158eeda8bb5af Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Mon, 30 Sep 2024 10:53:27 -0400 Subject: [PATCH] music persist fixes for title screen --- source/funkin/audio/FunkinSound.hx | 11 ++++++++--- source/funkin/ui/title/TitleState.hx | 6 +++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/source/funkin/audio/FunkinSound.hx b/source/funkin/audio/FunkinSound.hx index 98e0307ba..92da2b50a 100644 --- a/source/funkin/audio/FunkinSound.hx +++ b/source/funkin/audio/FunkinSound.hx @@ -390,7 +390,7 @@ class FunkinSound extends FlxSound implements ICloneable } else { - var music = FunkinSound.load(pathToUse, params?.startingVolume ?? 1.0, params.loop ?? true, false, true, params.onComplete); + var music = FunkinSound.load(pathToUse, params?.startingVolume ?? 1.0, params.loop ?? true, false, true, params.persist ?? false, params.onComplete); if (music != null) { FlxG.sound.music = music; @@ -514,7 +514,7 @@ class FunkinSound extends FlxSound implements ICloneable }); soundRequest.future.onComplete(function(partialSound) { - var snd = FunkinSound.load(partialSound, volume, looped, autoDestroy, autoPlay, onComplete, onLoad); + var snd = FunkinSound.load(partialSound, volume, looped, autoDestroy, autoPlay, false, onComplete, onLoad); promise.complete(snd); }); } @@ -544,7 +544,7 @@ class FunkinSound extends FlxSound implements ICloneable */ public static function playOnce(key:String, volume:Float = 1.0, ?onComplete:Void->Void, ?onLoad:Void->Void):Null { - var result:Null = FunkinSound.load(key, volume, false, true, true, onComplete, onLoad); + var result:Null = FunkinSound.load(key, volume, false, true, true, false, onComplete, onLoad); return result; } @@ -630,6 +630,11 @@ typedef FunkinSoundPlayMusicParams = var ?partialParams:PartialSoundParams; + /** + * Whether the sound should be destroyed on state switches + */ + var ?persist:Bool; + var ?onComplete:Void->Void; var ?onLoad:Void->Void; } diff --git a/source/funkin/ui/title/TitleState.hx b/source/funkin/ui/title/TitleState.hx index cdd1e3916..1b2816936 100644 --- a/source/funkin/ui/title/TitleState.hx +++ b/source/funkin/ui/title/TitleState.hx @@ -232,7 +232,8 @@ class TitleState extends MusicBeatState { startingVolume: 0.0, overrideExisting: true, - restartTrack: true + restartTrack: false, + persist: true }); // Fade from 0.0 to 1 over 4 seconds if (shouldFadeIn) FlxG.sound.music.fadeIn(4.0, 0.0, 1.0); @@ -488,8 +489,7 @@ class TitleState extends MusicBeatState // easter egg for when the game is trending with the wrong spelling // the random intro text would be "trending--only on x" - if (curWacky[0] == "trending") - addMoreText('Nigth'); + if (curWacky[0] == "trending") addMoreText('Nigth'); else addMoreText('Night'); case 15: