Update app loader to have a function for getting the long variant of the game title.

This commit is contained in:
Riley Hawksworth 2024-03-30 23:25:44 +00:00 committed by OpenSauce
parent 92f999d76b
commit 5873e292e7
3 changed files with 29 additions and 1 deletions

View File

@ -245,7 +245,7 @@ public:
}
/**
* Get the title of the application
* Get the short title of the application
* @param title Reference to store the application title into
* @return ResultStatus result of function
*/
@ -253,6 +253,15 @@ public:
return ResultStatus::ErrorNotImplemented;
}
/**
* Get the long title of the application
* @param title Referencec to store the application title into
* @param ResultStatus result of function
*/
virtual ResultStatus ReadTitleLong([[maybe_unused]]std::string& title) {
return ResultStatus::ErrorNotImplemented;
}
protected:
Core::System& system;
FileUtil::IOFile file;

View File

@ -381,4 +381,22 @@ ResultStatus AppLoader_NCCH::ReadTitle(std::string& title) {
return ResultStatus::Success;
}
ResultStatus AppLoader_NCCH::ReadTitleLong(std::string& title) {
std::vector<u8> data;
Loader::SMDH smdh;
ReadIcon(data);
if (!Loader::IsValidSMDH(data)) {
return ResultStatus::ErrorInvalidFormat;
}
std::memcpy(&smdh, data.data(), sizeof(Loader::SMDH));
const auto& long_title = smdh.GetLongTitle(SMDH::TitleLanguage::English);
auto title_end = std::find(long_title.begin(), long_title.end(), u'\0');
title = Common::UTF16ToUTF8(std::u16string{long_title.begin(), title_end});
return ResultStatus::Success;
}
} // namespace Loader

View File

@ -70,6 +70,7 @@ public:
ResultStatus DumpUpdateRomFS(const std::string& target_path) override;
ResultStatus ReadTitle(std::string& title) override;
ResultStatus ReadTitleLong(std::string& title) override;
private:
/**