Skip to content

Commit

Permalink
Port some settings to the new config system
Browse files Browse the repository at this point in the history
Other than the controller settings and JIT debug settings,
these are the only settings which were defined in Java code
but not defined in the new config system in C++. (There are
still a lot of settings that are defined in the new config
system but not yet saveable in the new config system, though.)
  • Loading branch information
JosJuice committed Aug 3, 2020
1 parent 25ebc3c commit b0f9bb9
Show file tree
Hide file tree
Showing 15 changed files with 68 additions and 68 deletions.
9 changes: 5 additions & 4 deletions Source/Core/Core/Analytics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "Common/Analytics.h"
#include "Common/CPUDetect.h"
#include "Common/CommonTypes.h"
#include "Common/Config/Config.h"
#include "Common/Random.h"
#include "Common/Timer.h"
#include "Common/Version.h"
Expand Down Expand Up @@ -65,7 +66,7 @@ void DolphinAnalytics::ReloadConfig()

// Install the HTTP backend if analytics support is enabled.
std::unique_ptr<Common::AnalyticsReportingBackend> new_backend;
if (SConfig::GetInstance().m_analytics_enabled)
if (Config::Get(Config::MAIN_ANALYTICS_ENABLED))
{
#if defined(ANDROID)
new_backend = std::make_unique<Common::AndroidAnalyticsBackend>(ANALYTICS_ENDPOINT);
Expand All @@ -76,7 +77,7 @@ void DolphinAnalytics::ReloadConfig()
m_reporter.SetBackend(std::move(new_backend));

// Load the unique ID or generate it if needed.
m_unique_id = SConfig::GetInstance().m_analytics_id;
m_unique_id = Config::Get(Config::MAIN_ANALYTICS_ID);
if (m_unique_id.empty())
{
GenerateNewIdentity();
Expand All @@ -90,8 +91,8 @@ void DolphinAnalytics::GenerateNewIdentity()
m_unique_id = fmt::format("{:016x}{:016x}", id_high, id_low);

// Save the new id in the configuration.
SConfig::GetInstance().m_analytics_id = m_unique_id;
SConfig::GetInstance().SaveSettings();
Config::SetBase(Config::MAIN_ANALYTICS_ID, m_unique_id);
Config::Save();
}

std::string DolphinAnalytics::MakeUniqueId(std::string_view data) const
Expand Down
11 changes: 11 additions & 0 deletions Source/Core/Core/Config/MainSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ const Info<bool> MAIN_CUSTOM_RTC_ENABLE{{System::Main, "Core", "EnableCustomRTC"
const Info<u32> MAIN_CUSTOM_RTC_VALUE{{System::Main, "Core", "CustomRTCValue"}, 946684800};
const Info<bool> MAIN_AUTO_DISC_CHANGE{{System::Main, "Core", "AutoDiscChange"}, false};
const Info<bool> MAIN_ALLOW_SD_WRITES{{System::Main, "Core", "WiiSDCardAllowWrites"}, true};
const Info<bool> MAIN_ENABLE_SAVESTATES{{System::Main, "Core", "EnableSaveStates"}, false};

// Main.Display

Expand Down Expand Up @@ -153,5 +154,15 @@ const Info<bool> MAIN_NETWORK_SSL_DUMP_PEER_CERT{{System::Main, "Network", "SSLD

// Main.Interface

const Info<bool> MAIN_USE_PANIC_HANDLERS{{System::Main, "Interface", "UsePanicHandlers"}, true};
const Info<bool> MAIN_OSD_MESSAGES{{System::Main, "Interface", "OnScreenDisplayMessages"}, true};
const Info<bool> MAIN_SKIP_NKIT_WARNING{{System::Main, "Interface", "SkipNKitWarning"}, false};

// Main.Analytics

const Info<std::string> MAIN_ANALYTICS_ID{{System::Main, "Analytics", "ID"}, ""};
const Info<bool> MAIN_ANALYTICS_ENABLED{{System::Main, "Analytics", "Enabled"}, false};
const Info<bool> MAIN_ANALYTICS_PERMISSION_ASKED{{System::Main, "Analytics", "PermissionAsked"},
false};

} // namespace Config
9 changes: 9 additions & 0 deletions Source/Core/Core/Config/MainSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ extern const Info<bool> MAIN_CUSTOM_RTC_ENABLE;
extern const Info<u32> MAIN_CUSTOM_RTC_VALUE;
extern const Info<bool> MAIN_AUTO_DISC_CHANGE;
extern const Info<bool> MAIN_ALLOW_SD_WRITES;
extern const Info<bool> MAIN_ENABLE_SAVESTATES;

// Main.DSP

Expand Down Expand Up @@ -129,5 +130,13 @@ extern const Info<bool> MAIN_NETWORK_SSL_DUMP_PEER_CERT;

// Main.Interface

extern const Info<bool> MAIN_USE_PANIC_HANDLERS;
extern const Info<bool> MAIN_OSD_MESSAGES;
extern const Info<bool> MAIN_SKIP_NKIT_WARNING;

// Main.Analytics

extern const Info<std::string> MAIN_ANALYTICS_ID;
extern const Info<bool> MAIN_ANALYTICS_ENABLED;
extern const Info<bool> MAIN_ANALYTICS_PERMISSION_ASKED;
} // namespace Config
6 changes: 5 additions & 1 deletion Source/Core/Core/Config/UISettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ namespace Config

const Info<bool> MAIN_USE_DISCORD_PRESENCE{{System::Main, "General", "UseDiscordPresence"}, true};
const Info<bool> MAIN_USE_GAME_COVERS{{System::Main, "General", "UseGameCovers"}, false};

const Info<bool> MAIN_FOCUSED_HOTKEYS{{System::Main, "General", "HotkeysRequireFocus"}, true};
const Info<bool> MAIN_RECURSIVE_ISO_PATHS{{System::Main, "General", "RecursiveISOPaths"}, false};

// UI.Android

const Info<int> MAIN_LAST_PLATFORM_TAB{{System::Main, "Android", "LastPlatformTab"}, 0};

} // namespace Config
7 changes: 6 additions & 1 deletion Source/Core/Core/Config/UISettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "Common/Config/Config.h"

// This is a temporary soluation, although they should be in their repected cpp file in UICommon.
// However, in order for IsSettingSaveable to commpile without some issues, this needs to be here.
// However, in order for IsSettingSaveable to compile without some issues, this needs to be here.
// Once IsSettingSaveable is removed, then you should able to move these back to UICommon.

namespace Config
Expand All @@ -19,5 +19,10 @@ namespace Config
extern const Info<bool> MAIN_USE_DISCORD_PRESENCE;
extern const Info<bool> MAIN_USE_GAME_COVERS;
extern const Info<bool> MAIN_FOCUSED_HOTKEYS;
extern const Info<bool> MAIN_RECURSIVE_ISO_PATHS;

// UI.Android

extern const Info<int> MAIN_LAST_PLATFORM_TAB;

} // namespace Config
11 changes: 9 additions & 2 deletions Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ bool IsSettingSaveable(const Config::Location& config_location)

if (config_location.system == Config::System::Main)
{
for (const char* section : {"NetPlay", "General", "Display", "Network"})
for (const std::string& section :
{"NetPlay", "General", "Display", "Network", "Analytics", "Android"})
{
if (config_location.section == section)
return true;
}
}

static constexpr std::array<const Config::Location*, 13> s_setting_saveable = {
static constexpr std::array<const Config::Location*, 16> s_setting_saveable = {
// Main.Core

&Config::MAIN_DEFAULT_ISO.location,
Expand All @@ -46,6 +47,12 @@ bool IsSettingSaveable(const Config::Location& config_location)
&Config::MAIN_MEM1_SIZE.location,
&Config::MAIN_MEM2_SIZE.location,
&Config::MAIN_GFX_BACKEND.location,
&Config::MAIN_ENABLE_SAVESTATES.location,

// Main.Interface

&Config::MAIN_USE_PANIC_HANDLERS.location,
&Config::MAIN_OSD_MESSAGES.location,

// Main.Interface

Expand Down
32 changes: 0 additions & 32 deletions Source/Core/Core/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ void SConfig::SaveSettings()
SaveDSPSettings(ini);
SaveInputSettings(ini);
SaveFifoPlayerSettings(ini);
SaveAnalyticsSettings(ini);
SaveBluetoothPassthroughSettings(ini);
SaveUSBPassthroughSettings(ini);
SaveAutoUpdateSettings(ini);
Expand Down Expand Up @@ -127,7 +126,6 @@ void SConfig::SaveGeneralSettings(IniFile& ini)
general->Set(fmt::format("ISOPath{}", i), m_ISOFolder[i]);
}

general->Set("RecursiveISOPaths", m_RecursiveISOFolder);
general->Set("WirelessMac", m_WirelessMac);

#ifdef USE_GDBSTUB
Expand All @@ -143,8 +141,6 @@ void SConfig::SaveInterfaceSettings(IniFile& ini)
IniFile::Section* interface = ini.GetOrCreateSection("Interface");

interface->Set("ConfirmStop", bConfirmStop);
interface->Set("UsePanicHandlers", bUsePanicHandlers);
interface->Set("OnScreenDisplayMessages", bOnScreenDisplayMessages);
interface->Set("HideCursor", bHideCursor);
interface->Set("LanguageCode", m_InterfaceLanguage);
interface->Set("ExtendedFPSInfo", m_InterfaceExtendedFPSInfo);
Expand Down Expand Up @@ -295,15 +291,6 @@ void SConfig::SaveFifoPlayerSettings(IniFile& ini)
fifoplayer->Set("LoopReplay", bLoopFifoReplay);
}

void SConfig::SaveAnalyticsSettings(IniFile& ini)
{
IniFile::Section* analytics = ini.GetOrCreateSection("Analytics");

analytics->Set("ID", m_analytics_id);
analytics->Set("Enabled", m_analytics_enabled);
analytics->Set("PermissionAsked", m_analytics_permission_asked);
}

void SConfig::SaveBluetoothPassthroughSettings(IniFile& ini)
{
IniFile::Section* section = ini.GetOrCreateSection("BluetoothPassthrough");
Expand Down Expand Up @@ -368,7 +355,6 @@ void SConfig::LoadSettings()
LoadDSPSettings(ini);
LoadInputSettings(ini);
LoadFifoPlayerSettings(ini);
LoadAnalyticsSettings(ini);
LoadBluetoothPassthroughSettings(ini);
LoadUSBPassthroughSettings(ini);
LoadAutoUpdateSettings(ini);
Expand Down Expand Up @@ -401,7 +387,6 @@ void SConfig::LoadGeneralSettings(IniFile& ini)
}
}

