mirror of
https://github.com/citra-emu/citra-canary.git
synced 2024-12-23 15:55:28 +00:00
Merge pull request #4917 from vitor-k/long-title
Allow displaying the long_title of the game
This commit is contained in:
commit
176b8b4a0b
|
@ -308,17 +308,19 @@ void Config::ReadValues() {
|
|||
}
|
||||
UISettings::values.game_list_icon_size = icon_size;
|
||||
|
||||
int row_1 = ReadSetting("row1", 2).toInt();
|
||||
if (row_1 < 0 || row_1 > 3) {
|
||||
row_1 = 2;
|
||||
UISettings::GameListText row_1 = UISettings::GameListText{
|
||||
ReadSetting("row1", static_cast<int>(UISettings::GameListText::TitleName)).toInt()};
|
||||
if (row_1 <= UISettings::GameListText::NoText || row_1 >= UISettings::GameListText::ListEnd) {
|
||||
row_1 = UISettings::GameListText::TitleName;
|
||||
}
|
||||
UISettings::values.game_list_row_1 = UISettings::GameListText{row_1};
|
||||
UISettings::values.game_list_row_1 = row_1;
|
||||
|
||||
int row_2 = ReadSetting("row2", 0).toInt();
|
||||
if (row_2 < -1 || row_2 > 3) {
|
||||
row_2 = 0;
|
||||
UISettings::GameListText row_2 = UISettings::GameListText{
|
||||
ReadSetting("row2", static_cast<int>(UISettings::GameListText::FileName)).toInt()};
|
||||
if (row_2 < UISettings::GameListText::NoText || row_2 >= UISettings::GameListText::ListEnd) {
|
||||
row_2 = UISettings::GameListText::FileName;
|
||||
}
|
||||
UISettings::values.game_list_row_2 = UISettings::GameListText{row_2};
|
||||
UISettings::values.game_list_row_2 = row_2;
|
||||
|
||||
UISettings::values.game_list_hide_no_icon = ReadSetting("hideNoIcon", false).toBool();
|
||||
UISettings::values.game_list_single_line_mode = ReadSetting("singleLineMode", false).toBool();
|
||||
|
|
|
@ -126,7 +126,7 @@
|
|||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Title Name</string>
|
||||
<string>Title Name (short)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
|
@ -134,6 +134,11 @@
|
|||
<string>Title ID</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Title Name (long)</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
@ -166,7 +171,7 @@
|
|||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Title Name</string>
|
||||
<string>Title Name (short)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
|
@ -174,6 +179,11 @@
|
|||
<string>Title ID</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Title Name (long)</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
|
|
@ -215,7 +215,7 @@ void GameList::onTextChanged(const QString& newText) {
|
|||
child->data(GameListItemPath::FullPathRole).toString().toLower();
|
||||
QString file_name = file_path.mid(file_path.lastIndexOf("/") + 1);
|
||||
const QString file_title =
|
||||
child->data(GameListItemPath::TitleRole).toString().toLower();
|
||||
child->data(GameListItemPath::LongTitleRole).toString().toLower();
|
||||
const QString file_programmid =
|
||||
child->data(GameListItemPath::ProgramIdRole).toString().toLower();
|
||||
|
||||
|
|
|
@ -70,6 +70,17 @@ static QString GetQStringShortTitleFromSMDH(const Loader::SMDH& smdh,
|
|||
return QString::fromUtf16(smdh.GetShortTitle(language).data());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the long game title from SMDH data.
|
||||
* @param smdh SMDH data
|
||||
* @param language title language
|
||||
* @return QString long title
|
||||
*/
|
||||
static QString GetQStringLongTitleFromSMDH(const Loader::SMDH& smdh,
|
||||
Loader::SMDH::TitleLanguage language) {
|
||||
return QString::fromUtf16(smdh.GetLongTitle(language).data());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the game region from SMDH data.
|
||||
* @param smdh SMDH data
|
||||
|
@ -139,6 +150,7 @@ public:
|
|||
static const int FullPathRole = SortRole + 1;
|
||||
static const int ProgramIdRole = SortRole + 2;
|
||||
static const int ExtdataIdRole = SortRole + 3;
|
||||
static const int LongTitleRole = SortRole + 4;
|
||||
|
||||
GameListItemPath() = default;
|
||||
GameListItemPath(const QString& game_path, const std::vector<u8>& smdh_data, u64 program_id,
|
||||
|
@ -173,6 +185,10 @@ public:
|
|||
// Get title from SMDH
|
||||
setData(GetQStringShortTitleFromSMDH(smdh, Loader::SMDH::TitleLanguage::English),
|
||||
TitleRole);
|
||||
|
||||
// Get long title from SMDH
|
||||
setData(GetQStringLongTitleFromSMDH(smdh, Loader::SMDH::TitleLanguage::English),
|
||||
LongTitleRole);
|
||||
}
|
||||
|
||||
int type() const override {
|
||||
|
@ -189,11 +205,12 @@ public:
|
|||
{UISettings::GameListText::FileName, QString::fromStdString(filename + extension)},
|
||||
{UISettings::GameListText::FullPath, data(FullPathRole).toString()},
|
||||
{UISettings::GameListText::TitleName, data(TitleRole).toString()},
|
||||
{UISettings::GameListText::LongTitleName, data(LongTitleRole).toString()},
|
||||
{UISettings::GameListText::TitleID,
|
||||
QString::fromStdString(fmt::format("{:016X}", data(ProgramIdRole).toULongLong()))},
|
||||
};
|
||||
|
||||
const QString& row1 = display_texts.at(UISettings::values.game_list_row_1);
|
||||
const QString& row1 = display_texts.at(UISettings::values.game_list_row_1).simplified();
|
||||
|
||||
QString row2;
|
||||
auto row_2_id = UISettings::values.game_list_row_2;
|
||||
|
@ -203,7 +220,7 @@ public:
|
|||
? QStringLiteral(" ")
|
||||
: QStringLiteral("\n ");
|
||||
}
|
||||
row2 += display_texts.at(row_2_id);
|
||||
row2 += display_texts.at(row_2_id).simplified();
|
||||
}
|
||||
return QString(row1 + row2);
|
||||
} else {
|
||||
|
|
|
@ -46,11 +46,13 @@ enum class GameListIconSize {
|
|||
};
|
||||
|
||||
enum class GameListText {
|
||||
NoText = -1, ///< No text
|
||||
FileName, ///< Display the file name of the entry
|
||||
FullPath, ///< Display the full path of the entry
|
||||
TitleName, ///< Display the name of the title
|
||||
TitleID, ///< Display the title ID
|
||||
NoText = -1, ///< No text
|
||||
FileName, ///< Display the file name of the entry
|
||||
FullPath, ///< Display the full path of the entry
|
||||
TitleName, ///< Display the name of the title
|
||||
TitleID, ///< Display the title ID
|
||||
LongTitleName, ///< Display the long name of the title
|
||||
ListEnd, ///< Keep this at the end of the enum.
|
||||
};
|
||||
|
||||
struct Values {
|
||||
|
|
|
@ -48,6 +48,10 @@ std::array<u16, 0x40> SMDH::GetShortTitle(Loader::SMDH::TitleLanguage language)
|
|||
return titles[static_cast<int>(language)].short_title;
|
||||
}
|
||||
|
||||
std::array<u16, 0x80> SMDH::GetLongTitle(Loader::SMDH::TitleLanguage language) const {
|
||||
return titles[static_cast<int>(language)].long_title;
|
||||
}
|
||||
|
||||
std::vector<SMDH::GameRegion> SMDH::GetRegions() const {
|
||||
constexpr u32 REGION_COUNT = 7;
|
||||
std::vector<GameRegion> result;
|
||||
|
|
|
@ -86,6 +86,13 @@ struct SMDH {
|
|||
*/
|
||||
std::array<u16, 0x40> GetShortTitle(Loader::SMDH::TitleLanguage language) const;
|
||||
|
||||
/**
|
||||
* Gets the long game title from SMDH
|
||||
* @param language title language
|
||||
* @return UTF-16 array of the long title
|
||||
*/
|
||||
std::array<u16, 0x80> GetLongTitle(Loader::SMDH::TitleLanguage language) const;
|
||||
|
||||
std::vector<GameRegion> GetRegions() const;
|
||||
};
|
||||
static_assert(sizeof(SMDH) == 0x36C0, "SMDH structure size is wrong");
|
||||
|
|
Loading…
Reference in a new issue