From c9f52b7223685d2e7fca925594171f94dd8c6e3b Mon Sep 17 00:00:00 2001 From: TrickyLeifa Date: Wed, 15 May 2024 00:00:17 +0200 Subject: 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 --- src/discord_rich_presence.cpp | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'src/discord_rich_presence.cpp') diff --git a/src/discord_rich_presence.cpp b/src/discord_rich_presence.cpp index 81e5a86..6969334 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) { -- cgit From db5ceb056955eff1018ea991e0117d6892366f2e Mon Sep 17 00:00:00 2001 From: TrickyLeifa Date: Sat, 18 May 2024 02:21:17 +0200 Subject: No longer required Discord-RPC headers when disabled --- src/discord_rich_presence.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/discord_rich_presence.cpp') diff --git a/src/discord_rich_presence.cpp b/src/discord_rich_presence.cpp index 6969334..c22a6f6 100644 --- a/src/discord_rich_presence.cpp +++ b/src/discord_rich_presence.cpp @@ -1,8 +1,11 @@ #include "discord_rich_presence.h" +#ifdef AO_ENABLE_DISCORD_RPC +#include +#endif + namespace AttorneyOnline { - #if defined(AO_ENABLE_DISCORD_RPC) && !defined(ANDROID) Discord::Discord() { -- cgit