general->Get("RecursiveISOPaths", &m_RecursiveISOFolder, false);
general->Get("WirelessMac", &m_WirelessMac);
}

Expand All @@ -410,8 +395,6 @@ void SConfig::LoadInterfaceSettings(IniFile& ini)
IniFile::Section* interface = ini.GetOrCreateSection("Interface");

interface->Get("ConfirmStop", &bConfirmStop, true);
interface->Get("UsePanicHandlers", &bUsePanicHandlers, true);
interface->Get("OnScreenDisplayMessages", &bOnScreenDisplayMessages, true);
interface->Get("HideCursor", &bHideCursor, false);
interface->Get("LanguageCode", &m_InterfaceLanguage, "");
interface->Get("ExtendedFPSInfo", &m_InterfaceExtendedFPSInfo, false);
Expand Down Expand Up @@ -578,15 +561,6 @@ void SConfig::LoadFifoPlayerSettings(IniFile& ini)
fifoplayer->Get("LoopReplay", &bLoopFifoReplay, true);
}

void SConfig::LoadAnalyticsSettings(IniFile& ini)
{
IniFile::Section* analytics = ini.GetOrCreateSection("Analytics");

analytics->Get("ID", &m_analytics_id, "");
analytics->Get("Enabled", &m_analytics_enabled, false);
analytics->Get("PermissionAsked", &m_analytics_permission_asked, false);
}

