Skip to content
This repository has been archived by the owner on Nov 9, 2024. It is now read-only.

Commit

Permalink
i finally got around to adding RPC, also gf fix
Browse files Browse the repository at this point in the history
  • Loading branch information
RadiantCorium committed Jun 27, 2022
1 parent 09139c7 commit d413906
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
8 changes: 3 additions & 5 deletions source/engine/io/Discord.hx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class DiscordClient
#if cpp
trace("Discord Client starting...");
DiscordRpc.start({
clientID: "814588678700924999",
clientID: "991042339101347860",
onReady: onReady,
onError: onError,
onDisconnected: onDisconnected
Expand Down Expand Up @@ -76,9 +76,8 @@ class DiscordClient
#end
}

public static function changePresence(details:String, state:Null<String>, ?smallImageKey : String, ?hasStartTimestamp : Bool, ?endTimestamp: Float)
public static function changePresence(details:String, state:Null<String>, ?hasStartTimestamp : Bool, ?endTimestamp: Float)
{
#if
var startTimestamp:Float = if(hasStartTimestamp) Date.now().getTime() else 0;

if (endTimestamp > 0)
Expand All @@ -91,13 +90,12 @@ class DiscordClient
state: state,
largeImageKey: 'icon',
largeImageText: "Friday Night Funkin'",
smallImageKey : smallImageKey,
// smallImageKey : smallImageKey,
// Obtained times are in milliseconds so they are divided so Discord can use it
startTimestamp : Std.int(startTimestamp / 1000),
endTimestamp : Std.int(endTimestamp / 1000)
});

//trace('Discord RPC Updated. Arguments: $details, $state, $smallImageKey, $hasStartTimestamp, $endTimestamp');
#end
}
}
23 changes: 12 additions & 11 deletions source/states/gameplay/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class PlayState extends MusicBeatState
public static var curStage:String = '';
public static var SONG:SwagSong;
public static var isStoryMode:Bool = false;
public static var isModded:Bool = false;
public static var storyWeek:Int = 0;
public static var storyPlaylist:Array<String> = [];
public static var storyDifficulty:Int = 1;
Expand Down Expand Up @@ -289,7 +290,7 @@ class PlayState extends MusicBeatState
detailsPausedText = "Paused - " + detailsText;

// Updating Discord Rich Presence.
DiscordClient.changePresence(detailsText, SONG.song + " (" + storyDifficultyText + ")", iconRPC);
DiscordClient.changePresence(detailsText, SONG.song + " (" + storyDifficultyText + ")");
#end

switch (SONG.song.toLowerCase())
Expand Down Expand Up @@ -651,7 +652,7 @@ class PlayState extends MusicBeatState
if (curStage == 'limo')
gfVersion = 'gf-car';

if (SONG.gf != null || SONG.gf != "")
if (SONG.gf.length > 0)
gfVersion = SONG.gf;

gf = new Character(400, 130, gfVersion);
Expand Down Expand Up @@ -1171,7 +1172,7 @@ class PlayState extends MusicBeatState
songLength = FlxG.sound.music.length;

// Updating Discord Rich Presence (with Time Left)
DiscordClient.changePresence(detailsText, SONG.song + " (" + storyDifficultyText + ")", iconRPC, true, songLength);
DiscordClient.changePresence(detailsText, SONG.song + " (" + storyDifficultyText + ")", true, songLength);
#end
}

Expand Down Expand Up @@ -1443,11 +1444,11 @@ class PlayState extends MusicBeatState
#if desktop
if (startTimer.finished)
{
DiscordClient.changePresence(detailsText, SONG.song + " (" + storyDifficultyText + ")", iconRPC, true, songLength - Conductor.songPosition);
DiscordClient.changePresence(detailsText, SONG.song + " (" + storyDifficultyText + ")", true, songLength - Conductor.songPosition);
}
else
{
DiscordClient.changePresence(detailsText, SONG.song + " (" + storyDifficultyText + ")", iconRPC);
DiscordClient.changePresence(detailsText, SONG.song + " (" + storyDifficultyText + ")");
}
#end
}
Expand All @@ -1462,11 +1463,11 @@ class PlayState extends MusicBeatState
{
if (Conductor.songPosition > 0.0)
{
DiscordClient.changePresence(detailsText, SONG.song + " (" + storyDifficultyText + ")", iconRPC, true, songLength - Conductor.songPosition);
DiscordClient.changePresence(detailsText, SONG.song + " (" + storyDifficultyText + ")", true, songLength - Conductor.songPosition);
}
else
{
DiscordClient.changePresence(detailsText, SONG.song + " (" + storyDifficultyText + ")", iconRPC);
DiscordClient.changePresence(detailsText, SONG.song + " (" + storyDifficultyText + ")");
}
}
#end
Expand All @@ -1479,7 +1480,7 @@ class PlayState extends MusicBeatState
#if desktop
if (health > 0 && !paused)
{
DiscordClient.changePresence(detailsPausedText, SONG.song + " (" + storyDifficultyText + ")", iconRPC);
DiscordClient.changePresence(detailsPausedText, SONG.song + " (" + storyDifficultyText + ")");
}
#end

Expand Down Expand Up @@ -1572,7 +1573,7 @@ class PlayState extends MusicBeatState
openSubState(new PauseSubState(boyfriend.getScreenPosition().x, boyfriend.getScreenPosition().y));

#if desktop
DiscordClient.changePresence(detailsPausedText, SONG.song + " (" + storyDifficultyText + ")", iconRPC);
DiscordClient.changePresence(detailsPausedText, SONG.song + " (" + storyDifficultyText + ")");
#end
}

Expand All @@ -1581,7 +1582,7 @@ class PlayState extends MusicBeatState
FlxG.switchState(new ChartingState());

#if desktop
DiscordClient.changePresence("Chart Editor", null, null, true);
DiscordClient.changePresence("Chart Editor", null, null);
#end
}

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

#if desktop
// Game Over doesn't get his own variable because it's only used here
DiscordClient.changePresence("Game Over - " + detailsText, SONG.song + " (" + storyDifficultyText + ")", iconRPC);
DiscordClient.changePresence("Game Over - " + detailsText, SONG.song + " (" + storyDifficultyText + ")");
#end
}

Expand Down

0 comments on commit d413906

Please sign in to comment.