1
0
Fork 0
forked from suyu/suyu

configure_system: Implement highlighted overrides

This commit is contained in:
lat9nq 2020-07-13 23:01:18 -04:00
parent 6316a3d8d9
commit a350ae6be6
3 changed files with 544 additions and 539 deletions

View file

@ -36,6 +36,9 @@ struct Trackers {
CheckState use_asynchronous_shaders;
CheckState use_fast_gpu_time;
CheckState force_30fps_mode;
CheckState use_rng_seed;
CheckState use_custom_rtc;
} extern trackers;
// Global-aware apply and set functions

View file

@ -67,12 +67,6 @@ void ConfigureSystem::SetConfiguration() {
const auto rtc_time = Settings::values.custom_rtc.GetValue().value_or(
std::chrono::seconds(QDateTime::currentSecsSinceEpoch()));
if (Settings::configuring_global) {
ui->combo_language->setCurrentIndex(Settings::values.language_index.GetValue());
ui->combo_region->setCurrentIndex(Settings::values.region_index.GetValue());
ui->combo_time_zone->setCurrentIndex(Settings::values.time_zone_index.GetValue());
ui->combo_sound->setCurrentIndex(Settings::values.sound_index.GetValue());
ui->rng_seed_checkbox->setChecked(Settings::values.rng_seed.GetValue().has_value());
ui->rng_seed_edit->setEnabled(Settings::values.rng_seed.GetValue().has_value() &&
Settings::values.rng_seed.UsingGlobal());
@ -82,6 +76,12 @@ void ConfigureSystem::SetConfiguration() {
ui->custom_rtc_edit->setEnabled(Settings::values.custom_rtc.GetValue().has_value() &&
Settings::values.rng_seed.UsingGlobal());
ui->custom_rtc_edit->setDateTime(QDateTime::fromSecsSinceEpoch(rtc_time.count()));
if (Settings::configuring_global) {
ui->combo_language->setCurrentIndex(Settings::values.language_index.GetValue());
ui->combo_region->setCurrentIndex(Settings::values.region_index.GetValue());
ui->combo_time_zone->setCurrentIndex(Settings::values.time_zone_index.GetValue());
ui->combo_sound->setCurrentIndex(Settings::values.sound_index.GetValue());
} else {
ConfigurationShared::SetPerGameSetting(ui->combo_language,
&Settings::values.language_index);
@ -89,28 +89,6 @@ void ConfigureSystem::SetConfiguration() {
ConfigurationShared::SetPerGameSetting(ui->combo_time_zone,
&Settings::values.time_zone_index);
ConfigurationShared::SetPerGameSetting(ui->combo_sound, &Settings::values.sound_index);
if (Settings::values.rng_seed.UsingGlobal()) {
ui->rng_seed_checkbox->setCheckState(Qt::PartiallyChecked);
} else {
ui->rng_seed_checkbox->setCheckState(
Settings::values.rng_seed.GetValue().has_value() ? Qt::Checked : Qt::Unchecked);
ui->rng_seed_edit->setEnabled(Settings::values.rng_seed.GetValue().has_value());
if (Settings::values.rng_seed.GetValue().has_value()) {
ui->rng_seed_edit->setText(rng_seed);
}
}
if (Settings::values.custom_rtc.UsingGlobal()) {
ui->custom_rtc_checkbox->setCheckState(Qt::PartiallyChecked);
} else {
ui->custom_rtc_checkbox->setCheckState(
Settings::values.custom_rtc.GetValue().has_value() ? Qt::Checked : Qt::Unchecked);
ui->custom_rtc_edit->setEnabled(Settings::values.custom_rtc.GetValue().has_value());
if (Settings::values.custom_rtc.GetValue().has_value()) {
ui->custom_rtc_edit->setDateTime(QDateTime::fromSecsSinceEpoch(rtc_time.count()));
}
}
}
}
@ -161,37 +139,42 @@ void ConfigureSystem::ApplyConfiguration() {
ui->combo_time_zone);
ConfigurationShared::ApplyPerGameSetting(&Settings::values.sound_index, ui->combo_sound);
switch (ui->rng_seed_checkbox->checkState()) {
case Qt::Checked:
Settings::values.rng_seed.SetGlobal(false);
Settings::values.rng_seed.SetValue(ui->rng_seed_edit->text().toULongLong(nullptr, 16));
break;
case Qt::Unchecked:
switch (ConfigurationShared::trackers.use_rng_seed) {
case ConfigurationShared::CheckState::On:
case ConfigurationShared::CheckState::Off:
Settings::values.rng_seed.SetGlobal(false);
if (ui->rng_seed_checkbox->isChecked()) {
Settings::values.rng_seed.SetValue(
ui->rng_seed_edit->text().toULongLong(nullptr, 16));
} else {
Settings::values.rng_seed.SetValue(std::nullopt);
}
break;
case Qt::PartiallyChecked:
case ConfigurationShared::CheckState::Global:
Settings::values.rng_seed.SetGlobal(false);
Settings::values.rng_seed.SetValue(std::nullopt);
Settings::values.rng_seed.SetGlobal(true);
break;
case ConfigurationShared::CheckState::Count:;
}
switch (ui->custom_rtc_checkbox->checkState()) {
case Qt::Checked:
switch (ConfigurationShared::trackers.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()));
break;
case Qt::Unchecked:
Settings::values.custom_rtc.SetGlobal(false);
} else {
Settings::values.custom_rtc.SetValue(std::nullopt);
}
break;
case Qt::PartiallyChecked:
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:;
}
}
@ -229,10 +212,25 @@ void ConfigureSystem::SetupPerGameUI() {
return;
}
ConfigurationShared::InsertGlobalItem(ui->combo_language);
ConfigurationShared::InsertGlobalItem(ui->combo_region);
ConfigurationShared::InsertGlobalItem(ui->combo_time_zone);
ConfigurationShared::InsertGlobalItem(ui->combo_sound);
ui->rng_seed_checkbox->setTristate(true);
ui->custom_rtc_checkbox->setTristate(true);
ConfigurationShared::SetColoredComboBox(ui->combo_language, ui->label_language,
"label_language",
Settings::values.language_index.GetValue(true));
ConfigurationShared::SetColoredComboBox(ui->combo_region, ui->label_region, "label_region",
Settings::values.region_index.GetValue(true));
ConfigurationShared::SetColoredComboBox(ui->combo_time_zone, ui->label_timezone,
"label_timezone",
Settings::values.time_zone_index.GetValue(true));
ConfigurationShared::SetColoredComboBox(ui->combo_sound, ui->label_sound, "label_sound",
Settings::values.sound_index.GetValue(true));
ConfigurationShared::SetColoredTristate(ui->rng_seed_checkbox, "rng_seed_checkbox",
Settings::values.rng_seed.UsingGlobal(),
Settings::values.rng_seed.GetValue().has_value(),
Settings::values.rng_seed.GetValue(true).has_value(),
ConfigurationShared::trackers.use_rng_seed);
ConfigurationShared::SetColoredTristate(ui->custom_rtc_checkbox, "custom_rtc_checkbox",
Settings::values.custom_rtc.UsingGlobal(),
Settings::values.custom_rtc.GetValue().has_value(),
Settings::values.custom_rtc.GetValue(true).has_value(),
ConfigurationShared::trackers.use_custom_rtc);
}

