mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2025-12-01 16:51:27 +00:00
Merge pull request #1 from WorstAquaPlayer/master
More additions to the RPC
This commit is contained in:
commit
2508b31ca2
|
|
@ -116,7 +116,7 @@
|
||||||
<haxelib name="newgrounds"/>
|
<haxelib name="newgrounds"/>
|
||||||
<haxelib name="faxe" if='switch'/>
|
<haxelib name="faxe" if='switch'/>
|
||||||
<haxelib name="polymod"/>
|
<haxelib name="polymod"/>
|
||||||
<haxelib name="discord_rpc" unless="web"/>
|
<haxelib name="discord_rpc" if="desktop"/>
|
||||||
<!-- <haxelib name="hxcpp-debug-server" if="desktop"/> -->
|
<!-- <haxelib name="hxcpp-debug-server" if="desktop"/> -->
|
||||||
|
|
||||||
<!-- <haxelib name="markdown" /> -->
|
<!-- <haxelib name="markdown" /> -->
|
||||||
|
|
|
||||||
|
|
@ -57,13 +57,26 @@ class DiscordClient
|
||||||
trace("Discord Client initialized");
|
trace("Discord Client initialized");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function changePresence(details:String, state:Null<String>)
|
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({
|
DiscordRpc.presence({
|
||||||
details: details,
|
details: details,
|
||||||
state: state,
|
state: state,
|
||||||
largeImageKey: 'icon',
|
largeImageKey: 'icon',
|
||||||
largeImageText: "Friday Night Funkin'"
|
largeImageText: "Friday Night Funkin'",
|
||||||
|
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');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
package;
|
package;
|
||||||
|
|
||||||
#if !html
|
#if desktop
|
||||||
import Discord.DiscordClient;
|
import Discord.DiscordClient;
|
||||||
#end
|
#end
|
||||||
import flash.text.TextField;
|
import flash.text.TextField;
|
||||||
|
|
@ -48,9 +48,9 @@ class FreeplayState extends MusicBeatState
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if !html
|
#if desktop
|
||||||
// Updating Discord Rich Presence
|
// Updating Discord Rich Presence
|
||||||
DiscordClient.changePresence("In the menus.", null);
|
DiscordClient.changePresence("In the Menus", null);
|
||||||
#end
|
#end
|
||||||
|
|
||||||
var isDebug:Bool = false;
|
var isDebug:Bool = false;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
package;
|
package;
|
||||||
|
|
||||||
|
#if desktop
|
||||||
|
import Discord.DiscordClient;
|
||||||
|
#end
|
||||||
import flixel.FlxG;
|
import flixel.FlxG;
|
||||||
import flixel.FlxObject;
|
import flixel.FlxObject;
|
||||||
import flixel.FlxSprite;
|
import flixel.FlxSprite;
|
||||||
|
|
@ -33,6 +36,11 @@ class MainMenuState extends MusicBeatState
|
||||||
|
|
||||||
override function create()
|
override function create()
|
||||||
{
|
{
|
||||||
|
#if desktop
|
||||||
|
// Updating Discord Rich Presence
|
||||||
|
DiscordClient.changePresence("In the Menus", null);
|
||||||
|
#end
|
||||||
|
|
||||||
transIn = FlxTransitionableState.defaultTransIn;
|
transIn = FlxTransitionableState.defaultTransIn;
|
||||||
transOut = FlxTransitionableState.defaultTransOut;
|
transOut = FlxTransitionableState.defaultTransOut;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
package;
|
package;
|
||||||
|
|
||||||
#if !html
|
#if desktop
|
||||||
import Discord.DiscordClient;
|
import Discord.DiscordClient;
|
||||||
#end
|
#end
|
||||||
import Section.SwagSection;
|
import Section.SwagSection;
|
||||||
|
|
@ -125,6 +125,15 @@ class PlayState extends MusicBeatState
|
||||||
|
|
||||||
var inCutscene:Bool = false;
|
var inCutscene:Bool = false;
|
||||||
|
|
||||||
|
#if desktop
|
||||||
|
// Discord RPC variables
|
||||||
|
var storyDifficultyText:String = "";
|
||||||
|
var iconRPC:String = "";
|
||||||
|
var songLength:Float = 0;
|
||||||
|
var detailsText:String = "";
|
||||||
|
var detailsPausedText:String = "";
|
||||||
|
#end
|
||||||
|
|
||||||
override public function create()
|
override public function create()
|
||||||
{
|
{
|
||||||
if (FlxG.sound.music != null)
|
if (FlxG.sound.music != null)
|
||||||
|
|
@ -176,9 +185,8 @@ class PlayState extends MusicBeatState
|
||||||
dialogue = CoolUtil.coolTextFile(Paths.txt('thorns/thornsDialogue'));
|
dialogue = CoolUtil.coolTextFile(Paths.txt('thorns/thornsDialogue'));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !html
|
#if desktop
|
||||||
// Making difficulty text for Discord Rich Presence.
|
// Making difficulty text for Discord Rich Presence.
|
||||||
var storyDifficultyText = "";
|
|
||||||
switch (storyDifficulty)
|
switch (storyDifficulty)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
|
|
@ -188,15 +196,35 @@ class PlayState extends MusicBeatState
|
||||||
case 2:
|
case 2:
|
||||||
storyDifficultyText = "Hard";
|
storyDifficultyText = "Hard";
|
||||||
}
|
}
|
||||||
// Updating Discord Rich Presence.
|
|
||||||
|
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';
|
||||||
|
}
|
||||||
|
|
||||||
|
// String that contains the mode defined here so it isn't necessary to call changePresence for each mode
|
||||||
if (isStoryMode)
|
if (isStoryMode)
|
||||||
{
|
{
|
||||||
DiscordClient.changePresence("Story Mode: Week " + storyWeek, SONG.song + " (" + storyDifficultyText + ")");
|
detailsText = "Story Mode: Week " + storyWeek;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DiscordClient.changePresence("Freeplay", SONG.song + " (" + storyDifficultyText + ")");
|
detailsText = "Freeplay";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// String for when the game is paused
|
||||||
|
detailsPausedText = "Paused - " + detailsText;
|
||||||
|
|
||||||
|
// Updating Discord Rich Presence.
|
||||||
|
DiscordClient.changePresence(detailsText, SONG.song + " (" + storyDifficultyText + ")", iconRPC);
|
||||||
#end
|
#end
|
||||||
|
|
||||||
if (SONG.song.toLowerCase() == 'spookeez' || SONG.song.toLowerCase() == 'monster' || SONG.song.toLowerCase() == 'south')
|
if (SONG.song.toLowerCase() == 'spookeez' || SONG.song.toLowerCase() == 'monster' || SONG.song.toLowerCase() == 'south')
|
||||||
|
|
@ -992,6 +1020,14 @@ class PlayState extends MusicBeatState
|
||||||
FlxG.sound.playMusic(Paths.inst(PlayState.SONG.song), 1, false);
|
FlxG.sound.playMusic(Paths.inst(PlayState.SONG.song), 1, false);
|
||||||
FlxG.sound.music.onComplete = endSong;
|
FlxG.sound.music.onComplete = endSong;
|
||||||
vocals.play();
|
vocals.play();
|
||||||
|
|
||||||
|
#if desktop
|
||||||
|
// Song duration in a float, useful for the time left feature
|
||||||
|
songLength = FlxG.sound.music.length;
|
||||||
|
|
||||||
|
// Updating Discord Rich Presence (with Time Left)
|
||||||
|
DiscordClient.changePresence(detailsText, SONG.song + " (" + storyDifficultyText + ")", iconRPC, true, songLength);
|
||||||
|
#end
|
||||||
}
|
}
|
||||||
|
|
||||||
var debugNum:Int = 0;
|
var debugNum:Int = 0;
|
||||||
|
|
@ -1232,11 +1268,53 @@ class PlayState extends MusicBeatState
|
||||||
if (!startTimer.finished)
|
if (!startTimer.finished)
|
||||||
startTimer.active = true;
|
startTimer.active = true;
|
||||||
paused = false;
|
paused = false;
|
||||||
|
|
||||||
|
#if desktop
|
||||||
|
if (startTimer.finished)
|
||||||
|
{
|
||||||
|
DiscordClient.changePresence(detailsText, SONG.song + " (" + storyDifficultyText + ")", iconRPC, true, songLength - Conductor.songPosition);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DiscordClient.changePresence(detailsText, SONG.song + " (" + storyDifficultyText + ")", iconRPC);
|
||||||
|
}
|
||||||
|
#end
|
||||||
}
|
}
|
||||||
|
|
||||||
super.closeSubState();
|
super.closeSubState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override public function onFocus():Void
|
||||||
|
{
|
||||||
|
#if desktop
|
||||||
|
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 desktop
|
||||||
|
if (health > 0 && !paused)
|
||||||
|
{
|
||||||
|
DiscordClient.changePresence(detailsPausedText, SONG.song + " (" + storyDifficultyText + ")", iconRPC);
|
||||||
|
}
|
||||||
|
#end
|
||||||
|
|
||||||
|
super.onFocusLost();
|
||||||
|
}
|
||||||
|
|
||||||
function resyncVocals():Void
|
function resyncVocals():Void
|
||||||
{
|
{
|
||||||
vocals.pause();
|
vocals.pause();
|
||||||
|
|
@ -1299,11 +1377,19 @@ class PlayState extends MusicBeatState
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
openSubState(new PauseSubState(boyfriend.getScreenPosition().x, boyfriend.getScreenPosition().y));
|
openSubState(new PauseSubState(boyfriend.getScreenPosition().x, boyfriend.getScreenPosition().y));
|
||||||
|
|
||||||
|
#if desktop
|
||||||
|
DiscordClient.changePresence(detailsPausedText, SONG.song + " (" + storyDifficultyText + ")", iconRPC);
|
||||||
|
#end
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FlxG.keys.justPressed.SEVEN)
|
if (FlxG.keys.justPressed.SEVEN)
|
||||||
{
|
{
|
||||||
FlxG.switchState(new ChartingState());
|
FlxG.switchState(new ChartingState());
|
||||||
|
|
||||||
|
#if desktop
|
||||||
|
DiscordClient.changePresence("Chart Editor", null, null, true);
|
||||||
|
#end
|
||||||
}
|
}
|
||||||
|
|
||||||
// FlxG.watch.addQuick('VOL', vocals.amplitudeLeft);
|
// FlxG.watch.addQuick('VOL', vocals.amplitudeLeft);
|
||||||
|
|
@ -1499,6 +1585,11 @@ class PlayState extends MusicBeatState
|
||||||
openSubState(new GameOverSubstate(boyfriend.getScreenPosition().x, boyfriend.getScreenPosition().y));
|
openSubState(new GameOverSubstate(boyfriend.getScreenPosition().x, boyfriend.getScreenPosition().y));
|
||||||
|
|
||||||
// FlxG.switchState(new GameOverState(boyfriend.getScreenPosition().x, boyfriend.getScreenPosition().y));
|
// FlxG.switchState(new GameOverState(boyfriend.getScreenPosition().x, boyfriend.getScreenPosition().y));
|
||||||
|
|
||||||
|
#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);
|
||||||
|
#end
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unspawnNotes[0] != null)
|
if (unspawnNotes[0] != null)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
package;
|
package;
|
||||||
|
|
||||||
#if !html
|
#if desktop
|
||||||
import Discord.DiscordClient;
|
import Discord.DiscordClient;
|
||||||
#end
|
#end
|
||||||
import flixel.FlxG;
|
import flixel.FlxG;
|
||||||
|
|
@ -112,9 +112,10 @@ class StoryMenuState extends MusicBeatState
|
||||||
add(grpLocks);
|
add(grpLocks);
|
||||||
|
|
||||||
trace("Line 70");
|
trace("Line 70");
|
||||||
#if !html
|
|
||||||
|
#if desktop
|
||||||
// Updating Discord Rich Presence
|
// Updating Discord Rich Presence
|
||||||
DiscordClient.changePresence("In the menus.", null);
|
DiscordClient.changePresence("In the Menus", null);
|
||||||
#end
|
#end
|
||||||
|
|
||||||
for (i in 0...weekData.length)
|
for (i in 0...weekData.length)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
package;
|
package;
|
||||||
|
|
||||||
#if !html5
|
#if desktop
|
||||||
import Discord.DiscordClient;
|
import Discord.DiscordClient;
|
||||||
import sys.thread.Thread;
|
import sys.thread.Thread;
|
||||||
#end
|
#end
|
||||||
|
|
@ -94,7 +94,7 @@ class TitleState extends MusicBeatState
|
||||||
});
|
});
|
||||||
#end
|
#end
|
||||||
|
|
||||||
#if !html
|
#if desktop
|
||||||
DiscordClient.initialize();
|
DiscordClient.initialize();
|
||||||
#end
|
#end
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue