Merge pull request #586 from FunkinCrew/bugfix/mod-songs-freeplay-preview

Disable song previews for mod songs rather than crashing the game
This commit is contained in:
Cameron Taylor 2024-05-31 18:07:32 -04:00 committed by GitHub
commit 00566848e9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 9 deletions

View file

@ -377,7 +377,7 @@ class FunkinSound extends FlxSound implements ICloneable<FunkinSound>
FlxG.sound.music = partialMusic;
FlxG.sound.list.remove(FlxG.sound.music);
if (params.onLoad != null) params.onLoad();
if (FlxG.sound.music != null && params.onLoad != null) params.onLoad();
});
return true;
@ -488,6 +488,12 @@ class FunkinSound extends FlxSound implements ICloneable<FunkinSound>
var soundRequest = FlxPartialSound.partialLoadFromFile(path, start, end);
if (soundRequest == null)
{
promise.complete(null);
}
else
{
promise.future.onError(function(e) {
soundRequest.error("Sound loading was errored or cancelled");
});
@ -496,6 +502,7 @@ class FunkinSound extends FlxSound implements ICloneable<FunkinSound>
var snd = FunkinSound.load(partialSound, volume, looped, autoDestroy, autoPlay, onComplete, onLoad);
promise.complete(snd);
});
}
return promise;
}

View file

@ -830,7 +830,7 @@ class FreeplayState extends MusicBeatSubState
dj.fistPump();
// rankCamera.fade(FlxColor.BLACK, 0.5, true);
rankCamera.fade(0xFF000000, 0.5, true, null, true);
FlxG.sound.music.volume = 0;
if (FlxG.sound.music != null) FlxG.sound.music.volume = 0;
rankBg.alpha = 1;
originalPos.x = grpCapsules.members[curSelected].x;