summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/frontend_common/config.cpp29
-rw-r--r--src/frontend_common/config.h4
-rw-r--r--src/yuzu/configuration/qt_config.cpp3
3 files changed, 34 insertions, 2 deletions
diff --git a/src/frontend_common/config.cpp b/src/frontend_common/config.cpp
index 40a44ae12..a68a9cb4b 100644
--- a/src/frontend_common/config.cpp
+++ b/src/frontend_common/config.cpp
@@ -284,7 +284,7 @@ void Config::ReadDisabledAddOnValues() {
284 const int size = BeginArray(std::string("")); 284 const int size = BeginArray(std::string(""));
285 for (int i = 0; i < size; ++i) { 285 for (int i = 0; i < size; ++i) {
286 SetArrayIndex(i); 286 SetArrayIndex(i);
287 const auto title_id = ReadIntegerSetting(std::string("title_id"), 0); 287 const auto title_id = ReadUnsignedIntegerSetting(std::string("title_id"), 0);
288 std::vector<std::string> out; 288 std::vector<std::string> out;
289 const int d_size = BeginArray("disabled"); 289 const int d_size = BeginArray("disabled");
290 for (int j = 0; j < d_size; ++j) { 290 for (int j = 0; j < d_size; ++j) {
@@ -664,6 +664,33 @@ s64 Config::ReadIntegerSetting(const std::string& key, const std::optional<s64>
664 return result; 664 return result;
665} 665}
666 666
667u64 Config::ReadUnsignedIntegerSetting(const std::string& key,
668 const std::optional<u64> default_value) {
669 std::string full_key = GetFullKey(key, false);
670 if (!default_value.has_value()) {
671 try {
672 return std::stoull(
673 std::string(config->GetValue(GetSection().c_str(), full_key.c_str(), "0")));
674 } catch (...) {
675 return 0;
676 }
677 }
678
679 u64 result = 0;
680 if (config->GetBoolValue(GetSection().c_str(),
681 std::string(full_key).append("\\default").c_str(), true)) {
682 result = default_value.value();
683 } else {
684 try {
685 result = std::stoull(std::string(config->GetValue(
686 GetSection().c_str(), full_key.c_str(), ToString(default_value.value()).c_str())));
687 } catch (...) {
688 result = default_value.value();
689 }
690 }
691 return result;
692}
693
667double Config::ReadDoubleSetting(const std::string& key, 694double Config::ReadDoubleSetting(const std::string& key,
668 const std::optional<double> default_value) { 695 const std::optional<double> default_value) {
669 std::string full_key = GetFullKey(key, false); 696 std::string full_key = GetFullKey(key, false);
diff --git a/src/frontend_common/config.h b/src/frontend_common/config.h
index f741aa8bb..20a1a8056 100644
--- a/src/frontend_common/config.h
+++ b/src/frontend_common/config.h
@@ -137,6 +137,8 @@ protected:
137 bool ReadBooleanSetting(const std::string& key, 137 bool ReadBooleanSetting(const std::string& key,
138 std::optional<bool> default_value = std::nullopt); 138 std::optional<bool> default_value = std::nullopt);
139 s64 ReadIntegerSetting(const std::string& key, std::optional<s64> default_value = std::nullopt); 139 s64 ReadIntegerSetting(const std::string& key, std::optional<s64> default_value = std::nullopt);
140 u64 ReadUnsignedIntegerSetting(const std::string& key,
141 std::optional<u64> default_value = std::nullopt);
140 double ReadDoubleSetting(const std::string& key, 142 double ReadDoubleSetting(const std::string& key,
141 std::optional<double> default_value = std::nullopt); 143 std::optional<double> default_value = std::nullopt);
142 std::string ReadStringSetting(const std::string& key, 144 std::string ReadStringSetting(const std::string& key,
@@ -170,6 +172,8 @@ protected:
170 return value_.has_value() ? std::to_string(*value_) : "none"; 172 return value_.has_value() ? std::to_string(*value_) : "none";
171 } else if constexpr (std::is_same_v<T, bool>) { 173 } else if constexpr (std::is_same_v<T, bool>) {
172 return value_ ? "true" : "false"; 174 return value_ ? "true" : "false";
175 } else if constexpr (std::is_same_v<T, u64>) {
176 return std::to_string(static_cast<u64>(value_));
173 } else { 177 } else {
174 return std::to_string(static_cast<s64>(value_)); 178 return std::to_string(static_cast<s64>(value_));
175 } 179 }
diff --git a/src/yuzu/configuration/qt_config.cpp b/src/yuzu/configuration/qt_config.cpp
index 82402ec70..5a8e69aa9 100644
--- a/src/yuzu/configuration/qt_config.cpp
+++ b/src/yuzu/configuration/qt_config.cpp
@@ -283,7 +283,8 @@ void QtConfig::ReadUIGamelistValues() {
283 const int favorites_size = BeginArray("favorites"); 283 const int favorites_size = BeginArray("favorites");
284 for (int i = 0; i < favorites_size; i++) { 284 for (int i = 0; i < favorites_size; i++) {
285 SetArrayIndex(i); 285 SetArrayIndex(i);
286 UISettings::values.favorited_ids.append(ReadIntegerSetting(std::string("program_id"))); 286 UISettings::values.favorited_ids.append(
287 ReadUnsignedIntegerSetting(std::string("program_id")));
287 } 288 }
288 EndArray(); 289 EndArray();
289 290