1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2025-05-23 23:52:51 +00:00

Merge pull request #608 from FunkinCrew/bugfix/instrumental-id

Play song IDs based on the chart file's "instrumental" field, not the variation ID.
This commit is contained in:
Cameron Taylor 2024-06-11 16:15:24 -04:00 committed by GitHub
commit b64af80eba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 24 additions and 7 deletions

View file

@ -175,6 +175,12 @@ class PlayState extends MusicBeatSubState
*/ */
public var currentVariation:String = Constants.DEFAULT_VARIATION; public var currentVariation:String = Constants.DEFAULT_VARIATION;
/**
* The currently selected instrumental ID.
* @default `''`
*/
public var currentInstrumental:String = '';
/** /**
* The currently active Stage. This is the object containing all the props. * The currently active Stage. This is the object containing all the props.
*/ */
@ -603,6 +609,7 @@ class PlayState extends MusicBeatSubState
currentSong = params.targetSong; currentSong = params.targetSong;
if (params.targetDifficulty != null) currentDifficulty = params.targetDifficulty; if (params.targetDifficulty != null) currentDifficulty = params.targetDifficulty;
if (params.targetVariation != null) currentVariation = params.targetVariation; if (params.targetVariation != null) currentVariation = params.targetVariation;
if (params.targetInstrumental != null) currentInstrumental = params.targetInstrumental;
isPracticeMode = params.practiceMode ?? false; isPracticeMode = params.practiceMode ?? false;
isBotPlayMode = params.botPlayMode ?? false; isBotPlayMode = params.botPlayMode ?? false;
isMinimalMode = params.minimalMode ?? false; isMinimalMode = params.minimalMode ?? false;
@ -1974,7 +1981,7 @@ class PlayState extends MusicBeatSubState
if (!overrideMusic && !isGamePaused && currentChart != null) if (!overrideMusic && !isGamePaused && currentChart != null)
{ {
currentChart.playInst(1.0, false); currentChart.playInst(1.0, currentInstrumental, false);
} }
if (FlxG.sound.music == null) if (FlxG.sound.music == null)

View file

@ -682,9 +682,9 @@ class SongDifficulty
FlxG.sound.cache(getInstPath(instrumental)); FlxG.sound.cache(getInstPath(instrumental));
} }
public function playInst(volume:Float = 1.0, looped:Bool = false):Void public function playInst(volume:Float = 1.0, instId:String = '', looped:Bool = false):Void
{ {
var suffix:String = (variation != null && variation != '' && variation != 'default') ? '-$variation' : ''; var suffix:String = (instId != '') ? '-$instId' : '';
FlxG.sound.music = FunkinSound.load(Paths.inst(this.song.id, suffix), volume, looped, false, true); FlxG.sound.music = FunkinSound.load(Paths.inst(this.song.id, suffix), volume, looped, false, true);

View file

@ -1712,11 +1712,20 @@ class FreeplayState extends MusicBeatSubState
FlxG.log.warn('WARN: could not find song with id (${cap.songData.songId})'); FlxG.log.warn('WARN: could not find song with id (${cap.songData.songId})');
return; return;
} }
var targetDifficulty:String = currentDifficulty; var targetDifficultyId:String = currentDifficulty;
var targetVariation:String = targetSong.getFirstValidVariation(targetDifficulty); var targetVariation:String = targetSong.getFirstValidVariation(targetDifficultyId);
PlayStatePlaylist.campaignId = cap.songData.levelId; PlayStatePlaylist.campaignId = cap.songData.levelId;
var targetDifficulty:SongDifficulty = targetSong.getDifficulty(targetDifficultyId, targetVariation);
if (targetDifficulty == null)
{
FlxG.log.warn('WARN: could not find difficulty with id (${targetDifficultyId})');
return;
}
// TODO: Change this with alternate instrumentals
var targetInstId:String = targetDifficulty.characters.instrumental;
// Visual and audio effects. // Visual and audio effects.
FunkinSound.playOnce(Paths.sound('confirmMenu')); FunkinSound.playOnce(Paths.sound('confirmMenu'));
dj.confirm(); dj.confirm();
@ -1765,8 +1774,9 @@ class FreeplayState extends MusicBeatSubState
LoadingState.loadPlayState( LoadingState.loadPlayState(
{ {
targetSong: targetSong, targetSong: targetSong,
targetDifficulty: targetDifficulty, targetDifficulty: targetDifficultyId,
targetVariation: targetVariation, targetVariation: targetVariation,
targetInstrumental: targetInstId,
practiceMode: false, practiceMode: false,
minimalMode: false, minimalMode: false,