settings: use a template to duplicate memory for each setting
Replaces the type of each variable in the Settings::Values struct with a new class that allows basic data reading and writing. The new struct Settings::Setting duplicates the data in memory and can manage global overrides per each setting.
This commit is contained in:
@@ -30,7 +30,8 @@ StreamPtr AudioOut::OpenStream(Core::Timing::CoreTiming& core_timing, u32 sample
|
||||
u32 num_channels, std::string&& name,
|
||||
Stream::ReleaseCallback&& release_callback) {
|
||||
if (!sink) {
|
||||
sink = CreateSinkFromID(Settings::values->sink_id, Settings::values->audio_device_id);
|
||||
sink = CreateSinkFromID(Settings::values->sink_id.GetValue(),
|
||||
Settings::values->audio_device_id.GetValue());
|
||||
}
|
||||
|
||||
return std::make_shared<Stream>(
|
||||
|
||||
@@ -162,7 +162,7 @@ struct System::Impl {
|
||||
const auto current_time = std::chrono::duration_cast<std::chrono::seconds>(
|
||||
std::chrono::system_clock::now().time_since_epoch());
|
||||
Settings::values->custom_rtc_differential =
|
||||
Settings::values->custom_rtc.value_or(current_time) - current_time;
|
||||
Settings::values->custom_rtc.GetValue().value_or(current_time) - current_time;
|
||||
|
||||
// Create a default fs if one doesn't already exist.
|
||||
if (virtual_filesystem == nullptr)
|
||||
|
||||
@@ -29,7 +29,7 @@ FramebufferLayout DefaultFrameLayout(u32 width, u32 height) {
|
||||
|
||||
const float window_aspect_ratio = static_cast<float>(height) / width;
|
||||
const float emulation_aspect_ratio = EmulationAspectRatio(
|
||||
static_cast<AspectRatio>(Settings::values->aspect_ratio), window_aspect_ratio);
|
||||
static_cast<AspectRatio>(Settings::values->aspect_ratio.GetValue()), window_aspect_ratio);
|
||||
|
||||
const Common::Rectangle<u32> screen_window_area{0, 0, width, height};
|
||||
Common::Rectangle<u32> screen = MaxRectangle(screen_window_area, emulation_aspect_ratio);
|
||||
|
||||
@@ -123,7 +123,7 @@ std::shared_ptr<Process> Process::Create(Core::System& system, std::string name,
|
||||
: kernel.CreateNewUserProcessID();
|
||||
process->capabilities.InitializeForMetadatalessProcess();
|
||||
|
||||
std::mt19937 rng(Settings::values->rng_seed.value_or(0));
|
||||
std::mt19937 rng(Settings::values->rng_seed.GetValue().value_or(0));
|
||||
std::uniform_int_distribution<u64> distribution;
|
||||
std::generate(process->random_entropy.begin(), process->random_entropy.end(),
|
||||
[&] { return distribution(rng); });
|
||||
|
||||
@@ -163,11 +163,11 @@ void SET::GetQuestFlag(Kernel::HLERequestContext& ctx) {
|
||||
}
|
||||
|
||||
void SET::GetLanguageCode(Kernel::HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_SET, "called {}", Settings::values->language_index);
|
||||
LOG_DEBUG(Service_SET, "called {}", Settings::values->language_index.GetValue());
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 4};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.PushEnum(available_language_codes[Settings::values->language_index]);
|
||||
rb.PushEnum(available_language_codes[Settings::values->language_index.GetValue()]);
|
||||
}
|
||||
|
||||
void SET::GetRegionCode(Kernel::HLERequestContext& ctx) {
|
||||
@@ -175,7 +175,7 @@ void SET::GetRegionCode(Kernel::HLERequestContext& ctx) {
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.Push(Settings::values->region_index);
|
||||
rb.Push(Settings::values->region_index.GetValue());
|
||||
}
|
||||
|
||||
void SET::GetKeyCodeMap(Kernel::HLERequestContext& ctx) {
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Service::SPL {
|
||||
|
||||
Module::Interface::Interface(std::shared_ptr<Module> module, const char* name)
|
||||
: ServiceFramework(name), module(std::move(module)),
|
||||
rng(Settings::values->rng_seed.value_or(std::time(nullptr))) {}
|
||||
rng(Settings::values->rng_seed.GetValue().value_or(std::time(nullptr))) {}
|
||||
|
||||
Module::Interface::~Interface() = default;
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ constexpr Clock::TimeSpanType standard_network_clock_accuracy{0x0009356907420000
|
||||
static std::chrono::seconds GetSecondsSinceEpoch() {
|
||||
return std::chrono::duration_cast<std::chrono::seconds>(
|
||||
std::chrono::system_clock::now().time_since_epoch()) +
|
||||
Settings::values->custom_rtc_differential;
|
||||
Settings::values->custom_rtc_differential.GetValue();
|
||||
}
|
||||
|
||||
static s64 GetExternalTimeZoneOffset() {
|
||||
|
||||
@@ -177,7 +177,7 @@ void LogSetting(const std::string& name, const T& value) {
|
||||
void LogSettings() {
|
||||
LOG_INFO(Config, "yuzu Configuration:");
|
||||
LogSetting("System_UseDockedMode", Settings::base_values.use_docked_mode);
|
||||
LogSetting("System_RngSeed", Settings::values->rng_seed.value_or(0));
|
||||
LogSetting("System_RngSeed", Settings::values->rng_seed.GetValue().value_or(0));
|
||||
LogSetting("System_CurrentUser", Settings::values->current_user);
|
||||
LogSetting("System_LanguageIndex", Settings::values->language_index);
|
||||
LogSetting("System_RegionIndex", Settings::values->region_index);
|
||||
@@ -187,15 +187,15 @@ void LogSettings() {
|
||||
LogSetting("Renderer_UseFrameLimit", Settings::values->use_frame_limit);
|
||||
LogSetting("Renderer_FrameLimit", Settings::values->frame_limit);
|
||||
LogSetting("Renderer_UseDiskShaderCache", Settings::values->use_disk_shader_cache);
|
||||
LogSetting("Renderer_GPUAccuracyLevel", Settings::values->gpu_accuracy);
|
||||
LogSetting("Renderer_GPUAccuracyLevel", Settings::values->gpu_accuracy.GetValue());
|
||||
LogSetting("Renderer_UseAsynchronousGpuEmulation",
|
||||
Settings::values->use_asynchronous_gpu_emulation);
|
||||
LogSetting("Renderer_UseVsync", Settings::values->use_vsync);
|
||||
LogSetting("Renderer_UseAssemblyShaders", Settings::values->use_assembly_shaders);
|
||||
LogSetting("Renderer_AnisotropicFilteringLevel", Settings::values->max_anisotropy);
|
||||
LogSetting("Audio_OutputEngine", Settings::values->sink_id);
|
||||
LogSetting("Audio_OutputEngine", Settings::values->sink_id.GetValue());
|
||||
LogSetting("Audio_EnableAudioStretching", Settings::values->enable_audio_stretching);
|
||||
LogSetting("Audio_OutputDevice", Settings::values->audio_device_id);
|
||||
LogSetting("Audio_OutputDevice", Settings::values->audio_device_id.GetValue());
|
||||
LogSetting("DataStorage_UseVirtualSd", Settings::base_values.use_virtual_sd);
|
||||
LogSetting("DataStorage_NandDir", FileUtil::GetUserPath(FileUtil::UserPath::NANDDir));
|
||||
LogSetting("DataStorage_SdmcDir", FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir));
|
||||
|
||||
@@ -382,55 +382,99 @@ enum class GPUAccuracy : u32 {
|
||||
Extreme = 2,
|
||||
};
|
||||
|
||||
template <typename Type>
|
||||
class Setting {
|
||||
public:
|
||||
Setting() {
|
||||
use_global = true;
|
||||
}
|
||||
~Setting() = default;
|
||||
void SetGlobal(bool to_global) {
|
||||
use_global = to_global;
|
||||
};
|
||||
Type GetValue() {
|
||||
if (use_global) {
|
||||
return global;
|
||||
}
|
||||
return local;
|
||||
};
|
||||
void SetValue(Type value) {
|
||||
if (use_global) {
|
||||
global = value;
|
||||
}
|
||||
else {
|
||||
local = value;
|
||||
}
|
||||
};
|
||||
operator Type() const {
|
||||
if (use_global)
|
||||
return global;
|
||||
return local;
|
||||
};
|
||||
Type operator=(const Type& b) {
|
||||
if (use_global) {
|
||||
global = b;
|
||||
}
|
||||
else {
|
||||
local = b;
|
||||
}
|
||||
return b;
|
||||
};
|
||||
private:
|
||||
bool use_global;
|
||||
Type global;
|
||||
Type local;
|
||||
};
|
||||
|
||||
struct Values {
|
||||
// Audio
|
||||
std::string sink_id;
|
||||
bool enable_audio_stretching;
|
||||
std::string audio_device_id;
|
||||
float volume;
|
||||
Setting<std::string> sink_id;
|
||||
Setting<bool> enable_audio_stretching;
|
||||
Setting<std::string> audio_device_id;
|
||||
Setting<float> volume;
|
||||
|
||||
// Core
|
||||
bool use_multi_core;
|
||||
Setting<bool> use_multi_core;
|
||||
|
||||
// Misceallaneous
|
||||
std::string log_filter;
|
||||
bool use_dev_keys;
|
||||
bool use_global_values;
|
||||
Setting<std::string> log_filter;
|
||||
Setting<bool> use_dev_keys;
|
||||
Setting<bool> use_global_values;
|
||||
|
||||
// Renderer
|
||||
RendererBackend renderer_backend;
|
||||
bool renderer_debug;
|
||||
int vulkan_device;
|
||||
Setting<RendererBackend> renderer_backend;
|
||||
Setting<bool> renderer_debug;
|
||||
Setting<int> vulkan_device;
|
||||
|
||||
u16 resolution_factor{1};
|
||||
int aspect_ratio;
|
||||
int max_anisotropy;
|
||||
bool use_frame_limit;
|
||||
u16 frame_limit;
|
||||
bool use_disk_shader_cache;
|
||||
GPUAccuracy gpu_accuracy;
|
||||
bool use_asynchronous_gpu_emulation;
|
||||
bool use_vsync;
|
||||
bool use_assembly_shaders;
|
||||
bool force_30fps_mode;
|
||||
bool use_fast_gpu_time;
|
||||
Setting<u16> resolution_factor;
|
||||
Setting<int> aspect_ratio;
|
||||
Setting<int> max_anisotropy;
|
||||
Setting<bool> use_frame_limit;
|
||||
Setting<u16> frame_limit;
|
||||
Setting<bool> use_disk_shader_cache;
|
||||
Setting<GPUAccuracy> gpu_accuracy;
|
||||
Setting<bool> use_asynchronous_gpu_emulation;
|
||||
Setting<bool> use_vsync;
|
||||
Setting<bool> use_assembly_shaders;
|
||||
Setting<bool> force_30fps_mode;
|
||||
Setting<bool> use_fast_gpu_time;
|
||||
|
||||
float bg_red;
|
||||
float bg_green;
|
||||
float bg_blue;
|
||||
Setting<float> bg_red;
|
||||
Setting<float> bg_green;
|
||||
Setting<float> bg_blue;
|
||||
|
||||
// System
|
||||
std::optional<u32> rng_seed;
|
||||
Setting<std::optional<u32>> rng_seed;
|
||||
// Measured in seconds since epoch
|
||||
std::optional<std::chrono::seconds> custom_rtc;
|
||||
Setting<std::optional<std::chrono::seconds>> custom_rtc;
|
||||
// Set on game boot, reset on stop. Seconds difference between current time and `custom_rtc`
|
||||
std::chrono::seconds custom_rtc_differential;
|
||||
Setting<std::chrono::seconds> custom_rtc_differential;
|
||||
|
||||
s32 current_user;
|
||||
s32 language_index;
|
||||
s32 region_index;
|
||||
s32 time_zone_index;
|
||||
s32 sound_index;
|
||||
Setting<s32> current_user;
|
||||
Setting<s32> language_index;
|
||||
Setting<s32> region_index;
|
||||
Setting<s32> time_zone_index;
|
||||
Setting<s32> sound_index;
|
||||
};
|
||||
|
||||
struct NonSwitchingValues {
|
||||
|
||||
@@ -189,20 +189,25 @@ void TelemetrySession::AddInitialInfo(Loader::AppLoader& app_loader) {
|
||||
|
||||
// Log user configuration information
|
||||
constexpr auto field_type = Telemetry::FieldType::UserConfig;
|
||||
AddField(field_type, "Audio_SinkId", Settings::values->sink_id);
|
||||
AddField(field_type, "Audio_EnableAudioStretching", Settings::values->enable_audio_stretching);
|
||||
AddField(field_type, "Core_UseMultiCore", Settings::values->use_multi_core);
|
||||
AddField(field_type, "Renderer_Backend", TranslateRenderer(Settings::values->renderer_backend));
|
||||
AddField(field_type, "Renderer_ResolutionFactor", Settings::values->resolution_factor);
|
||||
AddField(field_type, "Renderer_UseFrameLimit", Settings::values->use_frame_limit);
|
||||
AddField(field_type, "Renderer_FrameLimit", Settings::values->frame_limit);
|
||||
AddField(field_type, "Renderer_UseDiskShaderCache", Settings::values->use_disk_shader_cache);
|
||||
AddField(field_type, "Audio_SinkId", Settings::values->sink_id.GetValue());
|
||||
AddField(field_type, "Audio_EnableAudioStretching",
|
||||
Settings::values->enable_audio_stretching.GetValue());
|
||||
AddField(field_type, "Core_UseMultiCore", Settings::values->use_multi_core.GetValue());
|
||||
AddField(field_type, "Renderer_Backend",
|
||||
TranslateRenderer(Settings::values->renderer_backend.GetValue()));
|
||||
AddField(field_type, "Renderer_ResolutionFactor",
|
||||
Settings::values->resolution_factor.GetValue());
|
||||
AddField(field_type, "Renderer_UseFrameLimit", Settings::values->use_frame_limit.GetValue());
|
||||
AddField(field_type, "Renderer_FrameLimit", Settings::values->frame_limit.GetValue());
|
||||
AddField(field_type, "Renderer_UseDiskShaderCache",
|
||||
Settings::values->use_disk_shader_cache.GetValue());
|
||||
AddField(field_type, "Renderer_GPUAccuracyLevel",
|
||||
TranslateGPUAccuracyLevel(Settings::values->gpu_accuracy));
|
||||
TranslateGPUAccuracyLevel(Settings::values->gpu_accuracy.GetValue()));
|
||||
AddField(field_type, "Renderer_UseAsynchronousGpuEmulation",
|
||||
Settings::values->use_asynchronous_gpu_emulation);
|
||||
AddField(field_type, "Renderer_UseVsync", Settings::values->use_vsync);
|
||||
AddField(field_type, "Renderer_UseAssemblyShaders", Settings::values->use_assembly_shaders);
|
||||
Settings::values->use_asynchronous_gpu_emulation.GetValue());
|
||||
AddField(field_type, "Renderer_UseVsync", Settings::values->use_vsync.GetValue());
|
||||
AddField(field_type, "Renderer_UseAssemblyShaders",
|
||||
Settings::values->use_assembly_shaders.GetValue());
|
||||
AddField(field_type, "System_UseDockedMode", Settings::base_values.use_docked_mode);
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ constexpr std::array<float, 256> SRGB_CONVERSION_LUT = {
|
||||
};
|
||||
|
||||
unsigned SettingsMinimumAnisotropy() noexcept {
|
||||
switch (static_cast<Anisotropy>(Settings::values->max_anisotropy)) {
|
||||
switch (static_cast<Anisotropy>(Settings::values->max_anisotropy.GetValue())) {
|
||||
default:
|
||||
case Anisotropy::Default:
|
||||
return 1U;
|
||||
|
||||
@@ -945,14 +945,14 @@ void Config::SaveAudioValues() {
|
||||
qt_config->beginGroup(QStringLiteral("Audio"));
|
||||
|
||||
WriteSetting(QStringLiteral("output_engine"),
|
||||
QString::fromStdString(Settings::config_values->sink_id),
|
||||
QString::fromStdString(Settings::config_values->sink_id.GetValue()),
|
||||
QStringLiteral("auto"));
|
||||
WriteSetting(QStringLiteral("enable_audio_stretching"),
|
||||
Settings::config_values->enable_audio_stretching, true);
|
||||
Settings::config_values->enable_audio_stretching.GetValue(), true);
|
||||
WriteSetting(QStringLiteral("output_device"),
|
||||
QString::fromStdString(Settings::config_values->audio_device_id),
|
||||
QString::fromStdString(Settings::config_values->audio_device_id.GetValue()),
|
||||
QStringLiteral("auto"));
|
||||
WriteSetting(QStringLiteral("volume"), Settings::config_values->volume, 1.0f);
|
||||
WriteSetting(QStringLiteral("volume"), Settings::config_values->volume.GetValue(), 1.0f);
|
||||
|
||||
qt_config->endGroup();
|
||||
}
|
||||
@@ -985,7 +985,8 @@ void Config::SaveControlValues() {
|
||||
void Config::SaveCoreValues() {
|
||||
qt_config->beginGroup(QStringLiteral("Core"));
|
||||
|
||||
WriteSetting(QStringLiteral("use_multi_core"), Settings::config_values->use_multi_core, false);
|
||||
WriteSetting(QStringLiteral("use_multi_core"),
|
||||
Settings::config_values->use_multi_core.GetValue(), false);
|
||||
|
||||
qt_config->endGroup();
|
||||
}
|
||||
@@ -1089,10 +1090,12 @@ void Config::SaveMiscellaneousValues() {
|
||||
qt_config->beginGroup(QStringLiteral("Miscellaneous"));
|
||||
|
||||
WriteSetting(QStringLiteral("log_filter"),
|
||||
QString::fromStdString(Settings::config_values->log_filter),
|
||||
QString::fromStdString(Settings::config_values->log_filter.GetValue()),
|
||||
QStringLiteral("*:Info"));
|
||||
WriteSetting(QStringLiteral("use_dev_keys"), Settings::config_values->use_dev_keys, false);
|
||||
WriteSetting(QStringLiteral("use_global_values"), Settings::config_values->use_global_values,
|
||||
WriteSetting(QStringLiteral("use_dev_keys"), Settings::config_values->use_dev_keys.GetValue(),
|
||||
false);
|
||||
WriteSetting(QStringLiteral("use_global_values"),
|
||||
Settings::config_values->use_global_values.GetValue(),
|
||||
true);
|
||||
|
||||
qt_config->endGroup();
|
||||
@@ -1122,26 +1125,32 @@ void Config::SaveRendererValues() {
|
||||
qt_config->beginGroup(QStringLiteral("Renderer"));
|
||||
|
||||
WriteSetting(QStringLiteral("backend"),
|
||||
static_cast<int>(Settings::config_values->renderer_backend), 0);
|
||||
WriteSetting(QStringLiteral("debug"), Settings::config_values->renderer_debug, false);
|
||||
WriteSetting(QStringLiteral("vulkan_device"), Settings::config_values->vulkan_device, 0);
|
||||
WriteSetting(QStringLiteral("aspect_ratio"), Settings::config_values->aspect_ratio, 0);
|
||||
WriteSetting(QStringLiteral("max_anisotropy"), Settings::config_values->max_anisotropy, 0);
|
||||
WriteSetting(QStringLiteral("use_frame_limit"), Settings::config_values->use_frame_limit, true);
|
||||
WriteSetting(QStringLiteral("frame_limit"), Settings::config_values->frame_limit, 100);
|
||||
static_cast<int>(Settings::config_values->renderer_backend.GetValue()), 0);
|
||||
WriteSetting(QStringLiteral("debug"),
|
||||
Settings::config_values->renderer_debug.GetValue(), false);
|
||||
WriteSetting(QStringLiteral("vulkan_device"),
|
||||
Settings::config_values->vulkan_device.GetValue(), 0);
|
||||
WriteSetting(QStringLiteral("aspect_ratio"), Settings::config_values->aspect_ratio.GetValue(),
|
||||
0);
|
||||
WriteSetting(QStringLiteral("max_anisotropy"),
|
||||
Settings::config_values->max_anisotropy.GetValue(), 0);
|
||||
WriteSetting(QStringLiteral("use_frame_limit"),
|
||||
Settings::config_values->use_frame_limit.GetValue(), true);
|
||||
WriteSetting(QStringLiteral("frame_limit"), Settings::config_values->frame_limit.GetValue(),
|
||||
100);
|
||||
WriteSetting(QStringLiteral("use_disk_shader_cache"),
|
||||
Settings::config_values->use_disk_shader_cache, true);
|
||||
Settings::config_values->use_disk_shader_cache.GetValue(), true);
|
||||
WriteSetting(QStringLiteral("gpu_accuracy"),
|
||||
static_cast<int>(Settings::config_values->gpu_accuracy), 0);
|
||||
static_cast<int>(Settings::config_values->gpu_accuracy.GetValue()), 0);
|
||||
WriteSetting(QStringLiteral("use_asynchronous_gpu_emulation"),
|
||||
Settings::config_values->use_asynchronous_gpu_emulation, false);
|
||||
WriteSetting(QStringLiteral("use_vsync"), Settings::config_values->use_vsync, true);
|
||||
Settings::config_values->use_asynchronous_gpu_emulation.GetValue(), false);
|
||||
WriteSetting(QStringLiteral("use_vsync"), Settings::config_values->use_vsync.GetValue(), true);
|
||||
WriteSetting(QStringLiteral("use_assembly_shaders"),
|
||||
Settings::config_values->use_assembly_shaders, false);
|
||||
Settings::config_values->use_assembly_shaders.GetValue(), false);
|
||||
WriteSetting(QStringLiteral("use_fast_gpu_time"),
|
||||
Settings::config_values->use_fast_gpu_time, true);
|
||||
Settings::config_values->use_fast_gpu_time.GetValue(), true);
|
||||
WriteSetting(QStringLiteral("force_30fps_mode"),
|
||||
Settings::config_values->force_30fps_mode, false);
|
||||
Settings::config_values->force_30fps_mode.GetValue(), false);
|
||||
|
||||
// Cast to double because Qt's written float values are not human-readable
|
||||
WriteSetting(QStringLiteral("bg_red"),
|
||||
@@ -1177,23 +1186,30 @@ void Config::SaveShortcutValues() {
|
||||
void Config::SaveSystemValues() {
|
||||
qt_config->beginGroup(QStringLiteral("System"));
|
||||
|
||||
WriteSetting(QStringLiteral("current_user"), Settings::config_values->current_user, 0);
|
||||
WriteSetting(QStringLiteral("language_index"), Settings::config_values->language_index, 1);
|
||||
WriteSetting(QStringLiteral("region_index"), Settings::config_values->region_index, 1);
|
||||
WriteSetting(QStringLiteral("time_zone_index"), Settings::config_values->time_zone_index, 0);
|
||||
WriteSetting(QStringLiteral("current_user"),
|
||||
Settings::config_values->current_user.GetValue(), 0);
|
||||
WriteSetting(QStringLiteral("language_index"),
|
||||
Settings::config_values->language_index.GetValue(), 1);
|
||||
WriteSetting(QStringLiteral("region_index"),
|
||||
Settings::config_values->region_index.GetValue(), 1);
|
||||
WriteSetting(QStringLiteral("time_zone_index"),
|
||||
Settings::config_values->time_zone_index.GetValue(), 0);
|
||||
|
||||
WriteSetting(QStringLiteral("rng_seed_enabled"), Settings::config_values->rng_seed.has_value(),
|
||||
WriteSetting(QStringLiteral("rng_seed_enabled"),
|
||||
Settings::config_values->rng_seed.GetValue().has_value(),
|
||||
false);
|
||||
WriteSetting(QStringLiteral("rng_seed"), Settings::config_values->rng_seed.value_or(0), 0);
|
||||
WriteSetting(QStringLiteral("rng_seed"),
|
||||
Settings::config_values->rng_seed.GetValue().value_or(0), 0);
|
||||
|
||||
WriteSetting(QStringLiteral("custom_rtc_enabled"),
|
||||
Settings::config_values->custom_rtc.has_value(), false);
|
||||
Settings::config_values->custom_rtc.GetValue().has_value(), false);
|
||||
WriteSetting(QStringLiteral("custom_rtc"),
|
||||
QVariant::fromValue<long long>(
|
||||
Settings::config_values->custom_rtc.value_or(std::chrono::seconds{}).count()),
|
||||
Settings::config_values->custom_rtc.GetValue()
|
||||
.value_or(std::chrono::seconds{}).count()),
|
||||
0);
|
||||
|
||||
WriteSetting(QStringLiteral("sound_index"), Settings::config_values->sound_index, 1);
|
||||
WriteSetting(QStringLiteral("sound_index"), Settings::config_values->sound_index.GetValue(), 1);
|
||||
|
||||
qt_config->endGroup();
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ void ConfigureDebug::ApplyConfiguration() {
|
||||
Settings::base_values.disable_macro_jit = ui->disable_macro_jit->isChecked();
|
||||
Debugger::ToggleConsole();
|
||||
Log::Filter filter;
|
||||
filter.ParseFilterString(Settings::config_values->log_filter);
|
||||
filter.ParseFilterString(Settings::config_values->log_filter.GetValue());
|
||||
Log::SetGlobalFilter(filter);
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,8 @@ void ConfigureGraphics::SetConfiguration() {
|
||||
const bool runtime_lock = !Core::System::GetInstance().IsPoweredOn();
|
||||
|
||||
ui->api->setEnabled(runtime_lock);
|
||||
ui->api->setCurrentIndex(static_cast<int>(Settings::config_values->renderer_backend));
|
||||
ui->api->setCurrentIndex(static_cast<int>(
|
||||
Settings::config_values->renderer_backend.GetValue()));
|
||||
ui->aspect_ratio_combobox->setCurrentIndex(Settings::config_values->aspect_ratio);
|
||||
ui->use_disk_shader_cache->setEnabled(runtime_lock);
|
||||
ui->use_disk_shader_cache->setChecked(Settings::config_values->use_disk_shader_cache);
|
||||
|
||||
@@ -19,7 +19,8 @@ ConfigureGraphicsAdvanced::~ConfigureGraphicsAdvanced() = default;
|
||||
|
||||
void ConfigureGraphicsAdvanced::SetConfiguration() {
|
||||
const bool runtime_lock = !Core::System::GetInstance().IsPoweredOn();
|
||||
ui->gpu_accuracy->setCurrentIndex(static_cast<int>(Settings::config_values->gpu_accuracy));
|
||||
ui->gpu_accuracy->setCurrentIndex(static_cast<int>(
|
||||
Settings::config_values->gpu_accuracy.GetValue()));
|
||||
ui->use_vsync->setEnabled(runtime_lock);
|
||||
ui->use_vsync->setChecked(Settings::config_values->use_vsync);
|
||||
ui->use_assembly_shaders->setEnabled(runtime_lock);
|
||||
|
||||
@@ -64,19 +64,19 @@ void ConfigureSystem::SetConfiguration() {
|
||||
ui->combo_time_zone->setCurrentIndex(Settings::config_values->time_zone_index);
|
||||
ui->combo_sound->setCurrentIndex(Settings::config_values->sound_index);
|
||||
|
||||
ui->rng_seed_checkbox->setChecked(Settings::config_values->rng_seed.has_value());
|
||||
ui->rng_seed_edit->setEnabled(Settings::config_values->rng_seed.has_value());
|
||||
ui->rng_seed_checkbox->setChecked(Settings::config_values->rng_seed.GetValue().has_value());
|
||||
ui->rng_seed_edit->setEnabled(Settings::config_values->rng_seed.GetValue().has_value());
|
||||
|
||||
const auto rng_seed = QStringLiteral("%1")
|
||||
.arg(Settings::config_values->rng_seed.value_or(0), 8, 16,
|
||||
.arg(Settings::config_values->rng_seed.GetValue().value_or(0), 8, 16,
|
||||
QLatin1Char{'0'})
|
||||
.toUpper();
|
||||
ui->rng_seed_edit->setText(rng_seed);
|
||||
|
||||
ui->custom_rtc_checkbox->setChecked(Settings::config_values->custom_rtc.has_value());
|
||||
ui->custom_rtc_edit->setEnabled(Settings::config_values->custom_rtc.has_value());
|
||||
ui->custom_rtc_checkbox->setChecked(Settings::config_values->custom_rtc.GetValue().has_value());
|
||||
ui->custom_rtc_edit->setEnabled(Settings::config_values->custom_rtc.GetValue().has_value());
|
||||
|
||||
const auto rtc_time = Settings::config_values->custom_rtc.value_or(
|
||||
const auto rtc_time = Settings::config_values->custom_rtc.GetValue().value_or(
|
||||
std::chrono::seconds(QDateTime::currentSecsSinceEpoch()));
|
||||
ui->custom_rtc_edit->setDateTime(QDateTime::fromSecsSinceEpoch(rtc_time.count()));
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ const int GMainWindow::max_recent_files_item;
|
||||
|
||||
static void InitializeLogging() {
|
||||
Log::Filter log_filter;
|
||||
log_filter.ParseFilterString(Settings::values->log_filter);
|
||||
log_filter.ParseFilterString(Settings::values->log_filter.GetValue());
|
||||
Log::SetGlobalFilter(log_filter);
|
||||
|
||||
const std::string& log_dir = FileUtil::GetUserPath(FileUtil::UserPath::LogDir);
|
||||
@@ -735,14 +735,16 @@ void GMainWindow::InitializeHotkeys() {
|
||||
connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Increase Speed Limit"), this),
|
||||
&QShortcut::activated, this, [&] {
|
||||
if (Settings::values->frame_limit < 9999 - SPEED_LIMIT_STEP) {
|
||||
Settings::values->frame_limit += SPEED_LIMIT_STEP;
|
||||
Settings::values->frame_limit =
|
||||
SPEED_LIMIT_STEP + Settings::values->frame_limit;
|
||||
UpdateStatusBar();
|
||||
}
|
||||
});
|
||||
connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Decrease Speed Limit"), this),
|
||||
&QShortcut::activated, this, [&] {
|
||||
if (Settings::values->frame_limit > SPEED_LIMIT_STEP) {
|
||||
Settings::values->frame_limit -= SPEED_LIMIT_STEP;
|
||||
Settings::values->frame_limit =
|
||||
Settings::values->frame_limit - SPEED_LIMIT_STEP;
|
||||
UpdateStatusBar();
|
||||
}
|
||||
});
|
||||
@@ -769,7 +771,7 @@ void GMainWindow::InitializeHotkeys() {
|
||||
&QShortcut::activated, this,
|
||||
[] { Settings::values.audio_muted = !Settings::values.audio_muted; });
|
||||
}
|
||||
|
||||
-
|
||||
void GMainWindow::SetDefaultUIGeometry() {
|
||||
// geometry: 53% of the window contents are in the upper screen half, 47% in the lower half
|
||||
const QRect screenRect = QApplication::desktop()->screenGeometry(this);
|
||||
@@ -1956,7 +1958,7 @@ void GMainWindow::ToggleWindowMode() {
|
||||
|
||||
void GMainWindow::ResetWindowSize() {
|
||||
const auto aspect_ratio = Layout::EmulationAspectRatio(
|
||||
static_cast<Layout::AspectRatio>(Settings::values->aspect_ratio),
|
||||
static_cast<Layout::AspectRatio>(Settings::values->aspect_ratio.GetValue()),
|
||||
static_cast<float>(Layout::ScreenUndocked::Height) / Layout::ScreenUndocked::Width);
|
||||
if (!ui.action_Single_Window_Mode->isChecked()) {
|
||||
render_window->resize(Layout::ScreenUndocked::Height / aspect_ratio,
|
||||
|
||||
@@ -77,7 +77,7 @@ static void PrintVersion() {
|
||||
|
||||
static void InitializeLogging() {
|
||||
Log::Filter log_filter(Log::Level::Debug);
|
||||
log_filter.ParseFilterString(Settings::values->log_filter);
|
||||
log_filter.ParseFilterString(Settings::values->log_filter.GetValue());
|
||||
Log::SetGlobalFilter(log_filter);
|
||||
|
||||
Log::AddBackend(std::make_unique<Log::ColorConsoleBackend>());
|
||||
|
||||
@@ -73,7 +73,7 @@ static void PrintVersion() {
|
||||
|
||||
static void InitializeLogging(bool console) {
|
||||
Log::Filter log_filter(Log::Level::Debug);
|
||||
log_filter.ParseFilterString(Settings::values->log_filter);
|
||||
log_filter.ParseFilterString(Settings::values->log_filter.GetValue());
|
||||
Log::SetGlobalFilter(log_filter);
|
||||
|
||||
if (console)
|
||||
|
||||
Reference in New Issue
Block a user