diff options
Diffstat (limited to 'src/common/settings.cpp')
| -rw-r--r-- | src/common/settings.cpp | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/src/common/settings.cpp b/src/common/settings.cpp index ff53e80bb..66dffc9bf 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp | |||
| @@ -1,12 +1,16 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project | 1 | // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #if __cpp_lib_chrono >= 201907L | ||
| 5 | #include <chrono> | ||
| 6 | #endif | ||
| 4 | #include <string_view> | 7 | #include <string_view> |
| 5 | 8 | ||
| 6 | #include "common/assert.h" | 9 | #include "common/assert.h" |
| 7 | #include "common/fs/path_util.h" | 10 | #include "common/fs/path_util.h" |
| 8 | #include "common/logging/log.h" | 11 | #include "common/logging/log.h" |
| 9 | #include "common/settings.h" | 12 | #include "common/settings.h" |
| 13 | #include "common/time_zone.h" | ||
| 10 | 14 | ||
| 11 | namespace Settings { | 15 | namespace Settings { |
| 12 | 16 | ||
| @@ -14,18 +18,23 @@ Values values; | |||
| 14 | static bool configuring_global = true; | 18 | static bool configuring_global = true; |
| 15 | 19 | ||
| 16 | std::string GetTimeZoneString() { | 20 | std::string GetTimeZoneString() { |
| 17 | static constexpr std::array timezones{ | ||
| 18 | "auto", "default", "CET", "CST6CDT", "Cuba", "EET", "Egypt", "Eire", | ||
| 19 | "EST", "EST5EDT", "GB", "GB-Eire", "GMT", "GMT+0", "GMT-0", "GMT0", | ||
| 20 | "Greenwich", "Hongkong", "HST", "Iceland", "Iran", "Israel", "Jamaica", "Japan", | ||
| 21 | "Kwajalein", "Libya", "MET", "MST", "MST7MDT", "Navajo", "NZ", "NZ-CHAT", | ||
| 22 | "Poland", "Portugal", "PRC", "PST8PDT", "ROC", "ROK", "Singapore", "Turkey", | ||
| 23 | "UCT", "Universal", "UTC", "W-SU", "WET", "Zulu", | ||
| 24 | }; | ||
| 25 | |||
| 26 | const auto time_zone_index = static_cast<std::size_t>(values.time_zone_index.GetValue()); | 21 | const auto time_zone_index = static_cast<std::size_t>(values.time_zone_index.GetValue()); |
| 27 | ASSERT(time_zone_index < timezones.size()); | 22 | ASSERT(time_zone_index < Common::TimeZone::GetTimeZoneStrings().size()); |
| 28 | return timezones[time_zone_index]; | 23 | |
| 24 | std::string location_name; | ||
| 25 | if (time_zone_index == 0) { // Auto | ||
| 26 | #if __cpp_lib_chrono >= 201907L | ||
| 27 | const struct std::chrono::tzdb& time_zone_data = std::chrono::get_tzdb(); | ||
| 28 | const std::chrono::time_zone* current_zone = time_zone_data.current_zone(); | ||
| 29 | std::string_view current_zone_name = current_zone->name(); | ||
| 30 | location_name = current_zone_name; | ||
| 31 | #else | ||
| 32 | location_name = Common::TimeZone::FindSystemTimeZone(); | ||
| 33 | #endif | ||
| 34 | } else { | ||
| 35 | location_name = Common::TimeZone::GetTimeZoneStrings()[time_zone_index]; | ||
| 36 | } | ||
| 37 | return location_name; | ||
| 29 | } | 38 | } |
| 30 | 39 | ||
| 31 | void LogSettings() { | 40 | void LogSettings() { |
| @@ -235,6 +244,7 @@ void RestoreGlobalState(bool is_powered_on) { | |||
| 235 | values.bg_green.SetGlobal(true); | 244 | values.bg_green.SetGlobal(true); |
| 236 | values.bg_blue.SetGlobal(true); | 245 | values.bg_blue.SetGlobal(true); |
| 237 | values.enable_compute_pipelines.SetGlobal(true); | 246 | values.enable_compute_pipelines.SetGlobal(true); |
| 247 | values.use_video_framerate.SetGlobal(true); | ||
| 238 | 248 | ||
| 239 | // System | 249 | // System |
| 240 | values.language_index.SetGlobal(true); | 250 | values.language_index.SetGlobal(true); |