From 3c128660b444076bb8181259a11e7a0ca6faaab7 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sat, 22 Aug 2020 04:54:08 -0400 Subject: [PATCH] Add envelope icon, add sounds --- src/d_clisrv.c | 4 ++++ src/discord.c | 27 +++++++++++++++++---------- src/m_menu.c | 17 +++++++++++------ src/sdl/i_video.c | 9 +++++++++ src/sounds.c | 2 ++ src/sounds.h | 2 ++ src/st_stuff.c | 22 ++++++++++++++++++++++ src/st_stuff.h | 5 +++++ 8 files changed, 72 insertions(+), 16 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 93f14c32..ed016e5c 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -46,6 +46,7 @@ #include "lua_script.h" #include "lua_hook.h" #include "k_kart.h" +#include "s_sound.h" // sfx_syfail #ifdef CLIENT_LOADINGSCREEN // cl loading screen @@ -3130,6 +3131,9 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum) #endif } + if (msg != KICK_MSG_PLAYER_QUIT) + S_StartSound(NULL, sfx_syfail); // he he he + switch (msg) { case KICK_MSG_GO_AWAY: diff --git a/src/discord.c b/src/discord.c index 7e20cde6..31b1f9d9 100644 --- a/src/discord.c +++ b/src/discord.c @@ -268,6 +268,9 @@ static void DRPC_HandleJoinRequest(const DiscordUser *requestUser) { discordRequestList = newRequest; } + + // Made it to the end, request was valid, so play the request sound :) + S_StartSound(NULL, sfx_requst); } /*-------------------------------------------------- @@ -375,16 +378,6 @@ void DRPC_RecieveDiscordInfo(UINT8 **p, INT32 playernum) discordInfo.everyoneCanInvite = (boolean)READUINT8(*p); DRPC_UpdatePresence(); - - if (DRPC_InvitesAreAllowed() == false) - { - // Flush the request list, if it still exists - while (discordRequestList != NULL) - { - Discord_Respond(discordRequestList->userID, DISCORD_REPLY_IGNORE); - DRPC_RemoveRequest(discordRequestList); - } - } } #ifdef HAVE_CURL @@ -514,6 +507,8 @@ void DRPC_UpdatePresence(void) char charimg[4+SKINNAMESIZE+1]; char charname[11+SKINNAMESIZE+1]; + boolean joinSecretSet = false; + DiscordRichPresence discordPresence; memset(&discordPresence, 0, sizeof(discordPresence)); @@ -564,6 +559,8 @@ void DRPC_UpdatePresence(void) char *xorjoin = DRPC_XORIPString(join); discordPresence.joinSecret = xorjoin; free(xorjoin); + + joinSecretSet = true; } } } @@ -724,6 +721,16 @@ void DRPC_UpdatePresence(void) discordPresence.smallImageText = charname; // Character name } + if (joinSecretSet == false) + { + // Not able to join? Flush the request list, if it exists. + while (discordRequestList != NULL) + { + Discord_Respond(discordRequestList->userID, DISCORD_REPLY_IGNORE); + DRPC_RemoveRequest(discordRequestList); + } + } + Discord_UpdatePresence(&discordPresence); } diff --git a/src/m_menu.c b/src/m_menu.c index 04ed17fa..5e4121f8 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -11334,18 +11334,23 @@ static boolean confirmAccept = false; static void M_HandleDiscordRequests(INT32 choice) { + if (confirmDelay > 0) + return; + switch (choice) { - case KEY_ESCAPE: - Discord_Respond(discordRequestList->userID, DISCORD_REPLY_NO); - confirmAccept = false; - confirmDelay = confirmLength; - break; - case KEY_ENTER: Discord_Respond(discordRequestList->userID, DISCORD_REPLY_YES); confirmAccept = true; confirmDelay = confirmLength; + S_StartSound(NULL, sfx_s3k63); + break; + + case KEY_ESCAPE: + Discord_Respond(discordRequestList->userID, DISCORD_REPLY_NO); + confirmAccept = false; + confirmDelay = confirmLength; + S_StartSound(NULL, sfx_s3kb2); break; } } diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index a740ef84..cbd1e96c 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -81,6 +81,10 @@ #include "ogl_sdl.h" #endif +#ifdef HAVE_DISCORDRPC +#include "../discord.h" +#endif + // maximum number of windowed modes (see windowedModes[][]) #define MAXWINMODES (18) @@ -1387,6 +1391,11 @@ void I_FinishUpdate(void) if (cv_showping.value && netgame && consoleplayer != serverplayer) SCR_DisplayLocalPing(); +#ifdef HAVE_DISCORDRPC + if (discordRequestList != NULL) + ST_AskToJoinEnvelope(); +#endif + if (rendermode == render_soft && screens[0]) { SDL_Rect rect; diff --git a/src/sounds.c b/src/sounds.c index 61fddb76..40ef0f7f 100644 --- a/src/sounds.c +++ b/src/sounds.c @@ -816,6 +816,8 @@ sfxinfo_t S_sfx[NUMSFX] = {"mkuma", false, 96, 8, -1, NULL, 0, -1, -1, LUMPERROR}, // Trigger Happy Havoc Monokuma {"toada", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, // Arid Sands Toad scream {"bsnipe", false, 96, 8, -1, NULL, 0, -1, -1, LUMPERROR}, // Banana sniping + {"requst", false, 96, 8, -1, NULL, 0, -1, -1, LUMPERROR}, // Got a Discord join request + {"syfail", false, 96, 8, -1, NULL, 0, -1, -1, LUMPERROR}, // Funny sync failure {"itfree", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, // :shitsfree: {"dbgsal", false, 255, 8, -1, NULL, 0, -1, -1, LUMPERROR}, // Debug notification diff --git a/src/sounds.h b/src/sounds.h index dfd0bbdc..2a716919 100644 --- a/src/sounds.h +++ b/src/sounds.h @@ -891,6 +891,8 @@ typedef enum sfx_mkuma, sfx_toada, sfx_bsnipe, + sfx_requst, + sfx_syfail, sfx_itfree, sfx_dbgsal, diff --git a/src/st_stuff.c b/src/st_stuff.c index 252457f9..d570e318 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -129,6 +129,11 @@ static patch_t *gotbflag; static patch_t *hud_tv1; static patch_t *hud_tv2; +#ifdef HAVE_DISCORDRPC +// Discord Rich Presence +static patch_t *envelope; +#endif + // SRB2kart hudinfo_t hudinfo[NUMHUDITEMS] = @@ -349,6 +354,11 @@ void ST_LoadGraphics(void) // Midnight Channel: hud_tv1 = W_CachePatchName("HUD_TV1", PU_HUDGFX); hud_tv2 = W_CachePatchName("HUD_TV2", PU_HUDGFX); + +#ifdef HAVE_DISCORDRPC + // Discord Rich Presence + envelope = W_CachePatchName("K_REQUES", PU_HUDGFX); +#endif } // made separate so that skins code can reload custom face graphics @@ -2080,6 +2090,18 @@ static void ST_MayonakaStatic(void) V_DrawFixedPatch(320<