mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-17 12:03:07 +01:00
Delay presence refresh to 5s interval
This commit is contained in:
@@ -17,18 +17,19 @@
|
||||
#ifdef __ENABLE_DISCORD__
|
||||
|
||||
#include <discord-rpc.h>
|
||||
#include "../Context.h"
|
||||
#include "../core/Console.hpp"
|
||||
#include "../core/Memory.hpp"
|
||||
#include "../core/String.hpp"
|
||||
#include "../localisation/localisation.h"
|
||||
#include "../OpenRCT2.h"
|
||||
#include "../scenario/scenario.h"
|
||||
#include "../world/park.h"
|
||||
#include "DiscordService.h"
|
||||
#include "network.h"
|
||||
|
||||
constexpr const char * APPLICATION_ID = "378612438200877056";
|
||||
constexpr const char * STEAM_APP_ID = nullptr;
|
||||
constexpr const uint32 REFRESH_INTERVAL = 5 * GAME_UPDATE_FPS; // 5 seconds
|
||||
|
||||
static void OnReady()
|
||||
{
|
||||
@@ -71,6 +72,19 @@ void DiscordService::Update()
|
||||
{
|
||||
Discord_RunCallbacks();
|
||||
|
||||
if (_ticksSinceLastRefresh >= REFRESH_INTERVAL)
|
||||
{
|
||||
_ticksSinceLastRefresh = 0;
|
||||
RefreshPresence();
|
||||
}
|
||||
else
|
||||
{
|
||||
_ticksSinceLastRefresh++;
|
||||
}
|
||||
}
|
||||
|
||||
void DiscordService::RefreshPresence()
|
||||
{
|
||||
DiscordRichPresence discordPresence;
|
||||
Memory::Set(&discordPresence, 0, sizeof(discordPresence));
|
||||
discordPresence.largeImageKey = "logo";
|
||||
@@ -110,7 +124,7 @@ void DiscordService::Update()
|
||||
details = "In Track Designer";
|
||||
break;
|
||||
case SCREEN_FLAGS_TRACK_MANAGER:
|
||||
details = "In Track Manager";
|
||||
details = "In Track Designs Manager";
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,13 +18,22 @@
|
||||
|
||||
#ifdef __ENABLE_DISCORD__
|
||||
|
||||
#include "../common.h"
|
||||
#include <limits>
|
||||
|
||||
class DiscordService
|
||||
{
|
||||
private:
|
||||
uint32 _ticksSinceLastRefresh = std::numeric_limits<uint32>::max();
|
||||
|
||||
public:
|
||||
DiscordService();
|
||||
~DiscordService();
|
||||
|
||||
void Update();
|
||||
|
||||
private:
|
||||
void RefreshPresence();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user