Instead of there being an "Abort/Continue" prompt when a savestate fails to save or load, it just brings up a warning box. (#6236)

* This fixes #6041 by changing OnCoreError. Instead of there being an "Abort/Continue" prompt when a savestate fails to save or load, it just brings up a warning box.

I also changed "Abort/Continue" to "Quit Game/Continue" for better clarity

* Fixed formatting
This commit is contained in:
upadsamay387 2023-01-15 10:15:16 -06:00 committed by GitHub
parent ad2cbe2b26
commit bd1cabce86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2269,6 +2269,7 @@ void GMainWindow::OnCoreError(Core::System::ResultStatus result, std::string det
QString status_message; QString status_message;
QString title, message; QString title, message;
QMessageBox::Icon error_severity_icon;
if (result == Core::System::ResultStatus::ErrorSystemFiles) { if (result == Core::System::ResultStatus::ErrorSystemFiles) {
const QString common_message = const QString common_message =
tr("%1 is missing. Please <a " tr("%1 is missing. Please <a "
@ -2284,9 +2285,11 @@ void GMainWindow::OnCoreError(Core::System::ResultStatus result, std::string det
title = tr("System Archive Not Found"); title = tr("System Archive Not Found");
status_message = tr("System Archive Missing"); status_message = tr("System Archive Missing");
error_severity_icon = QMessageBox::Icon::Critical;
} else if (result == Core::System::ResultStatus::ErrorSavestate) { } else if (result == Core::System::ResultStatus::ErrorSavestate) {
title = tr("Save/load Error"); title = tr("Save/load Error");
message = QString::fromStdString(details); message = QString::fromStdString(details);
error_severity_icon = QMessageBox::Icon::Warning;
} else { } else {
title = tr("Fatal Error"); title = tr("Fatal Error");
message = message =
@ -2295,30 +2298,39 @@ void GMainWindow::OnCoreError(Core::System::ResultStatus result, std::string det
"the log</a> for details." "the log</a> for details."
"<br/>Continuing emulation may result in crashes and bugs."); "<br/>Continuing emulation may result in crashes and bugs.");
status_message = tr("Fatal Error encountered"); status_message = tr("Fatal Error encountered");
error_severity_icon = QMessageBox::Icon::Critical;
} }
QMessageBox message_box; QMessageBox message_box;
message_box.setWindowTitle(title); message_box.setWindowTitle(title);
message_box.setText(message); message_box.setText(message);
message_box.setIcon(QMessageBox::Icon::Critical); message_box.setIcon(error_severity_icon);
message_box.addButton(tr("Continue"), QMessageBox::RejectRole); if (error_severity_icon == QMessageBox::Icon::Critical) {
QPushButton* abort_button = message_box.addButton(tr("Abort"), QMessageBox::AcceptRole); message_box.addButton(tr("Continue"), QMessageBox::RejectRole);
if (result != Core::System::ResultStatus::ShutdownRequested) QPushButton* abort_button = message_box.addButton(tr("Quit Game"), QMessageBox::AcceptRole);
message_box.exec(); if (result != Core::System::ResultStatus::ShutdownRequested)
message_box.exec();
if (result == Core::System::ResultStatus::ShutdownRequested || if (result == Core::System::ResultStatus::ShutdownRequested ||
message_box.clickedButton() == abort_button) { message_box.clickedButton() == abort_button) {
if (emu_thread) { if (emu_thread) {
ShutdownGame(); ShutdownGame();
return;
}
} }
} else { } else {
// Only show the message if the game is still running. // This block should run when the error isn't too big of a deal
if (emu_thread) { // e.g. when a save state can't be saved or loaded
emu_thread->SetRunning(true); message_box.addButton(tr("OK"), QMessageBox::RejectRole);
message_label->setText(status_message); message_box.exec();
message_label->setVisible(true); }
message_label_used_for_movie = false;
} // Only show the message if the game is still running.
if (emu_thread) {
emu_thread->SetRunning(true);
message_label->setText(status_message);
message_label->setVisible(true);
message_label_used_for_movie = false;
} }
} }