Skip to content

Commit

Permalink
Merge pull request ShadowMario#11414 from Raltyro/discord-patch
Browse files Browse the repository at this point in the history
Dont deinitialize discordrpc twice onClose and initialize discordrpc on Main instead of TitleState
  • Loading branch information
ShadowMario authored Dec 6, 2022
2 parents afbd28b + 3908a9d commit efd5adc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
12 changes: 7 additions & 5 deletions source/Main.hx
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import openfl.display.FPS;
import openfl.display.Sprite;
import openfl.events.Event;
import openfl.display.StageScaleMode;
import lime.app.Application;

#if desktop
import Discord.DiscordClient;
#end

//crash handler stuff
#if CRASH_HANDLER
import lime.app.Application;
import openfl.events.UncaughtErrorEvent;
import haxe.CallStack;
import haxe.io.Path;
Expand Down Expand Up @@ -110,10 +110,12 @@ class Main extends Sprite
#end

#if desktop
FlxG.stage.application.window.onClose.add(function()
{
DiscordClient.shutdown();
});
if (!DiscordClient.isInitialized) {
DiscordClient.initialize();
Application.current.window.onClose.add(function() {
DiscordClient.shutdown();
});
}
#end
}

Expand Down
12 changes: 0 additions & 12 deletions source/TitleState.hx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package;

#if desktop
import Discord.DiscordClient;
import sys.thread.Thread;
#end
import flixel.FlxG;
Expand Down Expand Up @@ -35,7 +34,6 @@ import flixel.tweens.FlxEase;
import flixel.tweens.FlxTween;
import flixel.util.FlxColor;
import flixel.util.FlxTimer;
import lime.app.Application;
import openfl.Assets;

using StringTools;
Expand Down Expand Up @@ -208,16 +206,6 @@ class TitleState extends MusicBeatState
FlxTransitionableState.skipNextTransOut = true;
MusicBeatState.switchState(new FlashingState());
} else {
#if desktop
if (!DiscordClient.isInitialized)
{
DiscordClient.initialize();
Application.current.onExit.add (function (exitCode) {
DiscordClient.shutdown();
});
}
#end

if (initialized)
startIntro();
else
Expand Down

0 comments on commit efd5adc

Please sign in to comment.