diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/yuzu/game_list_worker.cpp | 105 |
1 files changed, 46 insertions, 59 deletions
diff --git a/src/yuzu/game_list_worker.cpp b/src/yuzu/game_list_worker.cpp index 1edc60df7..9fd074223 100644 --- a/src/yuzu/game_list_worker.cpp +++ b/src/yuzu/game_list_worker.cpp | |||
| @@ -86,6 +86,35 @@ QString FormatPatchNameVersions(const FileSys::PatchManager& patch_manager, | |||
| 86 | out.chop(1); | 86 | out.chop(1); |
| 87 | return out; | 87 | return out; |
| 88 | } | 88 | } |
| 89 | |||
| 90 | QList<QStandardItem*> MakeGameListEntry(const std::string& path, const std::string& name, | ||
| 91 | const std::vector<u8>& icon, Loader::AppLoader& loader, | ||
| 92 | u64 program_id, const CompatibilityList& compatibility_list, | ||
| 93 | const FileSys::PatchManager& patch) { | ||
| 94 | const auto it = FindMatchingCompatibilityEntry(compatibility_list, program_id); | ||
| 95 | |||
| 96 | // The game list uses this as compatibility number for untested games | ||
| 97 | QString compatibility{"99"}; | ||
| 98 | if (it != compatibility_list.end()) { | ||
| 99 | compatibility = it->second.first; | ||
| 100 | } | ||
| 101 | |||
| 102 | QList<QStandardItem*> list{ | ||
| 103 | new GameListItemPath( | ||
| 104 | FormatGameName(path), icon, QString::fromStdString(name), | ||
| 105 | QString::fromStdString(Loader::GetFileTypeString(loader.GetFileType())), program_id), | ||
| 106 | new GameListItemCompat(compatibility), | ||
| 107 | new GameListItem(QString::fromStdString(Loader::GetFileTypeString(loader.GetFileType()))), | ||
| 108 | new GameListItemSize(FileUtil::GetSize(path)), | ||
| 109 | }; | ||
| 110 | |||
| 111 | if (UISettings::values.show_add_ons) { | ||
| 112 | list.insert( | ||
| 113 | 2, new GameListItem(FormatPatchNameVersions(patch, loader, loader.IsRomFSUpdatable()))); | ||
| 114 | } | ||
| 115 | |||
| 116 | return list; | ||
| 117 | } | ||
| 89 | } // Anonymous namespace | 118 | } // Anonymous namespace |
| 90 | 119 | ||
| 91 | GameListWorker::GameListWorker(FileSys::VirtualFilesystem vfs, QString dir_path, bool deep_scan, | 120 | GameListWorker::GameListWorker(FileSys::VirtualFilesystem vfs, QString dir_path, bool deep_scan, |
| @@ -116,29 +145,8 @@ void GameListWorker::AddInstalledTitlesToGameList() { | |||
| 116 | if (control != nullptr) | 145 | if (control != nullptr) |
| 117 | GetMetadataFromControlNCA(patch, *control, icon, name); | 146 | GetMetadataFromControlNCA(patch, *control, icon, name); |
| 118 | 147 | ||
| 119 | auto it = FindMatchingCompatibilityEntry(compatibility_list, program_id); | 148 | emit EntryReady(MakeGameListEntry(file->GetFullPath(), name, icon, *loader, program_id, |
| 120 | 149 | compatibility_list, patch)); | |
| 121 | // The game list uses this as compatibility number for untested games | ||
| 122 | QString compatibility("99"); | ||
| 123 | if (it != compatibility_list.end()) | ||
| 124 | compatibility = it->second.first; | ||
| 125 | |||
| 126 | QList<QStandardItem*> list{ | ||
| 127 | new GameListItemPath( | ||
| 128 | FormatGameName(file->GetFullPath()), icon, QString::fromStdString(name), | ||
| 129 | QString::fromStdString(Loader::GetFileTypeString(loader->GetFileType())), | ||
| 130 | program_id), | ||
| 131 | new GameListItemCompat(compatibility), | ||
| 132 | new GameListItem( | ||
| 133 | QString::fromStdString(Loader::GetFileTypeString(loader->GetFileType()))), | ||
| 134 | new GameListItemSize(file->GetSize()), | ||
| 135 | }; | ||
| 136 | |||
| 137 | if (UISettings::values.show_add_ons) { | ||
| 138 | list.insert(2, new GameListItem(FormatPatchNameVersions(patch, *loader))); | ||
| 139 | } | ||
| 140 | |||
| 141 | emit EntryReady(list); | ||
| 142 | } | 150 | } |
| 143 | 151 | ||
| 144 | const auto control_data = cache.ListEntriesFilter(FileSys::TitleType::Application, | 152 | const auto control_data = cache.ListEntriesFilter(FileSys::TitleType::Application, |
| @@ -155,14 +163,14 @@ void GameListWorker::AddInstalledTitlesToGameList() { | |||
| 155 | void GameListWorker::FillControlMap(const std::string& dir_path) { | 163 | void GameListWorker::FillControlMap(const std::string& dir_path) { |
| 156 | const auto nca_control_callback = [this](u64* num_entries_out, const std::string& directory, | 164 | const auto nca_control_callback = [this](u64* num_entries_out, const std::string& directory, |
| 157 | const std::string& virtual_name) -> bool { | 165 | const std::string& virtual_name) -> bool { |
| 158 | std::string physical_name = directory + DIR_SEP + virtual_name; | 166 | if (stop_processing) { |
| 159 | 167 | // Breaks the callback loop | |
| 160 | if (stop_processing) | 168 | return false; |
| 161 | return false; // Breaks the callback loop. | 169 | } |
| 162 | 170 | ||
| 163 | bool is_dir = FileUtil::IsDirectory(physical_name); | 171 | const std::string physical_name = directory + DIR_SEP + virtual_name; |
| 164 | QFileInfo file_info(physical_name.c_str()); | 172 | const QFileInfo file_info(QString::fromStdString(physical_name)); |
| 165 | if (!is_dir && file_info.suffix().toStdString() == "nca") { | 173 | if (!file_info.isDir() && file_info.suffix() == QStringLiteral("nca")) { |
| 166 | auto nca = | 174 | auto nca = |
| 167 | std::make_unique<FileSys::NCA>(vfs->OpenFile(physical_name, FileSys::Mode::Read)); | 175 | std::make_unique<FileSys::NCA>(vfs->OpenFile(physical_name, FileSys::Mode::Read)); |
| 168 | if (nca->GetType() == FileSys::NCAContentType::Control) { | 176 | if (nca->GetType() == FileSys::NCAContentType::Control) { |
| @@ -179,12 +187,13 @@ void GameListWorker::FillControlMap(const std::string& dir_path) { | |||
| 179 | void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, unsigned int recursion) { | 187 | void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, unsigned int recursion) { |
| 180 | const auto callback = [this, recursion](u64* num_entries_out, const std::string& directory, | 188 | const auto callback = [this, recursion](u64* num_entries_out, const std::string& directory, |
| 181 | const std::string& virtual_name) -> bool { | 189 | const std::string& virtual_name) -> bool { |
| 182 | std::string physical_name = directory + DIR_SEP + virtual_name; | 190 | if (stop_processing) { |
| 183 | 191 | // Breaks the callback loop. | |
| 184 | if (stop_processing) | 192 | return false; |
| 185 | return false; // Breaks the callback loop. | 193 | } |
| 186 | 194 | ||
| 187 | bool is_dir = FileUtil::IsDirectory(physical_name); | 195 | const std::string physical_name = directory + DIR_SEP + virtual_name; |
| 196 | const bool is_dir = FileUtil::IsDirectory(physical_name); | ||
| 188 | if (!is_dir && | 197 | if (!is_dir && |
| 189 | (HasSupportedFileExtension(physical_name) || IsExtractedNCAMain(physical_name))) { | 198 | (HasSupportedFileExtension(physical_name) || IsExtractedNCAMain(physical_name))) { |
| 190 | std::unique_ptr<Loader::AppLoader> loader = | 199 | std::unique_ptr<Loader::AppLoader> loader = |
| @@ -214,30 +223,8 @@ void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, unsign | |||
| 214 | } | 223 | } |
| 215 | } | 224 | } |
| 216 | 225 | ||
| 217 | auto it = FindMatchingCompatibilityEntry(compatibility_list, program_id); | 226 | emit EntryReady(MakeGameListEntry(physical_name, name, icon, *loader, program_id, |
| 218 | 227 | compatibility_list, patch)); | |
| 219 | // The game list uses this as compatibility number for untested games | ||
| 220 | QString compatibility("99"); | ||
| 221 | if (it != compatibility_list.end()) | ||
| 222 | compatibility = it->second.first; | ||
| 223 | |||
| 224 | QList<QStandardItem*> list{ | ||
| 225 | new GameListItemPath( | ||
| 226 | FormatGameName(physical_name), icon, QString::fromStdString(name), | ||
| 227 | QString::fromStdString(Loader::GetFileTypeString(loader->GetFileType())), | ||
| 228 | program_id), | ||
| 229 | new GameListItemCompat(compatibility), | ||
| 230 | new GameListItem( | ||
| 231 | QString::fromStdString(Loader::GetFileTypeString(loader->GetFileType()))), | ||
| 232 | new GameListItemSize(FileUtil::GetSize(physical_name)), | ||
| 233 | }; | ||
| 234 | |||
| 235 | if (UISettings::values.show_add_ons) { | ||
| 236 | list.insert(2, new GameListItem(FormatPatchNameVersions( | ||
| 237 | patch, *loader, loader->IsRomFSUpdatable()))); | ||
| 238 | } | ||
| 239 | |||
| 240 | emit EntryReady(std::move(list)); | ||
| 241 | } else if (is_dir && recursion > 0) { | 228 | } else if (is_dir && recursion > 0) { |
| 242 | watch_list.append(QString::fromStdString(physical_name)); | 229 | watch_list.append(QString::fromStdString(physical_name)); |
| 243 | AddFstEntriesToGameList(physical_name, recursion - 1); | 230 | AddFstEntriesToGameList(physical_name, recursion - 1); |