void SConfig::LoadBluetoothPassthroughSettings(IniFile& ini)
{
IniFile::Section* section = ini.GetOrCreateSection("BluetoothPassthrough");
Expand Down Expand Up @@ -771,12 +745,6 @@ void SConfig::LoadDefaults()
iLatency = 20;
m_audio_stretch = false;
m_audio_stretch_max_latency = 80;
bUsePanicHandlers = true;
bOnScreenDisplayMessages = true;

m_analytics_id = "";
m_analytics_enabled = false;
m_analytics_permission_asked = false;

bLoopFifoReplay = true;

Expand Down
10 changes: 0 additions & 10 deletions Source/Core/Core/ConfigManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ struct SConfig

// ISO folder
std::vector<std::string> m_ISOFolder;
bool m_RecursiveISOFolder;

// Settings
bool bEnableDebugging = false;
Expand Down Expand Up @@ -149,15 +148,8 @@ struct SConfig
// Interface settings
bool bConfirmStop = false;
bool bHideCursor = false;
bool bUsePanicHandlers = true;
bool bOnScreenDisplayMessages = true;
std::string theme_name;

// Analytics settings.
std::string m_analytics_id;
bool m_analytics_enabled = false;
bool m_analytics_permission_asked = false;

// Bluetooth passthrough mode settings
bool m_bt_passthrough_enabled = false;
int m_bt_passthrough_pid = -1;
Expand Down Expand Up @@ -343,7 +335,6 @@ struct SConfig
void SaveInputSettings(IniFile& ini);
void SaveMovieSettings(IniFile& ini);
void SaveFifoPlayerSettings(IniFile& ini);
void SaveAnalyticsSettings(IniFile& ini);
void SaveBluetoothPassthroughSettings(IniFile& ini);
void SaveUSBPassthroughSettings(IniFile& ini);
void SaveAutoUpdateSettings(IniFile& ini);
Expand All @@ -357,7 +348,6 @@ struct SConfig
void LoadInputSettings(IniFile& ini);
void LoadMovieSettings(IniFile& ini);
void LoadFifoPlayerSettings(IniFile& ini);
void LoadAnalyticsSettings(IniFile& ini);
void LoadBluetoothPassthroughSettings(IniFile& ini);
void LoadUSBPassthroughSettings(IniFile& ini);
void LoadAutoUpdateSettings(IniFile& ini);
Expand Down
6 changes: 4 additions & 2 deletions Source/Core/DolphinQt/GameList/GameTracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
#include <QDirIterator>
#include <QFile>

#include "Core/ConfigManager.h"
#include "Common/Config/Config.h"

#include "Core/Config/UISettings.h"

#include "DiscIO/DirectoryBlob.h"

Expand Down Expand Up @@ -224,7 +226,7 @@ void GameTracker::AddDirectoryInternal(const QString& dir)
static std::unique_ptr<QDirIterator> GetIterator(const QString& dir)
{
return std::make_unique<QDirIterator>(dir, game_filters, QDir::NoFilter,
SConfig::GetInstance().m_RecursiveISOFolder ?
Config::Get(Config::MAIN_RECURSIVE_ISO_PATHS) ?
QDirIterator::Subdirectories :
QDirIterator::NoIteratorFlags);
}
Expand Down
7 changes: 4 additions & 3 deletions Source/Core/DolphinQt/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@
#include <QPushButton>
#include <QWidget>

#include "Common/Config/Config.h"
#include "Common/MsgHandler.h"
#include "Common/ScopeGuard.h"

#include "Core/Analytics.h"
#include "Core/Boot/Boot.h"
#include "Core/ConfigManager.h"
#include "Core/Config/MainSettings.h"
#include "Core/Core.h"

#include "DolphinQt/Host.h"
Expand Down Expand Up @@ -219,7 +220,7 @@ int main(int argc, char* argv[])
win.Show();

#if defined(USE_ANALYTICS) && USE_ANALYTICS
if (!SConfig::GetInstance().m_analytics_permission_asked)
if (!Config::Get(Config::MAIN_ANALYTICS_PERMISSION_ASKED))
{
ModalMessageBox analytics_prompt(&win);

Expand All @@ -241,7 +242,7 @@ int main(int argc, char* argv[])

const int answer = analytics_prompt.exec();

SConfig::GetInstance().m_analytics_permission_asked = true;
Config::SetBase(Config::MAIN_ANALYTICS_PERMISSION_ASKED, true);
Settings::Instance().SetAnalyticsEnabled(answer == QMessageBox::Yes);

DolphinAnalytics::Instance().ReloadConfig();
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/DolphinQt/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -515,14 +515,14 @@ void Settings::SetAnalyticsEnabled(bool enabled)
if (enabled == IsAnalyticsEnabled())
return;

SConfig::GetInstance().m_analytics_enabled = enabled;
Config::SetBase(Config::MAIN_ANALYTICS_PERMISSION_ASKED, enabled);

emit AnalyticsToggled(enabled);
}

bool Settings::IsAnalyticsEnabled() const
{
return SConfig::GetInstance().m_analytics_enabled;
return Config::Get(Config::MAIN_ANALYTICS_PERMISSION_ASKED);
}

void Settings::SetToolBarVisible(bool visible)
Expand Down
11 changes: 6 additions & 5 deletions Source/Core/DolphinQt/Settings/InterfacePane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "Common/MsgHandler.h"
#include "Common/StringUtil.h"

#include "Core/Config/MainSettings.h"
#include "Core/Config/UISettings.h"
#include "Core/ConfigManager.h"

Expand Down Expand Up @@ -229,8 +230,8 @@ void InterfacePane::LoadConfig()
// Render Window Options
m_checkbox_top_window->setChecked(Settings::Instance().IsKeepWindowOnTopEnabled());
m_checkbox_confirm_on_stop->setChecked(startup_params.bConfirmStop);
m_checkbox_use_panic_handlers->setChecked(startup_params.bUsePanicHandlers);
m_checkbox_enable_osd->setChecked(startup_params.bOnScreenDisplayMessages);
m_checkbox_use_panic_handlers->setChecked(Config::Get(Config::MAIN_USE_PANIC_HANDLERS));
m_checkbox_enable_osd->setChecked(Config::Get(Config::MAIN_OSD_MESSAGES));
m_checkbox_show_active_title->setChecked(startup_params.m_show_active_title);
m_checkbox_pause_on_focus_lost->setChecked(startup_params.m_PauseOnFocusLost);
m_checkbox_use_covers->setChecked(Config::Get(Config::MAIN_USE_GAME_COVERS));
Expand All @@ -254,12 +255,12 @@ void InterfacePane::OnSaveConfig()
// Render Window Options
Settings::Instance().SetKeepWindowOnTop(m_checkbox_top_window->isChecked());
settings.bConfirmStop = m_checkbox_confirm_on_stop->isChecked();
settings.bUsePanicHandlers = m_checkbox_use_panic_handlers->isChecked();
settings.bOnScreenDisplayMessages = m_checkbox_enable_osd->isChecked();
Config::SetBase(Config::MAIN_USE_PANIC_HANDLERS, m_checkbox_use_panic_handlers->isChecked());
Config::SetBase(Config::MAIN_OSD_MESSAGES, m_checkbox_enable_osd->isChecked());
settings.m_show_active_title = m_checkbox_show_active_title->isChecked();
settings.m_PauseOnFocusLost = m_checkbox_pause_on_focus_lost->isChecked();

Common::SetEnableAlert(settings.bUsePanicHandlers);
Common::SetEnableAlert(Config::Get(Config::MAIN_USE_PANIC_HANDLERS));

auto new_language = m_combobox_language->currentData().toString().toStdString();
if (new_language != SConfig::GetInstance().m_InterfaceLanguage)
Expand Down
Loading

0 comments on commit b0f9bb9

Please sign in to comment.