diff options
| author | 2018-08-28 22:38:19 -0400 | |
|---|---|---|
| committer | 2018-09-04 16:24:02 -0400 | |
| commit | 2814ca362494c3d3af90abab8a66db5eb2db56f6 (patch) | |
| tree | 708b7d30356d988e85be9033a1c0dc7758102a20 /src | |
| parent | bktr: Implement IVFC offset shifting (diff) | |
| download | yuzu-2814ca362494c3d3af90abab8a66db5eb2db56f6.tar.gz yuzu-2814ca362494c3d3af90abab8a66db5eb2db56f6.tar.xz yuzu-2814ca362494c3d3af90abab8a66db5eb2db56f6.zip | |
game_list: Use friendly game versions
Mainly, from control.nacp metadata instead of cnmt metadata
Diffstat (limited to 'src')
| -rw-r--r-- | src/yuzu/game_list.cpp | 45 |
1 files changed, 32 insertions, 13 deletions
diff --git a/src/yuzu/game_list.cpp b/src/yuzu/game_list.cpp index 1aec08cdb..02d8a3882 100644 --- a/src/yuzu/game_list.cpp +++ b/src/yuzu/game_list.cpp | |||
| @@ -456,8 +456,9 @@ static QString FormatGameName(const std::string& physical_name) { | |||
| 456 | return physical_name_as_qstring; | 456 | return physical_name_as_qstring; |
| 457 | } | 457 | } |
| 458 | 458 | ||
| 459 | static QString FormatPatchNameVersions(u64 title_id, bool updatable = true) { | 459 | static QString FormatPatchNameVersions(const FileSys::PatchManager& patch_manager, |
| 460 | const FileSys::PatchManager patch_manager(title_id); | 460 | std::string update_version_override = "", |
| 461 | bool updatable = true) { | ||
| 461 | QString out; | 462 | QString out; |
| 462 | for (const auto& kv : patch_manager.GetPatchVersionNames()) { | 463 | for (const auto& kv : patch_manager.GetPatchVersionNames()) { |
| 463 | if (!updatable && kv.first == FileSys::PatchType::Update) | 464 | if (!updatable && kv.first == FileSys::PatchType::Update) |
| @@ -466,9 +467,13 @@ static QString FormatPatchNameVersions(u64 title_id, bool updatable = true) { | |||
| 466 | if (kv.second == 0) { | 467 | if (kv.second == 0) { |
| 467 | out.append(fmt::format("{}\n", FileSys::FormatPatchTypeName(kv.first)).c_str()); | 468 | out.append(fmt::format("{}\n", FileSys::FormatPatchTypeName(kv.first)).c_str()); |
| 468 | } else { | 469 | } else { |
| 469 | out.append(fmt::format("{} ({})\n", FileSys::FormatPatchTypeName(kv.first), | 470 | auto version_data = FileSys::FormatTitleVersion(kv.second); |
| 470 | FileSys::FormatTitleVersion(kv.second)) | 471 | if (kv.first == FileSys::PatchType::Update && !update_version_override.empty()) |
| 471 | .c_str()); | 472 | version_data = update_version_override; |
| 473 | |||
| 474 | out.append( | ||
| 475 | fmt::format("{} ({})\n", FileSys::FormatPatchTypeName(kv.first), version_data) | ||
| 476 | .c_str()); | ||
| 472 | } | 477 | } |
| 473 | } | 478 | } |
| 474 | 479 | ||
| @@ -484,9 +489,16 @@ void GameList::RefreshGameDirectory() { | |||
| 484 | } | 489 | } |
| 485 | } | 490 | } |
| 486 | 491 | ||
| 487 | static void GetMetadataFromControlNCA(const std::shared_ptr<FileSys::NCA>& nca, | 492 | static void GetMetadataFromControlNCA(const FileSys::PatchManager& patch_manager, |
| 488 | std::vector<u8>& icon, std::string& name) { | 493 | const std::shared_ptr<FileSys::NCA>& nca, |
| 489 | const auto control_dir = FileSys::ExtractRomFS(nca->GetRomFS()); | 494 | std::vector<u8>& icon, std::string& name, |
| 495 | std::string& version) { | ||
| 496 | const auto romfs = patch_manager.PatchRomFS(nca->GetRomFS(), nca->GetBaseIVFCOffset(), | ||
| 497 | FileSys::ContentRecordType::Control); | ||
| 498 | if (romfs == nullptr) | ||
| 499 | return; | ||
| 500 | |||
| 501 | const auto control_dir = FileSys::ExtractRomFS(romfs); | ||
| 490 | if (control_dir == nullptr) | 502 | if (control_dir == nullptr) |
| 491 | return; | 503 | return; |
| 492 | 504 | ||
| @@ -495,6 +507,7 @@ static void GetMetadataFromControlNCA(const std::shared_ptr<FileSys::NCA>& nca, | |||
| 495 | return; | 507 | return; |
| 496 | FileSys::NACP nacp(nacp_file); | 508 | FileSys::NACP nacp(nacp_file); |
| 497 | name = nacp.GetApplicationName(); | 509 | name = nacp.GetApplicationName(); |
| 510 | version = nacp.GetVersionString(); | ||
| 498 | 511 | ||
| 499 | FileSys::VirtualFile icon_file = nullptr; | 512 | FileSys::VirtualFile icon_file = nullptr; |
| 500 | for (const auto& language : FileSys::LANGUAGE_NAMES) { | 513 | for (const auto& language : FileSys::LANGUAGE_NAMES) { |
| @@ -526,18 +539,20 @@ void GameListWorker::AddInstalledTitlesToGameList(std::shared_ptr<FileSys::Regis | |||
| 526 | 539 | ||
| 527 | std::vector<u8> icon; | 540 | std::vector<u8> icon; |
| 528 | std::string name; | 541 | std::string name; |
| 542 | std::string version = ""; | ||
| 529 | u64 program_id = 0; | 543 | u64 program_id = 0; |
| 530 | loader->ReadProgramId(program_id); | 544 | loader->ReadProgramId(program_id); |
| 531 | 545 | ||
| 546 | const FileSys::PatchManager patch{program_id}; | ||
| 532 | const auto& control = cache->GetEntry(game.title_id, FileSys::ContentRecordType::Control); | 547 | const auto& control = cache->GetEntry(game.title_id, FileSys::ContentRecordType::Control); |
| 533 | if (control != nullptr) | 548 | if (control != nullptr) |
| 534 | GetMetadataFromControlNCA(control, icon, name); | 549 | GetMetadataFromControlNCA(patch, control, icon, name, version); |
| 535 | emit EntryReady({ | 550 | emit EntryReady({ |
| 536 | new GameListItemPath( | 551 | new GameListItemPath( |
| 537 | FormatGameName(file->GetFullPath()), icon, QString::fromStdString(name), | 552 | FormatGameName(file->GetFullPath()), icon, QString::fromStdString(name), |
| 538 | QString::fromStdString(Loader::GetFileTypeString(loader->GetFileType())), | 553 | QString::fromStdString(Loader::GetFileTypeString(loader->GetFileType())), |
| 539 | program_id), | 554 | program_id), |
| 540 | new GameListItem(FormatPatchNameVersions(program_id)), | 555 | new GameListItem(FormatPatchNameVersions(patch, version)), |
| 541 | new GameListItem( | 556 | new GameListItem( |
| 542 | QString::fromStdString(Loader::GetFileTypeString(loader->GetFileType()))), | 557 | QString::fromStdString(Loader::GetFileTypeString(loader->GetFileType()))), |
| 543 | new GameListItemSize(file->GetSize()), | 558 | new GameListItemSize(file->GetSize()), |
| @@ -603,12 +618,16 @@ void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, unsign | |||
| 603 | std::string name = " "; | 618 | std::string name = " "; |
| 604 | const auto res3 = loader->ReadTitle(name); | 619 | const auto res3 = loader->ReadTitle(name); |
| 605 | 620 | ||
| 621 | const FileSys::PatchManager patch{program_id}; | ||
| 622 | |||
| 623 | std::string version = ""; | ||
| 624 | |||
| 606 | if (res1 != Loader::ResultStatus::Success && res3 != Loader::ResultStatus::Success && | 625 | if (res1 != Loader::ResultStatus::Success && res3 != Loader::ResultStatus::Success && |
| 607 | res2 == Loader::ResultStatus::Success) { | 626 | res2 == Loader::ResultStatus::Success) { |
| 608 | // Use from metadata pool. | 627 | // Use from metadata pool. |
| 609 | if (nca_control_map.find(program_id) != nca_control_map.end()) { | 628 | if (nca_control_map.find(program_id) != nca_control_map.end()) { |
| 610 | const auto nca = nca_control_map[program_id]; | 629 | const auto nca = nca_control_map[program_id]; |
| 611 | GetMetadataFromControlNCA(nca, icon, name); | 630 | GetMetadataFromControlNCA(patch, nca, icon, name, version); |
| 612 | } | 631 | } |
| 613 | } | 632 | } |
| 614 | 633 | ||
| @@ -619,8 +638,6 @@ void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, unsign | |||
| 619 | if (it != compatibility_list.end()) | 638 | if (it != compatibility_list.end()) |
| 620 | compatibility = it->second.first; | 639 | compatibility = it->second.first; |
| 621 | 640 | ||
| 622 | FileSys::PatchManager patch{program_id}; | ||
| 623 | |||
| 624 | emit EntryReady({ | 641 | emit EntryReady({ |
| 625 | new GameListItemPath( | 642 | new GameListItemPath( |
| 626 | FormatGameName(physical_name), icon, QString::fromStdString(name), | 643 | FormatGameName(physical_name), icon, QString::fromStdString(name), |
| @@ -629,6 +646,8 @@ void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, unsign | |||
| 629 | new GameListItemCompat(compatibility), | 646 | new GameListItemCompat(compatibility), |
| 630 | new GameListItem(FormatPatchNameVersions(program_id, loader->IsRomFSUpdatable())), | 647 | new GameListItem(FormatPatchNameVersions(program_id, loader->IsRomFSUpdatable())), |
| 631 | new GameListItem( | 648 | new GameListItem( |
| 649 | FormatPatchNameVersions(patch, version, loader->IsRomFSUpdatable())), | ||
| 650 | new GameListItem( | ||
| 632 | QString::fromStdString(Loader::GetFileTypeString(loader->GetFileType()))), | 651 | QString::fromStdString(Loader::GetFileTypeString(loader->GetFileType()))), |
| 633 | new GameListItemSize(FileUtil::GetSize(physical_name)), | 652 | new GameListItemSize(FileUtil::GetSize(physical_name)), |
| 634 | }); | 653 | }); |