1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-11-15 11:22:55 +00:00

fading in and erect track loading

This commit is contained in:
Cameron Taylor 2024-05-09 01:56:52 -04:00
parent 1b6febf01c
commit f2a06ad37b
2 changed files with 19 additions and 4 deletions

View file

@ -347,10 +347,11 @@ class FunkinSound extends FlxSound implements ICloneable<FunkinSound>
}
}
var pathsFunction = params.pathsFunction ?? MUSIC;
var suffix = params.suffix ?? '';
var pathToUse = switch (pathsFunction)
{
case MUSIC: Paths.music('$key/$key');
case INST: Paths.inst('$key');
case INST: Paths.inst('$key', suffix);
default: Paths.music('$key/$key');
}
@ -359,7 +360,7 @@ class FunkinSound extends FlxSound implements ICloneable<FunkinSound>
if (shouldLoadPartial)
{
var music = FunkinSound.loadPartial(pathToUse, params.partialParams?.start ?? 0, params.partialParams?.end ?? 1, params?.startingVolume ?? 1.0,
params.loop ?? true, false, true);
params.loop ?? true, false, true, params.onComplete, params.onLoad);
if (music != null)
{
@ -541,6 +542,12 @@ typedef FunkinSoundPlayMusicParams =
*/
var ?startingVolume:Float;
/**
* The suffix of the music file to play. Usually for "-erect" tracks when loading an INST file
* @default ``
*/
var ?suffix:String;
/**
* Whether to override music if a different track is already playing.
* @default `false`
@ -572,6 +579,9 @@ typedef FunkinSoundPlayMusicParams =
var ?pathsFunction:PathsFunction;
var ?partialParams:PartialSoundParams;
var ?onComplete:Void->Void;
var ?onLoad:Void->Void;
}
typedef PartialSoundParams =

View file

@ -1243,19 +1243,24 @@ class FreeplayState extends MusicBeatSubState
}
else
{
var potentiallyErect:String = (currentDifficulty == "erect") || (currentDifficulty == "nightmare") ? "-erect" : "";
// TODO: Stream the instrumental of the selected song?
FunkinSound.playMusic(daSongCapsule.songData.songId,
{
startingVolume: 0.5,
startingVolume: 0.0,
overrideExisting: true,
restartTrack: false,
pathsFunction: INST,
suffix: potentiallyErect,
partialParams:
{
loadPartial: true,
start: 0,
end: 0.1
}
},
onLoad: function() {
FlxG.sound.music.fadeIn(2, 0, 0.4);
}
});
}
grpCapsules.members[curSelected].selected = true;