Add per game configuration options (#6187)
* common: Move settings to common from core. - Removes a dependency on core and input_common from common. * code: Wrap settings values * Port from yuzu to allow per game settings * citra_qt: Initial per-game settings dialog * citra_qt: Use new API for read/save of config values * citra_qt: Per game audio settings * citra_qt: Per game graphics settings * citra_qt: Per game system settings * citra_qt: Per game general settings * citra_qt: Document and run clang format * citra_qt: Make icon smaller and centered * citra_qt: Remove version number * Not sure how to extract that, can always add it back later * citra_qt: Wrap UISettings * citra_qt: Fix unthottled fps setting * citra_qt: Remove margin in emulation tab * citra_qt: Implement some suggestions * Bring back speed switch hotkey * Allow configuration when game is running * Rename/adjust UI stuff * citra_qt: Fix build with separate windows * citra_qt: Address feedback * citra_qt: Log per-game settings before launching games * citra_qt: Add shader cache options * Also fix android build * citra_qt: Add DLC menu option * citra_qt: Run clang-format * citra_qt: Adjust for time offset * citra_qt: Implement suggestions * Run clang-format Co-authored-by: bunnei <bunneidev@gmail.com>
This commit is contained in:
parent
f261daf2fa
commit
48ee112ceb
92 changed files with 3171 additions and 1546 deletions
|
@ -4,12 +4,12 @@
|
|||
|
||||
#include <cstring>
|
||||
#include <QMessageBox>
|
||||
#include "citra_qt/configuration/configuration_shared.h"
|
||||
#include "citra_qt/configuration/configure_system.h"
|
||||
#include "citra_qt/uisettings.h"
|
||||
#include "common/settings.h"
|
||||
#include "core/core.h"
|
||||
#include "core/hle/service/cfg/cfg.h"
|
||||
#include "core/hle/service/ptm/ptm.h"
|
||||
#include "core/settings.h"
|
||||
#include "ui_configure_system.h"
|
||||
|
||||
static const std::array<int, 12> days_in_month = {{
|
||||
|
@ -249,10 +249,14 @@ ConfigureSystem::ConfigureSystem(QWidget* parent)
|
|||
// This scales across DPIs. (This value should be enough for "xxx%")
|
||||
ui->clock_display_label->setMinimumWidth(40);
|
||||
|
||||
connect(ui->slider_clock_speed, &QSlider::valueChanged, [&](int value) {
|
||||
connect(ui->slider_clock_speed, &QSlider::valueChanged, this, [&](int value) {
|
||||
ui->clock_display_label->setText(QStringLiteral("%1%").arg(SliderToSettings(value)));
|
||||
});
|
||||
|
||||
ui->clock_speed_label->setVisible(Settings::IsConfiguringGlobal());
|
||||
ui->clock_speed_combo->setVisible(!Settings::IsConfiguringGlobal());
|
||||
|
||||
SetupPerGameUI();
|
||||
ConfigureTime();
|
||||
}
|
||||
|
||||
|
@ -261,12 +265,12 @@ ConfigureSystem::~ConfigureSystem() = default;
|
|||
void ConfigureSystem::SetConfiguration() {
|
||||
enabled = !Core::System::GetInstance().IsPoweredOn();
|
||||
|
||||
ui->combo_init_clock->setCurrentIndex(static_cast<u8>(Settings::values.init_clock));
|
||||
ui->combo_init_clock->setCurrentIndex(static_cast<u8>(Settings::values.init_clock.GetValue()));
|
||||
QDateTime date_time;
|
||||
date_time.setTime_t(Settings::values.init_time);
|
||||
date_time.setTime_t(Settings::values.init_time.GetValue());
|
||||
ui->edit_init_time->setDateTime(date_time);
|
||||
|
||||
long long init_time_offset = Settings::values.init_time_offset;
|
||||
long long init_time_offset = Settings::values.init_time_offset.GetValue();
|
||||
long long days_offset = init_time_offset / 86400;
|
||||
ui->edit_init_time_offset_days->setValue(days_offset);
|
||||
|
||||
|
@ -287,20 +291,29 @@ void ConfigureSystem::SetConfiguration() {
|
|||
ui->label_disable_info->hide();
|
||||
}
|
||||
|
||||
ui->slider_clock_speed->setValue(SettingsToSlider(Settings::values.cpu_clock_percentage));
|
||||
ui->clock_display_label->setText(
|
||||
QStringLiteral("%1%").arg(Settings::values.cpu_clock_percentage));
|
||||
if (!Settings::IsConfiguringGlobal()) {
|
||||
if (Settings::values.cpu_clock_percentage.UsingGlobal()) {
|
||||
ui->clock_speed_combo->setCurrentIndex(0);
|
||||
ui->slider_clock_speed->setEnabled(false);
|
||||
} else {
|
||||
ui->clock_speed_combo->setCurrentIndex(1);
|
||||
ui->slider_clock_speed->setEnabled(true);
|
||||
}
|
||||
ConfigurationShared::SetHighlight(ui->clock_speed_widget,
|
||||
!Settings::values.cpu_clock_percentage.UsingGlobal());
|
||||
}
|
||||
|
||||
ui->toggle_new_3ds->setChecked(Settings::values.is_new_3ds);
|
||||
ui->slider_clock_speed->setValue(
|
||||
SettingsToSlider(Settings::values.cpu_clock_percentage.GetValue()));
|
||||
ui->clock_display_label->setText(
|
||||
QStringLiteral("%1%").arg(Settings::values.cpu_clock_percentage.GetValue()));
|
||||
ui->toggle_new_3ds->setChecked(Settings::values.is_new_3ds.GetValue());
|
||||
}
|
||||
|
||||
void ConfigureSystem::ReadSystemSettings() {
|
||||
// set username
|
||||
username = cfg->GetUsername();
|
||||
// TODO(wwylele): Use this when we move to Qt 5.5
|
||||
// ui->edit_username->setText(QString::fromStdU16String(username));
|
||||
ui->edit_username->setText(
|
||||
QString::fromUtf16(reinterpret_cast<const ushort*>(username.data())));
|
||||
ui->edit_username->setText(QString::fromStdU16String(username));
|
||||
|
||||
// set birthday
|
||||
std::tie(birthmonth, birthday) = cfg->GetBirthday();
|
||||
|
@ -337,32 +350,29 @@ void ConfigureSystem::ApplyConfiguration() {
|
|||
bool modified = false;
|
||||
|
||||
// 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()));
|
||||
std::u16string new_username = ui->edit_username->text().toStdU16String();
|
||||
if (new_username != username) {
|
||||
cfg->SetUsername(new_username);
|
||||
modified = true;
|
||||
}
|
||||
|
||||
// apply birthday
|
||||
int new_birthmonth = ui->combo_birthmonth->currentIndex() + 1;
|
||||
int new_birthday = ui->combo_birthday->currentIndex() + 1;
|
||||
s32 new_birthmonth = ui->combo_birthmonth->currentIndex() + 1;
|
||||
s32 new_birthday = ui->combo_birthday->currentIndex() + 1;
|
||||
if (birthmonth != new_birthmonth || birthday != new_birthday) {
|
||||
cfg->SetBirthday(new_birthmonth, new_birthday);
|
||||
modified = true;
|
||||
}
|
||||
|
||||
// apply language
|
||||
int new_language = ui->combo_language->currentIndex();
|
||||
s32 new_language = ui->combo_language->currentIndex();
|
||||
if (language_index != new_language) {
|
||||
cfg->SetSystemLanguage(static_cast<Service::CFG::SystemLanguage>(new_language));
|
||||
modified = true;
|
||||
}
|
||||
|
||||
// apply sound
|
||||
int new_sound = ui->combo_sound->currentIndex();
|
||||
s32 new_sound = ui->combo_sound->currentIndex();
|
||||
if (sound_index != new_sound) {
|
||||
cfg->SetSoundOutputMode(static_cast<Service::CFG::SoundOutputMode>(new_sound));
|
||||
modified = true;
|
||||
|
@ -386,6 +396,9 @@ void ConfigureSystem::ApplyConfiguration() {
|
|||
cfg->UpdateConfigNANDSavegame();
|
||||
}
|
||||
|
||||
ConfigurationShared::ApplyPerGameSetting(&Settings::values.is_new_3ds, ui->toggle_new_3ds,
|
||||
is_new_3ds);
|
||||
|
||||
Settings::values.init_clock =
|
||||
static_cast<Settings::InitClock>(ui->combo_init_clock->currentIndex());
|
||||
Settings::values.init_time = ui->edit_init_time->dateTime().toTime_t();
|
||||
|
@ -398,11 +411,11 @@ void ConfigureSystem::ApplyConfiguration() {
|
|||
}
|
||||
|
||||
Settings::values.init_time_offset = time_offset_days + time_offset_time;
|
||||
Settings::values.is_new_3ds = ui->toggle_new_3ds->isChecked();
|
||||
}
|
||||
|
||||
Settings::values.cpu_clock_percentage = SliderToSettings(ui->slider_clock_speed->value());
|
||||
Settings::Apply();
|
||||
ConfigurationShared::ApplyPerGameSetting(
|
||||
&Settings::values.cpu_clock_percentage, ui->clock_speed_combo,
|
||||
[this](s32) { return SliderToSettings(ui->slider_clock_speed->value()); });
|
||||
}
|
||||
|
||||
void ConfigureSystem::UpdateBirthdayComboBox(int birthmonth_index) {
|
||||
|
@ -410,10 +423,10 @@ void ConfigureSystem::UpdateBirthdayComboBox(int birthmonth_index) {
|
|||
return;
|
||||
|
||||
// store current day selection
|
||||
int birthday_index = ui->combo_birthday->currentIndex();
|
||||
s32 birthday_index = ui->combo_birthday->currentIndex();
|
||||
|
||||
// get number of days in the new selected month
|
||||
int days = days_in_month[birthmonth_index];
|
||||
s32 days = days_in_month[birthmonth_index];
|
||||
|
||||
// if the selected day is out of range,
|
||||
// reset it to 1st
|
||||
|
@ -422,7 +435,7 @@ void ConfigureSystem::UpdateBirthdayComboBox(int birthmonth_index) {
|
|||
|
||||
// update the day combo box
|
||||
ui->combo_birthday->clear();
|
||||
for (int i = 1; i <= days; ++i) {
|
||||
for (s32 i = 1; i <= days; ++i) {
|
||||
ui->combo_birthday->addItem(QString::number(i));
|
||||
}
|
||||
|
||||
|
@ -442,15 +455,16 @@ void ConfigureSystem::ConfigureTime() {
|
|||
}
|
||||
|
||||
void ConfigureSystem::UpdateInitTime(int init_clock) {
|
||||
const bool is_global = Settings::IsConfiguringGlobal();
|
||||
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);
|
||||
ui->label_init_time->setVisible(is_fixed_time && is_global);
|
||||
ui->edit_init_time->setVisible(is_fixed_time && is_global);
|
||||
|
||||
ui->label_init_time_offset->setVisible(!is_fixed_time);
|
||||
ui->edit_init_time_offset_days->setVisible(!is_fixed_time);
|
||||
ui->edit_init_time_offset_time->setVisible(!is_fixed_time);
|
||||
ui->label_init_time_offset->setVisible(!is_fixed_time && is_global);
|
||||
ui->edit_init_time_offset_days->setVisible(!is_fixed_time && is_global);
|
||||
ui->edit_init_time_offset_time->setVisible(!is_fixed_time && is_global);
|
||||
}
|
||||
|
||||
void ConfigureSystem::RefreshConsoleID() {
|
||||
|
@ -475,3 +489,43 @@ void ConfigureSystem::RefreshConsoleID() {
|
|||
void ConfigureSystem::RetranslateUI() {
|
||||
ui->retranslateUi(this);
|
||||
}
|
||||
|
||||
void ConfigureSystem::SetupPerGameUI() {
|
||||
// Block the global settings if a game is currently running that overrides them
|
||||
if (Settings::IsConfiguringGlobal()) {
|
||||
ui->toggle_new_3ds->setEnabled(Settings::values.is_new_3ds.UsingGlobal());
|
||||
ui->slider_clock_speed->setEnabled(Settings::values.cpu_clock_percentage.UsingGlobal());
|
||||
return;
|
||||
}
|
||||
|
||||
// Hide most settings for now, we can implement them later
|
||||
ui->label_username->setVisible(false);
|
||||
ui->label_birthday->setVisible(false);
|
||||
ui->label_init_clock->setVisible(false);
|
||||
ui->label_init_time->setVisible(false);
|
||||
ui->label_console_id->setVisible(false);
|
||||
ui->label_sound->setVisible(false);
|
||||
ui->label_language->setVisible(false);
|
||||
ui->label_country->setVisible(false);
|
||||
ui->label_play_coins->setVisible(false);
|
||||
ui->edit_username->setVisible(false);
|
||||
ui->spinBox_play_coins->setVisible(false);
|
||||
ui->combo_birthday->setVisible(false);
|
||||
ui->combo_birthmonth->setVisible(false);
|
||||
ui->combo_init_clock->setVisible(false);
|
||||
ui->combo_sound->setVisible(false);
|
||||
ui->combo_language->setVisible(false);
|
||||
ui->combo_country->setVisible(false);
|
||||
ui->label_init_time_offset->setVisible(false);
|
||||
ui->edit_init_time_offset_days->setVisible(false);
|
||||
ui->edit_init_time_offset_time->setVisible(false);
|
||||
ui->button_regenerate_console_id->setVisible(false);
|
||||
|
||||
connect(ui->clock_speed_combo, qOverload<int>(&QComboBox::activated), this, [this](int index) {
|
||||
ui->slider_clock_speed->setEnabled(index == 1);
|
||||
ConfigurationShared::SetHighlight(ui->clock_speed_widget, index == 1);
|
||||
});
|
||||
|
||||
ConfigurationShared::SetColoredTristate(ui->toggle_new_3ds, Settings::values.is_new_3ds,
|
||||
is_new_3ds);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue