From f416f6c1f4495ff462470870f8000dd0414040bf Mon Sep 17 00:00:00 2001 From: WorstAquaPlayer Date: Sat, 27 Feb 2021 20:49:53 -0300 Subject: [PATCH] Alt+Tab and Game Over updates RPC --- source/PlayState.hx | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/source/PlayState.hx b/source/PlayState.hx index 13e95d896..3f80deb92 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -1284,6 +1284,37 @@ class PlayState extends MusicBeatState super.closeSubState(); } + override public function onFocus():Void + { + #if !html + if (health > 0 && !paused) + { + if (Conductor.songPosition > 0.0) + { + DiscordClient.changePresence(detailsText, SONG.song + " (" + storyDifficultyText + ")", iconRPC, true, songLength - Conductor.songPosition); + } + else + { + DiscordClient.changePresence(detailsText, SONG.song + " (" + storyDifficultyText + ")", iconRPC); + } + } + #end + + super.onFocus(); + } + + override public function onFocusLost():Void + { + #if !html + if (health > 0 && !paused) + { + DiscordClient.changePresence(detailsPausedText, SONG.song + " (" + storyDifficultyText + ")", iconRPC); + } + #end + + super.onFocusLost(); + } + function resyncVocals():Void { vocals.pause(); @@ -1550,6 +1581,9 @@ class PlayState extends MusicBeatState openSubState(new GameOverSubstate(boyfriend.getScreenPosition().x, boyfriend.getScreenPosition().y)); // FlxG.switchState(new GameOverState(boyfriend.getScreenPosition().x, boyfriend.getScreenPosition().y)); + + // Game Over doesn't get his own variable because it's only used here + DiscordClient.changePresence("Game Over - " + detailsText, SONG.song + " (" + storyDifficultyText + ")", iconRPC); } if (unspawnNotes[0] != null)