diff options
| author | 2018-06-18 16:09:46 -0400 | |
|---|---|---|
| committer | 2018-06-18 16:09:46 -0400 | |
| commit | c11cfaa70543094efe9cbb493843546dfa0fa6cf (patch) | |
| tree | 053bd7cfcd86b5e22deea4bf4aee711dcef097d1 /src | |
| parent | Merge pull request #572 from Armada651/user-except-stub (diff) | |
| parent | Bug fixes, testing, and review changes (diff) | |
| download | yuzu-c11cfaa70543094efe9cbb493843546dfa0fa6cf.tar.gz yuzu-c11cfaa70543094efe9cbb493843546dfa0fa6cf.tar.xz yuzu-c11cfaa70543094efe9cbb493843546dfa0fa6cf.zip | |
Merge pull request #562 from DarkLordZach/extracted-ncas-ui
Add UI support for extracted NCA folders
Diffstat (limited to 'src')
| -rw-r--r-- | src/yuzu/game_list.cpp | 30 | ||||
| -rw-r--r-- | src/yuzu/main.cpp | 16 | ||||
| -rw-r--r-- | src/yuzu/main.h | 1 | ||||
| -rw-r--r-- | src/yuzu/main.ui | 6 |
4 files changed, 50 insertions, 3 deletions
diff --git a/src/yuzu/game_list.cpp b/src/yuzu/game_list.cpp index bbd681eae..9e585b082 100644 --- a/src/yuzu/game_list.cpp +++ b/src/yuzu/game_list.cpp | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <QApplication> | 5 | #include <QApplication> |
| 6 | #include <QDir> | ||
| 6 | #include <QFileInfo> | 7 | #include <QFileInfo> |
| 7 | #include <QHeaderView> | 8 | #include <QHeaderView> |
| 8 | #include <QKeyEvent> | 9 | #include <QKeyEvent> |
| @@ -264,8 +265,17 @@ void GameList::ValidateEntry(const QModelIndex& item) { | |||
| 264 | if (file_path.isEmpty()) | 265 | if (file_path.isEmpty()) |
| 265 | return; | 266 | return; |
| 266 | std::string std_file_path(file_path.toStdString()); | 267 | std::string std_file_path(file_path.toStdString()); |
| 267 | if (!FileUtil::Exists(std_file_path) || FileUtil::IsDirectory(std_file_path)) | 268 | if (!FileUtil::Exists(std_file_path)) |
| 268 | return; | 269 | return; |
| 270 | if (FileUtil::IsDirectory(std_file_path)) { | ||
| 271 | QDir dir(std_file_path.c_str()); | ||
| 272 | QStringList matching_main = dir.entryList(QStringList("main"), QDir::Files); | ||
| 273 | if (matching_main.size() == 1) { | ||
| 274 | emit GameChosen(dir.path() + DIR_SEP + matching_main[0]); | ||
| 275 | } | ||
| 276 | return; | ||
| 277 | } | ||
| 278 | |||
| 269 | // Users usually want to run a diffrent game after closing one | 279 | // Users usually want to run a diffrent game after closing one |
| 270 | search_field->clear(); | 280 | search_field->clear(); |
| 271 | emit GameChosen(file_path); | 281 | emit GameChosen(file_path); |
| @@ -363,6 +373,19 @@ static bool HasSupportedFileExtension(const std::string& file_name) { | |||
| 363 | return GameList::supported_file_extensions.contains(file.suffix(), Qt::CaseInsensitive); | 373 | return GameList::supported_file_extensions.contains(file.suffix(), Qt::CaseInsensitive); |
| 364 | } | 374 | } |
| 365 | 375 | ||
| 376 | static bool IsExtractedNCAMain(const std::string& file_name) { | ||
| 377 | return QFileInfo(file_name.c_str()).fileName() == "main"; | ||
| 378 | } | ||
| 379 | |||
| 380 | static QString FormatGameName(const std::string& physical_name) { | ||
| 381 | QFileInfo file_info(physical_name.c_str()); | ||
| 382 | if (IsExtractedNCAMain(physical_name)) { | ||
| 383 | return file_info.dir().path(); | ||
| 384 | } else { | ||
| 385 | return QString::fromStdString(physical_name); | ||
| 386 | } | ||
| 387 | } | ||
| 388 | |||
| 366 | void GameList::RefreshGameDirectory() { | 389 | void GameList::RefreshGameDirectory() { |
| 367 | if (!UISettings::values.gamedir.isEmpty() && current_worker != nullptr) { | 390 | if (!UISettings::values.gamedir.isEmpty() && current_worker != nullptr) { |
| 368 | NGLOG_INFO(Frontend, "Change detected in the games directory. Reloading game list."); | 391 | NGLOG_INFO(Frontend, "Change detected in the games directory. Reloading game list."); |
| @@ -380,7 +403,8 @@ void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, unsign | |||
| 380 | return false; // Breaks the callback loop. | 403 | return false; // Breaks the callback loop. |
| 381 | 404 | ||
| 382 | bool is_dir = FileUtil::IsDirectory(physical_name); | 405 | bool is_dir = FileUtil::IsDirectory(physical_name); |
| 383 | if (!is_dir && HasSupportedFileExtension(physical_name)) { | 406 | if (!is_dir && |
| 407 | (HasSupportedFileExtension(physical_name) || IsExtractedNCAMain(physical_name))) { | ||
| 384 | std::unique_ptr<Loader::AppLoader> loader = Loader::GetLoader(physical_name); | 408 | std::unique_ptr<Loader::AppLoader> loader = Loader::GetLoader(physical_name); |
| 385 | if (!loader) | 409 | if (!loader) |
| 386 | return true; | 410 | return true; |
| @@ -392,7 +416,7 @@ void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, unsign | |||
| 392 | loader->ReadProgramId(program_id); | 416 | loader->ReadProgramId(program_id); |
| 393 | 417 | ||
| 394 | emit EntryReady({ | 418 | emit EntryReady({ |
| 395 | new GameListItemPath(QString::fromStdString(physical_name), smdh, program_id), | 419 | new GameListItemPath(FormatGameName(physical_name), smdh, program_id), |
| 396 | new GameListItem( | 420 | new GameListItem( |
| 397 | QString::fromStdString(Loader::GetFileTypeString(loader->GetFileType()))), | 421 | QString::fromStdString(Loader::GetFileTypeString(loader->GetFileType()))), |
| 398 | new GameListItemSize(FileUtil::GetSize(physical_name)), | 422 | new GameListItemSize(FileUtil::GetSize(physical_name)), |
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index aa9028399..97be548d7 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp | |||
| @@ -13,6 +13,7 @@ | |||
| 13 | #include <QMessageBox> | 13 | #include <QMessageBox> |
| 14 | #include <QtGui> | 14 | #include <QtGui> |
| 15 | #include <QtWidgets> | 15 | #include <QtWidgets> |
| 16 | #include "common/common_paths.h" | ||
| 16 | #include "common/logging/backend.h" | 17 | #include "common/logging/backend.h" |
| 17 | #include "common/logging/filter.h" | 18 | #include "common/logging/filter.h" |
| 18 | #include "common/logging/log.h" | 19 | #include "common/logging/log.h" |
| @@ -278,6 +279,7 @@ void GMainWindow::ConnectWidgetEvents() { | |||
| 278 | void GMainWindow::ConnectMenuEvents() { | 279 | void GMainWindow::ConnectMenuEvents() { |
| 279 | // File | 280 | // File |
| 280 | connect(ui.action_Load_File, &QAction::triggered, this, &GMainWindow::OnMenuLoadFile); | 281 | connect(ui.action_Load_File, &QAction::triggered, this, &GMainWindow::OnMenuLoadFile); |
| 282 | connect(ui.action_Load_Folder, &QAction::triggered, this, &GMainWindow::OnMenuLoadFolder); | ||
| 281 | connect(ui.action_Select_Game_List_Root, &QAction::triggered, this, | 283 | connect(ui.action_Select_Game_List_Root, &QAction::triggered, this, |
| 282 | &GMainWindow::OnMenuSelectGameListRoot); | 284 | &GMainWindow::OnMenuSelectGameListRoot); |
| 283 | connect(ui.action_Exit, &QAction::triggered, this, &QMainWindow::close); | 285 | connect(ui.action_Exit, &QAction::triggered, this, &QMainWindow::close); |
| @@ -550,6 +552,8 @@ void GMainWindow::OnMenuLoadFile() { | |||
| 550 | for (const auto& piece : game_list->supported_file_extensions) | 552 | for (const auto& piece : game_list->supported_file_extensions) |
| 551 | extensions += "*." + piece + " "; | 553 | extensions += "*." + piece + " "; |
| 552 | 554 | ||
| 555 | extensions += "main "; | ||
| 556 | |||
| 553 | QString file_filter = tr("Switch Executable") + " (" + extensions + ")"; | 557 | QString file_filter = tr("Switch Executable") + " (" + extensions + ")"; |
| 554 | file_filter += ";;" + tr("All Files (*.*)"); | 558 | file_filter += ";;" + tr("All Files (*.*)"); |
| 555 | 559 | ||
| @@ -562,6 +566,18 @@ void GMainWindow::OnMenuLoadFile() { | |||
| 562 | } | 566 | } |
| 563 | } | 567 | } |
| 564 | 568 | ||
| 569 | void GMainWindow::OnMenuLoadFolder() { | ||
| 570 | QDir dir = QFileDialog::getExistingDirectory(this, tr("Open Extracted ROM Directory")); | ||
| 571 | |||
| 572 | QStringList matching_main = dir.entryList(QStringList("main"), QDir::Files); | ||
| 573 | if (matching_main.size() == 1) { | ||
| 574 | BootGame(dir.path() + DIR_SEP + matching_main[0]); | ||
| 575 | } else { | ||
| 576 | QMessageBox::warning(this, tr("Invalid Directory Selected"), | ||
| 577 | tr("The directory you have selected does not contain a 'main' file.")); | ||
| 578 | } | ||
| 579 | } | ||
| 580 | |||
| 565 | void GMainWindow::OnMenuSelectGameListRoot() { | 581 | void GMainWindow::OnMenuSelectGameListRoot() { |
| 566 | QString dir_path = QFileDialog::getExistingDirectory(this, tr("Select Directory")); | 582 | QString dir_path = QFileDialog::getExistingDirectory(this, tr("Select Directory")); |
| 567 | if (!dir_path.isEmpty()) { | 583 | if (!dir_path.isEmpty()) { |
diff --git a/src/yuzu/main.h b/src/yuzu/main.h index 3e29d5fc4..074bba3f9 100644 --- a/src/yuzu/main.h +++ b/src/yuzu/main.h | |||
| @@ -123,6 +123,7 @@ private slots: | |||
| 123 | void OnGameListLoadFile(QString game_path); | 123 | void OnGameListLoadFile(QString game_path); |
| 124 | void OnGameListOpenSaveFolder(u64 program_id); | 124 | void OnGameListOpenSaveFolder(u64 program_id); |
| 125 | void OnMenuLoadFile(); | 125 | void OnMenuLoadFile(); |
| 126 | void OnMenuLoadFolder(); | ||
| 126 | /// Called whenever a user selects the "File->Select Game List Root" menu item | 127 | /// Called whenever a user selects the "File->Select Game List Root" menu item |
| 127 | void OnMenuSelectGameListRoot(); | 128 | void OnMenuSelectGameListRoot(); |
| 128 | void OnMenuRecentFile(); | 129 | void OnMenuRecentFile(); |
diff --git a/src/yuzu/main.ui b/src/yuzu/main.ui index 0fcd93cc2..22c4cad08 100644 --- a/src/yuzu/main.ui +++ b/src/yuzu/main.ui | |||
| @@ -58,6 +58,7 @@ | |||
| 58 | </property> | 58 | </property> |
| 59 | </widget> | 59 | </widget> |
| 60 | <addaction name="action_Load_File"/> | 60 | <addaction name="action_Load_File"/> |
| 61 | <addaction name="action_Load_Folder"/> | ||
| 61 | <addaction name="separator"/> | 62 | <addaction name="separator"/> |
| 62 | <addaction name="action_Select_Game_List_Root"/> | 63 | <addaction name="action_Select_Game_List_Root"/> |
| 63 | <addaction name="menu_recent_files"/> | 64 | <addaction name="menu_recent_files"/> |
| @@ -106,6 +107,11 @@ | |||
| 106 | <string>Load File...</string> | 107 | <string>Load File...</string> |
| 107 | </property> | 108 | </property> |
| 108 | </action> | 109 | </action> |
| 110 | <action name="action_Load_Folder"> | ||
| 111 | <property name="text"> | ||
| 112 | <string>Load Folder...</string> | ||
| 113 | </property> | ||
| 114 | </action> | ||
| 109 | <action name="action_Load_Symbol_Map"> | 115 | <action name="action_Load_Symbol_Map"> |
| 110 | <property name="text"> | 116 | <property name="text"> |
| 111 | <string>Load Symbol Map...</string> | 117 | <string>Load Symbol Map...</string> |