1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-11-15 11:22:55 +00:00

Better status messages, buttons, updated album art, basic chart editor support

This commit is contained in:
EliteMasterEric 2024-09-19 11:13:05 -04:00
parent 8fd84f9d13
commit 35aa8731d0
4 changed files with 93 additions and 31 deletions

View file

@ -96,16 +96,28 @@ class DiscordClient
// The large image displaying what the user is doing. // The large image displaying what the user is doing.
// This should probably be album art. // This should probably be album art.
// IMPORTANT NOTE: This can be an asset key uploaded to Discord's developer panel OR any URL you like. // IMPORTANT NOTE: This can be an asset key uploaded to Discord's developer panel OR any URL you like.
// TODO: Make this use the song's album art.
// presence.largeImageKey = "icon"; // presence.largeImageKey = "icon";
presence.largeImageKey = "https://f4.bcbits.com/img/a3122193953_16.jpg"; presence.largeImageKey = "https://f4.bcbits.com/img/a0746694746_16.jpg";
// The small inset image for what the user is doing. // The small inset image for what the user is doing.
// This can be the opponent's health icon? // This can be the opponent's health icon?
presence.smallImageKey = cast(params.smallImageKey, Null<String>); presence.smallImageKey = cast(params.smallImageKey, Null<String>);
// Start timestamp, used to power elapsed/remaining data // NOTE: In previous versions, this showed as "Elapsed", but now shows as playtime and doesn't look good
// presence.startTimestamp // presence.startTimestamp = time - 10;
// End timestamp, used to power elapsed/remaining data // presence.endTimestamp = time + 30;
// presence.endTimestamp
final button1:DiscordButton = DiscordButton.create();
button1.label = "Play on Web";
button1.url = Constants.URL_NEWGROUNDS;
presence.buttons[0] = button1;
final button2:DiscordButton = DiscordButton.create();
button2.label = "Download";
button2.url = Constants.URL_ITCH;
presence.buttons[1] = button2;
return presence; return presence;
} }

View file

