mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2024-11-20 13:53:13 +00:00
Make the playback rate option explicit so it doesn't break in the future.
This commit is contained in:
parent
d9dbb5791c
commit
684eb919b5
|
@ -97,7 +97,7 @@ typedef PlayStateParams =
|
|||
?targetDifficulty:String,
|
||||
/**
|
||||
* The variation to play on.
|
||||
* @default `Constants.DEFAULT_VARIATION` .
|
||||
* @default `Constants.DEFAULT_VARIATION`
|
||||
*/
|
||||
?targetVariation:String,
|
||||
/**
|
||||
|
@ -118,8 +118,14 @@ typedef PlayStateParams =
|
|||
?minimalMode:Bool,
|
||||
/**
|
||||
* If specified, the game will jump to the specified timestamp after the countdown ends.
|
||||
* @default `0.0`
|
||||
*/
|
||||
?startTimestamp:Float,
|
||||
/**
|
||||
* If specified, the game will play the song with the given speed.
|
||||
* @default `1.0` for 100% speed.
|
||||
*/
|
||||
?playbackRate:Float,
|
||||
/**
|
||||
* If specified, the game will not load the instrumental or vocal tracks,
|
||||
* and must be loaded externally.
|
||||
|
@ -210,6 +216,12 @@ class PlayState extends MusicBeatSubState
|
|||
*/
|
||||
public var startTimestamp:Float = 0.0;
|
||||
|
||||
/**
|
||||
* Play back the song at this speed.
|
||||
* @default `1.0` for normal speed.
|
||||
*/
|
||||
public var playbackRate:Float = 1.0;
|
||||
|
||||
/**
|
||||
* An empty FlxObject contained in the scene.
|
||||
* The current gameplay camera will always follow this object. Tween its position to move the camera smoothly.
|
||||
|
@ -550,6 +562,7 @@ class PlayState extends MusicBeatSubState
|
|||
isPracticeMode = params.practiceMode ?? false;
|
||||
isMinimalMode = params.minimalMode ?? false;
|
||||
startTimestamp = params.startTimestamp ?? 0.0;
|
||||
playbackRate = params.playbackRate ?? 1.0;
|
||||
overrideMusic = params.overrideMusic ?? false;
|
||||
previousCameraFollowPoint = params.cameraFollowPoint;
|
||||
|
||||
|
@ -777,6 +790,7 @@ class PlayState extends MusicBeatSubState
|
|||
|
||||
// Reset music properly.
|
||||
FlxG.sound.music.time = startTimestamp - Conductor.instance.instrumentalOffset;
|
||||
FlxG.sound.music.pitch = playbackRate;
|
||||
FlxG.sound.music.pause();
|
||||
|
||||
if (!overrideMusic)
|
||||
|
@ -1783,14 +1797,16 @@ class PlayState extends MusicBeatSubState
|
|||
// A negative instrumental offset means the song skips the first few milliseconds of the track.
|
||||
// This just gets added into the startTimestamp behavior so we don't need to do anything extra.
|
||||
FlxG.sound.music.play(true, startTimestamp - Conductor.instance.instrumentalOffset);
|
||||
FlxG.sound.music.pitch = playbackRate;
|
||||
|
||||
// I am going insane.
|
||||
FlxG.sound.music.volume = 1.0;
|
||||
FlxG.sound.music.fadeTween.cancel();
|
||||
if (FlxG.sound.music.fadeTween != null) FlxG.sound.music.fadeTween.cancel();
|
||||
|
||||
trace('Playing vocals...');
|
||||
add(vocals);
|
||||
vocals.play();
|
||||
vocals.pitch = playbackRate;
|
||||
resyncVocals();
|
||||
|
||||
#if discord_rpc
|
||||
|
|
|
@ -5308,6 +5308,10 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
|
|||
var startTimestamp:Float = 0;
|
||||
if (playtestStartTime) startTimestamp = scrollPositionInMs + playheadPositionInMs;
|
||||
|
||||
var playbackRate:Float = (menubarItemPlaybackSpeed.value.toFloat() * 2.0) / 100.0;
|
||||
playbackRate = Math.floor(playbackRate / 0.05) * 0.05; // Round to nearest 5%
|
||||
playbackRate = Math.max(0.05, Math.min(2.0, playbackRate)); // Clamp to 5% to 200%
|
||||
|
||||
var targetSong:Song;
|
||||
try
|
||||
{
|
||||
|
@ -5357,6 +5361,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
|
|||
practiceMode: playtestPracticeMode,
|
||||
minimalMode: minimal,
|
||||
startTimestamp: startTimestamp,
|
||||
playbackRate: playbackRate,
|
||||
overrideMusic: true,
|
||||
});
|
||||
|
||||
|
|
|
@ -1143,6 +1143,12 @@ class FreeplayState extends MusicBeatSubState
|
|||
targetSong: targetSong,
|
||||
targetDifficulty: targetDifficulty,
|
||||
targetVariation: targetVariation,
|
||||
// TODO: Make this an option!
|
||||
// startTimestamp: 0.0,
|
||||
// TODO: Make this an option!
|
||||
// playbackRate: 0.5,
|
||||
practiceMode: false,
|
||||
minimalMode: false,
|
||||
}, true);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue