|
| 1 | +#pragma once |
| 2 | + |
| 3 | +#include "GameNetwork/GeneralsOnline/Vendor/DiscordRPC/discord_rpc.h" |
| 4 | + |
| 5 | +#include <chrono> |
| 6 | +#include <string> |
| 7 | + |
| 8 | +class NGMP_OnlineServices_LobbyInterface; |
| 9 | + |
| 10 | +// TheSuperHackers @feature ultimate2000 19/07/2026 Adds Discord Rich Presence |
| 11 | +// for Generals Online lobbies and matches. |
| 12 | +class GeneralsOnlineDiscordRPC { |
| 13 | +public: |
| 14 | + GeneralsOnlineDiscordRPC() = default; |
| 15 | + ~GeneralsOnlineDiscordRPC(); |
| 16 | + |
| 17 | + bool Initialize(); |
| 18 | + void Shutdown(); |
| 19 | + void Tick(const NGMP_OnlineServices_LobbyInterface *lobbyInterface); |
| 20 | + |
| 21 | +private: |
| 22 | + using InitializeFunction = void (*)(const char *, DiscordEventHandlers *, int, |
| 23 | + const char *); |
| 24 | + using ShutdownFunction = void (*)(); |
| 25 | + using RunCallbacksFunction = void (*)(); |
| 26 | + using UpdatePresenceFunction = void (*)(const DiscordRichPresence *); |
| 27 | + using ClearPresenceFunction = void (*)(); |
| 28 | + |
| 29 | + struct PresenceData { |
| 30 | + std::string state; |
| 31 | + std::string details; |
| 32 | + std::string largeImageKey; |
| 33 | + std::string largeImageText; |
| 34 | + std::string smallImageKey; |
| 35 | + std::string smallImageText; |
| 36 | + std::string partyId; |
| 37 | + int partySize = 0; |
| 38 | + int partyMax = 0; |
| 39 | + |
| 40 | + std::string Fingerprint() const; |
| 41 | + }; |
| 42 | + |
| 43 | + PresenceData |
| 44 | + BuildPresence(const NGMP_OnlineServices_LobbyInterface *lobbyInterface) const; |
| 45 | + void UpdatePresence(const PresenceData &data); |
| 46 | + void ResetFunctions(); |
| 47 | + |
| 48 | + void *m_module = nullptr; |
| 49 | + InitializeFunction m_initialize = nullptr; |
| 50 | + ShutdownFunction m_shutdown = nullptr; |
| 51 | + RunCallbacksFunction m_runCallbacks = nullptr; |
| 52 | + UpdatePresenceFunction m_updatePresence = nullptr; |
| 53 | + ClearPresenceFunction m_clearPresence = nullptr; |
| 54 | + bool m_initialized = false; |
| 55 | + std::string m_lastPresence; |
| 56 | + std::chrono::steady_clock::time_point m_nextPresenceUpdate; |
| 57 | +}; |
0 commit comments