aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstonedDiscord <stoned@derpymail.org>2019-03-12 00:27:11 +0100
committerstonedDiscord <stoned@derpymail.org>2019-03-12 00:27:11 +0100
commit744c100159ff7b79e01c40ec57e42d37650d139b (patch)
tree6bcdec9f6897988ed29cec3d37793875d40ce6ba
parente4edb7e127b0513aec7ebe62da5c542ef6def7ce (diff)
make discord optional
-rw-r--r--src/discord_rich_presence.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/discord_rich_presence.cpp b/src/discord_rich_presence.cpp
index 10f5833e..0bb7f9fb 100644
--- a/src/discord_rich_presence.cpp
+++ b/src/discord_rich_presence.cpp
@@ -4,6 +4,7 @@ namespace AttorneyOnline {
Discord::Discord()
{
+ #ifdef DISCORD
DiscordEventHandlers handlers;
std::memset(&handlers, 0, sizeof(handlers));
handlers = {};
@@ -18,15 +19,19 @@ Discord::Discord()
};
qInfo() << "Initializing Discord RPC";
Discord_Initialize(APPLICATION_ID, &handlers, 1, nullptr);
+ #endif
}
Discord::~Discord()
{
+ #ifdef DISCORD
Discord_Shutdown();
+ #endif
}
void Discord::state_lobby()
{
+ #ifdef DISCORD
DiscordRichPresence presence;
std::memset(&presence, 0, sizeof(presence));
presence.largeImageKey = "ao2-logo";
@@ -36,12 +41,13 @@ void Discord::state_lobby()
presence.state = "In Lobby";
presence.details = "Idle";
Discord_UpdatePresence(&presence);
+ #endif
}
void Discord::state_server(std::string name, std::string server_id)
{
qDebug() << "Discord RPC: Setting server state";
-
+ #ifdef DISCORD
DiscordRichPresence presence;
std::memset(&presence, 0, sizeof(presence));
presence.largeImageKey = "ao2-logo";
@@ -59,6 +65,7 @@ void Discord::state_server(std::string name, std::string server_id)
this->server_name = name;
this->timestamp = timestamp;
Discord_UpdatePresence(&presence);
+ #endif
}
void Discord::state_character(std::string name)
@@ -67,7 +74,7 @@ void Discord::state_character(std::string name)
auto name_friendly = QString(name.c_str()).replace('_', ' ').toStdString();
const std::string playing_as = "Playing as " + name_friendly;
qDebug() << "Discord RPC: Setting character state (" << playing_as.c_str() << ")";
-
+ #ifdef DISCORD
DiscordRichPresence presence;
std::memset(&presence, 0, sizeof(presence));
presence.largeImageKey = "ao2-logo";
@@ -81,12 +88,13 @@ void Discord::state_character(std::string name)
presence.smallImageKey = name_internal.c_str();
// presence.smallImageText = name_internal.c_str();
Discord_UpdatePresence(&presence);
+ #endif
}
void Discord::state_spectate()
{
qDebug() << "Discord RPC: Setting specator state";
-
+ #ifdef DISCORD
DiscordRichPresence presence;
std::memset(&presence, 0, sizeof(presence));
presence.largeImageKey = "ao2-logo";
@@ -98,6 +106,7 @@ void Discord::state_spectate()
presence.state = "Spectating";
Discord_UpdatePresence(&presence);
+ #endif
}
}