mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2025-07-05 02:07:02 +00:00
Imported music now plays properly in chart editor state
This commit is contained in:
parent
3e093510af
commit
a0a8d47216
|
@ -39,8 +39,8 @@ class Countdown
|
||||||
PlayState.instance.isInCountdown = true;
|
PlayState.instance.isInCountdown = true;
|
||||||
Conductor.update(PlayState.instance.startTimestamp + Conductor.beatLengthMs * -5);
|
Conductor.update(PlayState.instance.startTimestamp + Conductor.beatLengthMs * -5);
|
||||||
// Handle onBeatHit events manually
|
// Handle onBeatHit events manually
|
||||||
@:privateAccess
|
// @:privateAccess
|
||||||
PlayState.instance.dispatchEvent(new SongTimeScriptEvent(ScriptEvent.SONG_BEAT_HIT, 0, 0));
|
// PlayState.instance.dispatchEvent(new SongTimeScriptEvent(ScriptEvent.SONG_BEAT_HIT, 0, 0));
|
||||||
|
|
||||||
// The timer function gets called based on the beat of the song.
|
// The timer function gets called based on the beat of the song.
|
||||||
countdownTimer = new FlxTimer();
|
countdownTimer = new FlxTimer();
|
||||||
|
|
|
@ -7,6 +7,7 @@ import funkin.play.notes.notestyle.NoteStyle;
|
||||||
import funkin.data.notestyle.NoteStyleData;
|
import funkin.data.notestyle.NoteStyleData;
|
||||||
import funkin.data.notestyle.NoteStyleRegistry;
|
import funkin.data.notestyle.NoteStyleRegistry;
|
||||||
import flixel.addons.display.FlxPieDial;
|
import flixel.addons.display.FlxPieDial;
|
||||||
|
import flixel.addons.transition.Transition;
|
||||||
import flixel.addons.transition.FlxTransitionableState;
|
import flixel.addons.transition.FlxTransitionableState;
|
||||||
import flixel.FlxCamera;
|
import flixel.FlxCamera;
|
||||||
import flixel.FlxObject;
|
import flixel.FlxObject;
|
||||||
|
@ -93,6 +94,11 @@ typedef PlayStateParams =
|
||||||
* If specified, the game will jump to the specified timestamp after the countdown ends.
|
* If specified, the game will jump to the specified timestamp after the countdown ends.
|
||||||
*/
|
*/
|
||||||
?startTimestamp:Float,
|
?startTimestamp:Float,
|
||||||
|
/**
|
||||||
|
* If specified, the game will not load the instrumental or vocal tracks,
|
||||||
|
* and must be loaded externally.
|
||||||
|
*/
|
||||||
|
?overrideMusic:Bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -243,6 +249,8 @@ class PlayState extends MusicBeatSubState
|
||||||
|
|
||||||
public var startTimestamp:Float = 0.0;
|
public var startTimestamp:Float = 0.0;
|
||||||
|
|
||||||
|
var overrideMusic:Bool = false;
|
||||||
|
|
||||||
public var isSubState(get, null):Bool;
|
public var isSubState(get, null):Bool;
|
||||||
|
|
||||||
function get_isSubState():Bool
|
function get_isSubState():Bool
|
||||||
|
@ -316,7 +324,7 @@ class PlayState extends MusicBeatSubState
|
||||||
/**
|
/**
|
||||||
* A group of audio tracks, used to play the song's vocals.
|
* A group of audio tracks, used to play the song's vocals.
|
||||||
*/
|
*/
|
||||||
var vocals:VoicesGroup;
|
public var vocals:VoicesGroup;
|
||||||
|
|
||||||
#if discord_rpc
|
#if discord_rpc
|
||||||
// Discord RPC variables
|
// Discord RPC variables
|
||||||
|
@ -479,6 +487,7 @@ class PlayState extends MusicBeatSubState
|
||||||
isPracticeMode = params.practiceMode ?? false;
|
isPracticeMode = params.practiceMode ?? false;
|
||||||
isMinimalMode = params.minimalMode ?? false;
|
isMinimalMode = params.minimalMode ?? false;
|
||||||
startTimestamp = params.startTimestamp ?? 0.0;
|
startTimestamp = params.startTimestamp ?? 0.0;
|
||||||
|
overrideMusic = params.overrideMusic ?? false;
|
||||||
|
|
||||||
// Don't do anything else here! Wait until create() when we attach to the camera.
|
// Don't do anything else here! Wait until create() when we attach to the camera.
|
||||||
}
|
}
|
||||||
|
@ -555,16 +564,17 @@ class PlayState extends MusicBeatSubState
|
||||||
this.persistentDraw = true;
|
this.persistentDraw = true;
|
||||||
|
|
||||||
// Stop any pre-existing music.
|
// Stop any pre-existing music.
|
||||||
if (FlxG.sound.music != null) FlxG.sound.music.stop();
|
if (!overrideMusic && FlxG.sound.music != null) FlxG.sound.music.stop();
|
||||||
|
|
||||||
// Prepare the current song's instrumental and vocals to be played.
|
// Prepare the current song's instrumental and vocals to be played.
|
||||||
if (currentChart != null)
|
if (!overrideMusic && currentChart != null)
|
||||||
{
|
{
|
||||||
currentChart.cacheInst(currentPlayerId);
|
currentChart.cacheInst(currentPlayerId);
|
||||||
currentChart.cacheVocals(currentPlayerId);
|
currentChart.cacheVocals(currentPlayerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepare the Conductor.
|
// Prepare the Conductor.
|
||||||
|
Conductor.forceBPM(null);
|
||||||
Conductor.mapTimeChanges(currentChart.timeChanges);
|
Conductor.mapTimeChanges(currentChart.timeChanges);
|
||||||
Conductor.update((Conductor.beatLengthMs * -5) + startTimestamp);
|
Conductor.update((Conductor.beatLengthMs * -5) + startTimestamp);
|
||||||
|
|
||||||
|
@ -966,7 +976,7 @@ class PlayState extends MusicBeatSubState
|
||||||
*/
|
*/
|
||||||
public override function closeSubState():Void
|
public override function closeSubState():Void
|
||||||
{
|
{
|
||||||
if (isGamePaused)
|
if (Std.isOfType(subState, PauseSubState))
|
||||||
{
|
{
|
||||||
var event:ScriptEvent = new ScriptEvent(ScriptEvent.RESUME, true);
|
var event:ScriptEvent = new ScriptEvent(ScriptEvent.RESUME, true);
|
||||||
|
|
||||||
|
@ -994,6 +1004,10 @@ class PlayState extends MusicBeatSubState
|
||||||
}
|
}
|
||||||
#end
|
#end
|
||||||
}
|
}
|
||||||
|
else if (Std.isOfType(subState, Transition))
|
||||||
|
{
|
||||||
|
// Do nothing.
|
||||||
|
}
|
||||||
|
|
||||||
super.closeSubState();
|
super.closeSubState();
|
||||||
}
|
}
|
||||||
|
@ -1534,12 +1548,16 @@ class PlayState extends MusicBeatSubState
|
||||||
trace('Song difficulty could not be loaded.');
|
trace('Song difficulty could not be loaded.');
|
||||||
}
|
}
|
||||||
|
|
||||||
Conductor.forceBPM(currentChart.getStartingBPM());
|
// Conductor.forceBPM(currentChart.getStartingBPM());
|
||||||
|
|
||||||
vocals = currentChart.buildVocals(currentPlayerId);
|
if (!overrideMusic)
|
||||||
if (vocals.members.length == 0)
|
|
||||||
{
|
{
|
||||||
trace('WARNING: No vocals found for this song.');
|
vocals = currentChart.buildVocals(currentPlayerId);
|
||||||
|
|
||||||
|
if (vocals.members.length == 0)
|
||||||
|
{
|
||||||
|
trace('WARNING: No vocals found for this song.');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
regenNoteData();
|
regenNoteData();
|
||||||
|
@ -1648,7 +1666,7 @@ class PlayState extends MusicBeatSubState
|
||||||
|
|
||||||
startingSong = false;
|
startingSong = false;
|
||||||
|
|
||||||
if (!isGamePaused && currentChart != null)
|
if (!overrideMusic && !isGamePaused && currentChart != null)
|
||||||
{
|
{
|
||||||
currentChart.playInst(1.0, false);
|
currentChart.playInst(1.0, false);
|
||||||
}
|
}
|
||||||
|
@ -2600,9 +2618,17 @@ class PlayState extends MusicBeatSubState
|
||||||
// TODO: Uncache the song.
|
// TODO: Uncache the song.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stop the music.
|
if (!overrideMusic)
|
||||||
FlxG.sound.music.pause();
|
{
|
||||||
vocals.stop();
|
// Stop the music.
|
||||||
|
FlxG.sound.music.pause();
|
||||||
|
vocals.stop();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FlxG.sound.music.pause();
|
||||||
|
remove(vocals);
|
||||||
|
}
|
||||||
|
|
||||||
// Remove reference to stage and remove sprites from it to save memory.
|
// Remove reference to stage and remove sprites from it to save memory.
|
||||||
if (currentStage != null)
|
if (currentStage != null)
|
||||||
|
|
|
@ -3340,7 +3340,7 @@ class ChartEditorState extends HaxeUIState
|
||||||
FlxTransitionableState.skipNextTransIn = false;
|
FlxTransitionableState.skipNextTransIn = false;
|
||||||
FlxTransitionableState.skipNextTransOut = false;
|
FlxTransitionableState.skipNextTransOut = false;
|
||||||
|
|
||||||
openSubState(new PlayState(
|
var targetState = new PlayState(
|
||||||
{
|
{
|
||||||
targetSong: targetSong,
|
targetSong: targetSong,
|
||||||
targetDifficulty: selectedDifficulty,
|
targetDifficulty: selectedDifficulty,
|
||||||
|
@ -3349,7 +3349,14 @@ class ChartEditorState extends HaxeUIState
|
||||||
practiceMode: true,
|
practiceMode: true,
|
||||||
minimalMode: minimal,
|
minimalMode: minimal,
|
||||||
startTimestamp: startTimestamp,
|
startTimestamp: startTimestamp,
|
||||||
}));
|
overrideMusic: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Override music.
|
||||||
|
FlxG.sound.music = audioInstTrack;
|
||||||
|
targetState.vocals = audioVocalTrackGroup;
|
||||||
|
|
||||||
|
openSubState(targetState);
|
||||||
}
|
}
|
||||||
|
|
||||||
function fixCamera(_:FlxSubState = null):Void
|
function fixCamera(_:FlxSubState = null):Void
|
||||||
|
|
Loading…
Reference in a new issue