From 208928b6dccc864c3db5b02217056d84f44fefa0 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sun, 16 Feb 2020 00:15:18 +0900 Subject: [PATCH] Qt: Fix load state menu not refreshing after save --- src/duckstation-qt/mainwindow.cpp | 10 ++++++++++ src/duckstation-qt/mainwindow.h | 1 + src/duckstation-qt/qthostinterface.cpp | 7 +++++-- src/duckstation-qt/qthostinterface.h | 1 + 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/duckstation-qt/mainwindow.cpp b/src/duckstation-qt/mainwindow.cpp index 27e1060d1..39c5fe294 100644 --- a/src/duckstation-qt/mainwindow.cpp +++ b/src/duckstation-qt/mainwindow.cpp @@ -119,6 +119,15 @@ void MainWindow::onEmulationPaused(bool paused) m_ui.actionPause->setChecked(paused); } +void MainWindow::onStateSaved(const QString& game_code, bool global, qint32 slot) +{ + // don't bother updating for the resume state since we're powering off anyway + if (slot < 0) + return; + + m_host_interface->populateSaveStateMenus(game_code.toStdString().c_str(), m_ui.menuLoadState, m_ui.menuSaveState); +} + void MainWindow::onSystemPerformanceCountersUpdated(float speed, float fps, float vps, float average_frame_time, float worst_frame_time) { @@ -331,6 +340,7 @@ void MainWindow::connectSignals() connect(m_host_interface, &QtHostInterface::emulationStarted, this, &MainWindow::onEmulationStarted); connect(m_host_interface, &QtHostInterface::emulationStopped, this, &MainWindow::onEmulationStopped); connect(m_host_interface, &QtHostInterface::emulationPaused, this, &MainWindow::onEmulationPaused); + connect(m_host_interface, &QtHostInterface::stateSaved, this, &MainWindow::onStateSaved); connect(m_host_interface, &QtHostInterface::systemPerformanceCountersUpdated, this, &MainWindow::onSystemPerformanceCountersUpdated); connect(m_host_interface, &QtHostInterface::runningGameChanged, this, &MainWindow::onRunningGameChanged); diff --git a/src/duckstation-qt/mainwindow.h b/src/duckstation-qt/mainwindow.h index 600b9c77d..f18345c37 100644 --- a/src/duckstation-qt/mainwindow.h +++ b/src/duckstation-qt/mainwindow.h @@ -30,6 +30,7 @@ private Q_SLOTS: void onEmulationStarted(); void onEmulationStopped(); void onEmulationPaused(bool paused); + void onStateSaved(const QString& game_code, bool global, qint32 slot); void onSystemPerformanceCountersUpdated(float speed, float fps, float vps, float average_frame_time, float worst_frame_time); void onRunningGameChanged(const QString& filename, const QString& game_code, const QString& game_title); diff --git a/src/duckstation-qt/qthostinterface.cpp b/src/duckstation-qt/qthostinterface.cpp index 9cb9c4d98..9ee385ded 100644 --- a/src/duckstation-qt/qthostinterface.cpp +++ b/src/duckstation-qt/qthostinterface.cpp @@ -651,7 +651,7 @@ void QtHostInterface::populateSaveStateMenus(const char* game_code, QMenu* load_ for (s32 i = 1; i <= PER_GAME_SAVE_STATE_SLOTS; i++) { QAction* action = save_menu->addAction(tr("Game Save %1").arg(i)); - connect(action, &QAction::triggered, [this, i]() { saveState(i, false); }); + connect(action, &QAction::triggered, [this, i]() { saveState(false, i); }); } save_menu->addSeparator(); @@ -660,7 +660,7 @@ void QtHostInterface::populateSaveStateMenus(const char* game_code, QMenu* load_ for (s32 i = 1; i <= GLOBAL_SAVE_STATE_SLOTS; i++) { QAction* action = save_menu->addAction(tr("Global Save %1").arg(i)); - connect(action, &QAction::triggered, [this, i]() { saveState(i, true); }); + connect(action, &QAction::triggered, [this, i]() { saveState(true, i); }); } } @@ -696,7 +696,10 @@ void QtHostInterface::saveState(bool global, qint32 slot, bool block_until_done } if (m_system) + { SaveState(global, slot); + emit stateSaved(QString::fromStdString(m_system->GetRunningCode()), global, slot); + } } void QtHostInterface::enableBackgroundControllerPolling() diff --git a/src/duckstation-qt/qthostinterface.h b/src/duckstation-qt/qthostinterface.h index 97d7509a2..0844470a8 100644 --- a/src/duckstation-qt/qthostinterface.h +++ b/src/duckstation-qt/qthostinterface.h @@ -67,6 +67,7 @@ Q_SIGNALS: void emulationStarted(); void emulationStopped(); void emulationPaused(bool paused); + void stateSaved(const QString& game_code, bool global, qint32 slot); void gameListRefreshed(); void createDisplayWindowRequested(QThread* worker_thread, bool use_debug_device); void destroyDisplayWindowRequested();