From 701780e2ef51ac587170457e932567f5f9219e68 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Fri, 22 Jul 2022 22:51:29 +1000 Subject: [PATCH] Qt: Regression fixes --- src/core/analog_joystick.cpp | 2 +- src/core/spu.cpp | 2 +- src/core/system.cpp | 9 +++--- src/duckstation-qt/consolesettingswidget.cpp | 32 ++++++++++++++------ src/duckstation-qt/mainwindow.cpp | 2 +- src/frontend-common/common_host.cpp | 27 +++++++++-------- 6 files changed, 46 insertions(+), 28 deletions(-) diff --git a/src/core/analog_joystick.cpp b/src/core/analog_joystick.cpp index 5002d1535..212b62fca 100644 --- a/src/core/analog_joystick.cpp +++ b/src/core/analog_joystick.cpp @@ -327,7 +327,7 @@ static const Controller::ControllerBindingInfo s_binding_info[] = { static const SettingInfo s_settings[] = { {SettingInfo::Type::Float, "AnalogDeadzone", TRANSLATABLE("AnalogController", "Analog Deadzone"), TRANSLATABLE("AnalogController", - "Sets the analog stick deadzone, i.e. the fraction of the stick movement which will be ignored.s"), + "Sets the analog stick deadzone, i.e. the fraction of the stick movement which will be ignored."), "1.00f", "0.00f", "1.00f", "0.01f"}, {SettingInfo::Type::Float, "AnalogSensitivity", TRANSLATABLE("AnalogController", "Analog Sensitivity"), TRANSLATABLE( diff --git a/src/core/spu.cpp b/src/core/spu.cpp index 621e94b6f..922cebbd4 100644 --- a/src/core/spu.cpp +++ b/src/core/spu.cpp @@ -1951,7 +1951,7 @@ void SPU::DrawDebugStateWindow() { static const ImVec4 active_color{1.0f, 1.0f, 1.0f, 1.0f}; static const ImVec4 inactive_color{0.4f, 0.4f, 0.4f, 1.0f}; - const float framebuffer_scale = ImGui::GetIO().DisplayFramebufferScale.x; + const float framebuffer_scale = Host::GetOSDScale(); ImGui::SetNextWindowSize(ImVec2(800.0f * framebuffer_scale, 800.0f * framebuffer_scale), ImGuiCond_FirstUseEver); if (!ImGui::Begin("SPU State", nullptr)) diff --git a/src/core/system.cpp b/src/core/system.cpp index 0fab79235..941718279 100644 --- a/src/core/system.cpp +++ b/src/core/system.cpp @@ -3910,7 +3910,8 @@ bool System::LoadCheatList(const char* filename) bool System::LoadCheatListFromGameTitle() { - if (!IsValid() || Achievements::ChallengeModeActive()) + // Called when booting, needs to test for shutdown. + if (IsShutdown() || Achievements::ChallengeModeActive()) return false; const std::string filename(GetCheatFileName()); @@ -3922,15 +3923,15 @@ bool System::LoadCheatListFromGameTitle() bool System::LoadCheatListFromDatabase() { - if (System::GetRunningCode().empty() || Achievements::ChallengeModeActive()) + if (IsShutdown() || s_running_game_code.empty() || Achievements::ChallengeModeActive()) return false; std::unique_ptr cl = std::make_unique(); - if (!cl->LoadFromPackage(System::GetRunningCode())) + if (!cl->LoadFromPackage(s_running_game_code)) return false; Log_InfoPrintf("Loaded %u cheats from database.", cl->GetCodeCount()); - System::SetCheatList(std::move(cl)); + SetCheatList(std::move(cl)); return true; } diff --git a/src/duckstation-qt/consolesettingswidget.cpp b/src/duckstation-qt/consolesettingswidget.cpp index acdfaf323..fd7c94934 100644 --- a/src/duckstation-qt/consolesettingswidget.cpp +++ b/src/duckstation-qt/consolesettingswidget.cpp @@ -5,6 +5,7 @@ #include "settingwidgetbinder.h" #include "util/cd_image.h" #include +#include ConsoleSettingsWidget::ConsoleSettingsWidget(SettingsDialog* dialog, QWidget* parent) : QWidget(parent), m_dialog(dialog) @@ -92,7 +93,7 @@ ConsoleSettingsWidget::ConsoleSettingsWidget(SettingsDialog* dialog, QWidget* pa tr("Automatically applies patches to disc images when they are present in the same " "directory. Currently only PPF patches are supported with this option.")); - m_ui.cpuClockSpeed->setEnabled(m_ui.enableCPUClockSpeedControl->checkState() == Qt::Checked); + m_ui.cpuClockSpeed->setEnabled(m_dialog->getEffectiveBoolValue("CPU", "OverclockEnable", false)); connect(m_ui.enableCPUClockSpeedControl, &QCheckBox::stateChanged, this, &ConsoleSettingsWidget::onEnableCPUClockSpeedControlChecked); @@ -105,28 +106,41 @@ ConsoleSettingsWidget::~ConsoleSettingsWidget() = default; void ConsoleSettingsWidget::onEnableCPUClockSpeedControlChecked(int state) { - if (state == Qt::Checked && !Host::GetBaseBoolSettingValue("UI", "CPUOverclockingWarningShown", false)) + if (state == Qt::Checked && + (!m_dialog->isPerGameSettings() || !Host::GetBaseBoolSettingValue("CPU", "OverclockEnable", false)) && + !Host::GetBaseBoolSettingValue("UI", "CPUOverclockingWarningShown", false)) { const QString message = tr("Enabling CPU overclocking will break games, cause bugs, reduce performance and can significantly increase " "system requirements.\n\nBy enabling this option you are agreeing to not create any bug reports unless you " "have confirmed the bug also occurs with overclocking disabled.\n\nThis warning will only be shown once."); - const QString yes_button = tr("Yes, I will confirm bugs without overclocking before reporting."); - const QString no_button = tr("No, take me back to safety."); - if (QMessageBox::question(QtUtils::GetRootWidget(this), tr("CPU Overclocking Warning"), message, - QMessageBox::Yes | QMessageBox::No) != 0) + QMessageBox mb(QMessageBox::Warning, tr("CPU Overclocking Warning"), message, QMessageBox::NoButton, this); + const QAbstractButton* const yes_button = mb.addButton(tr("Yes, I will confirm bugs without overclocking before reporting."), QMessageBox::YesRole); + mb.addButton(tr("No, take me back to safety."), QMessageBox::NoRole); + mb.exec(); + + if (mb.clickedButton() != yes_button) { QSignalBlocker sb(m_ui.enableCPUClockSpeedControl); - m_ui.enableCPUClockSpeedControl->setChecked(Qt::Unchecked); - m_dialog->setBoolSettingValue("CPU", "OverclockEnable", false); + if (m_dialog->isPerGameSettings()) + { + m_ui.enableCPUClockSpeedControl->setCheckState(Qt::PartiallyChecked); + m_dialog->removeSettingValue("CPU", "OverclockEnable"); + } + else + { + m_ui.enableCPUClockSpeedControl->setCheckState(Qt::Unchecked); + m_dialog->setBoolSettingValue("CPU", "OverclockEnable", false); + } + return; } Host::SetBaseBoolSettingValue("UI", "CPUOverclockingWarningShown", true); } - m_ui.cpuClockSpeed->setEnabled(state == Qt::Checked); + m_ui.cpuClockSpeed->setEnabled(m_dialog->getEffectiveBoolValue("CPU", "OverclockEnable", false)); updateCPUClockSpeedLabel(); } diff --git a/src/duckstation-qt/mainwindow.cpp b/src/duckstation-qt/mainwindow.cpp index daa77feba..2123e6765 100644 --- a/src/duckstation-qt/mainwindow.cpp +++ b/src/duckstation-qt/mainwindow.cpp @@ -269,7 +269,7 @@ bool MainWindow::updateDisplay(bool fullscreen, bool render_to_main, bool surfac m_display_widget->setFocus(); m_display_widget->setShouldHideCursor(shouldHideMouseCursor()); - m_display_widget->updateRelativeMode(s_system_valid && !s_system_paused); + m_display_widget->updateRelativeMode(m_relative_mouse_mode && s_system_valid && !s_system_paused); m_display_widget->updateCursor(s_system_valid && !s_system_paused); QSignalBlocker blocker(m_ui.actionFullscreen); diff --git a/src/frontend-common/common_host.cpp b/src/frontend-common/common_host.cpp index f9283a495..1897debef 100644 --- a/src/frontend-common/common_host.cpp +++ b/src/frontend-common/common_host.cpp @@ -415,18 +415,21 @@ void Host::DisplayLoadingScreen(const char* message, int progress_min /*= -1*/, void ImGuiManager::RenderDebugWindows() { - if (g_settings.debugging.show_gpu_state) - g_gpu->DrawDebugStateWindow(); - if (g_settings.debugging.show_cdrom_state) - g_cdrom.DrawDebugWindow(); - if (g_settings.debugging.show_timers_state) - g_timers.DrawDebugStateWindow(); - if (g_settings.debugging.show_spu_state) - g_spu.DrawDebugStateWindow(); - if (g_settings.debugging.show_mdec_state) - g_mdec.DrawDebugStateWindow(); - if (g_settings.debugging.show_dma_state) - g_dma.DrawDebugStateWindow(); + if (System::IsValid()) + { + if (g_settings.debugging.show_gpu_state) + g_gpu->DrawDebugStateWindow(); + if (g_settings.debugging.show_cdrom_state) + g_cdrom.DrawDebugWindow(); + if (g_settings.debugging.show_timers_state) + g_timers.DrawDebugStateWindow(); + if (g_settings.debugging.show_spu_state) + g_spu.DrawDebugStateWindow(); + if (g_settings.debugging.show_mdec_state) + g_mdec.DrawDebugStateWindow(); + if (g_settings.debugging.show_dma_state) + g_dma.DrawDebugStateWindow(); + } } #ifdef WITH_DISCORD_PRESENCE