From 0409bdfea5ea046e3d040ab494b8a0764fd35424 Mon Sep 17 00:00:00 2001 From: TheKoopaKingdom Date: Thu, 13 Apr 2017 01:15:23 -0400 Subject: [PATCH] Optimized messages that were repetitive and added ability for core errors to specify more details optionally. --- src/citra_qt/bootmanager.cpp | 2 +- src/citra_qt/bootmanager.h | 2 +- src/citra_qt/main.cpp | 88 ++++++++++++++++++++++-------------- src/citra_qt/main.h | 2 +- src/core/core.h | 17 ++++++- 5 files changed, 71 insertions(+), 40 deletions(-) diff --git a/src/citra_qt/bootmanager.cpp b/src/citra_qt/bootmanager.cpp index 0fdf0c600..a8a4aed8b 100644 --- a/src/citra_qt/bootmanager.cpp +++ b/src/citra_qt/bootmanager.cpp @@ -39,7 +39,7 @@ void EmuThread::run() { Core::System::ResultStatus result = Core::System::GetInstance().RunLoop(); if (result != Core::System::ResultStatus::Success) { - emit ErrorThrown(result); + emit ErrorThrown(result, Core::System::GetInstance().GetStatusDetails()); } was_active = running || exec_step; diff --git a/src/citra_qt/bootmanager.h b/src/citra_qt/bootmanager.h index c5430a3fa..b12b37132 100644 --- a/src/citra_qt/bootmanager.h +++ b/src/citra_qt/bootmanager.h @@ -99,7 +99,7 @@ signals: */ void DebugModeLeft(); - void ErrorThrown(Core::System::ResultStatus); + void ErrorThrown(Core::System::ResultStatus, boost::optional); }; class GRenderWindow : public QWidget, public EmuWindow { diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp index 6121d4728..1688e55cd 100644 --- a/src/citra_qt/main.cpp +++ b/src/citra_qt/main.cpp @@ -553,8 +553,10 @@ void GMainWindow::OnMenuRecentFile() { void GMainWindow::OnStartGame() { emu_thread->SetRunning(true); qRegisterMetaType("Core::System::ResultStatus"); - connect(emu_thread.get(), SIGNAL(ErrorThrown(Core::System::ResultStatus)), this, - SLOT(OnCoreError(Core::System::ResultStatus))); + qRegisterMetaType>("boost::optional"); + connect(emu_thread.get(), + SIGNAL(ErrorThrown(Core::System::ResultStatus, boost::optional)), this, + SLOT(OnCoreError(Core::System::ResultStatus, boost::optional))); ui.action_Start->setEnabled(false); ui.action_Start->setText(tr("Continue")); @@ -647,52 +649,68 @@ void GMainWindow::UpdateStatusBar() { emu_frametime_label->setVisible(true); } -void GMainWindow::OnCoreError(Core::System::ResultStatus result) { +void GMainWindow::OnCoreError(Core::System::ResultStatus result, + boost::optional details) { + QMessageBox::StandardButton answer; + QString status_message; + const QString common_message = + tr("The game you are trying to load requires additional files from your 3DS to be dumped " + "before playing.

For more information on dumping these files, please see the " + "following wiki page: Dumping System " + "Archives and the Shared Fonts from a 3DS Console.

Would you like to quit " + "back to the game list?"); switch (result) { - case Core::System::ResultStatus::ErrorSystemFiles: - QMessageBox::critical( - this, "System Archive Not Found", - "Citra was unable to locate the 3DS system archive.

" - "The game you are trying to load requires additional files from your 3DS to be dumped " - "before playing.

" - "For more information on dumping these files, please see the following wiki page: " - "Dumping System " - "Archives and the Shared Fonts from a 3DS Console" - "."); - break; + case Core::System::ResultStatus::ErrorSystemFiles: { + QString message = "Citra was unable to locate a 3DS system archive"; + if (details) + message.append(tr(": %1. ").arg(details.get().c_str())); + else + message.append(". "); + message.append(common_message); - case Core::System::ResultStatus::ErrorSharedFont: - QMessageBox::critical( - this, "Shared Fonts Not Found", - "Citra was unable to locate the 3DS shared fonts.

" - "The game you are trying to load requires additional files from your 3DS to be dumped " - "before playing.

" - "For more information on dumping these files, please see the following wiki page: " - "Dumping System " - "Archives and the Shared Fonts from a 3DS Console" - "."); + answer = QMessageBox::question(this, tr("System Archive Not Found"), message, + QMessageBox::Yes | QMessageBox::No, QMessageBox::No); + status_message = "System Archive Missing"; break; + } + + case Core::System::ResultStatus::ErrorSharedFont: { + QString message = tr("Citra was unable to locate the 3DS shared fonts. "); + message.append(common_message); + answer = QMessageBox::question(this, tr("Shared Fonts Not Found"), message, + QMessageBox::Yes | QMessageBox::No, QMessageBox::No); + status_message = "Shared Font Missing"; + break; + } default: - QMessageBox::critical( - this, "Fatal Error", - "Citra has encountered a fatal error, please see the log for more details. " - "For more information on accessing the log, please see the following page: " - "How to " - "Upload the Log File."); + answer = QMessageBox::question( + this, tr("Fatal Error"), + tr("Citra has encountered a fatal error, please see the log for more details. " + "For more information on accessing the log, please see the following page: " + "How to " + "Upload the Log File.

Would you like to quit back to the game list?"), + QMessageBox::Yes | QMessageBox::No, QMessageBox::No); + status_message = "Fatal Error encountered."; break; } + + if (answer == QMessageBox::Yes) { + if (emu_thread != nullptr) + ShutdownGame(); + } else { + message_label->setText(status_message); + message_label->setVisible(true); + } } bool GMainWindow::ConfirmClose() { if (emu_thread == nullptr || !UISettings::values.confirm_before_closing) return true; - auto answer = + QMessageBox::StandardButton answer = QMessageBox::question(this, tr("Citra"), tr("Are you sure you want to close Citra?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No); return answer != QMessageBox::No; diff --git a/src/citra_qt/main.h b/src/citra_qt/main.h index 3ecbc001e..eb2b055f6 100644 --- a/src/citra_qt/main.h +++ b/src/citra_qt/main.h @@ -125,7 +125,7 @@ private slots: void OnDisplayTitleBars(bool); void ToggleWindowMode(); void OnCreateGraphicsSurfaceViewer(); - void OnCoreError(Core::System::ResultStatus); + void OnCoreError(Core::System::ResultStatus, boost::optional); private: void UpdateStatusBar(); diff --git a/src/core/core.h b/src/core/core.h index a7b4f8d62..bc363ed97 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -6,6 +6,9 @@ #include #include + +#include + #include "common/common_types.h" #include "core/memory.h" #include "core/perf_stats.h" @@ -112,8 +115,16 @@ public: return status; } - void SetStatus(ResultStatus newStatus) { - status = newStatus; + void SetStatus(ResultStatus new_status, std::string details = std::string()) { + status = new_status; + if (details == std::string()) + status_details = boost::none; + else + status_details = details; + } + + boost::optional GetStatusDetails() { + return status_details; } private: @@ -141,7 +152,9 @@ private: std::unique_ptr telemetry_session; static System s_instance; + ResultStatus status; + boost::optional status_details; }; inline ARM_Interface& CPU() {