Qt: Fix game properties being inaccessible in batch mode

This commit is contained in:
Connor McLaughlin 2021-07-27 18:11:32 +10:00
parent 6a99ff9c08
commit 0af334bba5
4 changed files with 28 additions and 9 deletions

View file

@ -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();

View file

@ -146,6 +146,7 @@ private:
void updateDebugMenuCPUExecutionMode();
void updateDebugMenuGPURenderer();
void updateDebugMenuCropMode();
void ensureGameListLoaded();
Ui::MainWindow m_ui;

View file

@ -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;

View file

@ -99,6 +99,7 @@ public:
const u32 GetEntryCount() const { return static_cast<u32>(m_entries.size()); }
const std::vector<DirectoryEntry>& GetSearchDirectories() const { return m_search_directories; }
const u32 GetSearchDirectoryCount() const { return static_cast<u32>(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;
};