Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable auto-pause for Video Cutscenes #2902

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions source/funkin/play/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -1318,6 +1324,7 @@ class PlayState extends MusicBeatSubState
else
DiscordClient.changePresence(detailsText, currentSong.song + ' (' + storyDifficultyText + ')', iconRPC);
}
#end

super.onFocus();
}
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion source/funkin/play/cutscene/VideoCutscene.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down