Merge pull request #9311 from JosJuice/config-get-fast-2

Add caching to Config::Info
This commit is contained in:
Léo Lam 2020-12-13 03:55:39 +01:00 committed by GitHub
commit 3634508e46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 188 additions and 83 deletions

View File

@ -86,7 +86,7 @@ template <typename T>
static void Set(jint layer, const Config::Location& location, T value) static void Set(jint layer, const Config::Location& location, T value)
{ {
GetLayer(layer, location)->Set(location, value); GetLayer(layer, location)->Set(location, value);
Config::InvokeConfigChangedCallbacks(); Config::OnConfigChanged();
} }
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -3,6 +3,7 @@
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <algorithm> #include <algorithm>
#include <atomic>
#include <list> #include <list>
#include <map> #include <map>
#include <mutex> #include <mutex>
@ -17,6 +18,7 @@ using Layers = std::map<LayerType, std::shared_ptr<Layer>>;
static Layers s_layers; static Layers s_layers;
static std::list<ConfigChangedCallback> s_callbacks; static std::list<ConfigChangedCallback> s_callbacks;
static u32 s_callback_guards = 0; static u32 s_callback_guards = 0;
static std::atomic<u64> s_config_version = 0;
static std::shared_mutex s_layers_rw_lock; static std::shared_mutex s_layers_rw_lock;
@ -31,7 +33,7 @@ static void AddLayerInternal(std::shared_ptr<Layer> layer)
const Config::LayerType layer_type = layer->GetLayer(); const Config::LayerType layer_type = layer->GetLayer();
s_layers.insert_or_assign(layer_type, std::move(layer)); s_layers.insert_or_assign(layer_type, std::move(layer));
} }
InvokeConfigChangedCallbacks(); OnConfigChanged();
} }
void AddLayer(std::unique_ptr<ConfigLayerLoader> loader) void AddLayer(std::unique_ptr<ConfigLayerLoader> loader)
@ -59,7 +61,7 @@ void RemoveLayer(LayerType layer)
s_layers.erase(layer); s_layers.erase(layer);
} }
InvokeConfigChangedCallbacks(); OnConfigChanged();
} }
void AddConfigChangedCallback(ConfigChangedCallback func) void AddConfigChangedCallback(ConfigChangedCallback func)
@ -67,15 +69,22 @@ void AddConfigChangedCallback(ConfigChangedCallback func)
s_callbacks.emplace_back(std::move(func)); s_callbacks.emplace_back(std::move(func));
} }
void InvokeConfigChangedCallbacks() void OnConfigChanged()
{ {
if (s_callback_guards) if (s_callback_guards)
return; return;
s_config_version.fetch_add(1, std::memory_order_relaxed);
for (const auto& callback : s_callbacks) for (const auto& callback : s_callbacks)
callback(); callback();
} }
u64 GetConfigVersion()
{
return s_config_version.load(std::memory_order_relaxed);
}
// Explicit load and save of layers // Explicit load and save of layers
void Load() void Load()
{ {
@ -85,7 +94,7 @@ void Load()
for (auto& layer : s_layers) for (auto& layer : s_layers)
layer.second->Load(); layer.second->Load();
} }
InvokeConfigChangedCallbacks(); OnConfigChanged();
} }
void Save() void Save()
@ -96,7 +105,7 @@ void Save()
for (auto& layer : s_layers) for (auto& layer : s_layers)
layer.second->Save(); layer.second->Save();
} }
InvokeConfigChangedCallbacks(); OnConfigChanged();
} }
void Init() void Init()
@ -207,7 +216,7 @@ ConfigChangeCallbackGuard::~ConfigChangeCallbackGuard()
if (--s_callback_guards) if (--s_callback_guards)
return; return;
InvokeConfigChangedCallbacks(); OnConfigChanged();
} }
} // namespace Config } // namespace Config

View File

