Permalink
Browse files

Use new config system for Discord Rich Presence option

This doesn't feel like a mirror change to me.
  • Loading branch information...
yourWaifu committed Jun 6, 2018
1 parent f25d833 commit 57bd13a0ced5694cbeae24413bb5d9fe421a817a
@@ -9,6 +9,7 @@
#include "Common/Config/Config.h"
#include "Core/Config/GraphicsSettings.h"
#include "UICommon/DiscordPresence.h"
namespace ConfigLoaders
{
@@ -115,6 +116,10 @@ bool IsSettingSaveable(const Config::ConfigLocation& config_location)
Config::GFX_PERF_QUERIES_ENABLE.location,
// Main.General
MAIN_USE_DISCORD_PRESENCE.location,
};
return std::find(s_setting_saveable.begin(), s_setting_saveable.end(), config_location) !=
@@ -131,10 +131,6 @@ 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)
@@ -420,9 +416,6 @@ 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)
@@ -71,9 +71,6 @@ struct SConfig
#ifndef _WIN32
std::string gdb_socket;
#endif
#endif
#ifdef USE_DISCORD_PRESENCE
bool bUseDiscordPresence;
#endif
bool bAutomaticStart = false;
bool bBootToPause = false;
@@ -480,19 +480,3 @@ void Settings::SetBatchModeEnabled(bool batch)
{
m_batch = batch;
}
#ifdef USE_DISCORD_PRESENCE
void Settings::SetDiscordPresenceEnabled(bool enabled)
{
if (SConfig::GetInstance().bUseDiscordPresence == enabled)
return;
if (SConfig::GetInstance().bUseDiscordPresence)
Discord::Shutdown();
SConfig::GetInstance().bUseDiscordPresence = enabled;
if (SConfig::GetInstance().bUseDiscordPresence)
Discord::Init();
}
#endif
@@ -127,9 +127,6 @@ class Settings final : public QObject
// Other
GameListModel* GetGameListModel() const;
#ifdef USE_DISCORD_PRESENCE
void SetDiscordPresenceEnabled(bool enabled);
#endif
signals:
void ConfigChanged();
void EmulationStateChanged(Core::State new_state);
@@ -24,6 +24,9 @@
#include "Core/PowerPC/PowerPC.h"
#include "DolphinQt2/Settings.h"
#include "UICommon/AutoUpdate.h"
#ifdef USE_DISCORD_PRESENCE
#include "UICommon/DiscordPresence.h"
#endif
constexpr int AUTO_UPDATE_DISABLE_INDEX = 0;
constexpr int AUTO_UPDATE_STABLE_INDEX = 1;
@@ -127,7 +130,7 @@ void GeneralPane::CreateBasic()
basic_group_layout->addWidget(m_checkbox_cheats);
#ifdef USE_DISCORD_PRESENCE
m_checkbox_discord_presence = new QCheckBox(tr("Show Activity in Your Discord Status"));
m_checkbox_discord_presence = new QCheckBox(tr("Show Current Game on Discord"));
basic_group_layout->addWidget(m_checkbox_discord_presence);
#endif
@@ -224,7 +227,7 @@ void GeneralPane::LoadConfig()
m_checkbox_dualcore->setChecked(SConfig::GetInstance().bCPUThread);
m_checkbox_cheats->setChecked(Settings::Instance().GetCheatsEnabled());
#ifdef USE_DISCORD_PRESENCE
m_checkbox_discord_presence->setChecked(SConfig::GetInstance().bUseDiscordPresence);
m_checkbox_discord_presence->setChecked(Config::Get(MAIN_USE_DISCORD_PRESENCE));
#endif
int selection = qRound(SConfig::GetInstance().m_EmulationSpeed * 10);
if (selection < m_combobox_speedlimit->count())
@@ -272,7 +275,7 @@ void GeneralPane::OnSaveConfig()
}
#ifdef USE_DISCORD_PRESENCE
Settings::Instance().SetDiscordPresenceEnabled(m_checkbox_discord_presence->isChecked());
Discord::SetDiscordPresenceEnabled(m_checkbox_discord_presence->isChecked());
#endif
#if defined(USE_ANALYTICS) && USE_ANALYTICS
@@ -59,8 +59,7 @@ void GeneralConfigPane::InitializeGUI()
m_dual_core_checkbox = new wxCheckBox(this, wxID_ANY, _("Enable Dual Core (speedup)"));
m_cheats_checkbox = new wxCheckBox(this, wxID_ANY, _("Enable Cheats"));
#ifdef USE_DISCORD_PRESENCE
m_discord_presence_checkbox =
new wxCheckBox(this, wxID_ANY, _("Show Activity in Your Discord Status"));
m_discord_presence_checkbox = new wxCheckBox(this, wxID_ANY, _("Show Current Game on Discord"));
#endif
#if defined(USE_ANALYTICS) && USE_ANALYTICS
m_analytics_checkbox = new wxCheckBox(this, wxID_ANY, _("Enable Usage Statistics Reporting"));
@@ -83,8 +82,8 @@ void GeneralConfigPane::InitializeGUI()
m_cheats_checkbox->SetToolTip(_("Enables the use of Action Replay and Gecko cheats."));
#ifdef USE_DISCORD_PRESENCE
m_discord_presence_checkbox->SetToolTip(
_("Allow other people on Discord to see your current activity in Dolphin. Activities such as "
"games you are playing, and how long you've been doing something in Dolphin"));
_("Allow other people on Discord to see the current activity in Dolphin. Activities such as "
"the game being played, and for how long"));
#endif
#if defined(USE_ANALYTICS) && USE_ANALYTICS
m_analytics_checkbox->SetToolTip(
@@ -162,7 +161,7 @@ void GeneralConfigPane::LoadGUIValues()
m_cheats_checkbox->SetValue(startup_params.bEnableCheats);
#ifdef USE_DISCORD_PRESENCE
m_discord_presence_checkbox->SetValue(startup_params.bUseDiscordPresence);
m_discord_presence_checkbox->SetValue(Config::Get(MAIN_USE_DISCORD_PRESENCE));
#endif
#if defined(USE_ANALYTICS) && USE_ANALYTICS
@@ -222,13 +221,7 @@ void GeneralConfigPane::OnCheatCheckBoxChanged(wxCommandEvent& event)
#ifdef USE_DISCORD_PRESENCE
void GeneralConfigPane::OnDiscordPresenceCheckBoxChanged(wxCommandEvent& event)
{
if (SConfig::GetInstance().bUseDiscordPresence)
Discord::Shutdown();
SConfig::GetInstance().bUseDiscordPresence = m_discord_presence_checkbox->IsChecked();
if (SConfig::GetInstance().bUseDiscordPresence)
Discord::Init();
Discord::SetDiscordPresenceEnabled(m_discord_presence_checkbox->IsChecked());
}
#endif
@@ -13,12 +13,15 @@
#endif
const Config::ConfigInfo<bool> MAIN_USE_DISCORD_PRESENCE{
{Config::System::Main, "General", "UseDiscordPresence"}, true};
namespace Discord
{
void Init()
{
#ifdef USE_DISCORD_PRESENCE
if (!SConfig::GetInstance().bUseDiscordPresence)
if (!Config::Get(MAIN_USE_DISCORD_PRESENCE))
return;
DiscordEventHandlers handlers = {};
@@ -31,7 +34,7 @@ void Init()
void UpdateDiscordPresence()
{
#ifdef USE_DISCORD_PRESENCE
if (!SConfig::GetInstance().bUseDiscordPresence)
if (!Config::Get(MAIN_USE_DISCORD_PRESENCE))
return;
const std::string& title = SConfig::GetInstance().GetTitleDescription();
@@ -48,11 +51,26 @@ void UpdateDiscordPresence()
void Shutdown()
{
#ifdef USE_DISCORD_PRESENCE
if (!SConfig::GetInstance().bUseDiscordPresence)
if (!Config::Get(MAIN_USE_DISCORD_PRESENCE))
return;
Discord_ClearPresence();
Discord_Shutdown();
#endif
}
void SetDiscordPresenceEnabled(bool enabled)
{
if (Config::Get(MAIN_USE_DISCORD_PRESENCE) == enabled)
return;
if (Config::Get(MAIN_USE_DISCORD_PRESENCE))
Discord::Shutdown();
Config::SetBase(MAIN_USE_DISCORD_PRESENCE, enabled);
if (Config::Get(MAIN_USE_DISCORD_PRESENCE))
Discord::Init();
}
} // namespace Discord
@@ -4,9 +4,14 @@
#pragma once
#include "Common/Config/Config.h"
namespace Discord
{
void Init();
void UpdateDiscordPresence();
void Shutdown();
void SetDiscordPresenceEnabled(bool enabled);
} // namespace Discord
extern const Config::ConfigInfo<bool> MAIN_USE_DISCORD_PRESENCE;

0 comments on commit 57bd13a

Please sign in to comment.