2016-01-24 18:34:05 +01:00
|
|
|
// Copyright 2016 Citra Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2018-02-19 17:51:27 -07:00
|
|
|
#include <QDesktopServices>
|
|
|
|
#include <QUrl>
|
2023-02-18 23:24:15 +01:00
|
|
|
#include "citra_qt/configuration/configuration_shared.h"
|
2016-12-21 23:49:36 -05:00
|
|
|
#include "citra_qt/configuration/configure_debug.h"
|
2018-02-19 17:51:27 -07:00
|
|
|
#include "citra_qt/debugger/console.h"
|
2019-08-14 22:38:54 -06:00
|
|
|
#include "citra_qt/uisettings.h"
|
2018-02-19 17:51:27 -07:00
|
|
|
#include "common/file_util.h"
|
|
|
|
#include "common/logging/log.h"
|
2022-12-08 13:27:25 +02:00
|
|
|
#include "common/settings.h"
|
2018-02-19 17:51:27 -07:00
|
|
|
#include "core/core.h"
|
2016-09-21 00:21:23 +09:00
|
|
|
#include "ui_configure_debug.h"
|
2016-01-24 21:54:04 +01:00
|
|
|
|
2023-02-18 23:24:15 +01: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;
|
|
|
|
}
|
|
|
|
|
2020-09-30 22:23:01 -03:00
|
|
|
ConfigureDebug::ConfigureDebug(QWidget* parent)
|
|
|
|
: QWidget(parent), ui(std::make_unique<Ui::ConfigureDebug>()) {
|
2016-01-24 18:34:05 +01:00
|
|
|
ui->setupUi(this);
|
2019-05-26 00:39:23 -04:00
|
|
|
SetConfiguration();
|
|
|
|
|
2019-07-22 23:28:10 +02:00
|
|
|
connect(ui->open_log_button, &QPushButton::clicked, []() {
|
2018-07-21 15:52:42 -04:00
|
|
|
QString path = QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::LogDir));
|
2018-02-19 17:51:27 -07:00
|
|
|
QDesktopServices::openUrl(QUrl::fromLocalFile(path));
|
|
|
|
});
|
2022-11-04 23:32:57 +01:00
|
|
|
|
|
|
|
const bool is_powered_on = Core::System::GetInstance().IsPoweredOn();
|
|
|
|
ui->toggle_cpu_jit->setEnabled(!is_powered_on);
|
2023-03-27 14:29:17 +03:00
|
|
|
ui->toggle_renderer_debug->setEnabled(!is_powered_on);
|
2023-02-18 23:24:15 +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);
|
|
|
|
|
|
|
|
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();
|
2016-01-24 18:34:05 +01:00
|
|
|
}
|
|
|
|
|
2018-08-24 17:14:09 +02:00
|
|
|
ConfigureDebug::~ConfigureDebug() = default;
|
2016-01-24 18:34:05 +01:00
|
|
|
|
2019-05-26 00:39:23 -04:00
|
|
|
void ConfigureDebug::SetConfiguration() {
|
2022-12-08 13:27:25 +02:00
|
|
|
ui->toggle_gdbstub->setChecked(Settings::values.use_gdbstub.GetValue());
|
|
|
|
ui->gdbport_spinbox->setEnabled(Settings::values.use_gdbstub.GetValue());
|
|
|
|
ui->gdbport_spinbox->setValue(Settings::values.gdbstub_port.GetValue());
|
2018-02-19 17:51:27 -07:00
|
|
|
ui->toggle_console->setEnabled(!Core::System::GetInstance().IsPoweredOn());
|
2022-12-08 13:27:25 +02:00
|
|
|
ui->toggle_console->setChecked(UISettings::values.show_console.GetValue());
|
|
|
|
ui->log_filter_edit->setText(QString::fromStdString(Settings::values.log_filter.GetValue()));
|
|
|
|
ui->toggle_cpu_jit->setChecked(Settings::values.use_cpu_jit.GetValue());
|
2023-03-27 14:29:17 +03:00
|
|
|
ui->toggle_renderer_debug->setChecked(Settings::values.renderer_debug.GetValue());
|
2023-02-18 23:24:15 +01:00
|
|
|
|
|
|
|
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->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()));
|
2016-01-24 18:34:05 +01:00
|
|
|
}
|
|
|
|
|
2019-05-26 00:39:23 -04:00
|
|
|
void ConfigureDebug::ApplyConfiguration() {
|
2016-08-31 22:12:20 -04:00
|
|
|
Settings::values.use_gdbstub = ui->toggle_gdbstub->isChecked();
|
2016-01-24 21:54:04 +01:00
|
|
|
Settings::values.gdbstub_port = ui->gdbport_spinbox->value();
|
2018-02-19 17:51:27 -07:00
|
|
|
UISettings::values.show_console = ui->toggle_console->isChecked();
|
|
|
|
Settings::values.log_filter = ui->log_filter_edit->text().toStdString();
|
|
|
|
Debugger::ToggleConsole();
|
|
|
|
Log::Filter filter;
|
2022-12-08 13:27:25 +02:00
|
|
|
filter.ParseFilterString(Settings::values.log_filter.GetValue());
|
2018-02-19 17:51:27 -07:00
|
|
|
Log::SetGlobalFilter(filter);
|
2018-07-21 12:27:38 +05:30
|
|
|
Settings::values.use_cpu_jit = ui->toggle_cpu_jit->isChecked();
|
2023-03-27 14:29:17 +03:00
|
|
|
Settings::values.renderer_debug = ui->toggle_renderer_debug->isChecked();
|
2023-02-18 23:24:15 +01:00
|
|
|
|
|
|
|
ConfigurationShared::ApplyPerGameSetting(
|
|
|
|
&Settings::values.cpu_clock_percentage, ui->clock_speed_combo,
|
|
|
|
[this](s32) { return SliderToSettings(ui->slider_clock_speed->value()); });
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigureDebug::SetupPerGameUI() {
|
|
|
|
// Block the global settings if a game is currently running that overrides them
|
|
|
|
if (Settings::IsConfiguringGlobal()) {
|
|
|
|
ui->slider_clock_speed->setEnabled(Settings::values.cpu_clock_percentage.UsingGlobal());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
});
|
|
|
|
|
|
|
|
ui->groupBox->setVisible(false);
|
|
|
|
ui->groupBox_2->setVisible(false);
|
|
|
|
ui->toggle_cpu_jit->setVisible(false);
|
2016-01-24 18:34:05 +01:00
|
|
|
}
|
2017-09-23 16:13:59 +03:00
|
|
|
|
2019-05-26 00:39:23 -04:00
|
|
|
void ConfigureDebug::RetranslateUI() {
|
2017-09-23 16:13:59 +03:00
|
|
|
ui->retranslateUi(this);
|
|
|
|
}
|