mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2024-12-28 15:57:42 +00:00
Now shows P2 icon and time left when song starts
This commit is contained in:
parent
3d74f869d3
commit
700acb86a1
|
@ -57,16 +57,26 @@ class DiscordClient
|
|||
trace("Discord Client initialized");
|
||||
}
|
||||
|
||||
public static function changePresence(details:String, state:Null<String>, ?smallImageKey : String, ?startTimestamp: Int, ?endTimestamp: Int)
|
||||
public static function changePresence(details:String, state:Null<String>, ?smallImageKey : String, ?hasStartTimestamp : Bool, ?endTimestamp: Float)
|
||||
{
|
||||
var startTimestamp:Float = if(hasStartTimestamp) Date.now().getTime() else 0;
|
||||
|
||||
if (endTimestamp > 0)
|
||||
{
|
||||
endTimestamp = startTimestamp + endTimestamp;
|
||||
}
|
||||
|
||||
DiscordRpc.presence({
|
||||
details: details,
|
||||
state: state,
|
||||
largeImageKey: 'icon',
|
||||
largeImageText: "Friday Night Funkin'",
|
||||
smallImageKey : smallImageKey,
|
||||
startTimestamp : startTimestamp,
|
||||
endTimestamp : endTimestamp
|
||||
// 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. Argument: $details, $state, $smallImageKey, $hasStartTimestamp, $endTimestamp');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -125,6 +125,13 @@ class PlayState extends MusicBeatState
|
|||
|
||||
var inCutscene:Bool = false;
|
||||
|
||||
#if !html
|
||||
// Discord RPC variables
|
||||
var storyDifficultyText:String = "";
|
||||
var iconRPC:String = "";
|
||||
var songLength:Float = 0;
|
||||
#end
|
||||
|
||||
override public function create()
|
||||
{
|
||||
if (FlxG.sound.music != null)
|
||||
|
@ -178,7 +185,6 @@ class PlayState extends MusicBeatState
|
|||
|
||||
#if !html
|
||||
// Making difficulty text for Discord Rich Presence.
|
||||
var storyDifficultyText = "";
|
||||
switch (storyDifficulty)
|
||||
{
|
||||
case 0:
|
||||
|
@ -188,14 +194,28 @@ class PlayState extends MusicBeatState
|
|||
case 2:
|
||||
storyDifficultyText = "Hard";
|
||||
}
|
||||
|
||||
iconRPC = SONG.player2;
|
||||
|
||||
// To avoid having duplicate images in Discord assets
|
||||
switch (iconRPC)
|
||||
{
|
||||
case 'senpai-angry':
|
||||
iconRPC = 'senpai';
|
||||
case 'monster-christmas':
|
||||
iconRPC = 'monster';
|
||||
case 'mom-car':
|
||||
iconRPC = 'mom';
|
||||
}
|
||||
|
||||
// Updating Discord Rich Presence.
|
||||
if (isStoryMode)
|
||||
{
|
||||
DiscordClient.changePresence("Story Mode: Week " + storyWeek, SONG.song + " (" + storyDifficultyText + ")");
|
||||
DiscordClient.changePresence("Story Mode: Week " + storyWeek, SONG.song + " (" + storyDifficultyText + ")", iconRPC);
|
||||
}
|
||||
else
|
||||
{
|
||||
DiscordClient.changePresence("Freeplay", SONG.song + " (" + storyDifficultyText + ")");
|
||||
DiscordClient.changePresence("Freeplay", SONG.song + " (" + storyDifficultyText + ")", iconRPC);
|
||||
}
|
||||
#end
|
||||
|
||||
|
@ -992,6 +1012,21 @@ class PlayState extends MusicBeatState
|
|||
FlxG.sound.playMusic(Paths.inst(PlayState.SONG.song), 1, false);
|
||||
FlxG.sound.music.onComplete = endSong;
|
||||
vocals.play();
|
||||
|
||||
#if !html
|
||||
// Song duration in a float, useful for the time left feature
|
||||
songLength = FlxG.sound.music.length;
|
||||
|
||||
// Updating Discord Rich Presence (with Time Left)
|
||||
if (isStoryMode)
|
||||
{
|
||||
DiscordClient.changePresence("Story Mode: Week " + storyWeek, SONG.song + " (" + storyDifficultyText + ")", iconRPC, true, songLength);
|
||||
}
|
||||
else
|
||||
{
|
||||
DiscordClient.changePresence("Freeplay", SONG.song + " (" + storyDifficultyText + ")", iconRPC, true, songLength);
|
||||
}
|
||||
#end
|
||||
}
|
||||
|
||||
var debugNum:Int = 0;
|
||||
|
|
Loading…
Reference in a new issue