@ -447,10 +447,7 @@ class PlayState extends MusicBeatSubState
#if FEATURE_DISCORD_RPC #if FEATURE_DISCORD_RPC
// Discord RPC variables // Discord RPC variables
var discordRPCDifficulty:String = '';
var discordRPCIcon:String = ''; var discordRPCIcon:String = '';
var discordRPCDetailsText:String = '';
var discordRPCDetailsPausedText:String = '';
#end #end
/** /**
@ -986,8 +983,10 @@ class PlayState extends MusicBeatSubState
#if FEATURE_DISCORD_RPC #if FEATURE_DISCORD_RPC
DiscordClient.instance.setPresence( DiscordClient.instance.setPresence(
{ {
state: '${currentChart.songName} (${discordRPCDifficulty})', details: 'Paused - ${buildDiscordRPCDetails()}',
details: discordRPCDetailsPausedText,
state: buildDiscordRPCState(),
smallImageKey: discordRPCIcon smallImageKey: discordRPCIcon
}); });
#end #end
@ -1080,8 +1079,8 @@ class PlayState extends MusicBeatSubState
#if FEATURE_DISCORD_RPC #if FEATURE_DISCORD_RPC
DiscordClient.instance.setPresence( DiscordClient.instance.setPresence(
{ {
state: '${currentChart.songName} [${discordRPCDifficulty}]', details: 'Game Over - ${buildDiscordRPCDetails()}',
details: 'Game Over - ${discordRPCDetailsText}', state: buildDiscordRPCState(),
smallImageKey: discordRPCIcon smallImageKey: discordRPCIcon
}); });
#end #end
@ -1300,8 +1299,8 @@ class PlayState extends MusicBeatSubState
// currentSongLengthMs - Conductor.instance.songPosition); // currentSongLengthMs - Conductor.instance.songPosition);
DiscordClient.instance.setPresence( DiscordClient.instance.setPresence(
{ {
state: '${currentChart.songName} [${discordRPCDifficulty}]', state: buildDiscordRPCState(),
details: discordRPCDetailsText, details: 'Paused - ${buildDiscordRPCDetails()}',
smallImageKey: discordRPCIcon smallImageKey: discordRPCIcon
}); });
} }
@ -1309,8 +1308,8 @@ class PlayState extends MusicBeatSubState
{ {
DiscordClient.instance.setPresence( DiscordClient.instance.setPresence(
{ {
state: '${currentChart.songName} [${discordRPCDifficulty}]', state: buildDiscordRPCState(),
details: discordRPCDetailsText, details: 'Paused - ${buildDiscordRPCDetails()}',
smallImageKey: discordRPCIcon smallImageKey: discordRPCIcon
}); });
} }
@ -1344,8 +1343,8 @@ class PlayState extends MusicBeatSubState
{ {
DiscordClient.instance.setPresence( DiscordClient.instance.setPresence(
{ {
state: '${currentChart.songName} [${discordRPCDifficulty}]', state: buildDiscordRPCState(),
details: discordRPCDetailsText, details: buildDiscordRPCDetails(),
smallImageKey: discordRPCIcon smallImageKey: discordRPCIcon
}); });
} }
@ -1353,8 +1352,8 @@ class PlayState extends MusicBeatSubState
{ {
DiscordClient.instance.setPresence( DiscordClient.instance.setPresence(
{ {
state: '${currentChart.songName} [${discordRPCDifficulty}]', state: buildDiscordRPCState(),
details: discordRPCDetailsText, details: buildDiscordRPCDetails(),
smallImageKey: discordRPCIcon smallImageKey: discordRPCIcon
}); });
// DiscordClient.changePresence(detailsText, '${currentChart.songName} ($discordRPCDifficulty)', discordRPCIcon, true, // DiscordClient.changePresence(detailsText, '${currentChart.songName} ($discordRPCDifficulty)', discordRPCIcon, true,
@ -1380,8 +1379,8 @@ class PlayState extends MusicBeatSubState
{ {
DiscordClient.instance.setPresence( DiscordClient.instance.setPresence(
{ {
state: '${currentChart.songName} [${discordRPCDifficulty}]', state: buildDiscordRPCState(),
details: discordRPCDetailsText, details: buildDiscordRPCDetails(),
smallImageKey: discordRPCIcon smallImageKey: discordRPCIcon
}); });
} }
@ -1801,22 +1800,51 @@ class PlayState extends MusicBeatSubState
function initDiscord():Void function initDiscord():Void
{ {
#if FEATURE_DISCORD_RPC #if FEATURE_DISCORD_RPC
discordRPCDifficulty = PlayState.instance.currentDifficulty.replace('-', ' ').toTitleCase();
// Determine the details strings once and reuse them. // Determine the details strings once and reuse them.
discordRPCDetailsText = PlayStatePlaylist.isStoryMode ? 'Story Mode: Week ${PlayStatePlaylist.campaignId}' : 'Freeplay';
discordRPCDetailsPausedText = 'Paused - $discordRPCDetailsText';
// Updating Discord Rich Presence. // Updating Discord Rich Presence.
DiscordClient.instance.setPresence( DiscordClient.instance.setPresence(
{ {
state: '${currentChart.songName} [${discordRPCDifficulty}]', state: buildDiscordRPCState(),
details: discordRPCDetailsText, details: buildDiscordRPCDetails(),
smallImageKey: discordRPCIcon smallImageKey: discordRPCIcon
}); });
#end #end
} }
function buildDiscordRPCDetails():String
{
if (PlayStatePlaylist.isStoryMode)
{
return 'Story Mode: ${PlayStatePlaylist.campaignTitle}';
}
else
{
if (isChartingMode)
{
return 'Chart Editor [Playtest]';
}
else if (isPracticeMode)
{
return 'Freeplay [Practice]';
}
else if (isBotPlayMode)
{
return 'Freeplay [Bot Play]';
}
else
{
return 'Freeplay';
}
}
}
function buildDiscordRPCState():String
{
var discordRPCDifficulty = PlayState.instance.currentDifficulty.replace('-', ' ').toTitleCase();
return '${currentChart.songName} [${discordRPCDifficulty}]';
}
function initPreciseInputs():Void function initPreciseInputs():Void
{ {
PreciseInputManager.instance.onInputPressed.add(onKeyPress); PreciseInputManager.instance.onInputPressed.add(onKeyPress);
@ -2010,8 +2038,8 @@ class PlayState extends MusicBeatSubState
// Updating Discord Rich Presence (with Time Left) // Updating Discord Rich Presence (with Time Left)
DiscordClient.instance.setPresence( DiscordClient.instance.setPresence(
{ {
state: '${currentChart.songName} (${discordRPCDifficulty})', state: buildDiscordRPCState(),
details: discordRPCDetailsText, details: buildDiscordRPCDetails(),
smallImageKey: discordRPCIcon smallImageKey: discordRPCIcon
}); });
// DiscordClient.changePresence(detailsText, '${currentChart.songName} ($discordRPCDifficulty)', discordRPCIcon, true, currentSongLengthMs); // DiscordClient.changePresence(detailsText, '${currentChart.songName} ($discordRPCDifficulty)', discordRPCIcon, true, currentSongLengthMs);

View file

@ -2274,8 +2274,25 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
this.openBackupAvailableDialog(welcomeDialog); this.openBackupAvailableDialog(welcomeDialog);
} }
} }
#if FEATURE_DISCORD_RPC
updateDiscordRPC();
#end
} }
#if FEATURE_DISCORD_RPC
function updateDiscordRPC():Void
{
funkin.api.discord.DiscordClient.instance.setPresence(
{
// TODO: Make this display the song name and update when it changes.
// state: '${currentSongName} [${selectedDifficulty}]',
state: null,
details: 'Chart Editor [Charting]'
});
}
#end
function setupWelcomeMusic() function setupWelcomeMusic()
{ {
this.welcomeMusic.loadEmbedded(Paths.music('chartEditorLoop/chartEditorLoop')); this.welcomeMusic.loadEmbedded(Paths.music('chartEditorLoop/chartEditorLoop'));

View file

@ -78,7 +78,12 @@ class Constants
/** /**
* Link to download the game on Itch.io. * Link to download the game on Itch.io.
*/ */
public static final URL_ITCH:String = 'https://ninja-muffin24.itch.io/funkin/purchase'; public static final URL_ITCH:String = 'https://ninja-muffin24.itch.io/funkin';
/**
* Link to play the game on Newgrounds.
*/
public static final URL_NEWGROUNDS:String = 'https://www.newgrounds.com/portal/view/770371';
/** /**
* Link to the game's page on Kickstarter. * Link to the game's page on Kickstarter.