diff options
Diffstat (limited to 'src/frontend_common/config.cpp')
| -rw-r--r-- | src/frontend_common/config.cpp | 34 |
1 files changed, 28 insertions, 6 deletions
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); |