aboutsummaryrefslogtreecommitdiff
path: root/src/discord_rich_presence.cpp
diff options
context:
space:
mode:
authorTrickyLeifa <date.epoch@gmail.com>2024-05-15 00:00:17 +0200
committerTrickyLeifa <date.epoch@gmail.com>2024-05-15 00:04:16 +0200
commitc9f52b7223685d2e7fca925594171f94dd8c6e3b (patch)
tree740bb32a40da98a4d52836432f59a16b31333900 /src/discord_rich_presence.cpp
parent951766666621fa77e257e6b5616fe4ab1eb2a52f (diff)
Ported to CMake, ...
* Ported the project to CMake * Android and Mac support dropped for the time being. * Tests, BASS and Discord-RPC are now options * Restructured and reformated the project. * Merged `include` and `src` * Renamed `resource` to `data` * Renamed various files * External libraries headers are no longer included in `src` * Replaced header guards with #pragma once * Multiple refactors (keywords, headers) * Added Qt6 compatibility * Removed various unused functions and headers * Reworked AOPacket * When content is passed to AOPacket, it should be ensured that the content is already decoded. * Encoding/decoding are now static methods. * Fixed various memory leaks * Removed animation code for AOImage * AOImage is always using static images * Simplified ChatLogPiece
Diffstat (limited to 'src/discord_rich_presence.cpp')
-rw-r--r--src/discord_rich_presence.cpp29
1 files changed, 18 insertions, 11 deletions
diff --git a/src/discord_rich_presence.cpp b/src/discord_rich_presence.cpp
index 81e5a86c..6969334f 100644
--- a/src/discord_rich_presence.cpp
+++ b/src/discord_rich_presence.cpp
@@ -1,14 +1,17 @@
#include "discord_rich_presence.h"
-namespace AttorneyOnline {
+namespace AttorneyOnline
+{
-#if defined(DISCORD) && !defined(ANDROID)
+#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 +22,10 @@ Discord::Discord()
Discord_Initialize(APPLICATION_ID, &handlers, 1, nullptr);
}
-Discord::~Discord() { Discord_Shutdown(); }
+Discord::~Discord()
+{
+ Discord_Shutdown();
+}
void Discord::state_lobby()
{
@@ -59,12 +65,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 +102,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)
{