@ -24,7 +24,10 @@ std::shared_ptr<Layer> GetLayer(LayerType layer);
void RemoveLayer(LayerType layer); void RemoveLayer(LayerType layer);
void AddConfigChangedCallback(ConfigChangedCallback func); void AddConfigChangedCallback(ConfigChangedCallback func);
void InvokeConfigChangedCallbacks(); void OnConfigChanged();
// Returns the number of times the config has changed in the current execution of the program
u64 GetConfigVersion();
// Explicit load and save of layers // Explicit load and save of layers
void Load(); void Load();
@ -52,11 +55,28 @@ T Get(LayerType layer, const Info<T>& info)
template <typename T> template <typename T>
T Get(const Info<T>& info) T Get(const Info<T>& info)
{ {
const std::optional<std::string> str = GetAsString(info.location); CachedValue<T> cached = info.GetCachedValue();
if (!str) const u64 config_version = GetConfigVersion();
return info.default_value;
return detail::TryParse<T>(*str).value_or(info.default_value); if (cached.config_version < config_version)
{
cached.value = GetUncached(info);
cached.config_version = config_version;
info.SetCachedValue(cached);
}
return cached.value;
}
template <typename T>
T GetUncached(const Info<T>& info)
{
const std::optional<std::string> str = GetAsString(info.GetLocation());
if (!str)
return info.GetDefaultValue();
return detail::TryParse<T>(*str).value_or(info.GetDefaultValue());
} }
template <typename T> template <typename T>
@ -68,14 +88,14 @@ T GetBase(const Info<T>& info)
template <typename T> template <typename T>
LayerType GetActiveLayerForConfig(const Info<T>& info) LayerType GetActiveLayerForConfig(const Info<T>& info)
{ {
return GetActiveLayerForConfig(info.location); return GetActiveLayerForConfig(info.GetLocation());
} }
template <typename T> template <typename T>
void Set(LayerType layer, const Info<T>& info, const std::common_type_t<T>& value) void Set(LayerType layer, const Info<T>& info, const std::common_type_t<T>& value)
{ {
GetLayer(layer)->Set(info, value); GetLayer(layer)->Set(info, value);
InvokeConfigChangedCallbacks(); OnConfigChanged();
} }
template <typename T> template <typename T>
@ -99,7 +119,7 @@ void SetBaseOrCurrent(const Info<T>& info, const std::common_type_t<T>& value)
Set<T>(LayerType::CurrentRun, info, value); Set<T>(LayerType::CurrentRun, info, value);
} }
// Used to defer InvokeConfigChangedCallbacks until after the completion of many config changes. // Used to defer OnConfigChanged until after the completion of many config changes.
class ConfigChangeCallbackGuard class ConfigChangeCallbackGuard
{ {
public: public:

View File

@ -4,9 +4,13 @@
#pragma once #pragma once
#include <mutex>
#include <shared_mutex>
#include <string> #include <string>
#include <type_traits> #include <type_traits>
#include <utility>
#include "Common/CommonTypes.h"
#include "Common/Config/Enums.h" #include "Common/Config/Enums.h"
namespace Config namespace Config
@ -30,24 +34,92 @@ struct Location
}; };
template <typename T> template <typename T>
struct Info struct CachedValue
{ {
Info(const Location& location_, const T& default_value_) T value;
: location{location_}, default_value{default_value_} u64 config_version;
};
template <typename T>
class Info
{
public:
constexpr Info(const Location& location, const T& default_value)
: m_location{location}, m_default_value{default_value}, m_cached_value{default_value, 0}
{ {
} }
Info(const Info<T>& other) { *this = other; }
// Not thread-safe
Info(Info<T>&& other) { *this = std::move(other); }
// Make it easy to convert Info<Enum> into Info<UnderlyingType<Enum>> // Make it easy to convert Info<Enum> into Info<UnderlyingType<Enum>>
// so that enum settings can still easily work with code that doesn't care about the enum values. // so that enum settings can still easily work with code that doesn't care about the enum values.
template <typename Enum, template <typename Enum,
std::enable_if_t<std::is_same<T, detail::UnderlyingType<Enum>>::value>* = nullptr> std::enable_if_t<std::is_same<T, detail::UnderlyingType<Enum>>::value>* = nullptr>
Info(const Info<Enum>& other) Info(const Info<Enum>& other)
: location{other.location}, default_value{static_cast<detail::UnderlyingType<Enum>>(
other.default_value)}
{ {
*this = other;
} }
Location location; Info<T>& operator=(const Info<T>& other)
T default_value; {
m_location = other.GetLocation();
m_default_value = other.GetDefaultValue();
m_cached_value = other.GetCachedValue();
return *this;
}
// Not thread-safe
Info<T>& operator=(Info<T>&& other)
{
m_location = std::move(other.m_location);
m_default_value = std::move(other.m_default_value);
m_cached_value = std::move(other.m_cached_value);
return *this;
}
// Make it easy to convert Info<Enum> into Info<UnderlyingType<Enum>>
// so that enum settings can still easily work with code that doesn't care about the enum values.
template <typename Enum,
std::enable_if_t<std::is_same<T, detail::UnderlyingType<Enum>>::value>* = nullptr>
Info<T>& operator=(const Info<Enum>& other)
{
m_location = other.GetLocation();
m_default_value = static_cast<T>(other.GetDefaultValue());
m_cached_value = other.template GetCachedValueCasted<T>();
return *this;
}
constexpr const Location& GetLocation() const { return m_location; }
constexpr const T& GetDefaultValue() const { return m_default_value; }
CachedValue<T> GetCachedValue() const
{
std::shared_lock lock(m_cached_value_mutex);
return m_cached_value;
}
template <typename U>
CachedValue<U> GetCachedValueCasted() const
{
std::shared_lock lock(m_cached_value_mutex);
return CachedValue<U>{static_cast<U>(m_cached_value.value), m_cached_value.config_version};
}
void SetCachedValue(const CachedValue<T>& cached_value) const
{
std::unique_lock lock(m_cached_value_mutex);
if (m_cached_value.config_version < cached_value.config_version)
m_cached_value = cached_value;
}
private:
Location m_location;
T m_default_value;
mutable CachedValue<T> m_cached_value;
mutable std::shared_mutex m_cached_value_mutex;
}; };
} // namespace Config } // namespace Config

