all repos — mgba @ 087810a125cabbced5315a05aca105066ca2a210

mGBA Game Boy Advance Emulator

Qt: Error dialog if a game fails to load
Jeffrey Pfau jeffrey@endrift.com
Sat, 10 Jan 2015 23:28:30 -0800
commit

087810a125cabbced5315a05aca105066ca2a210

parent

78002b4df7cf200fa612a4c3b0d0cc8c8b7165fc

M src/platform/qt/GameController.cppsrc/platform/qt/GameController.cpp

@@ -204,6 +204,7 @@ }

if (!GBAThreadStart(&m_threadContext)) { m_gameOpen = false; + emit gameFailed(); } }
M src/platform/qt/GameController.hsrc/platform/qt/GameController.h

@@ -66,6 +66,7 @@ void gameStopped(GBAThread*);

void gamePaused(GBAThread*); void gameUnpaused(GBAThread*); void gameCrashed(const QString& errorMessage); + void gameFailed(); void stateLoaded(GBAThread*); void postLog(int level, const QString& log);
M src/platform/qt/Window.cppsrc/platform/qt/Window.cpp

@@ -83,6 +83,7 @@ connect(m_controller, SIGNAL(gameUnpaused(GBAThread*)), m_display, SLOT(unpauseDrawing()));

connect(m_controller, SIGNAL(postLog(int, const QString&)), m_logView, SLOT(postLog(int, const QString&))); connect(m_controller, SIGNAL(frameAvailable(const uint32_t*)), this, SLOT(recordFrame())); connect(m_controller, SIGNAL(gameCrashed(const QString&)), this, SLOT(gameCrashed(const QString&))); + connect(m_controller, SIGNAL(gameFailed()), this, SLOT(gameFailed())); connect(m_logView, SIGNAL(levelsSet(int)), m_controller, SLOT(setLogLevel(int))); connect(m_logView, SIGNAL(levelsEnabled(int)), m_controller, SLOT(enableLogLevel(int))); connect(m_logView, SIGNAL(levelsDisabled(int)), m_controller, SLOT(disableLogLevel(int)));

@@ -382,6 +383,14 @@ tr("The game has crashed with the following error:\n\n%1").arg(errorMessage),

QMessageBox::Ok, this, Qt::Sheet); crash->setAttribute(Qt::WA_DeleteOnClose); crash->show(); +} + +void Window::gameFailed() { + QMessageBox* fail = new QMessageBox(QMessageBox::Warning, tr("Couldn't Load"), + tr("Could not load game. Are you sure it's in the correct format?"), + QMessageBox::Ok, this, Qt::Sheet); + fail->setAttribute(Qt::WA_DeleteOnClose); + fail->show(); } void Window::redoLogo() {
M src/platform/qt/Window.hsrc/platform/qt/Window.h

@@ -96,6 +96,7 @@ private slots:

void gameStarted(GBAThread*); void gameStopped(); void gameCrashed(const QString&); + void gameFailed(); void redoLogo(); void recordFrame();