diff --git a/source/meta/data/ClientPrefs.hx b/source/meta/data/ClientPrefs.hx index 6c504c3b..063e09aa 100644 --- a/source/meta/data/ClientPrefs.hx +++ b/source/meta/data/ClientPrefs.hx @@ -41,6 +41,7 @@ class ClientPrefs { public static var displayMilliseconds:Bool = true; public static var weekendScore:Bool = false; public static var resultsScreen:Bool = true; + public static var autoPause:Bool = true; public static var gameplaySettings:Map = [ 'scrollspeed' => 1.0, 'scrolltype' => 'multiplicative', @@ -152,6 +153,7 @@ class ClientPrefs { FlxG.save.data.displayMilliseconds = displayMilliseconds; FlxG.save.data.weekendScore = weekendScore; FlxG.save.data.resultsScreen = resultsScreen; + FlxG.save.data.autoPause = autoPause; FlxG.save.flush(); @@ -193,6 +195,20 @@ class ClientPrefs { if(FlxG.save.data.shaders != null) { shaders = FlxG.save.data.shaders; } + + if(FlxG.save.data.autoPause != null) { + autoPause = FlxG.save.data.autoPause; + } + + #if (!html5 && !switch) + FlxG.autoPause = autoPause; + + if (FlxG.save.data.framerate == null) { + final refreshRate:Int = FlxG.stage.application.window.displayMode.refreshRate; + framerate = Std.int(FlxMath.bound(refreshRate, 60, 240)); + } + #end + if(FlxG.save.data.framerate != null) { framerate = FlxG.save.data.framerate; if(framerate > FlxG.drawFramerate) { diff --git a/source/meta/data/options/OptionsSubState.hx b/source/meta/data/options/OptionsSubState.hx index 0643d8bd..e95706c1 100644 --- a/source/meta/data/options/OptionsSubState.hx +++ b/source/meta/data/options/OptionsSubState.hx @@ -680,6 +680,14 @@ class GameplaySubState extends BaseOptionsMenu true); addOption(option); + var option:Option = new Option('Auto Pause', + "If checked, the game automatically pauses if the screen isn't on focus.", + 'autoPause', + 'bool', + true); + addOption(option); + option.onchange = onChangeAutoPause + var option:Option = new Option('Disable Reset Button', "If checked, pressing Reset won't do anything.", 'noReset', @@ -780,9 +788,10 @@ class GameplaySubState extends BaseOptionsMenu } function onChangeHitsoundVolume() - { FlxG.sound.play(Paths.sound('hitsound'), ClientPrefs.hitsoundVolume); - } + + function onChangeAutoPause() + FlxG.autoPause = ClientPrefs.autoPause; } class MiscSubState extends BaseOptionsMenu diff --git a/source/meta/state/FreeplayState.hx b/source/meta/state/FreeplayState.hx index 9da7ccb1..f1c0caae 100644 --- a/source/meta/state/FreeplayState.hx +++ b/source/meta/state/FreeplayState.hx @@ -7,6 +7,7 @@ class FreeplayState extends MusicBeatState var songs:Array = []; private static var curSelected:Int = 0; + var lerpSelected:Float = 0; var curDifficulty:Int = -1; private static var lastDifficultyName:String = ''; @@ -35,7 +36,7 @@ class FreeplayState extends MusicBeatState var repText:FlxText; var missingText:FlxText; - var missingBG:FlxSprite; + var missingTextBG:FlxSprite; var bottomString:String; var bottomText:FlxText; @@ -176,6 +177,7 @@ class FreeplayState extends MusicBeatState if(curSelected >= songs.length) curSelected = 0; bg.color = songs[curSelected].color; intendedColor = bg.color; + lerpSelected = curSelected; #if sys ArtemisIntegration.setBackgroundFlxColor (intendedColor); @@ -400,7 +402,7 @@ class FreeplayState extends MusicBeatState } else if (instPlaying == curSelected && player.playingMusic) { - player.pauseOrResume(player.paused); + player.pauseOrResume(!player.playingMusic); } } else if (accepted && !player.playingMusic) diff --git a/source/objects/userinterface/menu/MusicPlayer.hx b/source/objects/userinterface/menu/MusicPlayer.hx index 07f90163..09caa4a5 100644 --- a/source/objects/userinterface/menu/MusicPlayer.hx +++ b/source/objects/userinterface/menu/MusicPlayer.hx @@ -176,10 +176,10 @@ class MusicPlayer extends FlxGroup if (playing) { - if(FreeplayState.vocals != null) + if (FreeplayState.vocals != null) FreeplayState.vocals.volume = (FreeplayState.vocals.length > FlxG.sound.music.time) ? 0.8 : 0; - if(FreeplayState.vocals != null && FreeplayState.vocals.length > FlxG.sound.music.time && Math.abs(FlxG.sound.music.time - FreeplayState.vocals.time)) + if (FreeplayState.vocals != null && FreeplayState.vocals.length > FlxG.sound.music.time && Math.abs(FlxG.sound.music.time - FreeplayState.vocals.time) >= 25) { pauseOrResume(); setVocalsTime(FlxG.sound.music.time); @@ -219,7 +219,7 @@ class MusicPlayer extends FlxGroup public function switchPlayMusic() { - FlxG.autoPause = (!playingMusic && ClientPrefs.data.autoPause); + FlxG.autoPause = (!playingMusic && ClientPrefs.autoPause); active = visible = playingMusic; instance.scoreBG.visible = instance.diffText.visible = instance.scoreText.visible = instance.repText.visible = !playingMusic; //Hide Freeplay texts and boxes if playingMusic is true