Qt: Error dialog if a game fails to load

This commit is contained in:
Jeffrey Pfau 2015-01-10 23:28:30 -08:00
parent 78002b4df7
commit 087810a125
4 changed files with 12 additions and 0 deletions

View File

@ -204,6 +204,7 @@ void GameController::openGame() {
if (!GBAThreadStart(&m_threadContext)) {
m_gameOpen = false;
emit gameFailed();
}
}

View File

@ -66,6 +66,7 @@ signals:
void gamePaused(GBAThread*);
void gameUnpaused(GBAThread*);
void gameCrashed(const QString& errorMessage);
void gameFailed();
void stateLoaded(GBAThread*);
void postLog(int level, const QString& log);

View File

@ -83,6 +83,7 @@ Window::Window(ConfigController* config, QWidget* parent)
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)));
@ -384,6 +385,14 @@ void Window::gameCrashed(const QString& errorMessage) {
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() {
if (m_controller->isLoaded()) {
return;

View File

@ -96,6 +96,7 @@ private slots:
void gameStarted(GBAThread*);
void gameStopped();
void gameCrashed(const QString&);
void gameFailed();
void redoLogo();
void recordFrame();