From e3ad33366b534f934941142ffe9cc591d6c70f58 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Mon, 28 Jun 2021 15:41:58 -0700 Subject: [PATCH] Qt: Add time elapsed to Discord Rich Presence (closes #2225) --- CHANGES | 1 + src/platform/qt/DiscordCoordinator.cpp | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/CHANGES b/CHANGES index 4e5a1ef06..27931a979 100644 --- a/CHANGES +++ b/CHANGES @@ -7,6 +7,7 @@ Features: - Cheat code support in homebrew ports - Support for combo "Super Game Boy Color" SGB + GBC ROM hacks - Support for 64 kiB SRAM saves used in some bootlegs + - Discord Rich Presence now supports time elapsed - Additional scaling shaders Emulation fixes: - GB Memory: Add cursory cartridge open bus emulation (fixes mgba.io/i/2032) diff --git a/src/platform/qt/DiscordCoordinator.cpp b/src/platform/qt/DiscordCoordinator.cpp index ab6a0445a..b090863cd 100644 --- a/src/platform/qt/DiscordCoordinator.cpp +++ b/src/platform/qt/DiscordCoordinator.cpp @@ -5,6 +5,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "DiscordCoordinator.h" +#include + #include "CoreController.h" #include "GBAApp.h" @@ -31,6 +33,11 @@ static void updatePresence() { discordPresence.details = s_title.toUtf8().constData(); discordPresence.instance = 1; discordPresence.largeImageKey = "mgba"; +#if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0)) + discordPresence.startTimestamp = QDateTime::currentSecsSinceEpoch(); +#else + discordPresence.startTimestamp = QDateTime::currentMSecsSinceEpoch() / 1000; +#endif Discord_UpdatePresence(&discordPresence); } else { Discord_ClearPresence();