summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Zach Hilman2018-08-10 11:11:33 -0400
committerGravatar Zach Hilman2018-08-11 22:50:48 -0400
commit10812f8407e18d129664e837614d6124ef9bf1bc (patch)
treec8d76b4db7a10c1d0f4c19cb180587b56bdbb0ef /src
parentregistered_cache: Fix missing reading from yuzu_meta (diff)
downloadyuzu-10812f8407e18d129664e837614d6124ef9bf1bc.tar.gz
yuzu-10812f8407e18d129664e837614d6124ef9bf1bc.tar.xz
yuzu-10812f8407e18d129664e837614d6124ef9bf1bc.zip
game_list: Populate control data from installed NAND
Diffstat (limited to 'src')
-rw-r--r--src/yuzu/game_list.cpp64
-rw-r--r--src/yuzu/main.cpp2
2 files changed, 35 insertions, 31 deletions
diff --git a/src/yuzu/game_list.cpp b/src/yuzu/game_list.cpp
index 64c72035e..73a0aa281 100644
--- a/src/yuzu/game_list.cpp
+++ b/src/yuzu/game_list.cpp
@@ -403,6 +403,28 @@ void GameList::RefreshGameDirectory() {
403 } 403 }
404} 404}
405 405
406static void GetMetadataFromControlNCA(const std::shared_ptr<FileSys::NCA>& nca,
407 std::vector<u8>& icon, std::string& name) {
408 const auto control_dir = FileSys::ExtractRomFS(nca->GetRomFS());
409 if (control_dir == nullptr)
410 return;
411
412 const auto nacp_file = control_dir->GetFile("control.nacp");
413 if (nacp_file == nullptr)
414 return;
415 FileSys::NACP nacp(nacp_file);
416 name = nacp.GetApplicationName();
417
418 FileSys::VirtualFile icon_file = nullptr;
419 for (const auto& language : FileSys::LANGUAGE_NAMES) {
420 icon_file = control_dir->GetFile("icon_" + std::string(language) + ".dat");
421 if (icon_file != nullptr) {
422 icon = icon_file->ReadAllBytes();
423 break;
424 }
425 }
426}
427
406void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, unsigned int recursion) { 428void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, unsigned int recursion) {
407 const auto usernand = Service::FileSystem::GetUserNANDContents(); 429 const auto usernand = Service::FileSystem::GetUserNANDContents();
408 const auto installed_games = usernand->ListEntriesFilter(FileSys::TitleType::Application, 430 const auto installed_games = usernand->ListEntriesFilter(FileSys::TitleType::Application,
@@ -421,22 +443,8 @@ void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, unsign
421 443
422 const auto& control = 444 const auto& control =
423 usernand->GetEntry(game.title_id, FileSys::ContentRecordType::Control); 445 usernand->GetEntry(game.title_id, FileSys::ContentRecordType::Control);
424 if (control != nullptr) { 446 if (control != nullptr)
425 const auto control_dir = FileSys::ExtractRomFS(control->GetRomFS()); 447 GetMetadataFromControlNCA(control, icon, name);
426
427 const auto nacp_file = control_dir->GetFile("control.nacp");
428 FileSys::NACP nacp(nacp_file);
429 name = nacp.GetApplicationName();
430
431 FileSys::VirtualFile icon_file = nullptr;
432 for (const auto& language : FileSys::LANGUAGE_NAMES) {
433 icon_file = control_dir->GetFile("icon_" + std::string(language) + ".dat");
434 if (icon_file != nullptr) {
435 icon = icon_file->ReadAllBytes();
436 break;
437 }
438 }
439 }
440 emit EntryReady({ 448 emit EntryReady({
441 new GameListItemPath( 449 new GameListItemPath(
442 FormatGameName(file->GetFullPath()), icon, QString::fromStdString(name), 450 FormatGameName(file->GetFullPath()), icon, QString::fromStdString(name),
@@ -450,6 +458,15 @@ void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, unsign
450 458
451 boost::container::flat_map<u64, std::shared_ptr<FileSys::NCA>> nca_control_map; 459 boost::container::flat_map<u64, std::shared_ptr<FileSys::NCA>> nca_control_map;
452 460
461 const auto control_data = usernand->ListEntriesFilter(FileSys::TitleType::Application,
462 FileSys::ContentRecordType::Control);
463
464 for (const auto& entry : control_data) {
465 const auto nca = usernand->GetEntry(entry);
466 if (nca != nullptr)
467 nca_control_map.insert_or_assign(entry.title_id, nca);
468 }
469
453 const auto nca_control_callback = 470 const auto nca_control_callback =
454 [this, &nca_control_map](u64* num_entries_out, const std::string& directory, 471 [this, &nca_control_map](u64* num_entries_out, const std::string& directory,
455 const std::string& virtual_name) -> bool { 472 const std::string& virtual_name) -> bool {
@@ -503,20 +520,7 @@ void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, unsign
503 // Use from metadata pool. 520 // Use from metadata pool.
504 if (nca_control_map.find(program_id) != nca_control_map.end()) { 521 if (nca_control_map.find(program_id) != nca_control_map.end()) {
505 const auto nca = nca_control_map[program_id]; 522 const auto nca = nca_control_map[program_id];
506 const auto control_dir = FileSys::ExtractRomFS(nca->GetRomFS()); 523 GetMetadataFromControlNCA(nca, icon, name);
507
508 const auto nacp_file = control_dir->GetFile("control.nacp");
509 FileSys::NACP nacp(nacp_file);
510 name = nacp.GetApplicationName();
511
512 FileSys::VirtualFile icon_file = nullptr;
513 for (const auto& language : FileSys::LANGUAGE_NAMES) {
514 icon_file = control_dir->GetFile("icon_" + std::string(language) + ".dat");
515 if (icon_file != nullptr) {
516 icon = icon_file->ReadAllBytes();
517 break;
518 }
519 }
520 } 524 }
521 } 525 }
522 526
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index fd237df43..1f5a9bb02 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -682,7 +682,7 @@ void GMainWindow::OnMenuInstallToNAND() {
682 } 682 }
683 683
684 if (index >= 5) 684 if (index >= 5)
685 index += 0x80; 685 index += 0x7B;
686 686
687 if (Service::FileSystem::GetUserNANDContents()->InstallEntry( 687 if (Service::FileSystem::GetUserNANDContents()->InstallEntry(
688 nca, static_cast<FileSys::TitleType>(index))) { 688 nca, static_cast<FileSys::TitleType>(index))) {