Skip to content

Commit

Permalink
video cutscene autopause magic
Browse files Browse the repository at this point in the history
  • Loading branch information
AbnormalPoof authored and charlesisfeline committed Jun 24, 2024
1 parent 51cca5b commit 9f77d81
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 14 additions & 2 deletions source/funkin/play/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1314,12 +1314,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 @@ -1331,6 +1337,7 @@ class PlayState extends MusicBeatSubState
else
DiscordClient.changePresence(detailsText, currentSong.song + ' (' + storyDifficultyText + ')', iconRPC);
}
#end

super.onFocus();
}
Expand All @@ -1340,12 +1347,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

0 comments on commit 9f77d81

Please sign in to comment.