Skip to content

Commit

Permalink
fixed stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Joalor64GH authored Jun 5, 2024
1 parent 646ef28 commit 44dbace
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 7 deletions.
16 changes: 16 additions & 0 deletions source/meta/data/ClientPrefs.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, Dynamic> = [
'scrollspeed' => 1.0,
'scrolltype' => 'multiplicative',
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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) {
Expand Down
13 changes: 11 additions & 2 deletions source/meta/data/options/OptionsSubState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions source/meta/state/FreeplayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class FreeplayState extends MusicBeatState
var songs:Array<SongMetadata> = [];

private static var curSelected:Int = 0;
var lerpSelected:Float = 0;
var curDifficulty:Int = -1;
private static var lastDifficultyName:String = '';

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions source/objects/userinterface/menu/MusicPlayer.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 44dbace

Please sign in to comment.