Skip to content

Commit

Permalink
Merge pull request #1 from ninjamuffin99/sans_discord
Browse files Browse the repository at this point in the history
allow run without discord stuff
  • Loading branch information
ninjamuffin99 authored Mar 29, 2021
2 parents 7bf0f6b + 37e603d commit f2803be
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
<haxelib name="faxe" if='switch'/>
<haxelib name="polymod"/>
<haxelib name="hxcpp-debug-server" if="desktop debug"/>
<haxelib name="discord_rpc" if="desktop"/>
<haxelib name="discord_rpc" if="cpp"/> <!-- foesn't work with neko -->
<!-- <haxelib name="hxcpp-debug-server" if="desktop"/> -->

<!-- <haxelib name="markdown" /> -->
Expand Down
5 changes: 2 additions & 3 deletions source/FreeplayState.hx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package;

#if desktop
#if discord_rpc
import Discord.DiscordClient;
#end
import flash.text.TextField;
Expand Down Expand Up @@ -52,7 +51,7 @@ class FreeplayState extends MusicBeatState
FlxG.sound.playMusic(Paths.music('freakyMenu'));
}

#if desktop
#if discord_rpc
// Updating Discord Rich Presence
DiscordClient.changePresence("In the Menus", null);
#end
Expand Down
2 changes: 1 addition & 1 deletion source/MainMenuState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class MainMenuState extends MusicBeatState

override function create()
{
#if desktop
#if discord_rpc
// Updating Discord Rich Presence
DiscordClient.changePresence("In the Menus", null);
#end
Expand Down
22 changes: 10 additions & 12 deletions source/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import ui.PreferencesMenu;

using StringTools;

#if desktop
#if discord_rpc
import Discord.DiscordClient;
#end

Expand Down Expand Up @@ -134,7 +134,7 @@ class PlayState extends MusicBeatState

var inCutscene:Bool = false;

#if desktop
#if discord_rpc
// Discord RPC variables
var storyDifficultyText:String = "";
var iconRPC:String = "";
Expand Down Expand Up @@ -833,7 +833,7 @@ class PlayState extends MusicBeatState

function initDiscord():Void
{
#if desktop
#if discord_rpc
storyDifficultyText = CoolUtil.difficultyString();
iconRPC = SONG.player2;

Expand Down Expand Up @@ -1073,7 +1073,7 @@ class PlayState extends MusicBeatState
FlxG.sound.music.onComplete = endSong;
vocals.play();

#if desktop
#if discord_rpc
// Song duration in a float, useful for the time left feature
songLength = FlxG.sound.music.length;

Expand Down Expand Up @@ -1324,7 +1324,7 @@ class PlayState extends MusicBeatState
startTimer.active = true;
paused = false;

#if desktop
#if discord_rpc
if (startTimer.finished)
{
DiscordClient.changePresence(detailsText, SONG.song + " (" + storyDifficultyText + ")", iconRPC, true, songLength - Conductor.songPosition);
Expand All @@ -1339,9 +1339,9 @@ class PlayState extends MusicBeatState
super.closeSubState();
}

#if discord_rpc
override public function onFocus():Void
{
#if desktop
if (health > 0 && !paused)
{
if (Conductor.songPosition > 0.0)
Expand All @@ -1353,22 +1353,20 @@ class PlayState extends MusicBeatState
DiscordClient.changePresence(detailsText, SONG.song + " (" + storyDifficultyText + ")", iconRPC);
}
}
#end

super.onFocus();
}

override public function onFocusLost():Void
{
#if desktop
if (health > 0 && !paused)
{
DiscordClient.changePresence(detailsPausedText, SONG.song + " (" + storyDifficultyText + ")", iconRPC);
}
#end

super.onFocusLost();
}
#end

function resyncVocals():Void
{
Expand Down Expand Up @@ -1470,7 +1468,7 @@ class PlayState extends MusicBeatState
boyfriendPos.put();
}

#if desktop
#if discord_rpc
DiscordClient.changePresence(detailsPausedText, SONG.song + " (" + storyDifficultyText + ")", iconRPC);
#end
}
Expand All @@ -1479,7 +1477,7 @@ class PlayState extends MusicBeatState
{
FlxG.switchState(new ChartingState());

#if desktop
#if discord_rpc
DiscordClient.changePresence("Chart Editor", null, null, true);
#end
}
Expand Down Expand Up @@ -1598,7 +1596,7 @@ class PlayState extends MusicBeatState

// FlxG.switchState(new GameOverState(boyfriend.getScreenPosition().x, boyfriend.getScreenPosition().y));

#if desktop
#if discord_rpc
// Game Over doesn't get his own variable because it's only used here
DiscordClient.changePresence("Game Over - " + detailsText, SONG.song + " (" + storyDifficultyText + ")", iconRPC);
#end
Expand Down
4 changes: 2 additions & 2 deletions source/StoryMenuState.hx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package;

#if desktop
#if discord_rpc
import Discord.DiscordClient;
#end
import flixel.FlxG;
Expand Down Expand Up @@ -113,7 +113,7 @@ class StoryMenuState extends MusicBeatState

trace("Line 70");

#if desktop
#if discord_rpc
// Updating Discord Rich Presence
DiscordClient.changePresence("In the Menus", null);
#end
Expand Down
6 changes: 4 additions & 2 deletions source/TitleState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ import ui.PreferencesMenu;

using StringTools;

#if desktop
#if discord_rpc
import Discord.DiscordClient;
#end
#if desktop
import sys.thread.Thread;
#end

Expand Down Expand Up @@ -95,7 +97,7 @@ class TitleState extends MusicBeatState
});
#end

#if desktop
#if discord_rpc
DiscordClient.initialize();
#end
}
Expand Down

0 comments on commit f2803be

Please sign in to comment.