1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-11-15 03:13:45 +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.
// 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.
// TODO: Make this use the song's album art.
// 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.
// This can be the opponent's health icon?
presence.smallImageKey = cast(params.smallImageKey, Null<String>);
// Start timestamp, used to power elapsed/remaining data
// presence.startTimestamp
// End timestamp, used to power elapsed/remaining data
// presence.endTimestamp
// NOTE: In previous versions, this showed as "Elapsed", but now shows as playtime and doesn't look good
// presence.startTimestamp = time - 10;
// presence.endTimestamp = time + 30;
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;
}

View file

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

View file

@ -78,7 +78,12 @@ class Constants
/**
* 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.