Skip to content

Commit

Permalink
Add discord map icon support. Add to readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Bitl committed Mar 6, 2025
1 parent c909b07 commit 854fc2a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ This base is specific to multiplayer mod projects.
- NOTE: You may need to do some tinkering to make these singleplayer projects work well with the new SDK base. There are some bugs and crashes that won't be addressed by this base.
- NPC NextBot sensing support from FIREFIGHT RELOADED.
- Integrated Python binaries (on Windows) for more simple buiding.
- Implemented Discord RPC support. Mod authors can change the DiscordAppId parameter in their gameinfo.txt file for more personalized icons. Mods can also use the DiscordAllowMapIcons option to allow map specific icons. Mod icons must be named "ModImage" and map icons must be named the map name.

## Setup:
Read Autumn's setup guide at README_FROG.md for detailed setup.
Expand Down
25 changes: 24 additions & 1 deletion src/game/client/cdll_client_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ static ConVar s_cl_class("cl_class", "default", FCVAR_USERINFO|FCVAR_ARCHIVE, "D
#ifdef WIN32
// Discord RPC
static ConVar cl_discord_appid("cl_discord_appid", "1347077140306464838", FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT);
static ConVar cl_discord_mapicon("cl_discord_mapicon", "0", FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT);
static int64_t startTimestamp = time(0);

static ConVar cl_discord("cl_discord", "1", FCVAR_ARCHIVE);
Expand Down Expand Up @@ -1792,7 +1793,29 @@ void CHLClient::LevelInitPreEntity( char const* pMapName )
discordPresence.state = "In-Game";
sprintf(buffer, "Map: %s", pMapName);
discordPresence.details = buffer;
discordPresence.largeImageKey = "ModImage";

bool useMapIcon = false;

KeyValuesAD pKVGameInfo("GameInfo");
if (pKVGameInfo->LoadFromFile(g_pFullFileSystem, "gameinfo.txt", "MOD"))
{
useMapIcon = pKVGameInfo->GetBool("DiscordAllowMapIcons", cl_discord_mapicon.GetBool());
}
else
{
useMapIcon = cl_discord_mapicon.GetBool();
}

if (useMapIcon)
{
discordPresence.largeImageKey = pMapName;
discordPresence.smallImageKey = "ModImage";
}
else
{
discordPresence.largeImageKey = "ModImage";
}

Discord_UpdatePresence(&discordPresence);
}
}
Expand Down

0 comments on commit 854fc2a

Please sign in to comment.