diff options
| author | 2023-12-16 18:26:26 +0100 | |
|---|---|---|
| committer | 2024-01-08 18:43:56 +0100 | |
| commit | 63b835f822e5167aa529f2c27c5df136defef6eb (patch) | |
| tree | 45e69dabebeb24510902818d8e5d78e39bd4a365 | |
| parent | Merge pull request #12608 from szepeviktor/typos (diff) | |
| download | yuzu-63b835f822e5167aa529f2c27c5df136defef6eb.tar.gz yuzu-63b835f822e5167aa529f2c27c5df136defef6eb.tar.xz yuzu-63b835f822e5167aa529f2c27c5df136defef6eb.zip | |
Save profile name used
- Save the profile name in global config
- Read the profile name when reading the global config
| -rw-r--r-- | src/android/app/src/main/jni/android_config.cpp | 2 | ||||
| -rw-r--r-- | src/frontend_common/config.cpp | 34 | ||||
| -rw-r--r-- | src/frontend_common/config.h | 1 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_input_player.cpp | 16 | ||||
| -rw-r--r-- | src/yuzu/configuration/input_profiles.cpp | 3 | ||||
| -rw-r--r-- | src/yuzu/configuration/qt_config.cpp | 7 | ||||
| -rw-r--r-- | src/yuzu_cmd/sdl_config.cpp | 4 |
7 files changed, 55 insertions, 12 deletions
diff --git a/src/android/app/src/main/jni/android_config.cpp b/src/android/app/src/main/jni/android_config.cpp index 08aed3216..e147560c3 100644 --- a/src/android/app/src/main/jni/android_config.cpp +++ b/src/android/app/src/main/jni/android_config.cpp | |||
| @@ -21,7 +21,7 @@ void AndroidConfig::ReloadAllValues() { | |||
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | void AndroidConfig::SaveAllValues() { | 23 | void AndroidConfig::SaveAllValues() { |
| 24 | Save(); | 24 | SaveValues(); |
| 25 | SaveAndroidValues(); | 25 | SaveAndroidValues(); |
| 26 | } | 26 | } |
| 27 | 27 | ||
diff --git a/src/frontend_common/config.cpp b/src/frontend_common/config.cpp index 9eb4799a6..46277e288 100644 --- a/src/frontend_common/config.cpp +++ b/src/frontend_common/config.cpp | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | #include <array> | 5 | #include <array> |
| 6 | #include "common/fs/fs.h" | 6 | #include "common/fs/fs.h" |
| 7 | #include "common/fs/path_util.h" | 7 | #include "common/fs/path_util.h" |
| 8 | #include "common/logging/log.h" | ||
| 8 | #include "common/settings.h" | 9 | #include "common/settings.h" |
| 9 | #include "common/settings_common.h" | 10 | #include "common/settings_common.h" |
| 10 | #include "common/settings_enums.h" | 11 | #include "common/settings_enums.h" |
| @@ -58,6 +59,19 @@ void Config::Initialize(const std::optional<std::string> config_path) { | |||
| 58 | } | 59 | } |
| 59 | 60 | ||
| 60 | void Config::WriteToIni() const { | 61 | void Config::WriteToIni() const { |
| 62 | std::string config_type; | ||
| 63 | switch (type) { | ||
| 64 | case ConfigType::GlobalConfig: | ||
| 65 | config_type = "Global"; | ||
| 66 | break; | ||
| 67 | case ConfigType::PerGameConfig: | ||
| 68 | config_type = "Game Specific"; | ||
| 69 | break; | ||
| 70 | case ConfigType::InputProfile: | ||
| 71 | config_type = "Input Profile"; | ||
| 72 | break; | ||
| 73 | } | ||
| 74 | LOG_INFO(Config, "Writing {} configuration to: {}", config_type, config_loc); | ||
| 61 | FILE* fp = nullptr; | 75 | FILE* fp = nullptr; |
| 62 | #ifdef _WIN32 | 76 | #ifdef _WIN32 |
| 63 | fp = _wfopen(Common::UTF8ToUTF16W(config_loc).data(), L"wb"); | 77 | fp = _wfopen(Common::UTF8ToUTF16W(config_loc).data(), L"wb"); |
| @@ -117,10 +131,10 @@ void Config::ReadPlayerValues(const std::size_t player_index) { | |||
| 117 | player_prefix.append("player_").append(ToString(player_index)).append("_"); | 131 | player_prefix.append("player_").append(ToString(player_index)).append("_"); |
| 118 | } | 132 | } |
| 119 | 133 | ||
| 134 | const auto profile_name = ReadStringSetting(std::string(player_prefix).append("profile_name")); | ||
| 135 | |||
| 120 | auto& player = Settings::values.players.GetValue()[player_index]; | 136 | auto& player = Settings::values.players.GetValue()[player_index]; |
| 121 | if (IsCustomConfig()) { | 137 | if (IsCustomConfig()) { |
| 122 | const auto profile_name = | ||
| 123 | ReadStringSetting(std::string(player_prefix).append("profile_name")); | ||
| 124 | if (profile_name.empty()) { | 138 | if (profile_name.empty()) { |
| 125 | // Use the global input config | 139 | // Use the global input config |
| 126 | player = Settings::values.players.GetValue(true)[player_index]; | 140 | player = Settings::values.players.GetValue(true)[player_index]; |
| @@ -139,6 +153,10 @@ void Config::ReadPlayerValues(const std::size_t player_index) { | |||
| 139 | player.controller_type = controller; | 153 | player.controller_type = controller; |
| 140 | } | 154 | } |
| 141 | } else { | 155 | } else { |
| 156 | if (global) { | ||
| 157 | auto& player_global = Settings::values.players.GetValue(true)[player_index]; | ||
| 158 | player_global.profile_name = profile_name; | ||
| 159 | } | ||
| 142 | std::string connected_key = player_prefix; | 160 | std::string connected_key = player_prefix; |
| 143 | player.connected = ReadBooleanSetting(connected_key.append("connected"), | 161 | player.connected = ReadBooleanSetting(connected_key.append("connected"), |
| 144 | std::make_optional(player_index == 0)); | 162 | std::make_optional(player_index == 0)); |
| @@ -412,6 +430,11 @@ void Config::SavePlayerValues(const std::size_t player_index) { | |||
| 412 | std::make_optional(static_cast<u8>(Settings::ControllerType::ProController))); | 430 | std::make_optional(static_cast<u8>(Settings::ControllerType::ProController))); |
| 413 | 431 | ||
| 414 | if (!player_prefix.empty() || !Settings::IsConfiguringGlobal()) { | 432 | if (!player_prefix.empty() || !Settings::IsConfiguringGlobal()) { |
| 433 | if (global) { | ||
| 434 | const auto& player_global = Settings::values.players.GetValue(true)[player_index]; | ||
| 435 | WriteStringSetting(std::string(player_prefix).append("profile_name"), | ||
| 436 | player_global.profile_name, std::make_optional(std::string(""))); | ||
| 437 | } | ||
| 415 | WriteBooleanSetting(std::string(player_prefix).append("connected"), player.connected, | 438 | WriteBooleanSetting(std::string(player_prefix).append("connected"), player.connected, |
| 416 | std::make_optional(player_index == 0)); | 439 | std::make_optional(player_index == 0)); |
| 417 | WriteIntegerSetting(std::string(player_prefix).append("vibration_enabled"), | 440 | WriteIntegerSetting(std::string(player_prefix).append("vibration_enabled"), |
| @@ -468,12 +491,15 @@ void Config::SaveMotionTouchValues() { | |||
| 468 | 491 | ||
| 469 | void Config::SaveValues() { | 492 | void Config::SaveValues() { |
| 470 | if (global) { | 493 | if (global) { |
| 494 | LOG_DEBUG(Config, "Saving global generic configuration values"); | ||
| 471 | SaveDataStorageValues(); | 495 | SaveDataStorageValues(); |
| 472 | SaveDebuggingValues(); | 496 | SaveDebuggingValues(); |
| 473 | SaveDisabledAddOnValues(); | 497 | SaveDisabledAddOnValues(); |
| 474 | SaveNetworkValues(); | 498 | SaveNetworkValues(); |
| 475 | SaveWebServiceValues(); | 499 | SaveWebServiceValues(); |
| 476 | SaveMiscellaneousValues(); | 500 | SaveMiscellaneousValues(); |
| 501 | } else { | ||
| 502 | LOG_DEBUG(Config, "Saving only generic configuration values"); | ||
| 477 | } | 503 | } |
| 478 | SaveControlValues(); | 504 | SaveControlValues(); |
| 479 | SaveCoreValues(); | 505 | SaveCoreValues(); |
| @@ -814,10 +840,6 @@ void Config::Reload() { | |||
| 814 | SaveValues(); | 840 | SaveValues(); |
| 815 | } | 841 | } |
| 816 | 842 | ||
| 817 | void Config::Save() { | ||
| 818 | SaveValues(); | ||
| 819 | } | ||
| 820 | |||
| 821 | void Config::ClearControlPlayerValues() const { | 843 | void Config::ClearControlPlayerValues() const { |
| 822 | // If key is an empty string, all keys in the current group() are removed. | 844 | // If key is an empty string, all keys in the current group() are removed. |
| 823 | const char* section = Settings::TranslateCategory(Settings::Category::Controls); | 845 | const char* section = Settings::TranslateCategory(Settings::Category::Controls); |
diff --git a/src/frontend_common/config.h b/src/frontend_common/config.h index b01631649..4798d6432 100644 --- a/src/frontend_common/config.h +++ b/src/frontend_common/config.h | |||
| @@ -51,7 +51,6 @@ protected: | |||
| 51 | [[nodiscard]] bool IsCustomConfig() const; | 51 | [[nodiscard]] bool IsCustomConfig() const; |
| 52 | 52 | ||
| 53 | void Reload(); | 53 | void Reload(); |
| 54 | void Save(); | ||
| 55 | 54 | ||
| 56 | /** | 55 | /** |
| 57 | * Derived config classes must implement this so they can reload all platform-specific | 56 | * Derived config classes must implement this so they can reload all platform-specific |
diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp index f3552191a..9745757c7 100644 --- a/src/yuzu/configuration/configure_input_player.cpp +++ b/src/yuzu/configuration/configure_input_player.cpp | |||
| @@ -1650,9 +1650,21 @@ void ConfigureInputPlayer::SaveProfile() { | |||
| 1650 | void ConfigureInputPlayer::UpdateInputProfiles() { | 1650 | void ConfigureInputPlayer::UpdateInputProfiles() { |
| 1651 | ui->comboProfiles->clear(); | 1651 | ui->comboProfiles->clear(); |
| 1652 | 1652 | ||
| 1653 | for (const auto& profile_name : profiles->GetInputProfileNames()) { | 1653 | // Set current profile as empty by default |
| 1654 | int profile_index = -1; | ||
| 1655 | |||
| 1656 | // Add every available profile and search the player profile to set it as current one | ||
| 1657 | auto& current_profile = Settings::values.players.GetValue()[player_index].profile_name; | ||
| 1658 | std::vector<std::string> profile_names = profiles->GetInputProfileNames(); | ||
| 1659 | std::string profile_name; | ||
| 1660 | for (size_t i = 0; i < profile_names.size(); i++) { | ||
| 1661 | profile_name = profile_names[i]; | ||
| 1654 | ui->comboProfiles->addItem(QString::fromStdString(profile_name)); | 1662 | ui->comboProfiles->addItem(QString::fromStdString(profile_name)); |
| 1663 | if (current_profile == profile_name) { | ||
| 1664 | profile_index = (int)i; | ||
| 1665 | } | ||
| 1655 | } | 1666 | } |
| 1656 | 1667 | ||
| 1657 | ui->comboProfiles->setCurrentIndex(-1); | 1668 | LOG_DEBUG(Frontend, "Setting the current input profile to index {}", profile_index); |
| 1669 | ui->comboProfiles->setCurrentIndex(profile_index); | ||
| 1658 | } | 1670 | } |
diff --git a/src/yuzu/configuration/input_profiles.cpp b/src/yuzu/configuration/input_profiles.cpp index 716efbccd..ebebadc94 100644 --- a/src/yuzu/configuration/input_profiles.cpp +++ b/src/yuzu/configuration/input_profiles.cpp | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | 5 | ||
| 6 | #include "common/fs/fs.h" | 6 | #include "common/fs/fs.h" |
| 7 | #include "common/fs/path_util.h" | 7 | #include "common/fs/path_util.h" |
| 8 | #include "common/logging/log.h" | ||
| 8 | #include "frontend_common/config.h" | 9 | #include "frontend_common/config.h" |
| 9 | #include "yuzu/configuration/input_profiles.h" | 10 | #include "yuzu/configuration/input_profiles.h" |
| 10 | 11 | ||
| @@ -113,6 +114,8 @@ bool InputProfiles::LoadProfile(const std::string& profile_name, std::size_t pla | |||
| 113 | return false; | 114 | return false; |
| 114 | } | 115 | } |
| 115 | 116 | ||
| 117 | LOG_INFO(Config, "Loading input profile `{}`", profile_name); | ||
| 118 | |||
| 116 | map_profiles[profile_name]->ReadQtControlPlayerValues(player_index); | 119 | map_profiles[profile_name]->ReadQtControlPlayerValues(player_index); |
| 117 | return true; | 120 | return true; |
| 118 | } | 121 | } |
diff --git a/src/yuzu/configuration/qt_config.cpp b/src/yuzu/configuration/qt_config.cpp index 6aca71d7c..1051031f2 100644 --- a/src/yuzu/configuration/qt_config.cpp +++ b/src/yuzu/configuration/qt_config.cpp | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | // SPDX-FileCopyrightText: 2023 yuzu Emulator Project | 1 | // SPDX-FileCopyrightText: 2023 yuzu Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include "common/logging/log.h" | ||
| 4 | #include "input_common/main.h" | 5 | #include "input_common/main.h" |
| 5 | #include "qt_config.h" | 6 | #include "qt_config.h" |
| 6 | #include "uisettings.h" | 7 | #include "uisettings.h" |
| @@ -65,7 +66,7 @@ void QtConfig::ReloadAllValues() { | |||
| 65 | } | 66 | } |
| 66 | 67 | ||
| 67 | void QtConfig::SaveAllValues() { | 68 | void QtConfig::SaveAllValues() { |
| 68 | Save(); | 69 | SaveValues(); |
| 69 | SaveQtValues(); | 70 | SaveQtValues(); |
| 70 | } | 71 | } |
| 71 | 72 | ||
| @@ -327,7 +328,10 @@ void QtConfig::ReadMultiplayerValues() { | |||
| 327 | 328 | ||
| 328 | void QtConfig::SaveQtValues() { | 329 | void QtConfig::SaveQtValues() { |
| 329 | if (global) { | 330 | if (global) { |
| 331 | LOG_DEBUG(Config, "Saving global Qt configuration values"); | ||
| 330 | SaveUIValues(); | 332 | SaveUIValues(); |
| 333 | } else { | ||
| 334 | LOG_DEBUG(Config, "Saving Qt configuration values"); | ||
| 331 | } | 335 | } |
| 332 | SaveQtControlValues(); | 336 | SaveQtControlValues(); |
| 333 | 337 | ||
| @@ -545,6 +549,7 @@ void QtConfig::ReadQtControlPlayerValues(std::size_t player_index) { | |||
| 545 | void QtConfig::SaveQtControlPlayerValues(std::size_t player_index) { | 549 | void QtConfig::SaveQtControlPlayerValues(std::size_t player_index) { |
| 546 | BeginGroup(Settings::TranslateCategory(Settings::Category::Controls)); | 550 | BeginGroup(Settings::TranslateCategory(Settings::Category::Controls)); |
| 547 | 551 | ||
| 552 | LOG_DEBUG(Config, "Saving players control configuration values"); | ||
| 548 | SavePlayerValues(player_index); | 553 | SavePlayerValues(player_index); |
| 549 | SaveQtPlayerValues(player_index); | 554 | SaveQtPlayerValues(player_index); |
| 550 | 555 | ||
diff --git a/src/yuzu_cmd/sdl_config.cpp b/src/yuzu_cmd/sdl_config.cpp index e81bf5d45..995114510 100644 --- a/src/yuzu_cmd/sdl_config.cpp +++ b/src/yuzu_cmd/sdl_config.cpp | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | #define SDL_MAIN_HANDLED | 5 | #define SDL_MAIN_HANDLED |
| 6 | #include <SDL.h> | 6 | #include <SDL.h> |
| 7 | 7 | ||
| 8 | #include "common/logging/log.h" | ||
| 8 | #include "input_common/main.h" | 9 | #include "input_common/main.h" |
| 9 | #include "sdl_config.h" | 10 | #include "sdl_config.h" |
| 10 | 11 | ||
| @@ -64,7 +65,7 @@ void SdlConfig::ReloadAllValues() { | |||
| 64 | } | 65 | } |
| 65 | 66 | ||
| 66 | void SdlConfig::SaveAllValues() { | 67 | void SdlConfig::SaveAllValues() { |
| 67 | Save(); | 68 | SaveValues(); |
| 68 | SaveSdlValues(); | 69 | SaveSdlValues(); |
| 69 | } | 70 | } |
| 70 | 71 | ||
| @@ -177,6 +178,7 @@ void SdlConfig::ReadHidbusValues() { | |||
| 177 | } | 178 | } |
| 178 | 179 | ||
| 179 | void SdlConfig::SaveSdlValues() { | 180 | void SdlConfig::SaveSdlValues() { |
| 181 | LOG_DEBUG(Config, "Saving SDL configuration values"); | ||
| 180 | SaveSdlControlValues(); | 182 | SaveSdlControlValues(); |
| 181 | 183 | ||
| 182 | WriteToIni(); | 184 | WriteToIni(); |