From e4e15f234b91541557f8b5dbab2cc62b2828fde0 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Wed, 5 Feb 2020 17:43:25 +0900 Subject: [PATCH] Qt: Fix up debug CPU mode switch menu --- src/duckstation-qt/mainwindow.cpp | 49 ++++++++++++++++++++++++------- src/duckstation-qt/mainwindow.h | 1 + src/duckstation-qt/mainwindow.ui | 27 ----------------- 3 files changed, 40 insertions(+), 37 deletions(-) diff --git a/src/duckstation-qt/mainwindow.cpp b/src/duckstation-qt/mainwindow.cpp index 1b6802e5a..c7c001603 100644 --- a/src/duckstation-qt/mainwindow.cpp +++ b/src/duckstation-qt/mainwindow.cpp @@ -222,12 +222,26 @@ void MainWindow::setupAdditionalUi() m_status_frame_time_widget->setFixedSize(190, 16); m_status_frame_time_widget->hide(); + for (u32 i = 0; i < static_cast(CPUExecutionMode::Count); i++) + { + const CPUExecutionMode mode = static_cast(i); + QAction* action = m_ui.menuCPUExecutionMode->addAction(tr(Settings::GetCPUExecutionModeDisplayName(mode))); + action->setCheckable(true); + connect(action, &QAction::triggered, [this, mode]() { + m_host_interface->putSettingValue(QStringLiteral("CPU/ExecutionMode"), + QString(Settings::GetCPUExecutionModeName(mode))); + m_host_interface->applySettings(); + updateDebugMenuCPUExecutionMode(); + }); + } + updateDebugMenuCPUExecutionMode(); + for (u32 i = 0; i < static_cast(GPURenderer::Count); i++) { const GPURenderer renderer = static_cast(i); QAction* action = m_ui.menuRenderer->addAction(tr(Settings::GetRendererDisplayName(renderer))); action->setCheckable(true); - connect(action, &QAction::triggered, [this, action, renderer]() { + connect(action, &QAction::triggered, [this, renderer]() { m_host_interface->putSettingValue(QStringLiteral("GPU/Renderer"), QString(Settings::GetRendererName(renderer))); m_host_interface->applySettings(); }); @@ -396,21 +410,36 @@ void MainWindow::doSettings(SettingsDialog::Category category) dlg->setCategory(category); } +void MainWindow::updateDebugMenuCPUExecutionMode() +{ + std::optional current_mode = Settings::ParseCPUExecutionMode( + m_host_interface->getSettingValue(QStringLiteral("CPU/ExecutionMode")).toString().toStdString().c_str()); + if (!current_mode.has_value()) + return; + + const QString current_mode_display_name(tr(Settings::GetCPUExecutionModeDisplayName(current_mode.value()))); + for (QObject* obj : m_ui.menuCPUExecutionMode->children()) + { + QAction* action = qobject_cast(obj); + if (action) + action->setChecked(action->text() == current_mode_display_name); + } +} + void MainWindow::updateDebugMenuGPURenderer() { // update the menu with the new selected renderer std::optional current_renderer = Settings::ParseRendererName( m_host_interface->getSettingValue(QStringLiteral("GPU/Renderer")).toString().toStdString().c_str()); - if (current_renderer.has_value()) + if (!current_renderer.has_value()) + return; + + const QString current_renderer_display_name(tr(Settings::GetRendererDisplayName(current_renderer.value()))); + for (QObject* obj : m_ui.menuRenderer->children()) { - const QString current_renderer_display_name( - QString::fromUtf8(Settings::GetRendererDisplayName(current_renderer.value()))); - for (QObject* obj : m_ui.menuRenderer->children()) - { - QAction* action = qobject_cast(obj); - if (action) - action->setChecked(action->text() == current_renderer_display_name); - } + QAction* action = qobject_cast(obj); + if (action) + action->setChecked(action->text() == current_renderer_display_name); } } diff --git a/src/duckstation-qt/mainwindow.h b/src/duckstation-qt/mainwindow.h index e79bae1fd..8a88f458e 100644 --- a/src/duckstation-qt/mainwindow.h +++ b/src/duckstation-qt/mainwindow.h @@ -52,6 +52,7 @@ private: void switchToEmulationView(); SettingsDialog* getSettingsDialog(); void doSettings(SettingsDialog::Category category = SettingsDialog::Category::Count); + void updateDebugMenuCPUExecutionMode(); void updateDebugMenuGPURenderer(); void populateLoadSaveStateMenus(QString game_code); diff --git a/src/duckstation-qt/mainwindow.ui b/src/duckstation-qt/mainwindow.ui index 3bdcda870..5c9fcb239 100644 --- a/src/duckstation-qt/mainwindow.ui +++ b/src/duckstation-qt/mainwindow.ui @@ -117,9 +117,6 @@ Switch CPU Emulation Mode - - - @@ -288,30 +285,6 @@ Fullscreen - - - true - - - Interpreter (Slowest) - - - - - true - - - Cached Interpreter (Slower) - - - - - true - - - Recompiler (Fastest) - - Resolution Scale