mirror of
https://github.com/FunkinCrew/Funkin.git
synced 2024-11-14 19:25:16 -05:00
Limit the song time to 0 and the songs max length
use the new bool to tell if we should start the song add a public static bool to countdown: finished
This commit is contained in:
parent
a27c4ae24f
commit
b03c8a9cf8
3 changed files with 28 additions and 9 deletions
|
@ -397,9 +397,12 @@ class Conductor
|
|||
*/
|
||||
public function update(?songPos:Float, applyOffsets:Bool = true, forceDispatch:Bool = false)
|
||||
{
|
||||
var currentTime:Float = (FlxG.sound.music != null) ? FlxG.sound.music.time : 0.0;
|
||||
var currentLength:Float = (FlxG.sound.music != null) ? FlxG.sound.music.length : 0.0;
|
||||
|
||||
if (songPos == null)
|
||||
{
|
||||
songPos = (FlxG.sound.music != null) ? FlxG.sound.music.time : 0.0;
|
||||
songPos = currentTime;
|
||||
}
|
||||
|
||||
// Take into account instrumental and file format song offsets.
|
||||
|
@ -410,7 +413,7 @@ class Conductor
|
|||
var oldStep:Float = this.currentStep;
|
||||
|
||||
// Set the song position we are at (for purposes of calculating note positions, etc).
|
||||
this.songPosition = songPos;
|
||||
this.songPosition = Math.min(currentLength, Math.max(0, songPos));
|
||||
|
||||
currentTimeChange = timeChanges[0];
|
||||
if (this.songPosition > 0.0)
|
||||
|
@ -430,7 +433,8 @@ class Conductor
|
|||
else if (currentTimeChange != null && this.songPosition > 0.0)
|
||||
{
|
||||
// roundDecimal prevents representing 8 as 7.9999999
|
||||
this.currentStepTime = FlxMath.roundDecimal((currentTimeChange.beatTime * Constants.STEPS_PER_BEAT) + (this.songPosition - currentTimeChange.timeStamp) / stepLengthMs, 6);
|
||||
this.currentStepTime = FlxMath.roundDecimal((currentTimeChange.beatTime * Constants.STEPS_PER_BEAT)
|
||||
+ (this.songPosition - currentTimeChange.timeStamp) / stepLengthMs, 6);
|
||||
this.currentBeatTime = currentStepTime / Constants.STEPS_PER_BEAT;
|
||||
this.currentMeasureTime = currentStepTime / stepsPerMeasure;
|
||||
this.currentStep = Math.floor(currentStepTime);
|
||||
|
|
|
@ -29,6 +29,11 @@ class Countdown
|
|||
*/
|
||||
public static var soundSuffix:String = '';
|
||||
|
||||
/**
|
||||
* Whether the countdown has finished.
|
||||
*/
|
||||
public static var finished:Bool = false;
|
||||
|
||||
/**
|
||||
* Which alternate graphic on countdown to use.
|
||||
* You can set this via script.
|
||||
|
@ -53,6 +58,7 @@ class Countdown
|
|||
*/
|
||||
public static function performCountdown():Bool
|
||||
{
|
||||
finished = false;
|
||||
countdownStep = BEFORE;
|
||||
var cancelled:Bool = propagateCountdownEvent(countdownStep);
|
||||
if (cancelled)
|
||||
|
@ -101,6 +107,7 @@ class Countdown
|
|||
|
||||
if (countdownStep == AFTER)
|
||||
{
|
||||
finished = true;
|
||||
stopCountdown();
|
||||
}
|
||||
}, 5); // Before, 3, 2, 1, GO!, After
|
||||
|
|
|
@ -915,7 +915,11 @@ class PlayState extends MusicBeatSubState
|
|||
{
|
||||
// Do NOT apply offsets at this point, because they already got applied the previous frame!
|
||||
Conductor.instance.update(Conductor.instance.songPosition + elapsed * 1000, false);
|
||||
if (Conductor.instance.songPosition >= (startTimestamp)) startSong();
|
||||
if (Conductor.instance.songPosition - Conductor.instance.instrumentalOffset >= (startTimestamp) && Countdown.finished)
|
||||
{
|
||||
trace("started song at " + Conductor.instance.songPosition);
|
||||
startSong();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1391,14 +1395,16 @@ class PlayState extends MusicBeatSubState
|
|||
// activeNotes.sort(SortUtil.byStrumtime, FlxSort.DESCENDING);
|
||||
}
|
||||
|
||||
var correctSync:Float = Math.min(FlxG.sound.music.length, Math.max(0, Conductor.instance.songPosition - Conductor.instance.instrumentalOffset));
|
||||
|
||||
if (!startingSong
|
||||
&& FlxG.sound.music != null
|
||||
&& (Math.abs(FlxG.sound.music.time - (Conductor.instance.songPosition + Conductor.instance.instrumentalOffset)) > 100
|
||||
|| Math.abs(vocals.checkSyncError(Conductor.instance.songPosition + Conductor.instance.instrumentalOffset)) > 100))
|
||||
&& (Math.abs(FlxG.sound.music.time - correctSync) > 100 || Math.abs(vocals.checkSyncError(correctSync)) > 100))
|
||||
{
|
||||
trace("VOCALS NEED RESYNC");
|
||||
if (vocals != null) trace(vocals.checkSyncError(Conductor.instance.songPosition + Conductor.instance.instrumentalOffset));
|
||||
trace(FlxG.sound.music.time - (Conductor.instance.songPosition + Conductor.instance.instrumentalOffset));
|
||||
if (vocals != null) trace(vocals.checkSyncError(correctSync));
|
||||
trace(FlxG.sound.music.time);
|
||||
trace(correctSync);
|
||||
resyncVocals();
|
||||
}
|
||||
|
||||
|
@ -1993,7 +1999,9 @@ class PlayState extends MusicBeatSubState
|
|||
|
||||
// Skip this if the music is paused (GameOver, Pause menu, start-of-song offset, etc.)
|
||||
if (!(FlxG.sound.music?.playing ?? false)) return;
|
||||
var timeToPlayAt:Float = Conductor.instance.songPosition - Conductor.instance.instrumentalOffset;
|
||||
|
||||
var timeToPlayAt:Float = Math.min(FlxG.sound.music.length, Math.max(0, Conductor.instance.songPosition - Conductor.instance.instrumentalOffset));
|
||||
trace('Resyncing vocals to ${timeToPlayAt}');
|
||||
FlxG.sound.music.pause();
|
||||
vocals.pause();
|
||||
|
||||
|
|
Loading…
Reference in a new issue