show discord activity when offline

This commit is contained in:
dobrykafe 2024-04-02 23:57:17 +02:00
parent 3eda861c37
commit 990bb9b1ef

View file

@ -55,6 +55,7 @@ public:
} }
m_pActivityManager = m_pCore->get_activity_manager(m_pCore); m_pActivityManager = m_pCore->get_activity_manager(m_pCore);
ClearGameInfo();
return false; return false;
} }
void Update() override void Update() override
@ -63,7 +64,13 @@ public:
} }
void ClearGameInfo() override void ClearGameInfo() override
{ {
m_pActivityManager->clear_activity(m_pActivityManager, 0, 0); DiscordActivity Activity;
mem_zero(&Activity, sizeof(DiscordActivity));
str_copy(Activity.assets.large_image, "ddnet_logo", sizeof(Activity.assets.large_image));
str_copy(Activity.assets.large_text, "DDNet logo", sizeof(Activity.assets.large_text));
Activity.timestamps.start = time_timestamp();
str_copy(Activity.details, "Offline", sizeof(Activity.details));
m_pActivityManager->update_activity(m_pActivityManager, &Activity, 0, 0);
} }
void SetGameInfo(const NETADDR &ServerAddr, const char *pMapName, bool AnnounceAddr) override void SetGameInfo(const NETADDR &ServerAddr, const char *pMapName, bool AnnounceAddr) override
{ {
@ -72,7 +79,8 @@ public:
str_copy(Activity.assets.large_image, "ddnet_logo", sizeof(Activity.assets.large_image)); str_copy(Activity.assets.large_image, "ddnet_logo", sizeof(Activity.assets.large_image));
str_copy(Activity.assets.large_text, "DDNet logo", sizeof(Activity.assets.large_text)); str_copy(Activity.assets.large_text, "DDNet logo", sizeof(Activity.assets.large_text));
Activity.timestamps.start = time_timestamp(); Activity.timestamps.start = time_timestamp();
str_copy(Activity.details, pMapName, sizeof(Activity.details)); str_copy(Activity.details, "Online", sizeof(Activity.details));
str_copy(Activity.state, pMapName, sizeof(Activity.state));
m_pActivityManager->update_activity(m_pActivityManager, &Activity, 0, 0); m_pActivityManager->update_activity(m_pActivityManager, &Activity, 0, 0);
} }
}; };