Revert "make discord optional"

This reverts commit 744c100159.
This commit is contained in:
stonedDiscord 2019-03-12 19:27:13 +01:00
parent fced80661c
commit 92c54ba2eb

View File

@ -4,7 +4,6 @@ namespace AttorneyOnline {
Discord::Discord() Discord::Discord()
{ {
#ifdef DISCORD
DiscordEventHandlers handlers; DiscordEventHandlers handlers;
std::memset(&handlers, 0, sizeof(handlers)); std::memset(&handlers, 0, sizeof(handlers));
handlers = {}; handlers = {};
@ -19,19 +18,15 @@ Discord::Discord()
}; };
qInfo() << "Initializing Discord RPC"; qInfo() << "Initializing Discord RPC";
Discord_Initialize(APPLICATION_ID, &handlers, 1, nullptr); Discord_Initialize(APPLICATION_ID, &handlers, 1, nullptr);
#endif
} }
Discord::~Discord() Discord::~Discord()
{ {
#ifdef DISCORD
Discord_Shutdown(); Discord_Shutdown();
#endif
} }
void Discord::state_lobby() void Discord::state_lobby()
{ {
#ifdef DISCORD
DiscordRichPresence presence; DiscordRichPresence presence;
std::memset(&presence, 0, sizeof(presence)); std::memset(&presence, 0, sizeof(presence));
presence.largeImageKey = "ao2-logo"; presence.largeImageKey = "ao2-logo";
@ -41,13 +36,12 @@ void Discord::state_lobby()
presence.state = "In Lobby"; presence.state = "In Lobby";
presence.details = "Idle"; presence.details = "Idle";
Discord_UpdatePresence(&presence); Discord_UpdatePresence(&presence);
#endif
} }
void Discord::state_server(std::string name, std::string server_id) void Discord::state_server(std::string name, std::string server_id)
{ {
qDebug() << "Discord RPC: Setting server state"; qDebug() << "Discord RPC: Setting server state";
#ifdef DISCORD
DiscordRichPresence presence; DiscordRichPresence presence;
std::memset(&presence, 0, sizeof(presence)); std::memset(&presence, 0, sizeof(presence));
presence.largeImageKey = "ao2-logo"; presence.largeImageKey = "ao2-logo";
@ -65,7 +59,6 @@ void Discord::state_server(std::string name, std::string server_id)
this->server_name = name; this->server_name = name;
this->timestamp = timestamp; this->timestamp = timestamp;
Discord_UpdatePresence(&presence); Discord_UpdatePresence(&presence);
#endif
} }
void Discord::state_character(std::string name) void Discord::state_character(std::string name)
@ -74,7 +67,7 @@ void Discord::state_character(std::string name)
auto name_friendly = QString(name.c_str()).replace('_', ' ').toStdString(); auto name_friendly = QString(name.c_str()).replace('_', ' ').toStdString();
const std::string playing_as = "Playing as " + name_friendly; const std::string playing_as = "Playing as " + name_friendly;
qDebug() << "Discord RPC: Setting character state (" << playing_as.c_str() << ")"; qDebug() << "Discord RPC: Setting character state (" << playing_as.c_str() << ")";
#ifdef DISCORD
DiscordRichPresence presence; DiscordRichPresence presence;
std::memset(&presence, 0, sizeof(presence)); std::memset(&presence, 0, sizeof(presence));
presence.largeImageKey = "ao2-logo"; presence.largeImageKey = "ao2-logo";
@ -88,13 +81,12 @@ void Discord::state_character(std::string name)
presence.smallImageKey = name_internal.c_str(); presence.smallImageKey = name_internal.c_str();
// presence.smallImageText = name_internal.c_str(); // presence.smallImageText = name_internal.c_str();
Discord_UpdatePresence(&presence); Discord_UpdatePresence(&presence);
#endif
} }
void Discord::state_spectate() void Discord::state_spectate()
{ {
qDebug() << "Discord RPC: Setting specator state"; qDebug() << "Discord RPC: Setting specator state";
#ifdef DISCORD
DiscordRichPresence presence; DiscordRichPresence presence;
std::memset(&presence, 0, sizeof(presence)); std::memset(&presence, 0, sizeof(presence));
presence.largeImageKey = "ao2-logo"; presence.largeImageKey = "ao2-logo";
@ -106,7 +98,6 @@ void Discord::state_spectate()
presence.state = "Spectating"; presence.state = "Spectating";
Discord_UpdatePresence(&presence); Discord_UpdatePresence(&presence);
#endif
} }
} }