View File

@ -45,7 +45,7 @@ inline std::optional<std::string> TryParse(const std::string& str_value)
} // namespace detail } // namespace detail
template <typename T> template <typename T>
struct Info; class Info;
class Layer; class Layer;
using LayerMap = std::map<Location, std::optional<std::string>>; using LayerMap = std::map<Location, std::optional<std::string>>;
@ -105,7 +105,7 @@ public:
template <typename T> template <typename T>
T Get(const Info<T>& config_info) const T Get(const Info<T>& config_info) const
{ {
return Get<T>(config_info.location).value_or(config_info.default_value); return Get<T>(config_info.GetLocation()).value_or(config_info.GetDefaultValue());
} }
template <typename T> template <typename T>
@ -120,7 +120,7 @@ public:
template <typename T> template <typename T>
void Set(const Info<T>& config_info, const std::common_type_t<T>& value) void Set(const Info<T>& config_info, const std::common_type_t<T>& value)
{ {
Set(config_info.location, value); Set(config_info.GetLocation(), value);
} }
template <typename T> template <typename T>

View File

@ -472,11 +472,11 @@ static void RestoreSYSCONF()
for (const auto& setting : Config::SYSCONF_SETTINGS) for (const auto& setting : Config::SYSCONF_SETTINGS)
{ {
std::visit( std::visit(
[&](auto& info) { [&](auto* info) {
// If this setting was overridden, then we copy the base layer value back to the SYSCONF. // If this setting was overridden, then we copy the base layer value back to the SYSCONF.
// Otherwise we leave the new value in the SYSCONF. // Otherwise we leave the new value in the SYSCONF.
if (Config::GetActiveLayerForConfig(info) == Config::LayerType::Base) if (Config::GetActiveLayerForConfig(*info) == Config::LayerType::Base)
Config::SetBase(info, temp_layer.Get(info)); Config::SetBase(*info, temp_layer.Get(*info));
}, },
setting.config_info); setting.config_info);
} }

