From b91b76df4fe27d781bd95ddb89b78ff54df57029 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Mon, 28 Jun 2021 15:58:16 -0400 Subject: general: Make most settings a BasicSetting Creates a new BasicSettings class in common/settings, and forces setting a default and label for each setting that uses it in common/settings. Moves defaults and labels from both frontends into common settings. Creates a helper function in each frontend to facillitate reading the settings now with the new default and label properties. Settings::Setting is also now a subclass of Settings::BasicSetting. Also adds documentation for both Setting and BasicSetting. --- src/core/core.cpp | 6 +++--- src/core/frontend/applets/profile_select.cpp | 2 +- src/core/hle/service/acc/profile_manager.cpp | 3 ++- src/core/hle/service/am/am.cpp | 2 +- src/core/hle/service/nifm/nifm.cpp | 6 +++--- src/core/hle/service/set/set.cpp | 2 +- src/core/loader/nro.cpp | 4 ++-- src/core/loader/nso.cpp | 4 ++-- src/core/reporter.cpp | 2 +- src/core/telemetry_session.cpp | 2 +- 10 files changed, 17 insertions(+), 16 deletions(-) (limited to 'src/core') diff --git a/src/core/core.cpp b/src/core/core.cpp index e6f1aa0e7..fc6ec9512 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -263,9 +263,9 @@ struct System::Impl { if (Settings::values.gamecard_inserted) { if (Settings::values.gamecard_current_game) { fs_controller.SetGameCard(GetGameFileFromPath(virtual_filesystem, filepath)); - } else if (!Settings::values.gamecard_path.empty()) { - fs_controller.SetGameCard( - GetGameFileFromPath(virtual_filesystem, Settings::values.gamecard_path)); + } else if (!Settings::values.gamecard_path.GetValue().empty()) { + fs_controller.SetGameCard(GetGameFileFromPath( + virtual_filesystem, static_cast(Settings::values.gamecard_path))); } } diff --git a/src/core/frontend/applets/profile_select.cpp b/src/core/frontend/applets/profile_select.cpp index 8d960d1ca..4c58c310f 100644 --- a/src/core/frontend/applets/profile_select.cpp +++ b/src/core/frontend/applets/profile_select.cpp @@ -13,7 +13,7 @@ ProfileSelectApplet::~ProfileSelectApplet() = default; void DefaultProfileSelectApplet::SelectProfile( std::function)> callback) const { Service::Account::ProfileManager manager; - callback(manager.GetUser(Settings::values.current_user).value_or(Common::UUID{})); + callback(manager.GetUser(Settings::values.current_user.GetValue()).value_or(Common::UUID{})); LOG_INFO(Service_ACC, "called, selecting current user instead of prompting..."); } diff --git a/src/core/hle/service/acc/profile_manager.cpp b/src/core/hle/service/acc/profile_manager.cpp index f72d5d561..24a1c9157 100644 --- a/src/core/hle/service/acc/profile_manager.cpp +++ b/src/core/hle/service/acc/profile_manager.cpp @@ -48,7 +48,8 @@ ProfileManager::ProfileManager() { CreateNewUser(UUID::Generate(), "yuzu"); } - auto current = std::clamp(Settings::values.current_user, 0, MAX_USERS - 1); + auto current = + std::clamp(static_cast(Settings::values.current_user), 0, MAX_USERS - 1); // If user index don't exist. Load the first user and change the active user if (!UserExistsIndex(current)) { diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index b578153d3..23ebc1138 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp @@ -1443,7 +1443,7 @@ void IApplicationFunctions::PopLaunchParameter(Kernel::HLERequestContext& ctx) { params.is_account_selected = 1; Account::ProfileManager profile_manager{}; - const auto uuid = profile_manager.GetUser(Settings::values.current_user); + const auto uuid = profile_manager.GetUser(static_cast(Settings::values.current_user)); ASSERT(uuid); params.current_user = uuid->uuid; diff --git a/src/core/hle/service/nifm/nifm.cpp b/src/core/hle/service/nifm/nifm.cpp index f03b2666a..e742db48f 100644 --- a/src/core/hle/service/nifm/nifm.cpp +++ b/src/core/hle/service/nifm/nifm.cpp @@ -179,7 +179,7 @@ private: IPC::ResponseBuilder rb{ctx, 3}; rb.Push(ResultSuccess); - if (Settings::values.bcat_backend == "none") { + if (Settings::values.bcat_backend.GetValue() == "none") { rb.PushEnum(RequestState::NotSubmitted); } else { rb.PushEnum(RequestState::Connected); @@ -384,7 +384,7 @@ private: IPC::ResponseBuilder rb{ctx, 3}; rb.Push(ResultSuccess); - if (Settings::values.bcat_backend == "none") { + if (Settings::values.bcat_backend.GetValue() == "none") { rb.Push(0); } else { rb.Push(1); @@ -395,7 +395,7 @@ private: IPC::ResponseBuilder rb{ctx, 3}; rb.Push(ResultSuccess); - if (Settings::values.bcat_backend == "none") { + if (Settings::values.bcat_backend.GetValue() == "none") { rb.Push(0); } else { rb.Push(1); diff --git a/src/core/hle/service/set/set.cpp b/src/core/hle/service/set/set.cpp index ece2a74c6..522a604a5 100644 --- a/src/core/hle/service/set/set.cpp +++ b/src/core/hle/service/set/set.cpp @@ -160,7 +160,7 @@ void SET::GetQuestFlag(Kernel::HLERequestContext& ctx) { IPC::ResponseBuilder rb{ctx, 3}; rb.Push(ResultSuccess); - rb.Push(static_cast(Settings::values.quest_flag)); + rb.Push(static_cast(Settings::values.quest_flag.GetValue())); } void SET::GetLanguageCode(Kernel::HLERequestContext& ctx) { diff --git a/src/core/loader/nro.cpp b/src/core/loader/nro.cpp index 618555202..951ea966e 100644 --- a/src/core/loader/nro.cpp +++ b/src/core/loader/nro.cpp @@ -155,8 +155,8 @@ static bool LoadNroImpl(Kernel::KProcess& process, const std::vector& data) codeset.segments[i].size = PageAlignSize(nro_header.segments[i].size); } - if (!Settings::values.program_args.empty()) { - const auto arg_data = Settings::values.program_args; + if (!Settings::values.program_args.GetValue().empty()) { + const auto arg_data = Settings::values.program_args.GetValue(); codeset.DataSegment().size += NSO_ARGUMENT_DATA_ALLOCATION_SIZE; NSOArgumentHeader args_header{ NSO_ARGUMENT_DATA_ALLOCATION_SIZE, static_cast(arg_data.size()), {}}; diff --git a/src/core/loader/nso.cpp b/src/core/loader/nso.cpp index 0f5cfda68..4a2224c02 100644 --- a/src/core/loader/nso.cpp +++ b/src/core/loader/nso.cpp @@ -104,8 +104,8 @@ std::optional AppLoader_NSO::LoadModule(Kernel::KProcess& process, Core:: codeset.segments[i].size = nso_header.segments[i].size; } - if (should_pass_arguments && !Settings::values.program_args.empty()) { - const auto arg_data{Settings::values.program_args}; + if (should_pass_arguments && !Settings::values.program_args.GetValue().empty()) { + const auto arg_data{Settings::values.program_args.GetValue()}; codeset.DataSegment().size += NSO_ARGUMENT_DATA_ALLOCATION_SIZE; NSOArgumentHeader args_header{ diff --git a/src/core/reporter.cpp b/src/core/reporter.cpp index 82b0f535a..cfaf50105 100644 --- a/src/core/reporter.cpp +++ b/src/core/reporter.cpp @@ -397,7 +397,7 @@ void Reporter::ClearFSAccessLog() const { } bool Reporter::IsReportingEnabled() const { - return Settings::values.reporting_services; + return Settings::values.reporting_services.GetValue(); } } // namespace Core diff --git a/src/core/telemetry_session.cpp b/src/core/telemetry_session.cpp index d4c23ced2..44b8bab5b 100644 --- a/src/core/telemetry_session.cpp +++ b/src/core/telemetry_session.cpp @@ -212,7 +212,7 @@ 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_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()); -- cgit v1.2.3