Added INI setting for Discord Rich Presence

This commit is contained in:
Sleepy Flower Girl 2018-05-29 23:44:20 -04:00
parent 678f8da95b
commit d9351a5b45
5 changed files with 27 additions and 0 deletions

View File

@ -131,6 +131,10 @@ void SConfig::SaveGeneralSettings(IniFile& ini)
#endif
general->Set("GDBPort", iGDBPort);
#endif
#ifdef USE_DISCORD_PRESENCE
general->Set("UseDiscordPresence", bUseDiscordPresence);
#endif
}
void SConfig::SaveInterfaceSettings(IniFile& ini)
@ -416,6 +420,9 @@ void SConfig::LoadGeneralSettings(IniFile& ini)
general->Get("RecursiveISOPaths", &m_RecursiveISOFolder, false);
general->Get("WirelessMac", &m_WirelessMac);
#ifdef USE_DISCORD_PRESENCE
general->Get("UseDiscordPresence", &bUseDiscordPresence, true);
#endif
}
void SConfig::LoadInterfaceSettings(IniFile& ini)

View File

@ -71,6 +71,9 @@ struct SConfig
#ifndef _WIN32
std::string gdb_socket;
#endif
#endif
#ifdef USE_DISCORD_PRESENCE
bool bUseDiscordPresence;
#endif
bool bAutomaticStart = false;
bool bBootToPause = false;

View File

@ -570,7 +570,9 @@ void MainWindow::OnStopComplete()
m_stop_requested = false;
HideRenderWidget();
EnableScreenSaver(true);
#ifdef USE_DISCORD_PRESENCE
Discord::UpdateDiscordPresence();
#endif
SetFullScreenResolution(false);
@ -721,7 +723,9 @@ void MainWindow::StartGame(std::unique_ptr<BootParameters>&& parameters)
return;
}
ShowRenderWidget();
#ifdef USE_DISCORD_PRESENCE
Discord::UpdateDiscordPresence();
#endif
#ifdef Q_OS_WIN
// Prevents Windows from sleeping, turning off the display, or idling

View File

@ -745,7 +745,9 @@ void CFrame::StartGame(std::unique_ptr<BootParameters> boot)
else
{
EnableScreenSaver(false);
#ifdef USE_DISCORD_PRESENCE
Discord::UpdateDiscordPresence();
#endif
// We need this specifically to support setting the focus properly when using
// the 'render to main window' feature on Windows
@ -932,7 +934,9 @@ void CFrame::OnStopped()
wxPostEvent(GetMenuBar(), wxCommandEvent{DOLPHIN_EVT_UPDATE_LOAD_WII_MENU_ITEM});
EnableScreenSaver(true);
#ifdef USE_DISCORD_PRESENCE
Discord::UpdateDiscordPresence();
#endif
m_render_frame->SetTitle(StrToWxStr(Common::scm_rev_str));

View File

@ -18,6 +18,9 @@ namespace Discord
void Init()
{
#ifdef USE_DISCORD_PRESENCE
if (!SConfig::GetInstance().bUseDiscordPresence)
return;
DiscordEventHandlers handlers = {};
// The number is the client ID for Dolphin, it's used for images and the appication name
Discord_Initialize("450033159212630028", &handlers, 1, nullptr);
@ -28,6 +31,9 @@ void Init()
void UpdateDiscordPresence()
{
#ifdef USE_DISCORD_PRESENCE
if (!SConfig::GetInstance().bUseDiscordPresence)
return;
const std::string& title = SConfig::GetInstance().GetTitleDescription();
DiscordRichPresence discord_presence = {};
@ -42,6 +48,9 @@ void UpdateDiscordPresence()
void Shutdown()
{
#ifdef USE_DISCORD_PRESENCE
if (!SConfig::GetInstance().bUseDiscordPresence)
return;
Discord_Shutdown();
#endif
}