From 1c02ae101bbabd2174399a6cff82ff6ce6311716 Mon Sep 17 00:00:00 2001 From: LostDragonist Date: Fri, 15 Feb 2019 00:36:31 -0600 Subject: Improve game selection when multiple games are possible --- src/main.cpp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 0f6d7048..275845e2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -377,13 +377,30 @@ MOBase::IPluginGame *determineCurrentGame(QString const &moPath, QSettings &sett if (!gamePath.isEmpty()) { QDir gameDir(gamePath); + QList possibleGames; for (IPluginGame * const game : plugins.plugins()) { if (game->looksValid(gameDir)) { - return selectGame(settings, gameDir, game); + possibleGames.append(game); + //return selectGame(settings, gameDir, game); + } + } + if (possibleGames.count() > 1) { + SelectionDialog browseSelection(QObject::tr("Please select the game to manage"), nullptr, QSize(32, 32)); + for (IPluginGame *game : possibleGames) { + QString path = game->gameDirectory().absolutePath(); + browseSelection.addChoice(game->gameIcon(), game->gameName(), path, QVariant::fromValue(game)); } + if (browseSelection.exec() == QDialog::Accepted) { + return selectGame(settings, gameDir, browseSelection.getChoiceData().value()); + } else { + reportError(QObject::tr("Canceled finding game in \"%1\".").arg(gamePath)); + } + } else if(possibleGames.count() == 1) { + return selectGame(settings, gameDir, possibleGames[0]); + } else { + reportError(QObject::tr("No game identified in \"%1\". The directory is required to contain " + "the game binary.").arg(gamePath)); } - reportError(QObject::tr("No game identified in \"%1\". The directory is required to contain " - "the game binary.").arg(gamePath)); } } -- cgit v1.3.1