Merge pull request #8181 from dobrykafe/pr-discord-activity

Show Discord activity when offline
This commit is contained in:
Dennis Felsing 2024-04-03 05:35:16 +00:00 committed by GitHub
commit e263ce9bdc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -55,6 +55,7 @@ public:
}
m_pActivityManager = m_pCore->get_activity_manager(m_pCore);
ClearGameInfo();
return false;
}
void Update() override
@ -63,7 +64,13 @@ public:
}
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
{
@ -72,7 +79,8 @@ public:
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, 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);
}
};