diff --git a/src/duckstation-qt/mainwindow.cpp b/src/duckstation-qt/mainwindow.cpp index 1b8a96a32..409ae4350 100644 --- a/src/duckstation-qt/mainwindow.cpp +++ b/src/duckstation-qt/mainwindow.cpp @@ -464,15 +464,6 @@ void MainWindow::onRunningGameChanged(const QString& filename, const QString& ga if (m_display_widget) m_display_widget->setWindowTitle(windowTitle()); - bool has_game_list_entry = false; - if (!filename.isEmpty()) - { - const GameListEntry* entry = m_host_interface->getGameList()->GetEntryForPath(filename.toStdString().c_str()); - has_game_list_entry = (entry != nullptr); - } - - m_ui.actionViewGameProperties->setEnabled(has_game_list_entry); - m_running_game_code = game_code.toStdString(); } @@ -663,9 +654,16 @@ void MainWindow::onViewGamePropertiesActionTriggered() if (path.empty()) return; + ensureGameListLoaded(); + const GameListEntry* entry = m_host_interface->getGameList()->GetEntryForPath(path.c_str()); if (!entry) + { + QMessageBox::critical(this, tr("DuckStation"), + tr("Could not find a game list entry for the currently running file. Please make sure this " + "file is in a location scanned by the game list.")); return; + } GamePropertiesDialog::showForEntry(m_host_interface, entry, this); } @@ -961,6 +959,7 @@ void MainWindow::updateEmulationActions(bool starting, bool running, bool cheevo m_ui.menuWindowSize->setDisabled(starting || !running); m_ui.actionFullscreen->setDisabled(starting || !running); + m_ui.actionViewGameProperties->setDisabled(starting || !running); m_ui.actionLoadState->setDisabled(cheevos_challenge_mode); m_ui.menuLoadState->setDisabled(cheevos_challenge_mode); @@ -1538,6 +1537,21 @@ void MainWindow::updateDebugMenuCropMode() } } +void MainWindow::ensureGameListLoaded() +{ + if (m_host_interface->getGameList()->IsGameListLoaded()) + return; + + const bool was_running = System::IsRunning(); + if (m_emulation_running) + m_host_interface->pauseSystem(true, true); + + m_host_interface->refreshGameList(); + + if (!was_running) + m_host_interface->pauseSystem(false, false); +} + void MainWindow::closeEvent(QCloseEvent* event) { m_host_interface->synchronousPowerOffSystem(); diff --git a/src/duckstation-qt/mainwindow.h b/src/duckstation-qt/mainwindow.h index 06c12600e..79d507e8a 100644 --- a/src/duckstation-qt/mainwindow.h +++ b/src/duckstation-qt/mainwindow.h @@ -146,6 +146,7 @@ private: void updateDebugMenuCPUExecutionMode(); void updateDebugMenuGPURenderer(); void updateDebugMenuCropMode(); + void ensureGameListLoaded(); Ui::MainWindow m_ui; diff --git a/src/frontend-common/game_list.cpp b/src/frontend-common/game_list.cpp index b5a549959..4e82c8c5e 100644 --- a/src/frontend-common/game_list.cpp +++ b/src/frontend-common/game_list.cpp @@ -616,6 +616,8 @@ void GameList::SetSearchDirectoriesFromSettings(SettingsInterface& si) void GameList::Refresh(bool invalidate_cache, bool invalidate_database, ProgressCallback* progress /* = nullptr */) { + m_game_list_loaded = true; + if (!progress) progress = ProgressCallback::NullProgressCallback; diff --git a/src/frontend-common/game_list.h b/src/frontend-common/game_list.h index 1656f4548..279738e24 100644 --- a/src/frontend-common/game_list.h +++ b/src/frontend-common/game_list.h @@ -99,6 +99,7 @@ public: const u32 GetEntryCount() const { return static_cast(m_entries.size()); } const std::vector& GetSearchDirectories() const { return m_search_directories; } const u32 GetSearchDirectoryCount() const { return static_cast(m_search_directories.size()); } + const bool IsGameListLoaded() const { return m_game_list_loaded; } const GameListEntry* GetEntryForPath(const char* path) const; const GameListCompatibilityEntry* GetCompatibilityEntryForCode(const std::string& code) const; @@ -187,4 +188,5 @@ private: bool m_database_load_tried = false; bool m_compatibility_list_load_tried = false; bool m_game_settings_load_tried = false; + bool m_game_list_loaded = false; };