View File

@ -24,15 +24,15 @@ const Info<u32> SYSCONF_SPEAKER_VOLUME{{System::SYSCONF, "BT", "SPKV"}, 0x58};
const Info<bool> SYSCONF_WIIMOTE_MOTOR{{System::SYSCONF, "BT", "MOT"}, true}; const Info<bool> SYSCONF_WIIMOTE_MOTOR{{System::SYSCONF, "BT", "MOT"}, true};
const std::array<SYSCONFSetting, 11> SYSCONF_SETTINGS{ const std::array<SYSCONFSetting, 11> SYSCONF_SETTINGS{
{{SYSCONF_SCREENSAVER, SysConf::Entry::Type::Byte}, {{&SYSCONF_SCREENSAVER, SysConf::Entry::Type::Byte},
{SYSCONF_LANGUAGE, SysConf::Entry::Type::Byte}, {&SYSCONF_LANGUAGE, SysConf::Entry::Type::Byte},
{SYSCONF_COUNTRY, SysConf::Entry::Type::BigArray}, {&SYSCONF_COUNTRY, SysConf::Entry::Type::BigArray},
{SYSCONF_WIDESCREEN, SysConf::Entry::Type::Byte}, {&SYSCONF_WIDESCREEN, SysConf::Entry::Type::Byte},
{SYSCONF_PROGRESSIVE_SCAN, SysConf::Entry::Type::Byte}, {&SYSCONF_PROGRESSIVE_SCAN, SysConf::Entry::Type::Byte},
{SYSCONF_PAL60, SysConf::Entry::Type::Byte}, {&SYSCONF_PAL60, SysConf::Entry::Type::Byte},
{SYSCONF_SOUND_MODE, SysConf::Entry::Type::Byte}, {&SYSCONF_SOUND_MODE, SysConf::Entry::Type::Byte},
{SYSCONF_SENSOR_BAR_POSITION, SysConf::Entry::Type::Byte}, {&SYSCONF_SENSOR_BAR_POSITION, SysConf::Entry::Type::Byte},
{SYSCONF_SENSOR_BAR_SENSITIVITY, SysConf::Entry::Type::Long}, {&SYSCONF_SENSOR_BAR_SENSITIVITY, SysConf::Entry::Type::Long},
{SYSCONF_SPEAKER_VOLUME, SysConf::Entry::Type::Byte}, {&SYSCONF_SPEAKER_VOLUME, SysConf::Entry::Type::Byte},
{SYSCONF_WIIMOTE_MOTOR, SysConf::Entry::Type::Byte}}}; {&SYSCONF_WIIMOTE_MOTOR, SysConf::Entry::Type::Byte}}};
} // namespace Config } // namespace Config

View File

@ -33,7 +33,7 @@ extern const Info<bool> SYSCONF_WIIMOTE_MOTOR;
struct SYSCONFSetting struct SYSCONFSetting
{ {
std::variant<Info<u32>, Info<bool>> config_info; std::variant<const Info<u32>*, const Info<bool>*> config_info;
SysConf::Entry::Type type; SysConf::Entry::Type type;
}; };

View File

