2016-06-01 07:43:33 +00:00
|
|
|
// Copyright 2016 Citra Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2017-05-06 00:55:51 +00:00
|
|
|
#include <QMessageBox>
|
2017-02-20 02:37:14 +00:00
|
|
|
#include "core/core.h"
|
2018-08-03 15:02:55 +00:00
|
|
|
#include "core/settings.h"
|
2016-09-20 15:21:23 +00:00
|
|
|
#include "ui_configure_system.h"
|
2018-01-12 03:33:56 +00:00
|
|
|
#include "yuzu/configuration/configure_system.h"
|
2018-08-03 15:02:55 +00:00
|
|
|
#include "yuzu/main.h"
|
2018-01-12 03:33:56 +00:00
|
|
|
|
2016-09-19 01:01:46 +00:00
|
|
|
static const std::array<int, 12> days_in_month = {{
|
2018-01-20 07:48:02 +00:00
|
|
|
31,
|
|
|
|
29,
|
|
|
|
31,
|
|
|
|
30,
|
|
|
|
31,
|
|
|
|
30,
|
|
|
|
31,
|
|
|
|
31,
|
|
|
|
30,
|
|
|
|
31,
|
|
|
|
30,
|
|
|
|
31,
|
2016-09-19 01:01:46 +00:00
|
|
|
}};
|
2016-06-01 07:43:33 +00:00
|
|
|
|
2016-09-18 00:38:01 +00:00
|
|
|
ConfigureSystem::ConfigureSystem(QWidget* parent) : QWidget(parent), ui(new Ui::ConfigureSystem) {
|
2016-06-01 07:43:33 +00:00
|
|
|
ui->setupUi(this);
|
2017-05-06 00:55:51 +00:00
|
|
|
connect(ui->combo_birthmonth,
|
|
|
|
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
|
|
|
|
&ConfigureSystem::updateBirthdayComboBox);
|
|
|
|
connect(ui->button_regenerate_console_id, &QPushButton::clicked, this,
|
|
|
|
&ConfigureSystem::refreshConsoleID);
|
2016-09-13 05:04:17 +00:00
|
|
|
|
|
|
|
this->setConfiguration();
|
2016-06-01 07:43:33 +00:00
|
|
|
}
|
|
|
|
|
2016-09-19 01:01:46 +00:00
|
|
|
ConfigureSystem::~ConfigureSystem() {}
|
2016-06-01 07:43:33 +00:00
|
|
|
|
2016-09-02 12:18:45 +00:00
|
|
|
void ConfigureSystem::setConfiguration() {
|
2016-11-05 03:14:38 +00:00
|
|
|
enabled = !Core::System::GetInstance().IsPoweredOn();
|
2018-08-03 15:02:55 +00:00
|
|
|
ui->edit_username->setText(QString::fromStdString(Settings::values.username));
|
|
|
|
ui->combo_language->setCurrentIndex(Settings::values.language_index);
|
2016-06-01 07:43:33 +00:00
|
|
|
}
|
|
|
|
|
2018-01-12 03:33:56 +00:00
|
|
|
void ConfigureSystem::ReadSystemSettings() {}
|
2016-06-01 07:43:33 +00:00
|
|
|
|
|
|
|
void ConfigureSystem::applyConfiguration() {
|
|
|
|
if (!enabled)
|
|
|
|
return;
|
2018-08-03 15:02:55 +00:00
|
|
|
Settings::values.username = ui->edit_username->text().toStdString();
|
|
|
|
Settings::values.language_index = ui->combo_language->currentIndex();
|
|
|
|
Settings::Apply();
|
2016-06-01 07:43:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigureSystem::updateBirthdayComboBox(int birthmonth_index) {
|
|
|
|
if (birthmonth_index < 0 || birthmonth_index >= 12)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// store current day selection
|
|
|
|
int birthday_index = ui->combo_birthday->currentIndex();
|
|
|
|
|
|
|
|
// get number of days in the new selected month
|
|
|
|
int days = days_in_month[birthmonth_index];
|
|
|
|
|
|
|
|
// if the selected day is out of range,
|
|
|
|
// reset it to 1st
|
|
|
|
if (birthday_index < 0 || birthday_index >= days)
|
|
|
|
birthday_index = 0;
|
|
|
|
|
|
|
|
// update the day combo box
|
|
|
|
ui->combo_birthday->clear();
|
|
|
|
for (int i = 1; i <= days; ++i) {
|
|
|
|
ui->combo_birthday->addItem(QString::number(i));
|
|
|
|
}
|
|
|
|
|
|
|
|
// restore the day selection
|
|
|
|
ui->combo_birthday->setCurrentIndex(birthday_index);
|
|
|
|
}
|
2017-05-06 00:55:51 +00:00
|
|
|
|
|
|
|
void ConfigureSystem::refreshConsoleID() {
|
|
|
|
QMessageBox::StandardButton reply;
|
2018-01-13 23:49:16 +00: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-06 00:55:51 +00: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);
|
|
|
|
if (reply == QMessageBox::No)
|
|
|
|
return;
|
2017-10-13 01:21:49 +00:00
|
|
|
u64 console_id{};
|
2018-01-17 16:20:46 +00:00
|
|
|
ui->label_console_id->setText(
|
|
|
|
tr("Console ID: 0x%1").arg(QString::number(console_id, 16).toUpper()));
|
2017-05-06 00:55:51 +00:00
|
|
|
}
|