mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2025-12-09 05:29:12 +00:00
Don't play the music if the game paused due to losing focus.
This commit is contained in:
parent
5ce3315967
commit
92344d2e30
|
|
@ -37,6 +37,11 @@ typedef PauseSubStateParams =
|
|||
* Which mode to start in. Dictates what entries are displayed.
|
||||
*/
|
||||
?mode:PauseMode,
|
||||
|
||||
/**
|
||||
* Whether the game paused because the window lost focus.
|
||||
*/
|
||||
?lostFocus:Bool
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -151,6 +156,11 @@ class PauseSubState extends MusicBeatSubState
|
|||
*/
|
||||
var currentMode:PauseMode;
|
||||
|
||||
/**
|
||||
* Whether the game paused because the window lost focus.
|
||||
*/
|
||||
var lostFocus:Bool = false;
|
||||
|
||||
// ===============
|
||||
// Graphics Variables
|
||||
// ===============
|
||||
|
|
@ -231,6 +241,7 @@ class PauseSubState extends MusicBeatSubState
|
|||
{
|
||||
super();
|
||||
this.currentMode = params?.mode ?? Standard;
|
||||
this.lostFocus = params?.lostFocus ?? false;
|
||||
this.onPause = onPause;
|
||||
}
|
||||
|
||||
|
|
@ -256,6 +267,8 @@ class PauseSubState extends MusicBeatSubState
|
|||
|
||||
startPauseMusic();
|
||||
|
||||
if (lostFocus && Preferences.autoPause) pauseMusic.pause();
|
||||
|
||||
buildBackground();
|
||||
|
||||
buildMetadata();
|
||||
|
|
|
|||
|
|
@ -1312,7 +1312,12 @@ class PlayState extends MusicBeatSubState
|
|||
#end
|
||||
}
|
||||
|
||||
function pause(mode:PauseMode = Standard):Void
|
||||
/**
|
||||
* Pause the game.
|
||||
* @param mode Which set of pause menu options to display (distinguishes between standard, charting, and cutscene)
|
||||
* @param lostFocus Whether the game paused because the window lost focus
|
||||
*/
|
||||
function pause(mode:PauseMode = Standard, lostFocus:Bool = false):Void
|
||||
{
|
||||
if (!mayPauseGame || justUnpaused || isGamePaused || isPlayerDying) return;
|
||||
|
||||
|
|
@ -1320,11 +1325,11 @@ class PlayState extends MusicBeatSubState
|
|||
{
|
||||
case Conversation:
|
||||
preparePauseUI();
|
||||
openPauseSubState(Conversation, camPause, () -> currentConversation?.pauseMusic());
|
||||
openPauseSubState(Conversation, camPause, lostFocus, () -> currentConversation?.pauseMusic());
|
||||
|
||||
case Cutscene:
|
||||
preparePauseUI();
|
||||
openPauseSubState(Cutscene, camPause, () -> VideoCutscene.pauseVideo());
|
||||
openPauseSubState(Cutscene, camPause, lostFocus, () -> VideoCutscene.pauseVideo());
|
||||
|
||||
default: // also known as standard
|
||||
if (!isInCountdown || isInCutscene) return;
|
||||
|
|
@ -1356,7 +1361,7 @@ class PlayState extends MusicBeatSubState
|
|||
boyfriendPos = currentStage.getBoyfriend().getScreenPosition();
|
||||
}
|
||||
|
||||
openPauseSubState(isChartingMode ? Charting : Standard, camPause);
|
||||
openPauseSubState(isChartingMode ? Charting : Standard, camPause, lostFocus);
|
||||
}
|
||||
|
||||
#if FEATURE_DISCORD_RPC
|
||||
|
|
@ -1383,9 +1388,9 @@ class PlayState extends MusicBeatSubState
|
|||
#end
|
||||
}
|
||||
|
||||
function openPauseSubState(mode:PauseMode, cam:FlxCamera, ?onPause:Void->Void):Void
|
||||
function openPauseSubState(mode:PauseMode, cam:FlxCamera, lostFocus:Bool = false, ?onPause:Void->Void):Void
|
||||
{
|
||||
final pauseSubState = new PauseSubState({mode: mode}, onPause);
|
||||
final pauseSubState = new PauseSubState({mode: mode, lostFocus: lostFocus}, onPause);
|
||||
FlxTransitionableState.skipNextTransIn = true;
|
||||
FlxTransitionableState.skipNextTransOut = true;
|
||||
pauseSubState.camera = cam;
|
||||
|
|
@ -1748,15 +1753,15 @@ class PlayState extends MusicBeatSubState
|
|||
{
|
||||
if (currentConversation != null)
|
||||
{
|
||||
pause(Conversation);
|
||||
pause(Conversation, true);
|
||||
}
|
||||
else if (VideoCutscene.isPlaying())
|
||||
{
|
||||
pause(Cutscene);
|
||||
pause(Cutscene, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
pause();
|
||||
pause(true);
|
||||
}
|
||||
}
|
||||
super.onFocusLost();
|
||||
|
|
|
|||
Loading…
Reference in a new issue