mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-11-15 12:40:05 +00:00
general: Demote custom_rtc to regular setting
This commit is contained in:
parent
ab2677f0a1
commit
339dc4f806
@ -136,7 +136,6 @@ void RestoreGlobalState(bool is_powered_on) {
|
|||||||
values.region_index.SetGlobal(true);
|
values.region_index.SetGlobal(true);
|
||||||
values.time_zone_index.SetGlobal(true);
|
values.time_zone_index.SetGlobal(true);
|
||||||
values.rng_seed.SetGlobal(true);
|
values.rng_seed.SetGlobal(true);
|
||||||
values.custom_rtc.SetGlobal(true);
|
|
||||||
values.sound_index.SetGlobal(true);
|
values.sound_index.SetGlobal(true);
|
||||||
|
|
||||||
// Controls
|
// Controls
|
||||||
|
@ -157,7 +157,7 @@ struct Values {
|
|||||||
// System
|
// System
|
||||||
Setting<std::optional<u32>> rng_seed;
|
Setting<std::optional<u32>> rng_seed;
|
||||||
// Measured in seconds since epoch
|
// Measured in seconds since epoch
|
||||||
Setting<std::optional<std::chrono::seconds>> custom_rtc;
|
std::optional<std::chrono::seconds> custom_rtc;
|
||||||
// Set on game boot, reset on stop. Seconds difference between current time and `custom_rtc`
|
// Set on game boot, reset on stop. Seconds difference between current time and `custom_rtc`
|
||||||
std::chrono::seconds custom_rtc_differential;
|
std::chrono::seconds custom_rtc_differential;
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ struct System::Impl {
|
|||||||
const auto current_time = std::chrono::duration_cast<std::chrono::seconds>(
|
const auto current_time = std::chrono::duration_cast<std::chrono::seconds>(
|
||||||
std::chrono::system_clock::now().time_since_epoch());
|
std::chrono::system_clock::now().time_since_epoch());
|
||||||
Settings::values.custom_rtc_differential =
|
Settings::values.custom_rtc_differential =
|
||||||
Settings::values.custom_rtc.GetValue().value_or(current_time) - current_time;
|
Settings::values.custom_rtc.value_or(current_time) - current_time;
|
||||||
|
|
||||||
// Create a default fs if one doesn't already exist.
|
// Create a default fs if one doesn't already exist.
|
||||||
if (virtual_filesystem == nullptr)
|
if (virtual_filesystem == nullptr)
|
||||||
|
@ -868,17 +868,14 @@ void Config::ReadSystemValues() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool custom_rtc_enabled;
|
if (global) {
|
||||||
ReadSettingGlobal(custom_rtc_enabled, QStringLiteral("custom_rtc_enabled"), false);
|
const auto custom_rtc_enabled =
|
||||||
bool custom_rtc_global =
|
ReadSetting(QStringLiteral("custom_rtc_enabled"), false).toBool();
|
||||||
global || qt_config->value(QStringLiteral("custom_rtc/use_global"), true).toBool();
|
|
||||||
Settings::values.custom_rtc.SetGlobal(custom_rtc_global);
|
|
||||||
if (global || !custom_rtc_global) {
|
|
||||||
if (custom_rtc_enabled) {
|
if (custom_rtc_enabled) {
|
||||||
Settings::values.custom_rtc.SetValue(
|
Settings::values.custom_rtc =
|
||||||
std::chrono::seconds(ReadSetting(QStringLiteral("custom_rtc"), 0).toULongLong()));
|
std::chrono::seconds(ReadSetting(QStringLiteral("custom_rtc"), 0).toULongLong());
|
||||||
} else {
|
} else {
|
||||||
Settings::values.custom_rtc.SetValue(std::nullopt);
|
Settings::values.custom_rtc = std::nullopt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1433,14 +1430,14 @@ void Config::SaveSystemValues() {
|
|||||||
Settings::values.rng_seed.GetValue(global).value_or(0),
|
Settings::values.rng_seed.GetValue(global).value_or(0),
|
||||||
Settings::values.rng_seed.UsingGlobal(), 0);
|
Settings::values.rng_seed.UsingGlobal(), 0);
|
||||||
|
|
||||||
WriteSettingGlobal(QStringLiteral("custom_rtc_enabled"),
|
if (global) {
|
||||||
Settings::values.custom_rtc.GetValue(global).has_value(),
|
WriteSetting(QStringLiteral("custom_rtc_enabled"), Settings::values.custom_rtc.has_value(),
|
||||||
Settings::values.custom_rtc.UsingGlobal(), false);
|
false);
|
||||||
WriteSettingGlobal(
|
WriteSetting(QStringLiteral("custom_rtc"),
|
||||||
QStringLiteral("custom_rtc"),
|
|
||||||
QVariant::fromValue<long long>(
|
QVariant::fromValue<long long>(
|
||||||
Settings::values.custom_rtc.GetValue(global).value_or(std::chrono::seconds{}).count()),
|
Settings::values.custom_rtc.value_or(std::chrono::seconds{}).count()),
|
||||||
Settings::values.custom_rtc.UsingGlobal(), 0);
|
0);
|
||||||
|
}
|
||||||
|
|
||||||
WriteSettingGlobal(QStringLiteral("sound_index"), Settings::values.sound_index, 1);
|
WriteSettingGlobal(QStringLiteral("sound_index"), Settings::values.sound_index, 1);
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ void ConfigureSystem::SetConfiguration() {
|
|||||||
QStringLiteral("%1")
|
QStringLiteral("%1")
|
||||||
.arg(Settings::values.rng_seed.GetValue().value_or(0), 8, 16, QLatin1Char{'0'})
|
.arg(Settings::values.rng_seed.GetValue().value_or(0), 8, 16, QLatin1Char{'0'})
|
||||||
.toUpper();
|
.toUpper();
|
||||||
const auto rtc_time = Settings::values.custom_rtc.GetValue().value_or(
|
const auto rtc_time = Settings::values.custom_rtc.value_or(
|
||||||
std::chrono::seconds(QDateTime::currentSecsSinceEpoch()));
|
std::chrono::seconds(QDateTime::currentSecsSinceEpoch()));
|
||||||
|
|
||||||
ui->rng_seed_checkbox->setChecked(Settings::values.rng_seed.GetValue().has_value());
|
ui->rng_seed_checkbox->setChecked(Settings::values.rng_seed.GetValue().has_value());
|
||||||
@ -73,9 +73,8 @@ void ConfigureSystem::SetConfiguration() {
|
|||||||
Settings::values.rng_seed.UsingGlobal());
|
Settings::values.rng_seed.UsingGlobal());
|
||||||
ui->rng_seed_edit->setText(rng_seed);
|
ui->rng_seed_edit->setText(rng_seed);
|
||||||
|
|
||||||
ui->custom_rtc_checkbox->setChecked(Settings::values.custom_rtc.GetValue().has_value());
|
ui->custom_rtc_checkbox->setChecked(Settings::values.custom_rtc.has_value());
|
||||||
ui->custom_rtc_edit->setEnabled(Settings::values.custom_rtc.GetValue().has_value() &&
|
ui->custom_rtc_edit->setEnabled(Settings::values.custom_rtc.has_value());
|
||||||
Settings::values.rng_seed.UsingGlobal());
|
|
||||||
ui->custom_rtc_edit->setDateTime(QDateTime::fromSecsSinceEpoch(rtc_time.count()));
|
ui->custom_rtc_edit->setDateTime(QDateTime::fromSecsSinceEpoch(rtc_time.count()));
|
||||||
|
|
||||||
if (Settings::IsConfiguringGlobal()) {
|
if (Settings::IsConfiguringGlobal()) {
|
||||||
@ -109,17 +108,17 @@ void ConfigureSystem::ApplyConfiguration() {
|
|||||||
|
|
||||||
// Allow setting custom RTC even if system is powered on,
|
// Allow setting custom RTC even if system is powered on,
|
||||||
// to allow in-game time to be fast forwarded
|
// to allow in-game time to be fast forwarded
|
||||||
if (Settings::values.custom_rtc.UsingGlobal()) {
|
if (Settings::IsConfiguringGlobal()) {
|
||||||
if (ui->custom_rtc_checkbox->isChecked()) {
|
if (ui->custom_rtc_checkbox->isChecked()) {
|
||||||
Settings::values.custom_rtc.SetValue(
|
Settings::values.custom_rtc =
|
||||||
std::chrono::seconds(ui->custom_rtc_edit->dateTime().toSecsSinceEpoch()));
|
std::chrono::seconds(ui->custom_rtc_edit->dateTime().toSecsSinceEpoch());
|
||||||
if (system.IsPoweredOn()) {
|
if (system.IsPoweredOn()) {
|
||||||
const s64 posix_time{Settings::values.custom_rtc.GetValue()->count() +
|
const s64 posix_time{Settings::values.custom_rtc->count() +
|
||||||
Service::Time::TimeManager::GetExternalTimeZoneOffset()};
|
Service::Time::TimeManager::GetExternalTimeZoneOffset()};
|
||||||
system.GetTimeManager().UpdateLocalSystemClockTime(posix_time);
|
system.GetTimeManager().UpdateLocalSystemClockTime(posix_time);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Settings::values.custom_rtc.SetValue(std::nullopt);
|
Settings::values.custom_rtc = std::nullopt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,26 +162,6 @@ void ConfigureSystem::ApplyConfiguration() {
|
|||||||
case ConfigurationShared::CheckState::Count:
|
case ConfigurationShared::CheckState::Count:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (use_custom_rtc) {
|
|
||||||
case ConfigurationShared::CheckState::On:
|
|
||||||
case ConfigurationShared::CheckState::Off:
|
|
||||||
Settings::values.custom_rtc.SetGlobal(false);
|
|
||||||
if (ui->custom_rtc_checkbox->isChecked()) {
|
|
||||||
Settings::values.custom_rtc.SetValue(
|
|
||||||
std::chrono::seconds(ui->custom_rtc_edit->dateTime().toSecsSinceEpoch()));
|
|
||||||
} else {
|
|
||||||
Settings::values.custom_rtc.SetValue(std::nullopt);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case ConfigurationShared::CheckState::Global:
|
|
||||||
Settings::values.custom_rtc.SetGlobal(false);
|
|
||||||
Settings::values.custom_rtc.SetValue(std::nullopt);
|
|
||||||
Settings::values.custom_rtc.SetGlobal(true);
|
|
||||||
break;
|
|
||||||
case ConfigurationShared::CheckState::Count:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
system.ApplySettings();
|
system.ApplySettings();
|
||||||
@ -213,8 +192,6 @@ void ConfigureSystem::SetupPerGameUI() {
|
|||||||
ui->combo_sound->setEnabled(Settings::values.sound_index.UsingGlobal());
|
ui->combo_sound->setEnabled(Settings::values.sound_index.UsingGlobal());
|
||||||
ui->rng_seed_checkbox->setEnabled(Settings::values.rng_seed.UsingGlobal());
|
ui->rng_seed_checkbox->setEnabled(Settings::values.rng_seed.UsingGlobal());
|
||||||
ui->rng_seed_edit->setEnabled(Settings::values.rng_seed.UsingGlobal());
|
ui->rng_seed_edit->setEnabled(Settings::values.rng_seed.UsingGlobal());
|
||||||
ui->custom_rtc_checkbox->setEnabled(Settings::values.custom_rtc.UsingGlobal());
|
|
||||||
ui->custom_rtc_edit->setEnabled(Settings::values.custom_rtc.UsingGlobal());
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -232,8 +209,7 @@ void ConfigureSystem::SetupPerGameUI() {
|
|||||||
ui->rng_seed_checkbox, Settings::values.rng_seed.UsingGlobal(),
|
ui->rng_seed_checkbox, Settings::values.rng_seed.UsingGlobal(),
|
||||||
Settings::values.rng_seed.GetValue().has_value(),
|
Settings::values.rng_seed.GetValue().has_value(),
|
||||||
Settings::values.rng_seed.GetValue(true).has_value(), use_rng_seed);
|
Settings::values.rng_seed.GetValue(true).has_value(), use_rng_seed);
|
||||||
ConfigurationShared::SetColoredTristate(
|
|
||||||
ui->custom_rtc_checkbox, Settings::values.custom_rtc.UsingGlobal(),
|
ui->custom_rtc_checkbox->setVisible(false);
|
||||||
Settings::values.custom_rtc.GetValue().has_value(),
|
ui->custom_rtc_edit->setVisible(false);
|
||||||
Settings::values.custom_rtc.GetValue(true).has_value(), use_custom_rtc);
|
|
||||||
}
|
}
|
||||||
|
@ -361,10 +361,10 @@ void Config::ReadValues() {
|
|||||||
|
|
||||||
const auto custom_rtc_enabled = sdl2_config->GetBoolean("System", "custom_rtc_enabled", false);
|
const auto custom_rtc_enabled = sdl2_config->GetBoolean("System", "custom_rtc_enabled", false);
|
||||||
if (custom_rtc_enabled) {
|
if (custom_rtc_enabled) {
|
||||||
Settings::values.custom_rtc.SetValue(
|
Settings::values.custom_rtc =
|
||||||
std::chrono::seconds(sdl2_config->GetInteger("System", "custom_rtc", 0)));
|
std::chrono::seconds(sdl2_config->GetInteger("System", "custom_rtc", 0));
|
||||||
} else {
|
} else {
|
||||||
Settings::values.custom_rtc.SetValue(std::nullopt);
|
Settings::values.custom_rtc = std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
Settings::values.language_index.SetValue(
|
Settings::values.language_index.SetValue(
|
||||||
|
Loading…
Reference in New Issue
Block a user