@ -40,16 +40,16 @@ void SaveToSYSCONF(Config::LayerType layer)
for (const Config::SYSCONFSetting& setting : Config::SYSCONF_SETTINGS) for (const Config::SYSCONFSetting& setting : Config::SYSCONF_SETTINGS)
{ {
std::visit( std::visit(
[layer, &setting, &sysconf](auto& info) { [layer, &setting, &sysconf](auto* info) {
const std::string key = info.location.section + "." + info.location.key; const std::string key = info->GetLocation().section + "." + info->GetLocation().key;
if (setting.type == SysConf::Entry::Type::Long) if (setting.type == SysConf::Entry::Type::Long)
{ {
sysconf.SetData<u32>(key, setting.type, Config::Get(layer, info)); sysconf.SetData<u32>(key, setting.type, Config::Get(layer, *info));
} }
else if (setting.type == SysConf::Entry::Type::Byte) else if (setting.type == SysConf::Entry::Type::Byte)
{ {
sysconf.SetData<u8>(key, setting.type, static_cast<u8>(Config::Get(layer, info))); sysconf.SetData<u8>(key, setting.type, static_cast<u8>(Config::Get(layer, *info)));
} }
else if (setting.type == SysConf::Entry::Type::BigArray) else if (setting.type == SysConf::Entry::Type::BigArray)
{ {
@ -58,7 +58,7 @@ void SaveToSYSCONF(Config::LayerType layer)
SysConf::Entry* entry = sysconf.GetOrAddEntry(key, setting.type); SysConf::Entry* entry = sysconf.GetOrAddEntry(key, setting.type);
if (entry->bytes.size() < 0x1007 + 1) if (entry->bytes.size() < 0x1007 + 1)
entry->bytes.resize(0x1007 + 1); entry->bytes.resize(0x1007 + 1);
*reinterpret_cast<u32*>(entry->bytes.data()) = Config::Get(layer, info); *reinterpret_cast<u32*>(entry->bytes.data()) = Config::Get(layer, *info);
} }
}, },
setting.config_info); setting.config_info);
@ -179,28 +179,29 @@ private:
for (const Config::SYSCONFSetting& setting : Config::SYSCONF_SETTINGS) for (const Config::SYSCONFSetting& setting : Config::SYSCONF_SETTINGS)
{ {
std::visit( std::visit(
[&](auto& info) { [&](auto* info) {
const std::string key = info.location.section + "." + info.location.key; const Config::Location location = info->GetLocation();
const std::string key = location.section + "." + location.key;
if (setting.type == SysConf::Entry::Type::Long) if (setting.type == SysConf::Entry::Type::Long)
{ {
layer->Set(info.location, sysconf.GetData<u32>(key, info.default_value)); layer->Set(location, sysconf.GetData<u32>(key, info->GetDefaultValue()));
} }
else if (setting.type == SysConf::Entry::Type::Byte) else if (setting.type == SysConf::Entry::Type::Byte)
{ {
layer->Set(info.location, sysconf.GetData<u8>(key, info.default_value)); layer->Set(location, sysconf.GetData<u8>(key, info->GetDefaultValue()));
} }
else if (setting.type == SysConf::Entry::Type::BigArray) else if (setting.type == SysConf::Entry::Type::BigArray)
{ {
// Somewhat hacky support for IPL.SADR. The setting only stores the // Somewhat hacky support for IPL.SADR. The setting only stores the
// first 4 bytes even thought the SYSCONF entry is much bigger. // first 4 bytes even thought the SYSCONF entry is much bigger.
u32 value = info.default_value; u32 value = info->GetDefaultValue();
SysConf::Entry* entry = sysconf.GetEntry(key); SysConf::Entry* entry = sysconf.GetEntry(key);
if (entry) if (entry)
{ {
std::memcpy(&value, entry->bytes.data(), std::memcpy(&value, entry->bytes.data(),
std::min(entry->bytes.size(), sizeof(u32))); std::min(entry->bytes.size(), sizeof(u32)));
} }
layer->Set(info.location, value); layer->Set(location, value);
} }
}, },
setting.config_info); setting.config_info);

View File

@ -69,10 +69,10 @@ using INIToSectionMap = std::map<std::string, std::pair<Config::System, std::str
static const INIToLocationMap& GetINIToLocationMap() static const INIToLocationMap& GetINIToLocationMap()
{ {
static const INIToLocationMap ini_to_location = { static const INIToLocationMap ini_to_location = {
{{"Core", "ProgressiveScan"}, {Config::SYSCONF_PROGRESSIVE_SCAN.location}}, {{"Core", "ProgressiveScan"}, {Config::SYSCONF_PROGRESSIVE_SCAN.GetLocation()}},
{{"Core", "PAL60"}, {Config::SYSCONF_PAL60.location}}, {{"Core", "PAL60"}, {Config::SYSCONF_PAL60.GetLocation()}},
{{"Wii", "Widescreen"}, {Config::SYSCONF_WIDESCREEN.location}}, {{"Wii", "Widescreen"}, {Config::SYSCONF_WIDESCREEN.GetLocation()}},
{{"Wii", "Language"}, {Config::SYSCONF_LANGUAGE.location}}, {{"Wii", "Language"}, {Config::SYSCONF_LANGUAGE.GetLocation()}},
}; };
return ini_to_location; return ini_to_location;
} }

View File

@ -36,32 +36,32 @@ bool IsSettingSaveable(const Config::Location& config_location)
static constexpr std::array<const Config::Location*, 17> s_setting_saveable = { static constexpr std::array<const Config::Location*, 17> s_setting_saveable = {
// Main.Core // Main.Core
&Config::MAIN_DEFAULT_ISO.location, &Config::MAIN_DEFAULT_ISO.GetLocation(),
&Config::MAIN_MEMCARD_A_PATH.location, &Config::MAIN_MEMCARD_A_PATH.GetLocation(),
&Config::MAIN_MEMCARD_B_PATH.location, &Config::MAIN_MEMCARD_B_PATH.GetLocation(),
&Config::MAIN_AUTO_DISC_CHANGE.location, &Config::MAIN_AUTO_DISC_CHANGE.GetLocation(),
&Config::MAIN_ALLOW_SD_WRITES.location, &Config::MAIN_ALLOW_SD_WRITES.GetLocation(),
&Config::MAIN_DPL2_DECODER.location, &Config::MAIN_DPL2_DECODER.GetLocation(),
&Config::MAIN_DPL2_QUALITY.location, &Config::MAIN_DPL2_QUALITY.GetLocation(),
&Config::MAIN_RAM_OVERRIDE_ENABLE.location, &Config::MAIN_RAM_OVERRIDE_ENABLE.GetLocation(),
&Config::MAIN_MEM1_SIZE.location, &Config::MAIN_MEM1_SIZE.GetLocation(),
&Config::MAIN_MEM2_SIZE.location, &Config::MAIN_MEM2_SIZE.GetLocation(),
&Config::MAIN_GFX_BACKEND.location, &Config::MAIN_GFX_BACKEND.GetLocation(),
&Config::MAIN_ENABLE_SAVESTATES.location, &Config::MAIN_ENABLE_SAVESTATES.GetLocation(),
&Config::MAIN_FALLBACK_REGION.location, &Config::MAIN_FALLBACK_REGION.GetLocation(),
// Main.Interface // Main.Interface
&Config::MAIN_USE_PANIC_HANDLERS.location, &Config::MAIN_USE_PANIC_HANDLERS.GetLocation(),
&Config::MAIN_OSD_MESSAGES.location, &Config::MAIN_OSD_MESSAGES.GetLocation(),
// Main.Interface // Main.Interface
&Config::MAIN_SKIP_NKIT_WARNING.location, &Config::MAIN_SKIP_NKIT_WARNING.GetLocation(),
// UI.General // UI.General
&Config::MAIN_USE_DISCORD_PRESENCE.location, &Config::MAIN_USE_DISCORD_PRESENCE.GetLocation(),
}; };
return std::any_of(s_setting_saveable.cbegin(), s_setting_saveable.cend(), return std::any_of(s_setting_saveable.cbegin(), s_setting_saveable.cend(),

View File

@ -10,7 +10,7 @@
namespace Config namespace Config
{ {
template <typename T> template <typename T>
struct Info; class Info;
} }
class GraphicsBool : public ToolTipCheckBox class GraphicsBool : public ToolTipCheckBox

View File

@ -9,7 +9,7 @@
namespace Config namespace Config
{ {
template <typename T> template <typename T>
struct Info; class Info;
} }
class GraphicsInteger : public ToolTipSpinBox class GraphicsInteger : public ToolTipSpinBox

View File

@ -9,7 +9,7 @@
namespace Config namespace Config
{ {
template <typename T> template <typename T>
struct Info; class Info;
} }
class GraphicsSlider : public ToolTipSlider class GraphicsSlider : public ToolTipSlider

View File

@ -381,13 +381,13 @@ void NetPlaySetupDialog::PopulateGameList()
void NetPlaySetupDialog::ResetTraversalHost() void NetPlaySetupDialog::ResetTraversalHost()
{ {
Config::SetBaseOrCurrent(Config::NETPLAY_TRAVERSAL_SERVER, Config::SetBaseOrCurrent(Config::NETPLAY_TRAVERSAL_SERVER,
Config::NETPLAY_TRAVERSAL_SERVER.default_value); Config::NETPLAY_TRAVERSAL_SERVER.GetDefaultValue());
Config::SetBaseOrCurrent(Config::NETPLAY_TRAVERSAL_PORT, Config::SetBaseOrCurrent(Config::NETPLAY_TRAVERSAL_PORT,
Config::NETPLAY_TRAVERSAL_PORT.default_value); Config::NETPLAY_TRAVERSAL_PORT.GetDefaultValue());
ModalMessageBox::information( ModalMessageBox::information(
this, tr("Reset Traversal Server"), this, tr("Reset Traversal Server"),
tr("Reset Traversal Server to %1:%2") tr("Reset Traversal Server to %1:%2")
.arg(QString::fromStdString(Config::NETPLAY_TRAVERSAL_SERVER.default_value), .arg(QString::fromStdString(Config::NETPLAY_TRAVERSAL_SERVER.GetDefaultValue()),
QString::number(Config::NETPLAY_TRAVERSAL_PORT.default_value))); QString::number(Config::NETPLAY_TRAVERSAL_PORT.GetDefaultValue())));
} }

View File

@ -26,15 +26,18 @@ public:
: ConfigLayerLoader(Config::LayerType::CommandLine) : ConfigLayerLoader(Config::LayerType::CommandLine)
{ {
if (!video_backend.empty()) if (!video_backend.empty())
m_values.emplace_back(Config::MAIN_GFX_BACKEND.location, video_backend); m_values.emplace_back(Config::MAIN_GFX_BACKEND.GetLocation(), video_backend);
if (!audio_backend.empty()) if (!audio_backend.empty())
m_values.emplace_back(Config::MAIN_DSP_HLE.location, ValueToString(audio_backend == "HLE")); {
m_values.emplace_back(Config::MAIN_DSP_HLE.GetLocation(),
ValueToString(audio_backend == "HLE"));
}
// Batch mode hides the main window, and render to main hides the render window. To avoid a // Batch mode hides the main window, and render to main hides the render window. To avoid a
// situation where we would have no window at all, disable render to main when using batch mode. // situation where we would have no window at all, disable render to main when using batch mode.
if (batch) if (batch)
m_values.emplace_back(Config::MAIN_RENDER_TO_MAIN.location, ValueToString(false)); m_values.emplace_back(Config::MAIN_RENDER_TO_MAIN.GetLocation(), ValueToString(false));
// Arguments are in the format of <System>.<Section>.<Key>=Value // Arguments are in the format of <System>.<Section>.<Key>=Value
for (const auto& arg : args) for (const auto& arg : args)

View File

@ -50,7 +50,7 @@ void HandleDiscordJoin(const char* join_secret)
if (event_handler == nullptr) if (event_handler == nullptr)
return; return;
if (Config::Get(Config::NETPLAY_NICKNAME) == Config::NETPLAY_NICKNAME.default_value) if (Config::Get(Config::NETPLAY_NICKNAME) == Config::NETPLAY_NICKNAME.GetDefaultValue())
Config::SetCurrent(Config::NETPLAY_NICKNAME, username); Config::SetCurrent(Config::NETPLAY_NICKNAME, username);
std::string secret(join_secret); std::string secret(join_secret);