View file

@ -21,113 +21,9 @@
<property name="title">
<string>System Settings</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="3" column="0">
<widget class="QLabel" name="label_sound">
<property name="text">
<string>Sound output mode</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_console_id">
<property name="text">
<string>Console ID:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="combo_language">
<property name="toolTip">
<string>Note: this can be overridden when region setting is auto-select</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<property name="text">
<string>Japanese (日本語)</string>
</property>
</item>
<item>
<property name="text">
<string>English</string>
</property>
</item>
<item>
<property name="text">
<string>French (français)</string>
</property>
</item>
<item>
<property name="text">
<string>German (Deutsch)</string>
</property>
</item>
<item>
<property name="text">
<string>Italian (italiano)</string>
</property>
</item>
<item>
<property name="text">
<string>Spanish (español)</string>
</property>
</item>
<item>
<property name="text">
<string>Chinese</string>
</property>
</item>
<item>
<property name="text">
<string>Korean (한국어)</string>
</property>
</item>
<item>
<property name="text">
<string>Dutch (Nederlands)</string>
</property>
</item>
<item>
<property name="text">
<string>Portuguese (português)</string>
</property>
</item>
<item>
<property name="text">
<string>Russian (Русский)</string>
</property>
</item>
<item>
<property name="text">
<string>Taiwanese</string>
</property>
</item>
<item>
<property name="text">
<string>British English</string>
</property>
</item>
<item>
<property name="text">
<string>Canadian French</string>
</property>
</item>
<item>
<property name="text">
<string>Latin American Spanish</string>
</property>
</item>
<item>
<property name="text">
<string>Simplified Chinese</string>
</property>
</item>
<item>
<property name="text">
<string>Traditional Chinese (正體中文)</string>
</property>
</item>
</widget>
</item>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="0">
<widget class="QLabel" name="label_region">
<property name="text">
@ -135,52 +31,6 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="combo_region">
<item>
<property name="text">
<string>Japan</string>
</property>
</item>
<item>
<property name="text">
<string>USA</string>
</property>
</item>
<item>
<property name="text">
<string>Europe</string>
</property>
</item>
<item>
<property name="text">
<string>Australia</string>
</property>
</item>
<item>
<property name="text">
<string>China</string>
</property>
</item>
<item>
<property name="text">
<string>Korea</string>
</property>
</item>
<item>
<property name="text">
<string>Taiwan</string>
</property>
</item>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_timezone">
<property name="text">
<string>Time Zone:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="combo_time_zone">
<item>
@ -415,6 +265,158 @@
</item>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="combo_region">
<item>
<property name="text">
<string>Japan</string>
</property>
</item>
<item>
<property name="text">
<string>USA</string>
</property>
</item>
<item>
<property name="text">
<string>Europe</string>
</property>
</item>
<item>
<property name="text">
<string>Australia</string>
</property>
</item>
<item>
<property name="text">
<string>China</string>
</property>
</item>
<item>
<property name="text">
<string>Korea</string>
</property>
</item>
<item>
<property name="text">
<string>Taiwan</string>
</property>
</item>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_timezone">
<property name="text">
<string>Time Zone:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="combo_language">
<property name="toolTip">
<string>Note: this can be overridden when region setting is auto-select</string>
</property>
<item>
<property name="text">
<string>Japanese (日本語)</string>
</property>
</item>
<item>
<property name="text">
<string>English</string>
</property>
</item>
<item>
<property name="text">
<string>French (français)</string>
</property>
</item>
<item>
<property name="text">
<string>German (Deutsch)</string>
</property>
</item>
<item>
<property name="text">
<string>Italian (italiano)</string>
</property>
</item>
<item>
<property name="text">
<string>Spanish (español)</string>
</property>
</item>
<item>
<property name="text">
<string>Chinese</string>
</property>
</item>
<item>
<property name="text">
<string>Korean (한국어)</string>
</property>
</item>
<item>
<property name="text">
<string>Dutch (Nederlands)</string>
</property>
</item>
<item>
<property name="text">
<string>Portuguese (português)</string>
</property>
</item>
<item>
<property name="text">
<string>Russian (Русский)</string>
</property>
</item>
<item>
<property name="text">
<string>Taiwanese</string>
</property>
</item>
<item>
<property name="text">
<string>British English</string>
</property>
</item>
<item>
<property name="text">
<string>Canadian French</string>
</property>
</item>
<item>
<property name="text">
<string>Latin American Spanish</string>
</property>
</item>
<item>
<property name="text">
<string>Simplified Chinese</string>
</property>
</item>
<item>
<property name="text">
<string>Traditional Chinese (正體中文)</string>
</property>
</item>
</widget>
</item>
<item row="5" column="0">
<widget class="QCheckBox" name="custom_rtc_checkbox">
<property name="text">
<string>Custom RTC</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_language">
<property name="text">
<string>Language</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QCheckBox" name="rng_seed_checkbox">
<property name="text">
@ -441,33 +443,17 @@
</item>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_language">
<item row="4" column="0">
<widget class="QLabel" name="label_console_id">
<property name="text">
<string>Language</string>
<string>Console ID:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QPushButton" name="button_regenerate_console_id">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<item row="3" column="0">
<widget class="QLabel" name="label_sound">
<property name="text">
<string>Regenerate</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QCheckBox" name="custom_rtc_checkbox">
<property name="text">
<string>Custom RTC</string>
<string>Sound output mode</string>
</property>
</widget>
</item>
@ -506,6 +492,24 @@
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QPushButton" name="button_regenerate_console_id">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>Regenerate</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>