Qt: Confirm disc change type when switching to game list

This commit is contained in:
Connor McLaughlin 2022-05-06 23:34:07 +10:00 committed by refractionpcsx2
parent 98b537575f
commit ec0e9f078c
2 changed files with 25 additions and 2 deletions

View File

@ -811,8 +811,7 @@ void MainWindow::onGameListEntryActivated()
if (m_vm_valid)
{
// change disc on double click
g_emu_thread->changeDisc(QString::fromStdString(entry->path));
switchToEmulationView();
doDiscChange(QString::fromStdString(entry->path));
return;
}
@ -923,6 +922,7 @@ void MainWindow::onChangeDiscFromFileActionTriggered()
void MainWindow::onChangeDiscFromGameListActionTriggered()
{
m_was_disc_change_request = true;
switchToGameListView();
}
@ -1069,6 +1069,7 @@ void MainWindow::onVMStarting()
void MainWindow::onVMStarted()
{
m_vm_valid = true;
m_was_disc_change_request = false;
updateEmulationActions(true, true);
updateWindowTitle();
updateStatusBarWidgetVisibility();
@ -1097,6 +1098,7 @@ void MainWindow::onVMResumed()
}
m_vm_paused = false;
m_was_disc_change_request = false;
updateWindowTitle();
updateStatusBarWidgetVisibility();
m_status_fps_widget->setText(m_last_fps_status);
@ -1699,3 +1701,22 @@ void MainWindow::updateSaveStateMenus(const QString& filename, const QString& se
if (save_enabled)
populateSaveStateMenu(m_ui.menuSaveState, serial, crc);
}
void MainWindow::doDiscChange(const QString& path)
{
bool reset_system = false;
if (!m_was_disc_change_request)
{
const int choice = QMessageBox::question(this, tr("Confirm Disc Change"), tr("Do you want to swap discs or boot the new image (via system reset)?"),
tr("Swap Disc"), tr("Reset"), tr("Cancel"), 0, 2);
if (choice == 2)
return;
reset_system = (choice != 0);
}
switchToEmulationView();
g_emu_thread->changeDisc(path);
if (reset_system)
g_emu_thread->resetVM();
}

View File

@ -160,6 +160,7 @@ private:
void populateLoadStateMenu(QMenu* menu, const QString& filename, const QString& serial, quint32 crc);
void populateSaveStateMenu(QMenu* menu, const QString& serial, quint32 crc);
void updateSaveStateMenus(const QString& filename, const QString& serial, quint32 crc);
void doDiscChange(const QString& path);
Ui::MainWindow m_ui;
@ -184,6 +185,7 @@ private:
bool m_vm_paused = false;
bool m_save_states_invalidated = false;
bool m_was_paused_on_surface_loss = false;
bool m_was_disc_change_request = false;
QString m_last_fps_status;
};