2022-05-15 02:06:02 +02:00
|
|
|
// SPDX-FileCopyrightText: 2016 Citra Emulator Project
|
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2016-06-01 10:43:33 +03:00
|
|
|
|
2019-01-17 11:50:57 -05:00
|
|
|
#include <chrono>
|
|
|
|
|
#include <optional>
|
2023-07-21 23:09:09 -04:00
|
|
|
#include <vector>
|
2019-01-17 11:50:57 -05:00
|
|
|
|
2023-05-18 23:05:21 -04:00
|
|
|
#include <QCheckBox>
|
|
|
|
|
#include <QComboBox>
|
2023-05-10 17:57:25 -04:00
|
|
|
#include <QDateTimeEdit>
|
2018-10-10 21:49:20 -04:00
|
|
|
#include <QFileDialog>
|
2018-10-09 21:53:04 -04:00
|
|
|
#include <QGraphicsItem>
|
2023-05-10 17:57:25 -04:00
|
|
|
#include <QLineEdit>
|
2017-05-06 02:55:51 +02:00
|
|
|
#include <QMessageBox>
|
2021-04-14 16:07:40 -07:00
|
|
|
#include "common/settings.h"
|
2017-02-19 18:37:14 -08:00
|
|
|
#include "core/core.h"
|
2021-10-07 13:29:33 -04:00
|
|
|
#include "core/hle/service/time/time_manager.h"
|
2016-09-21 00:21:23 +09:00
|
|
|
#include "ui_configure_system.h"
|
2020-07-09 22:42:09 -04:00
|
|
|
#include "yuzu/configuration/configuration_shared.h"
|
2018-01-11 20:33:56 -07:00
|
|
|
#include "yuzu/configuration/configure_system.h"
|
2023-05-10 17:57:25 -04:00
|
|
|
#include "yuzu/configuration/shared_widget.h"
|
2018-01-11 20:33:56 -07:00
|
|
|
|
2022-12-28 19:08:31 +00:00
|
|
|
constexpr std::array<u32, 7> LOCALE_BLOCKLIST{
|
2022-12-29 16:29:50 +00:00
|
|
|
// pzzefezrpnkzeidfej
|
|
|
|
|
// thhsrnhutlohsternp
|
|
|
|
|
// BHH4CG U
|
|
|
|
|
// Raa1AB S
|
|
|
|
|
// nn9
|
|
|
|
|
// ts
|
|
|
|
|
0b0100011100001100000, // Japan
|
|
|
|
|
0b0000001101001100100, // Americas
|
|
|
|
|
0b0100110100001000010, // Europe
|
|
|
|
|
0b0100110100001000010, // Australia
|
|
|
|
|
0b0000000000000000000, // China
|
|
|
|
|
0b0100111100001000000, // Korea
|
|
|
|
|
0b0100111100001000000, // Taiwan
|
2022-12-28 19:08:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static bool IsValidLocale(u32 region_index, u32 language_index) {
|
2023-01-22 01:35:28 -06:00
|
|
|
if (region_index >= LOCALE_BLOCKLIST.size()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2022-12-29 14:25:22 +00:00
|
|
|
return ((LOCALE_BLOCKLIST.at(region_index) >> language_index) & 1) == 0;
|
2022-12-28 19:08:31 +00:00
|
|
|
}
|
|
|
|
|
|
2023-07-21 23:09:09 -04:00
|
|
|
ConfigureSystem::ConfigureSystem(Core::System& system_,
|
|
|
|
|
std::shared_ptr<std::vector<ConfigurationShared::Tab*>> group_,
|
|
|
|
|
const ConfigurationShared::Builder& builder, QWidget* parent)
|
2023-06-21 01:42:42 -04:00
|
|
|
: Tab(group_, parent), ui{std::make_unique<Ui::ConfigureSystem>()}, system{system_} {
|
2016-06-01 10:43:33 +03:00
|
|
|
ui->setupUi(this);
|
2016-09-13 13:04:17 +08:00
|
|
|
|
2023-06-21 01:42:42 -04:00
|
|
|
Setup(builder);
|
2023-05-10 17:57:25 -04:00
|
|
|
|
2023-06-05 16:03:45 -04:00
|
|
|
const auto locale_check = [this]() {
|
2023-05-10 17:57:25 -04:00
|
|
|
const auto region_index = combo_region->currentIndex();
|
|
|
|
|
const auto language_index = combo_language->currentIndex();
|
2023-01-22 01:35:28 -06:00
|
|
|
const bool valid_locale = IsValidLocale(region_index, language_index);
|
2022-12-28 19:08:31 +00:00
|
|
|
ui->label_warn_invalid_locale->setVisible(!valid_locale);
|
|
|
|
|
if (!valid_locale) {
|
|
|
|
|
ui->label_warn_invalid_locale->setText(
|
|
|
|
|
tr("Warning: \"%1\" is not a valid language for region \"%2\"")
|
2023-05-10 17:57:25 -04:00
|
|
|
.arg(combo_language->currentText())
|
|
|
|
|
.arg(combo_region->currentText()));
|
2022-12-28 19:08:31 +00:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2023-05-10 17:57:25 -04:00
|
|
|
connect(combo_language, qOverload<int>(&QComboBox::currentIndexChanged), this, locale_check);
|
|
|
|
|
connect(combo_region, qOverload<int>(&QComboBox::currentIndexChanged), this, locale_check);
|
2020-07-09 22:42:09 -04:00
|
|
|
|
2023-06-05 16:03:45 -04:00
|
|
|
ui->label_warn_invalid_locale->setVisible(false);
|
|
|
|
|
locale_check();
|
|
|
|
|
|
2019-05-26 00:39:23 -04:00
|
|
|
SetConfiguration();
|
2016-06-01 10:43:33 +03:00
|
|
|
}
|
|
|
|
|
|
2018-08-06 12:58:46 -04:00
|
|
|
ConfigureSystem::~ConfigureSystem() = default;
|
2016-06-01 10:43:33 +03: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);
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-21 01:42:42 -04:00
|
|
|
void ConfigureSystem::Setup(const ConfigurationShared::Builder& builder) {
|
2023-05-10 17:57:25 -04:00
|
|
|
auto& core_layout = *ui->core_widget->layout();
|
|
|
|
|
auto& system_layout = *ui->system_widget->layout();
|
2018-10-09 21:53:04 -04:00
|
|
|
|
2023-06-06 22:30:02 -04:00
|
|
|
std::map<u32, QWidget*> core_hold{};
|
|
|
|
|
std::map<u32, QWidget*> system_hold{};
|
2016-06-01 10:43:33 +03:00
|
|
|
|
2023-07-21 23:09:09 -04:00
|
|
|
std::vector<Settings::BasicSetting*> settings;
|
2023-07-19 13:45:16 -04:00
|
|
|
auto push = [&settings](auto& list) {
|
2023-05-10 17:57:25 -04:00
|
|
|
for (auto setting : list) {
|
2023-07-21 23:09:09 -04:00
|
|
|
settings.push_back(setting);
|
2020-10-12 18:09:15 -07:00
|
|
|
}
|
2023-05-10 17:57:25 -04:00
|
|
|
};
|
2020-10-12 18:09:15 -07:00
|
|
|
|
2023-05-10 17:57:25 -04:00
|
|
|
push(Settings::values.linkage.by_category[Settings::Category::Core]);
|
|
|
|
|
push(Settings::values.linkage.by_category[Settings::Category::System]);
|
|
|
|
|
|
|
|
|
|
for (auto setting : settings) {
|
2023-08-21 16:33:56 -04:00
|
|
|
if (setting->Id() == Settings::values.use_docked_mode.Id() &&
|
|
|
|
|
Settings::IsConfiguringGlobal()) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-21 05:04:21 -04:00
|
|
|
ConfigurationShared::Widget* widget = builder.BuildWidget(setting, apply_funcs);
|
2022-12-13 17:21:04 -05:00
|
|
|
|
2023-06-21 01:42:42 -04:00
|
|
|
if (widget == nullptr) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2023-05-10 17:57:25 -04:00
|
|
|
if (!widget->Valid()) {
|
2023-07-21 23:25:22 -04:00
|
|
|
widget->deleteLater();
|
2023-05-10 17:57:25 -04:00
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-21 04:04:48 -04:00
|
|
|
if (setting->Id() == Settings::values.region_index.Id()) {
|
2024-01-15 23:26:53 +00:00
|
|
|
// Keep track of the region_index (and language_index) combobox to validate the selected
|
2023-06-09 17:40:25 -04:00
|
|
|
// settings
|
2023-05-10 17:57:25 -04:00
|
|
|
combo_region = widget->combobox;
|
|
|
|
|
} else if (setting->Id() == Settings::values.language_index.Id()) {
|
|
|
|
|
combo_language = widget->combobox;
|
2020-07-09 22:42:09 -04:00
|
|
|
}
|
2023-05-10 17:57:25 -04:00
|
|
|
|
2023-07-18 15:42:59 -04:00
|
|
|
switch (setting->GetCategory()) {
|
2023-05-10 17:57:25 -04:00
|
|
|
case Settings::Category::Core:
|
2023-06-06 22:30:02 -04:00
|
|
|
core_hold.emplace(setting->Id(), widget);
|
2020-07-09 22:42:09 -04:00
|
|
|
break;
|
2023-05-10 17:57:25 -04:00
|
|
|
case Settings::Category::System:
|
2023-06-06 22:30:02 -04:00
|
|
|
system_hold.emplace(setting->Id(), widget);
|
2020-07-14 13:40:49 -04:00
|
|
|
break;
|
2023-05-10 17:57:25 -04:00
|
|
|
default:
|
2023-07-21 23:25:22 -04:00
|
|
|
widget->deleteLater();
|
2020-07-09 22:42:09 -04:00
|
|
|
}
|
2019-05-26 00:39:23 -04:00
|
|
|
}
|
2023-05-10 17:57:25 -04:00
|
|
|
for (const auto& [label, widget] : core_hold) {
|
|
|
|
|
core_layout.addWidget(widget);
|
|
|
|
|
}
|
2023-06-06 22:30:02 -04:00
|
|
|
for (const auto& [id, widget] : system_hold) {
|
2023-05-10 17:57:25 -04:00
|
|
|
system_layout.addWidget(widget);
|
|
|
|
|
}
|
2016-06-01 10:43:33 +03:00
|
|
|
}
|
|
|
|
|
|
2023-05-10 17:57:25 -04:00
|
|
|
void ConfigureSystem::SetConfiguration() {}
|
2020-07-09 22:42:09 -04:00
|
|
|
|
2023-05-10 17:57:25 -04:00
|
|
|
void ConfigureSystem::ApplyConfiguration() {
|
|
|
|
|
const bool powered_on = system.IsPoweredOn();
|
|
|
|
|
for (const auto& func : apply_funcs) {
|
|
|
|
|
func(powered_on);
|
2020-07-09 22:42:09 -04:00
|
|
|
}
|
|
|
|
|
}
|