2016-06-01 08:43:33 +01:00
|
|
|
// Copyright 2016 Citra Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2019-07-14 18:26:23 +01:00
|
|
|
#include <cstring>
|
2017-05-06 01:55:51 +01:00
|
|
|
#include <QMessageBox>
|
2016-12-22 04:49:36 +00:00
|
|
|
#include "citra_qt/configuration/configure_system.h"
|
2019-08-15 05:38:54 +01:00
|
|
|
#include "citra_qt/uisettings.h"
|
2017-02-20 02:37:14 +00:00
|
|
|
#include "core/core.h"
|
2016-06-01 08:43:33 +01:00
|
|
|
#include "core/hle/service/cfg/cfg.h"
|
2018-09-13 16:01:58 +01:00
|
|
|
#include "core/hle/service/ptm/ptm.h"
|
2018-08-26 18:47:45 +01:00
|
|
|
#include "core/settings.h"
|
2016-09-20 16:21:23 +01:00
|
|
|
#include "ui_configure_system.h"
|
2016-06-01 08:43:33 +01:00
|
|
|
|
2016-09-19 02:01:46 +01:00
|
|
|
static const std::array<int, 12> days_in_month = {{
|
2018-03-09 17:54:43 +00:00
|
|
|
31,
|
|
|
|
29,
|
|
|
|
31,
|
|
|
|
30,
|
|
|
|
31,
|
|
|
|
30,
|
|
|
|
31,
|
|
|
|
31,
|
|
|
|
30,
|
|
|
|
31,
|
|
|
|
30,
|
|
|
|
31,
|
2016-09-19 02:01:46 +01:00
|
|
|
}};
|
2016-06-01 08:43:33 +01:00
|
|
|
|
2018-07-18 07:32:56 +01:00
|
|
|
static const std::array<const char*, 187> country_names = {
|
|
|
|
"",
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Japan"),
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Anguilla"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Antigua and Barbuda"), // 0-9
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Argentina"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Aruba"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Bahamas"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Barbados"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Belize"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Bolivia"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Brazil"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "British Virgin Islands"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Canada"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Cayman Islands"), // 10-19
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Chile"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Colombia"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Costa Rica"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Dominica"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Dominican Republic"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Ecuador"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "El Salvador"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "French Guiana"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Grenada"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Guadeloupe"), // 20-29
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Guatemala"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Guyana"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Haiti"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Honduras"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Jamaica"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Martinique"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Mexico"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Montserrat"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Netherlands Antilles"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Nicaragua"), // 30-39
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Panama"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Paraguay"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Peru"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Saint Kitts and Nevis"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Saint Lucia"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Saint Vincent and the Grenadines"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Suriname"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Trinidad and Tobago"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Turks and Caicos Islands"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "United States"), // 40-49
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Uruguay"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "US Virgin Islands"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Venezuela"),
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
"", // 50-59
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Albania"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Australia"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Austria"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Belgium"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Bosnia and Herzegovina"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Botswana"), // 60-69
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Bulgaria"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Croatia"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Cyprus"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Czech Republic"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Denmark"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Estonia"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Finland"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "France"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Germany"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Greece"), // 70-79
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Hungary"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Iceland"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Ireland"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Italy"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Latvia"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Lesotho"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Liechtenstein"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Lithuania"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Luxembourg"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Macedonia"), // 80-89
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Malta"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Montenegro"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Mozambique"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Namibia"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Netherlands"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "New Zealand"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Norway"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Poland"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Portugal"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Romania"), // 90-99
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Russia"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Serbia"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Slovakia"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Slovenia"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "South Africa"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Spain"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Swaziland"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Sweden"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Switzerland"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Turkey"), // 100-109
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "United Kingdom"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Zambia"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Zimbabwe"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Azerbaijan"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Mauritania"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Mali"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Niger"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Chad"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Sudan"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Eritrea"), // 110-119
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Djibouti"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Somalia"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Andorra"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Gibraltar"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Guernsey"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Isle of Man"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Jersey"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Monaco"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Taiwan"),
|
|
|
|
"", // 120-129
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "South Korea"),
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
"", // 130-139
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Hong Kong"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Macau"),
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
"", // 140-149
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Indonesia"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Singapore"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Thailand"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Philippines"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Malaysia"),
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
"", // 150-159
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "China"),
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "United Arab Emirates"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "India"), // 160-169
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Egypt"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Oman"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Qatar"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Kuwait"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Saudi Arabia"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Syria"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Bahrain"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Jordan"),
|
|
|
|
"",
|
|
|
|
"", // 170-179
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "San Marino"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Vatican City"),
|
|
|
|
QT_TRANSLATE_NOOP("ConfigureSystem", "Bermuda"), // 180-186
|
|
|
|
};
|
|
|
|
|
2019-12-16 05:04:33 +00:00
|
|
|
// The QSlider doesn't have an easy way to set a custom step amount,
|
|
|
|
// so we can just convert from the sliders range (0 - 79) to the expected
|
|
|
|
// settings range (5 - 400) with simple math.
|
|
|
|
static constexpr int SliderToSettings(int value) {
|
|
|
|
return 5 * value + 5;
|
|
|
|
}
|
|
|
|
|
|
|
|
static constexpr int SettingsToSlider(int value) {
|
|
|
|
return (value - 5) / 5;
|
|
|
|
}
|
|
|
|
|
2016-09-18 01:38:01 +01:00
|
|
|
ConfigureSystem::ConfigureSystem(QWidget* parent) : QWidget(parent), ui(new Ui::ConfigureSystem) {
|
2016-06-01 08:43:33 +01:00
|
|
|
ui->setupUi(this);
|
2017-05-06 01:55:51 +01:00
|
|
|
connect(ui->combo_birthmonth,
|
|
|
|
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
|
2018-10-25 21:47:09 +01:00
|
|
|
&ConfigureSystem::UpdateBirthdayComboBox);
|
2018-08-26 18:47:45 +01:00
|
|
|
connect(ui->combo_init_clock,
|
|
|
|
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
|
2018-10-25 21:47:09 +01:00
|
|
|
&ConfigureSystem::UpdateInitTime);
|
2017-05-06 01:55:51 +01:00
|
|
|
connect(ui->button_regenerate_console_id, &QPushButton::clicked, this,
|
2018-10-25 21:47:09 +01:00
|
|
|
&ConfigureSystem::RefreshConsoleID);
|
2018-07-18 07:32:56 +01:00
|
|
|
for (u8 i = 0; i < country_names.size(); i++) {
|
2019-07-14 18:26:23 +01:00
|
|
|
if (std::strcmp(country_names.at(i), "") != 0) {
|
2018-07-18 07:32:56 +01:00
|
|
|
ui->combo_country->addItem(tr(country_names.at(i)), i);
|
|
|
|
}
|
|
|
|
}
|
2016-09-13 06:04:17 +01:00
|
|
|
|
2020-06-20 19:52:14 +01:00
|
|
|
// Set a minimum width for the label to prevent the slider from changing size.
|
|
|
|
// This scales across DPIs. (This value should be enough for "xxx%")
|
|
|
|
ui->clock_display_label->setMinimumWidth(40);
|
|
|
|
|
2019-12-16 05:04:33 +00:00
|
|
|
connect(ui->slider_clock_speed, &QSlider::valueChanged, [&](int value) {
|
|
|
|
ui->clock_display_label->setText(QStringLiteral("%1%").arg(SliderToSettings(value)));
|
|
|
|
});
|
|
|
|
|
2018-08-26 18:47:45 +01:00
|
|
|
ConfigureTime();
|
2016-06-01 08:43:33 +01:00
|
|
|
}
|
|
|
|
|
2018-08-24 16:14:09 +01:00
|
|
|
ConfigureSystem::~ConfigureSystem() = default;
|
2016-06-01 08:43:33 +01:00
|
|
|
|
2019-05-26 05:39:23 +01:00
|
|
|
void ConfigureSystem::SetConfiguration() {
|
2016-11-05 03:14:38 +00:00
|
|
|
enabled = !Core::System::GetInstance().IsPoweredOn();
|
2016-06-01 08:43:33 +01:00
|
|
|
|
2018-08-26 18:47:45 +01:00
|
|
|
ui->combo_init_clock->setCurrentIndex(static_cast<u8>(Settings::values.init_clock));
|
|
|
|
QDateTime date_time;
|
|
|
|
date_time.setTime_t(Settings::values.init_time);
|
|
|
|
ui->edit_init_time->setDateTime(date_time);
|
|
|
|
|
2016-06-01 08:43:33 +01:00
|
|
|
if (!enabled) {
|
2018-10-12 10:50:50 +01:00
|
|
|
cfg = Service::CFG::GetModule(Core::System::GetInstance());
|
2018-10-11 10:12:07 +01:00
|
|
|
ASSERT_MSG(cfg, "CFG Module missing!");
|
2016-06-01 08:43:33 +01:00
|
|
|
ReadSystemSettings();
|
|
|
|
ui->group_system_settings->setEnabled(false);
|
|
|
|
} else {
|
|
|
|
// This tab is enabled only when game is not running (i.e. all service are not initialized).
|
2018-03-06 08:43:24 +00:00
|
|
|
cfg = std::make_shared<Service::CFG::Module>();
|
2018-09-13 16:01:58 +01:00
|
|
|
ReadSystemSettings();
|
2016-06-01 08:43:33 +01:00
|
|
|
|
|
|
|
ui->label_disable_info->hide();
|
|
|
|
}
|
2019-12-16 05:04:33 +00:00
|
|
|
|
|
|
|
ui->slider_clock_speed->setValue(SettingsToSlider(Settings::values.cpu_clock_percentage));
|
|
|
|
ui->clock_display_label->setText(
|
|
|
|
QStringLiteral("%1%").arg(Settings::values.cpu_clock_percentage));
|
2020-02-28 01:56:24 +00:00
|
|
|
|
|
|
|
ui->toggle_new_3ds->setChecked(Settings::values.is_new_3ds);
|
2016-06-01 08:43:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigureSystem::ReadSystemSettings() {
|
|
|
|
// set username
|
2018-03-06 08:43:24 +00:00
|
|
|
username = cfg->GetUsername();
|
2016-09-19 02:01:46 +01:00
|
|
|
// TODO(wwylele): Use this when we move to Qt 5.5
|
|
|
|
// ui->edit_username->setText(QString::fromStdU16String(username));
|
2016-09-18 01:38:01 +01:00
|
|
|
ui->edit_username->setText(
|
|
|
|
QString::fromUtf16(reinterpret_cast<const ushort*>(username.data())));
|
2016-06-01 08:43:33 +01:00
|
|
|
|
|
|
|
// set birthday
|
2018-03-06 08:43:24 +00:00
|
|
|
std::tie(birthmonth, birthday) = cfg->GetBirthday();
|
2016-06-01 08:43:33 +01:00
|
|
|
ui->combo_birthmonth->setCurrentIndex(birthmonth - 1);
|
2018-10-25 21:47:09 +01:00
|
|
|
UpdateBirthdayComboBox(
|
2016-09-18 01:38:01 +01:00
|
|
|
birthmonth -
|
|
|
|
1); // explicitly update it because the signal from setCurrentIndex is not reliable
|
2016-06-01 08:43:33 +01:00
|
|
|
ui->combo_birthday->setCurrentIndex(birthday - 1);
|
|
|
|
|
|
|
|
// set system language
|
2018-03-06 08:43:24 +00:00
|
|
|
language_index = cfg->GetSystemLanguage();
|
2016-06-01 08:43:33 +01:00
|
|
|
ui->combo_language->setCurrentIndex(language_index);
|
|
|
|
|
|
|
|
// set sound output mode
|
2018-03-06 08:43:24 +00:00
|
|
|
sound_index = cfg->GetSoundOutputMode();
|
2016-06-01 08:43:33 +01:00
|
|
|
ui->combo_sound->setCurrentIndex(sound_index);
|
2017-05-06 01:55:51 +01:00
|
|
|
|
2018-07-18 07:32:56 +01:00
|
|
|
// set the country code
|
|
|
|
country_code = cfg->GetCountryCode();
|
|
|
|
ui->combo_country->setCurrentIndex(ui->combo_country->findData(country_code));
|
|
|
|
|
2017-05-06 01:55:51 +01:00
|
|
|
// set the console id
|
2018-03-06 08:43:24 +00:00
|
|
|
u64 console_id = cfg->GetConsoleUniqueId();
|
2017-09-24 15:52:11 +01:00
|
|
|
ui->label_console_id->setText(
|
|
|
|
tr("Console ID: 0x%1").arg(QString::number(console_id, 16).toUpper()));
|
2018-09-13 16:01:58 +01:00
|
|
|
|
|
|
|
// set play coin
|
|
|
|
play_coin = Service::PTM::Module::GetPlayCoins();
|
|
|
|
ui->spinBox_play_coins->setValue(play_coin);
|
2016-06-01 08:43:33 +01:00
|
|
|
}
|
|
|
|
|
2019-05-26 05:39:23 +01:00
|
|
|
void ConfigureSystem::ApplyConfiguration() {
|
2019-12-16 05:04:33 +00:00
|
|
|
if (enabled) {
|
|
|
|
bool modified = false;
|
2016-06-01 08:43:33 +01:00
|
|
|
|
2019-12-16 05:04:33 +00:00
|
|
|
// apply username
|
|
|
|
// TODO(wwylele): Use this when we move to Qt 5.5
|
|
|
|
// std::u16string new_username = ui->edit_username->text().toStdU16String();
|
|
|
|
std::u16string new_username(
|
|
|
|
reinterpret_cast<const char16_t*>(ui->edit_username->text().utf16()));
|
|
|
|
if (new_username != username) {
|
|
|
|
cfg->SetUsername(new_username);
|
|
|
|
modified = true;
|
|
|
|
}
|
2016-06-01 08:43:33 +01:00
|
|
|
|
2019-12-16 05:04:33 +00:00
|
|
|
// apply birthday
|
|
|
|
int new_birthmonth = ui->combo_birthmonth->currentIndex() + 1;
|
|
|
|
int new_birthday = ui->combo_birthday->currentIndex() + 1;
|
|
|
|
if (birthmonth != new_birthmonth || birthday != new_birthday) {
|
|
|
|
cfg->SetBirthday(new_birthmonth, new_birthday);
|
|
|
|
modified = true;
|
|
|
|
}
|
2016-06-01 08:43:33 +01:00
|
|
|
|
2019-12-16 05:04:33 +00:00
|
|
|
// apply language
|
|
|
|
int new_language = ui->combo_language->currentIndex();
|
|
|
|
if (language_index != new_language) {
|
|
|
|
cfg->SetSystemLanguage(static_cast<Service::CFG::SystemLanguage>(new_language));
|
|
|
|
modified = true;
|
|
|
|
}
|
2016-06-01 08:43:33 +01:00
|
|
|
|
2019-12-16 05:04:33 +00:00
|
|
|
// apply sound
|
|
|
|
int new_sound = ui->combo_sound->currentIndex();
|
|
|
|
if (sound_index != new_sound) {
|
|
|
|
cfg->SetSoundOutputMode(static_cast<Service::CFG::SoundOutputMode>(new_sound));
|
|
|
|
modified = true;
|
|
|
|
}
|
2016-06-01 08:43:33 +01:00
|
|
|
|
2019-12-16 05:04:33 +00:00
|
|
|
// apply country
|
|
|
|
u8 new_country = static_cast<u8>(ui->combo_country->currentData().toInt());
|
|
|
|
if (country_code != new_country) {
|
|
|
|
cfg->SetCountryCode(new_country);
|
|
|
|
modified = true;
|
|
|
|
}
|
2016-06-01 08:43:33 +01:00
|
|
|
|
2019-12-16 05:04:33 +00:00
|
|
|
// apply play coin
|
|
|
|
u16 new_play_coin = static_cast<u16>(ui->spinBox_play_coins->value());
|
|
|
|
if (play_coin != new_play_coin) {
|
|
|
|
Service::PTM::Module::SetPlayCoins(new_play_coin);
|
|
|
|
}
|
2018-07-18 07:32:56 +01:00
|
|
|
|
2019-12-16 05:04:33 +00:00
|
|
|
// update the config savegame if any item is modified.
|
|
|
|
if (modified) {
|
|
|
|
cfg->UpdateConfigNANDSavegame();
|
|
|
|
}
|
2018-09-13 16:01:58 +01:00
|
|
|
|
2019-12-16 05:04:33 +00:00
|
|
|
Settings::values.init_clock =
|
|
|
|
static_cast<Settings::InitClock>(ui->combo_init_clock->currentIndex());
|
|
|
|
Settings::values.init_time = ui->edit_init_time->dateTime().toTime_t();
|
2020-02-28 01:56:24 +00:00
|
|
|
|
|
|
|
Settings::values.is_new_3ds = ui->toggle_new_3ds->isChecked();
|
2019-05-26 05:39:23 +01:00
|
|
|
}
|
2018-08-26 18:47:45 +01:00
|
|
|
|
2019-12-16 05:04:33 +00:00
|
|
|
Settings::values.cpu_clock_percentage = SliderToSettings(ui->slider_clock_speed->value());
|
2018-08-26 18:47:45 +01:00
|
|
|
Settings::Apply();
|
2016-06-01 08:43:33 +01:00
|
|
|
}
|
|
|
|
|
2018-10-25 21:47:09 +01:00
|
|
|
void ConfigureSystem::UpdateBirthdayComboBox(int birthmonth_index) {
|
2016-06-01 08:43:33 +01:00
|
|
|
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 01:55:51 +01:00
|
|
|
|
2018-08-26 18:47:45 +01:00
|
|
|
void ConfigureSystem::ConfigureTime() {
|
|
|
|
ui->edit_init_time->setCalendarPopup(true);
|
|
|
|
QDateTime dt;
|
2019-07-26 20:11:14 +01:00
|
|
|
dt.fromString(QStringLiteral("2000-01-01 00:00:01"), QStringLiteral("yyyy-MM-dd hh:mm:ss"));
|
2018-08-26 18:47:45 +01:00
|
|
|
ui->edit_init_time->setMinimumDateTime(dt);
|
|
|
|
|
2019-05-26 05:39:23 +01:00
|
|
|
SetConfiguration();
|
2018-08-26 18:47:45 +01:00
|
|
|
|
2018-10-25 21:47:09 +01:00
|
|
|
UpdateInitTime(ui->combo_init_clock->currentIndex());
|
2018-08-26 18:47:45 +01:00
|
|
|
}
|
|
|
|
|
2018-10-25 21:47:09 +01:00
|
|
|
void ConfigureSystem::UpdateInitTime(int init_clock) {
|
2018-08-26 18:47:45 +01:00
|
|
|
const bool is_fixed_time =
|
|
|
|
static_cast<Settings::InitClock>(init_clock) == Settings::InitClock::FixedTime;
|
|
|
|
ui->label_init_time->setVisible(is_fixed_time);
|
|
|
|
ui->edit_init_time->setVisible(is_fixed_time);
|
|
|
|
}
|
|
|
|
|
2018-10-25 21:47:09 +01:00
|
|
|
void ConfigureSystem::RefreshConsoleID() {
|
2017-05-06 01:55:51 +01:00
|
|
|
QMessageBox::StandardButton reply;
|
|
|
|
QString warning_text = tr("This will replace your current virtual 3DS with a new one. "
|
|
|
|
"Your current virtual 3DS will not be recoverable. "
|
|
|
|
"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 05:39:23 +01:00
|
|
|
if (reply == QMessageBox::No) {
|
2017-05-06 01:55:51 +01:00
|
|
|
return;
|
2019-05-26 05:39:23 +01:00
|
|
|
}
|
|
|
|
|
2020-05-04 11:21:43 +01:00
|
|
|
const auto [random_number, console_id] = cfg->GenerateConsoleUniqueId();
|
2018-03-06 08:43:24 +00:00
|
|
|
cfg->SetConsoleUniqueId(random_number, console_id);
|
|
|
|
cfg->UpdateConfigNANDSavegame();
|
2018-07-18 07:50:38 +01:00
|
|
|
ui->label_console_id->setText(
|
|
|
|
tr("Console ID: 0x%1").arg(QString::number(console_id, 16).toUpper()));
|
2017-05-06 01:55:51 +01:00
|
|
|
}
|
2017-09-23 14:13:59 +01:00
|
|
|
|
2019-05-26 05:39:23 +01:00
|
|
|
void ConfigureSystem::RetranslateUI() {
|
2017-09-23 14:13:59 +01:00
|
|
|
ui->retranslateUi(this);
|
|
|
|
}
|