summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar ameerj2021-10-16 02:07:18 -0400
committerGravatar ameerj2021-10-17 00:37:49 -0400
commitef811c64259f0b83aa72c99bad9d4e48082129f8 (patch)
tree68a10f30c76c06fe2cbd7893d6481e7372e57613
parentMerge pull request #7190 from Morph1984/missing-ui-main (diff)
downloadyuzu-ef811c64259f0b83aa72c99bad9d4e48082129f8.tar.gz
yuzu-ef811c64259f0b83aa72c99bad9d4e48082129f8.tar.xz
yuzu-ef811c64259f0b83aa72c99bad9d4e48082129f8.zip
settings: Remove std::chrono usage
Alleviates the dependency on chrono for all files that include settings.h
-rw-r--r--src/common/settings.h5
-rw-r--r--src/core/core.cpp5
-rw-r--r--src/core/hle/service/time/time_manager.cpp13
-rw-r--r--src/video_core/renderer_opengl/gl_device.cpp1
-rw-r--r--src/yuzu/configuration/config.cpp7
-rw-r--r--src/yuzu/configuration/configure_system.cpp10
-rw-r--r--src/yuzu_cmd/config.cpp3
7 files changed, 20 insertions, 24 deletions
diff --git a/src/common/settings.h b/src/common/settings.h
index 402339443..9ff4cf85d 100644
--- a/src/common/settings.h
+++ b/src/common/settings.h
@@ -7,7 +7,6 @@
7#include <algorithm> 7#include <algorithm>
8#include <array> 8#include <array>
9#include <atomic> 9#include <atomic>
10#include <chrono>
11#include <map> 10#include <map>
12#include <optional> 11#include <optional>
13#include <string> 12#include <string>
@@ -487,9 +486,9 @@ struct Values {
487 // System 486 // System
488 Setting<std::optional<u32>> rng_seed{std::optional<u32>(), "rng_seed"}; 487 Setting<std::optional<u32>> rng_seed{std::optional<u32>(), "rng_seed"};
489 // Measured in seconds since epoch 488 // Measured in seconds since epoch
490 std::optional<std::chrono::seconds> custom_rtc; 489 std::optional<s64> custom_rtc;
491 // Set on game boot, reset on stop. Seconds difference between current time and `custom_rtc` 490 // Set on game boot, reset on stop. Seconds difference between current time and `custom_rtc`
492 std::chrono::seconds custom_rtc_differential; 491 s64 custom_rtc_differential;
493 492
494 BasicSetting<s32> current_user{0, "current_user"}; 493 BasicSetting<s32> current_user{0, "current_user"};
495 RangedSetting<s32> language_index{1, 0, 17, "language_index"}; 494 RangedSetting<s32> language_index{1, 0, 17, "language_index"};
diff --git a/src/core/core.cpp b/src/core/core.cpp
index 3042d611b..3c75f42ae 100644
--- a/src/core/core.cpp
+++ b/src/core/core.cpp
@@ -196,8 +196,9 @@ struct System::Impl {
196 cpu_manager.Initialize(); 196 cpu_manager.Initialize();
197 core_timing.Initialize([&system]() { system.RegisterHostThread(); }); 197 core_timing.Initialize([&system]() { system.RegisterHostThread(); });
198 198
199 const auto current_time = std::chrono::duration_cast<std::chrono::seconds>( 199 const auto posix_time = std::chrono::system_clock::now().time_since_epoch();
200 std::chrono::system_clock::now().time_since_epoch()); 200 const auto current_time =
201 std::chrono::duration_cast<std::chrono::seconds>(posix_time).count();
201 Settings::values.custom_rtc_differential = 202 Settings::values.custom_rtc_differential =
202 Settings::values.custom_rtc.value_or(current_time) - current_time; 203 Settings::values.custom_rtc.value_or(current_time) - current_time;
203 204
diff --git a/src/core/hle/service/time/time_manager.cpp b/src/core/hle/service/time/time_manager.cpp
index 4bbc606a1..9c4c960ef 100644
--- a/src/core/hle/service/time/time_manager.cpp
+++ b/src/core/hle/service/time/time_manager.cpp
@@ -13,18 +13,19 @@
13#include "core/hle/service/time/time_manager.h" 13#include "core/hle/service/time/time_manager.h"
14 14
15namespace Service::Time { 15namespace Service::Time {
16 16namespace {
17constexpr Clock::TimeSpanType standard_network_clock_accuracy{0x0009356907420000ULL}; 17constexpr Clock::TimeSpanType standard_network_clock_accuracy{0x0009356907420000ULL};
18 18
19static std::chrono::seconds GetSecondsSinceEpoch() { 19s64 GetSecondsSinceEpoch() {
20 return std::chrono::duration_cast<std::chrono::seconds>( 20 const auto time_since_epoch = std::chrono::system_clock::now().time_since_epoch();
21 std::chrono::system_clock::now().time_since_epoch()) + 21 return std::chrono::duration_cast<std::chrono::seconds>(time_since_epoch).count() +
22 Settings::values.custom_rtc_differential; 22 Settings::values.custom_rtc_differential;
23} 23}
24 24
25static s64 GetExternalRtcValue() { 25s64 GetExternalRtcValue() {
26 return GetSecondsSinceEpoch().count() + TimeManager::GetExternalTimeZoneOffset(); 26 return GetSecondsSinceEpoch() + TimeManager::GetExternalTimeZoneOffset();
27} 27}
28} // Anonymous namespace
28 29
29struct TimeManager::Impl final { 30struct TimeManager::Impl final {
30 explicit Impl(Core::System& system) 31 explicit Impl(Core::System& system)
diff --git a/src/video_core/renderer_opengl/gl_device.cpp b/src/video_core/renderer_opengl/gl_device.cpp
index 9692b8e94..1e1d1d020 100644
--- a/src/video_core/renderer_opengl/gl_device.cpp
+++ b/src/video_core/renderer_opengl/gl_device.cpp
@@ -10,6 +10,7 @@
10#include <limits> 10#include <limits>
11#include <optional> 11#include <optional>
12#include <span> 12#include <span>
13#include <stdexcept>
13#include <vector> 14#include <vector>
14 15
15#include <glad/glad.h> 16#include <glad/glad.h>
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp
index 30a864135..faea5dda1 100644
--- a/src/yuzu/configuration/config.cpp
+++ b/src/yuzu/configuration/config.cpp
@@ -918,8 +918,7 @@ void Config::ReadSystemValues() {
918 const auto custom_rtc_enabled = 918 const auto custom_rtc_enabled =
919 ReadSetting(QStringLiteral("custom_rtc_enabled"), false).toBool(); 919 ReadSetting(QStringLiteral("custom_rtc_enabled"), false).toBool();
920 if (custom_rtc_enabled) { 920 if (custom_rtc_enabled) {
921 Settings::values.custom_rtc = 921 Settings::values.custom_rtc = ReadSetting(QStringLiteral("custom_rtc"), 0).toLongLong();
922 std::chrono::seconds(ReadSetting(QStringLiteral("custom_rtc"), 0).toULongLong());
923 } else { 922 } else {
924 Settings::values.custom_rtc = std::nullopt; 923 Settings::values.custom_rtc = std::nullopt;
925 } 924 }
@@ -1450,9 +1449,7 @@ void Config::SaveSystemValues() {
1450 WriteSetting(QStringLiteral("custom_rtc_enabled"), Settings::values.custom_rtc.has_value(), 1449 WriteSetting(QStringLiteral("custom_rtc_enabled"), Settings::values.custom_rtc.has_value(),
1451 false); 1450 false);
1452 WriteSetting(QStringLiteral("custom_rtc"), 1451 WriteSetting(QStringLiteral("custom_rtc"),
1453 QVariant::fromValue<long long>( 1452 QVariant::fromValue<long long>(Settings::values.custom_rtc.value_or(0)), 0);
1454 Settings::values.custom_rtc.value_or(std::chrono::seconds{}).count()),
1455 0);
1456 } 1453 }
1457 1454
1458 WriteGlobalSetting(Settings::values.sound_index); 1455 WriteGlobalSetting(Settings::values.sound_index);
diff --git a/src/yuzu/configuration/configure_system.cpp b/src/yuzu/configuration/configure_system.cpp
index eea45f8ea..56c762d64 100644
--- a/src/yuzu/configuration/configure_system.cpp
+++ b/src/yuzu/configuration/configure_system.cpp
@@ -65,8 +65,7 @@ void ConfigureSystem::SetConfiguration() {
65 QStringLiteral("%1") 65 QStringLiteral("%1")
66 .arg(Settings::values.rng_seed.GetValue().value_or(0), 8, 16, QLatin1Char{'0'}) 66 .arg(Settings::values.rng_seed.GetValue().value_or(0), 8, 16, QLatin1Char{'0'})
67 .toUpper(); 67 .toUpper();
68 const auto rtc_time = Settings::values.custom_rtc.value_or( 68 const auto rtc_time = Settings::values.custom_rtc.value_or(QDateTime::currentSecsSinceEpoch());
69 std::chrono::seconds(QDateTime::currentSecsSinceEpoch()));
70 69
71 ui->rng_seed_checkbox->setChecked(Settings::values.rng_seed.GetValue().has_value()); 70 ui->rng_seed_checkbox->setChecked(Settings::values.rng_seed.GetValue().has_value());
72 ui->rng_seed_edit->setEnabled(Settings::values.rng_seed.GetValue().has_value() && 71 ui->rng_seed_edit->setEnabled(Settings::values.rng_seed.GetValue().has_value() &&
@@ -75,7 +74,7 @@ void ConfigureSystem::SetConfiguration() {
75 74
76 ui->custom_rtc_checkbox->setChecked(Settings::values.custom_rtc.has_value()); 75 ui->custom_rtc_checkbox->setChecked(Settings::values.custom_rtc.has_value());
77 ui->custom_rtc_edit->setEnabled(Settings::values.custom_rtc.has_value()); 76 ui->custom_rtc_edit->setEnabled(Settings::values.custom_rtc.has_value());
78 ui->custom_rtc_edit->setDateTime(QDateTime::fromSecsSinceEpoch(rtc_time.count())); 77 ui->custom_rtc_edit->setDateTime(QDateTime::fromSecsSinceEpoch(rtc_time));
79 78
80 if (Settings::IsConfiguringGlobal()) { 79 if (Settings::IsConfiguringGlobal()) {
81 ui->combo_language->setCurrentIndex(Settings::values.language_index.GetValue()); 80 ui->combo_language->setCurrentIndex(Settings::values.language_index.GetValue());
@@ -108,10 +107,9 @@ void ConfigureSystem::ApplyConfiguration() {
108 // to allow in-game time to be fast forwarded 107 // to allow in-game time to be fast forwarded
109 if (Settings::IsConfiguringGlobal()) { 108 if (Settings::IsConfiguringGlobal()) {
110 if (ui->custom_rtc_checkbox->isChecked()) { 109 if (ui->custom_rtc_checkbox->isChecked()) {
111 Settings::values.custom_rtc = 110 Settings::values.custom_rtc = ui->custom_rtc_edit->dateTime().toSecsSinceEpoch();
112 std::chrono::seconds(ui->custom_rtc_edit->dateTime().toSecsSinceEpoch());
113 if (system.IsPoweredOn()) { 111 if (system.IsPoweredOn()) {
114 const s64 posix_time{Settings::values.custom_rtc->count() + 112 const s64 posix_time{*Settings::values.custom_rtc +
115 Service::Time::TimeManager::GetExternalTimeZoneOffset()}; 113 Service::Time::TimeManager::GetExternalTimeZoneOffset()};
116 system.GetTimeManager().UpdateLocalSystemClockTime(posix_time); 114 system.GetTimeManager().UpdateLocalSystemClockTime(posix_time);
117 } 115 }
diff --git a/src/yuzu_cmd/config.cpp b/src/yuzu_cmd/config.cpp
index 8ca20679a..0b8fde691 100644
--- a/src/yuzu_cmd/config.cpp
+++ b/src/yuzu_cmd/config.cpp
@@ -412,8 +412,7 @@ void Config::ReadValues() {
412 412
413 const auto custom_rtc_enabled = sdl2_config->GetBoolean("System", "custom_rtc_enabled", false); 413 const auto custom_rtc_enabled = sdl2_config->GetBoolean("System", "custom_rtc_enabled", false);
414 if (custom_rtc_enabled) { 414 if (custom_rtc_enabled) {
415 Settings::values.custom_rtc = 415 Settings::values.custom_rtc = sdl2_config->GetInteger("System", "custom_rtc", 0);
416 std::chrono::seconds(sdl2_config->GetInteger("System", "custom_rtc", 0));
417 } else { 416 } else {
418 Settings::values.custom_rtc = std::nullopt; 417 Settings::values.custom_rtc = std::nullopt;
419 } 418 }