mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-25 00:02:47 +01:00
fix
This commit is contained in:
parent
6803515773
commit
c922d6559f
1 changed files with 55 additions and 41 deletions
|
@ -16,30 +16,39 @@
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
NintendoSwitchLibrary::NintendoSwitchLibrary(Core::System& system) : system(system) {}
|
/**
|
||||||
|
* NintendoSwitchLibrary class manages the operations related to installed games
|
||||||
|
* on the emulated Nintendo Switch, including listing games and launching them.
|
||||||
|
*/
|
||||||
|
class NintendoSwitchLibrary {
|
||||||
|
public:
|
||||||
|
explicit NintendoSwitchLibrary(Core::System& system) : system(system) {}
|
||||||
|
|
||||||
std::vector<NintendoSwitchLibrary::GameInfo> NintendoSwitchLibrary::GetInstalledGames() {
|
struct GameInfo {
|
||||||
|
u64 program_id;
|
||||||
|
std::string title_name;
|
||||||
|
std::string file_path;
|
||||||
|
};
|
||||||
|
|
||||||
|
[[nodiscard]] std::vector<GameInfo> GetInstalledGames() {
|
||||||
std::vector<GameInfo> games;
|
std::vector<GameInfo> games;
|
||||||
const auto& cache = system.GetContentProvider().GetUserNANDCache();
|
const auto& cache = system.GetContentProvider().GetUserNANDCache();
|
||||||
|
|
||||||
for (const auto& nca : cache.GetAllEntries()) {
|
for (const auto& [program_id, content_type] : cache.GetAllEntries()) {
|
||||||
if (nca.second == FileSys::ContentRecordType::Program) {
|
if (content_type == FileSys::ContentRecordType::Program) {
|
||||||
const auto program_id = nca.first;
|
|
||||||
const auto title_name = GetGameName(program_id);
|
const auto title_name = GetGameName(program_id);
|
||||||
const auto file_path = cache.GetEntryUnparsed(program_id, FileSys::ContentRecordType::Program);
|
const auto file_path = cache.GetEntryUnparsed(program_id, FileSys::ContentRecordType::Program);
|
||||||
|
|
||||||
if (title_name.empty() || file_path.empty()) {
|
if (!title_name.empty() && !file_path.empty()) {
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
games.push_back({program_id, title_name, file_path});
|
games.push_back({program_id, title_name, file_path});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return games;
|
return games;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string NintendoSwitchLibrary::GetGameName(u64 program_id) {
|
[[nodiscard]] std::string GetGameName(u64 program_id) {
|
||||||
const auto& patch_manager = system.GetFileSystemController().GetPatchManager(program_id);
|
const auto& patch_manager = system.GetFileSystemController().GetPatchManager(program_id);
|
||||||
const auto metadata = patch_manager.GetControlMetadata();
|
const auto metadata = patch_manager.GetControlMetadata();
|
||||||
|
|
||||||
|
@ -50,7 +59,7 @@ std::string NintendoSwitchLibrary::GetGameName(u64 program_id) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NintendoSwitchLibrary::LaunchGame(u64 program_id) {
|
[[nodiscard]] bool LaunchGame(u64 program_id) {
|
||||||
const auto file_path = system.GetContentProvider().GetUserNANDCache().GetEntryUnparsed(program_id, FileSys::ContentRecordType::Program);
|
const auto file_path = system.GetContentProvider().GetUserNANDCache().GetEntryUnparsed(program_id, FileSys::ContentRecordType::Program);
|
||||||
|
|
||||||
if (file_path.empty()) {
|
if (file_path.empty()) {
|
||||||
|
@ -70,7 +79,12 @@ bool NintendoSwitchLibrary::LaunchGame(u64 program_id) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LOG_INFO(Core, "Successfully launched game. program_id={:016X}", program_id);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
const Core::System& system;
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace Core
|
} // namespace Core
|
Loading…
Reference in a new issue