This commit is contained in:
Lasercar 2025-04-05 05:29:54 +10:00 committed by GitHub
commit c2e582acef
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -311,13 +311,22 @@ class FunkinSound extends FlxSound implements ICloneable<FunkinSound>
{
if (!(params.overrideExisting ?? false) && (FlxG.sound.music?.exists ?? false) && FlxG.sound.music.playing) return false;
var pathsFunction = params.pathsFunction ?? MUSIC;
var suffix = params.suffix ?? '';
var pathToUse = switch (pathsFunction)
{
case MUSIC: Paths.music('$key/$key');
case INST: Paths.inst('$key', suffix);
default: Paths.music('$key/$key');
}
if (!(params.restartTrack ?? false) && FlxG.sound.music?.playing)
{
if (FlxG.sound.music != null && Std.isOfType(FlxG.sound.music, FunkinSound))
{
var existingSound:FunkinSound = cast FlxG.sound.music;
// Stop here if we would play a matching music track.
if (existingSound._label == Paths.music('$key/$key'))
if (existingSound._label == pathToUse)
{
return false;
}
@ -346,15 +355,6 @@ class FunkinSound extends FlxSound implements ICloneable<FunkinSound>
FlxG.log.warn('Tried and failed to find music metadata for $key');
}
}
var pathsFunction = params.pathsFunction ?? MUSIC;
var suffix = params.suffix ?? '';
var pathToUse = switch (pathsFunction)
{
case MUSIC: Paths.music('$key/$key');
case INST: Paths.inst('$key', suffix);
default: Paths.music('$key/$key');
}
var shouldLoadPartial = params.partialParams?.loadPartial ?? false;
// even if we arent' trying to partial load a song, we want to error out any songs in progress,
@ -512,7 +512,8 @@ class FunkinSound extends FlxSound implements ICloneable<FunkinSound>
});
soundRequest.future.onComplete(function(partialSound) {
var snd = FunkinSound.load(partialSound, volume, looped, autoDestroy, autoPlay, false, onComplete, onLoad);
var snd:Null<FunkinSound> = FunkinSound.load(partialSound, volume, looped, autoDestroy, autoPlay, false, onComplete, onLoad);
if (snd != null) snd._label = path;
promise.complete(snd);
});
}