diff options
author | Zach Hilman <zachhilman@gmail.com> | 2018-06-14 23:25:40 +0200 |
---|---|---|
committer | Zach Hilman <zachhilman@gmail.com> | 2018-06-14 23:25:40 +0200 |
commit | acc8fe5a2a2d46c0f89642a9eccaedcea47c6c4f (patch) | |
tree | de2fc83d2e2a10579970337059fe01337d1378d9 /src | |
parent | Add 'Load Folder' menu option (diff) | |
download | yuzu-acc8fe5a2a2d46c0f89642a9eccaedcea47c6c4f.tar yuzu-acc8fe5a2a2d46c0f89642a9eccaedcea47c6c4f.tar.gz yuzu-acc8fe5a2a2d46c0f89642a9eccaedcea47c6c4f.tar.bz2 yuzu-acc8fe5a2a2d46c0f89642a9eccaedcea47c6c4f.tar.lz yuzu-acc8fe5a2a2d46c0f89642a9eccaedcea47c6c4f.tar.xz yuzu-acc8fe5a2a2d46c0f89642a9eccaedcea47c6c4f.tar.zst yuzu-acc8fe5a2a2d46c0f89642a9eccaedcea47c6c4f.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/yuzu/game_list.cpp | 17 | ||||
-rw-r--r-- | src/yuzu/main.cpp | 10 |
2 files changed, 20 insertions, 7 deletions
diff --git a/src/yuzu/game_list.cpp b/src/yuzu/game_list.cpp index 6b0f07757..9e585b082 100644 --- a/src/yuzu/game_list.cpp +++ b/src/yuzu/game_list.cpp @@ -265,8 +265,17 @@ void GameList::ValidateEntry(const QModelIndex& item) { if (file_path.isEmpty()) return; std::string std_file_path(file_path.toStdString()); - if (!FileUtil::Exists(std_file_path) || FileUtil::IsDirectory(std_file_path)) + if (!FileUtil::Exists(std_file_path)) return; + if (FileUtil::IsDirectory(std_file_path)) { + QDir dir(std_file_path.c_str()); + QStringList matching_main = dir.entryList(QStringList("main"), QDir::Files); + if (matching_main.size() == 1) { + emit GameChosen(dir.path() + DIR_SEP + matching_main[0]); + } + return; + } + // Users usually want to run a diffrent game after closing one search_field->clear(); emit GameChosen(file_path); @@ -368,10 +377,10 @@ static bool IsExtractedNCAMain(const std::string& file_name) { return QFileInfo(file_name.c_str()).fileName() == "main"; } -static QString FormatGameName(std::string physical_name) { - QFileInfo fileInfo(physical_name.c_str()); +static QString FormatGameName(const std::string& physical_name) { + QFileInfo file_info(physical_name.c_str()); if (IsExtractedNCAMain(physical_name)) { - return fileInfo.dir().dirName(); + return file_info.dir().path(); } else { return QString::fromStdString(physical_name); } diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index e2afe2131..97be548d7 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -13,6 +13,7 @@ #include <QMessageBox> #include <QtGui> #include <QtWidgets> +#include "common/common_paths.h" #include "common/logging/backend.h" #include "common/logging/filter.h" #include "common/logging/log.h" @@ -568,9 +569,12 @@ void GMainWindow::OnMenuLoadFile() { void GMainWindow::OnMenuLoadFolder() { QDir dir = QFileDialog::getExistingDirectory(this, tr("Open Extracted ROM Directory")); - QStringList matchingMain = dir.entryList(QStringList() << "main", QDir::Files); - if (matchingMain.size() == 1) { - BootGame(matchingMain[0]); + QStringList matching_main = dir.entryList(QStringList("main"), QDir::Files); + if (matching_main.size() == 1) { + BootGame(dir.path() + DIR_SEP + matching_main[0]); + } else { + QMessageBox::warning(this, tr("Invalid Directory Selected"), + tr("The directory you have selected does not contain a 'main' file.")); } } |