aboutsummaryrefslogtreecommitdiff
path: root/src/discord_rich_presence.cpp
diff options
context:
space:
mode:
authorSalanto <62221668+Salanto@users.noreply.github.com>2024-05-18 03:33:43 +0200
committerGitHub <noreply@github.com>2024-05-18 03:33:43 +0200
commit51338e30e046f1a62c84049b34577f0f3b5db6e3 (patch)
tree283c95f8f776ed852d03a816388695afd65c0f73 /src/discord_rich_presence.cpp
parent469e293a1885e49f1d5994d41ac7cfc9f4666952 (diff)
parentf9c7205210fb9f768f583065971ece09e6b5eb03 (diff)
Merge pull request #957 from AttorneyOnline/kaleidoscope
The Kaleidoscope - Hell, it's about time.
Diffstat (limited to 'src/discord_rich_presence.cpp')
-rw-r--r--src/discord_rich_presence.cpp32
1 files changed, 21 insertions, 11 deletions
diff --git a/src/discord_rich_presence.cpp b/src/discord_rich_presence.cpp
index 81e5a86..c22a6f6 100644
--- a/src/discord_rich_presence.cpp
+++ b/src/discord_rich_presence.cpp
@@ -1,14 +1,20 @@
#include "discord_rich_presence.h"
-namespace AttorneyOnline {
+#ifdef AO_ENABLE_DISCORD_RPC
+#include <discord_rpc.h>
+#endif
-#if defined(DISCORD) && !defined(ANDROID)
+namespace AttorneyOnline
+{
+#if defined(AO_ENABLE_DISCORD_RPC) && !defined(ANDROID)
Discord::Discord()
{
DiscordEventHandlers handlers;
std::memset(&handlers, 0, sizeof(handlers));
handlers = {};
- handlers.ready = [] { qInfo() << "Discord RPC ready"; };
+ handlers.ready = [](const DiscordUser *user) {
+ qInfo() << "Discord RPC ready";
+ };
handlers.disconnected = [](int errorCode, const char *message) {
qInfo() << "Discord RPC disconnected! " << message << errorCode;
};
@@ -19,7 +25,10 @@ Discord::Discord()
Discord_Initialize(APPLICATION_ID, &handlers, 1, nullptr);
}
-Discord::~Discord() { Discord_Shutdown(); }
+Discord::~Discord()
+{
+ Discord_Shutdown();
+}
void Discord::state_lobby()
{
@@ -59,12 +68,10 @@ void Discord::state_server(std::string name, std::string server_id)
void Discord::state_character(std::string name)
{
- auto name_internal =
- QString(name.c_str()).toLower().replace(' ', '_').toStdString();
+ auto name_internal = QString(name.c_str()).toLower().replace(' ', '_').toStdString();
auto name_friendly = QString(name.c_str()).replace('_', ' ').toStdString();
const std::string playing_as = "Playing as " + name_friendly;
- qDebug().nospace() << "Discord RPC: Setting character state (\"" << playing_as.c_str()
- << "\")";
+ qDebug().nospace() << "Discord RPC: Setting character state (\"" << playing_as.c_str() << "\")";
DiscordRichPresence presence;
std::memset(&presence, 0, sizeof(presence));
@@ -98,11 +105,14 @@ void Discord::state_spectate()
Discord_UpdatePresence(&presence);
}
#else
-Discord::Discord() {}
+Discord::Discord()
+{}
-Discord::~Discord() {}
+Discord::~Discord()
+{}
-void Discord::state_lobby() {}
+void Discord::state_lobby()
+{}
void Discord::state_server(std::string name, std::string server_id)
{