2016-06-01 03:43:33 -04:00
|
|
|
// Copyright 2016 Citra Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2019-01-17 11:50:57 -05:00
|
|
|
#include <array>
|
|
|
|
#include <chrono>
|
|
|
|
#include <optional>
|
|
|
|
|
2018-10-10 21:49:20 -04:00
|
|
|
#include <QFileDialog>
|
2018-10-09 21:53:04 -04:00
|
|
|
#include <QGraphicsItem>
|
2017-05-05 20:55:51 -04:00
|
|
|
#include <QMessageBox>
|
2018-10-28 18:11:17 -04:00
|
|
|
#include "common/assert.h"
|
|
|
|
#include "common/file_util.h"
|
2017-02-19 21:37:14 -05:00
|
|
|
#include "core/core.h"
|
2018-08-03 11:02:55 -04:00
|
|
|
#include "core/settings.h"
|
2016-09-20 11:21:23 -04:00
|
|
|
#include "ui_configure_system.h"
|
2018-01-11 22:33:56 -05:00
|
|
|
#include "yuzu/configuration/configure_system.h"
|
|
|
|
|
2019-01-04 17:32:13 -05:00
|
|
|
ConfigureSystem::ConfigureSystem(QWidget* parent) : QWidget(parent), ui(new Ui::ConfigureSystem) {
|
2016-06-01 03:43:33 -04:00
|
|
|
ui->setupUi(this);
|
2017-05-05 20:55:51 -04:00
|
|
|
connect(ui->button_regenerate_console_id, &QPushButton::clicked, this,
|
2018-10-25 16:47:09 -04:00
|
|
|
&ConfigureSystem::RefreshConsoleID);
|
2016-09-13 01:04:17 -04:00
|
|
|
|
2018-11-11 22:34:23 -05:00
|
|
|
connect(ui->rng_seed_checkbox, &QCheckBox::stateChanged, this, [this](bool checked) {
|
|
|
|
ui->rng_seed_edit->setEnabled(checked);
|
2019-05-26 00:39:23 -04:00
|
|
|
if (!checked) {
|
2018-11-13 12:25:43 -05:00
|
|
|
ui->rng_seed_edit->setText(QStringLiteral("00000000"));
|
2019-05-26 00:39:23 -04:00
|
|
|
}
|
2018-11-11 22:34:23 -05:00
|
|
|
});
|
|
|
|
|
2018-12-28 18:36:14 -05:00
|
|
|
connect(ui->custom_rtc_checkbox, &QCheckBox::stateChanged, this, [this](bool checked) {
|
|
|
|
ui->custom_rtc_edit->setEnabled(checked);
|
2019-05-26 00:39:23 -04:00
|
|
|
if (!checked) {
|
2018-12-28 18:36:14 -05:00
|
|
|
ui->custom_rtc_edit->setDateTime(QDateTime::currentDateTime());
|
2019-05-26 00:39:23 -04:00
|
|
|
}
|
2018-12-28 18:36:14 -05:00
|
|
|
});
|
|
|
|
|
2019-05-26 00:39:23 -04:00
|
|
|
SetConfiguration();
|
2016-06-01 03:43:33 -04:00
|
|
|
}
|
|
|
|
|
2018-08-06 12:58:46 -04:00
|
|
|
ConfigureSystem::~ConfigureSystem() = default;
|
2016-06-01 03:43:33 -04:00
|
|
|
|
2019-06-05 18:39:46 -04:00
|
|
|
void ConfigureSystem::changeEvent(QEvent* event) {
|
|
|
|
if (event->type() == QEvent::LanguageChange) {
|
|
|
|
RetranslateUI();
|
|
|
|
}
|
|
|
|
|
|
|
|
QWidget::changeEvent(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigureSystem::RetranslateUI() {
|
|
|
|
ui->retranslateUi(this);
|
|
|
|
}
|
|
|
|
|
2019-05-26 00:39:23 -04:00
|
|
|
void ConfigureSystem::SetConfiguration() {
|
2016-11-04 23:14:38 -04:00
|
|
|
enabled = !Core::System::GetInstance().IsPoweredOn();
|
2018-10-09 21:53:04 -04:00
|
|
|
|
2018-08-03 11:02:55 -04:00
|
|
|
ui->combo_language->setCurrentIndex(Settings::values.language_index);
|
2020-03-18 05:04:08 -04:00
|
|
|
ui->combo_region->setCurrentIndex(Settings::values.region_index);
|
2020-03-17 14:03:00 -04:00
|
|
|
ui->combo_sound->setCurrentIndex(Settings::values.sound_index);
|
2018-10-09 21:53:04 -04:00
|
|
|
|
2018-11-11 22:34:23 -05:00
|
|
|
ui->rng_seed_checkbox->setChecked(Settings::values.rng_seed.has_value());
|
|
|
|
ui->rng_seed_edit->setEnabled(Settings::values.rng_seed.has_value());
|
2018-11-12 21:46:21 -05:00
|
|
|
|
2019-05-19 12:56:39 -04:00
|
|
|
const auto rng_seed = QStringLiteral("%1")
|
|
|
|
.arg(Settings::values.rng_seed.value_or(0), 8, 16, QLatin1Char{'0'})
|
|
|
|
.toUpper();
|
2018-11-12 21:46:21 -05:00
|
|
|
ui->rng_seed_edit->setText(rng_seed);
|
2018-12-28 18:36:14 -05:00
|
|
|
|
|
|
|
ui->custom_rtc_checkbox->setChecked(Settings::values.custom_rtc.has_value());
|
|
|
|
ui->custom_rtc_edit->setEnabled(Settings::values.custom_rtc.has_value());
|
|
|
|
|
2018-12-28 20:24:24 -05:00
|
|
|
const auto rtc_time = Settings::values.custom_rtc.value_or(
|
|
|
|
std::chrono::seconds(QDateTime::currentSecsSinceEpoch()));
|
|
|
|
ui->custom_rtc_edit->setDateTime(QDateTime::fromSecsSinceEpoch(rtc_time.count()));
|
2018-10-09 21:53:04 -04:00
|
|
|
}
|
|
|
|
|
2018-01-11 22:33:56 -05:00
|
|
|
void ConfigureSystem::ReadSystemSettings() {}
|
2016-06-01 03:43:33 -04:00
|
|
|
|
2019-05-26 00:39:23 -04:00
|
|
|
void ConfigureSystem::ApplyConfiguration() {
|
|
|
|
if (!enabled) {
|
2016-06-01 03:43:33 -04:00
|
|
|
return;
|
2019-05-26 00:39:23 -04:00
|
|
|
}
|
2018-10-09 21:53:04 -04:00
|
|
|
|
2018-08-03 11:02:55 -04:00
|
|
|
Settings::values.language_index = ui->combo_language->currentIndex();
|
2020-03-18 05:04:08 -04:00
|
|
|
Settings::values.region_index = ui->combo_region->currentIndex();
|
2020-03-17 14:03:00 -04:00
|
|
|
Settings::values.sound_index = ui->combo_sound->currentIndex();
|
2018-11-11 22:34:23 -05:00
|
|
|
|
2019-05-26 00:39:23 -04:00
|
|
|
if (ui->rng_seed_checkbox->isChecked()) {
|
2018-11-11 22:34:23 -05:00
|
|
|
Settings::values.rng_seed = ui->rng_seed_edit->text().toULongLong(nullptr, 16);
|
2019-05-26 00:39:23 -04:00
|
|
|
} else {
|
2018-11-11 22:34:23 -05:00
|
|
|
Settings::values.rng_seed = std::nullopt;
|
2019-05-26 00:39:23 -04:00
|
|
|
}
|
2018-11-11 22:34:23 -05:00
|
|
|
|
2019-05-26 00:39:23 -04:00
|
|
|
if (ui->custom_rtc_checkbox->isChecked()) {
|
2018-12-28 20:24:24 -05:00
|
|
|
Settings::values.custom_rtc =
|
|
|
|
std::chrono::seconds(ui->custom_rtc_edit->dateTime().toSecsSinceEpoch());
|
2019-05-26 00:39:23 -04:00
|
|
|
} else {
|
2018-12-28 18:36:14 -05:00
|
|
|
Settings::values.custom_rtc = std::nullopt;
|
2019-05-26 00:39:23 -04:00
|
|
|
}
|
2018-12-28 18:36:14 -05:00
|
|
|
|
2018-08-03 11:02:55 -04:00
|
|
|
Settings::Apply();
|
2016-06-01 03:43:33 -04:00
|
|
|
}
|
|
|
|
|
2018-10-25 16:47:09 -04:00
|
|
|
void ConfigureSystem::RefreshConsoleID() {
|
2017-05-05 20:55:51 -04:00
|
|
|
QMessageBox::StandardButton reply;
|
2018-01-13 18:49:16 -05:00
|
|
|
QString warning_text = tr("This will replace your current virtual Switch with a new one. "
|
|
|
|
"Your current virtual Switch will not be recoverable. "
|
2017-05-05 20:55:51 -04:00
|
|
|
"This might have unexpected effects in games. This might fail, "
|
|
|
|
"if you use an outdated config savegame. Continue?");
|
|
|
|
reply = QMessageBox::critical(this, tr("Warning"), warning_text,
|
|
|
|
QMessageBox::No | QMessageBox::Yes);
|
2019-05-26 00:39:23 -04:00
|
|
|
if (reply == QMessageBox::No) {
|
2017-05-05 20:55:51 -04:00
|
|
|
return;
|
2019-05-26 00:39:23 -04:00
|
|
|
}
|
|
|
|
|
2017-10-12 21:21:49 -04:00
|
|
|
u64 console_id{};
|
2018-01-17 11:20:46 -05:00
|
|
|
ui->label_console_id->setText(
|
|
|
|
tr("Console ID: 0x%1").arg(QString::number(console_id, 16).toUpper()));
|
2017-05-05 20:55:51 -04:00
|
|
|
}
|