1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-12-24 22:26:50 +00:00

Merge pull request #644 from FunkinCrew/abnormalpoof/cutscene-auto-pause

[PUBLIC PR] Automatically pause video cutscenes when tabbing away from the game
This commit is contained in:
Cameron Taylor 2024-07-04 14:52:46 -04:00 committed by GitHub
commit eddfa23955
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 3 deletions

View file

@ -1301,12 +1301,18 @@ class PlayState extends MusicBeatSubState
super.closeSubState();
}
#if discord_rpc
/**
* Function called when the game window gains focus.
*/
public override function onFocus():Void
{
if (VideoCutscene.isPlaying() && FlxG.autoPause && isGamePaused) VideoCutscene.pauseVideo();
#if html5
else
VideoCutscene.resumeVideo();
#end
#if discord_rpc
if (health > Constants.HEALTH_MIN && !paused && FlxG.autoPause)
{
if (Conductor.instance.songPosition > 0.0) DiscordClient.changePresence(detailsText, currentSong.song
@ -1318,6 +1324,7 @@ class PlayState extends MusicBeatSubState
else
DiscordClient.changePresence(detailsText, currentSong.song + ' (' + storyDifficultyText + ')', iconRPC);
}
#end
super.onFocus();
}
@ -1327,12 +1334,17 @@ class PlayState extends MusicBeatSubState
*/
public override function onFocusLost():Void
{
#if html5
if (FlxG.autoPause) VideoCutscene.pauseVideo();
#end
#if discord_rpc
if (health > Constants.HEALTH_MIN && !paused && FlxG.autoPause) DiscordClient.changePresence(detailsPausedText,
currentSong.song + ' (' + storyDifficultyText + ')', iconRPC);
#end
super.onFocusLost();
}
#end
/**
* Removes any references to the current stage, then clears the stage cache,

View file

@ -145,7 +145,7 @@ class VideoCutscene
{
vid.zIndex = 0;
vid.bitmap.onEndReached.add(finishVideo.bind(0.5));
vid.autoPause = false;
vid.autoPause = FlxG.autoPause;
vid.cameras = [PlayState.instance.camCutscene];