From f9cded05fd621e5c37c478b2819ec6f6bcba99b2 Mon Sep 17 00:00:00 2001 From: vitor-k Date: Wed, 4 Sep 2019 23:15:37 -0300 Subject: [PATCH 1/5] Allow displaying of the full title in the interface, as well as use the full title in the search filter --- src/citra_qt/configuration/configure_ui.ui | 14 ++++++++++++-- src/citra_qt/game_list.cpp | 2 +- src/citra_qt/game_list_p.h | 19 ++++++++++++++++++- src/citra_qt/uisettings.h | 1 + src/core/loader/smdh.cpp | 4 ++++ src/core/loader/smdh.h | 7 +++++++ 6 files changed, 43 insertions(+), 4 deletions(-) diff --git a/src/citra_qt/configuration/configure_ui.ui b/src/citra_qt/configuration/configure_ui.ui index 4af177f3e..82a5a4283 100644 --- a/src/citra_qt/configuration/configure_ui.ui +++ b/src/citra_qt/configuration/configure_ui.ui @@ -126,7 +126,12 @@ - Title Name + Title Name (short) + + + + + Title Name (long) @@ -166,7 +171,12 @@ - Title Name + Title Name (short) + + + + + Title Name (long) diff --git a/src/citra_qt/game_list.cpp b/src/citra_qt/game_list.cpp index 0f0325ca2..e7fbfba9c 100644 --- a/src/citra_qt/game_list.cpp +++ b/src/citra_qt/game_list.cpp @@ -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(); diff --git a/src/citra_qt/game_list_p.h b/src/citra_qt/game_list_p.h index c03c073b3..3411445e7 100644 --- a/src/citra_qt/game_list_p.h +++ b/src/citra_qt/game_list_p.h @@ -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& 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; diff --git a/src/citra_qt/uisettings.h b/src/citra_qt/uisettings.h index 573b4d975..eaef36f3e 100644 --- a/src/citra_qt/uisettings.h +++ b/src/citra_qt/uisettings.h @@ -50,6 +50,7 @@ enum class GameListText { FileName, ///< Display the file name of the entry FullPath, ///< Display the full path of the entry TitleName, ///< Display the name of the title + LongTitleName, ///< Display the long name of the title TitleID, ///< Display the title ID }; diff --git a/src/core/loader/smdh.cpp b/src/core/loader/smdh.cpp index 1b9503d1d..4773d08e5 100644 --- a/src/core/loader/smdh.cpp +++ b/src/core/loader/smdh.cpp @@ -48,6 +48,10 @@ std::array SMDH::GetShortTitle(Loader::SMDH::TitleLanguage language) return titles[static_cast(language)].short_title; } +std::array SMDH::GetLongTitle(Loader::SMDH::TitleLanguage language) const { + return titles[static_cast(language)].long_title; +} + std::vector SMDH::GetRegions() const { constexpr u32 REGION_COUNT = 7; std::vector result; diff --git a/src/core/loader/smdh.h b/src/core/loader/smdh.h index 2156dec9c..63626f732 100644 --- a/src/core/loader/smdh.h +++ b/src/core/loader/smdh.h @@ -86,6 +86,13 @@ struct SMDH { */ std::array 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 GetLongTitle(Loader::SMDH::TitleLanguage language) const; + std::vector GetRegions() const; }; static_assert(sizeof(SMDH) == 0x36C0, "SMDH structure size is wrong"); From c866a8e42870f7e6d5952f39d3b33b62c52d08b3 Mon Sep 17 00:00:00 2001 From: vitor-k Date: Thu, 5 Sep 2019 14:28:40 -0300 Subject: [PATCH 2/5] Change GameListText order to improve configuration compatibility --- src/citra_qt/configuration/config.cpp | 4 ++-- src/citra_qt/configuration/configure_ui.ui | 8 ++++---- src/citra_qt/uisettings.h | 4 +++- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/citra_qt/configuration/config.cpp b/src/citra_qt/configuration/config.cpp index ddcb71e3d..6b214216e 100644 --- a/src/citra_qt/configuration/config.cpp +++ b/src/citra_qt/configuration/config.cpp @@ -307,13 +307,13 @@ void Config::ReadValues() { UISettings::values.game_list_icon_size = UISettings::GameListIconSize{icon_size}; int row_1 = ReadSetting("row1", 2).toInt(); - if (row_1 < 0 || row_1 > 3) { + if (row_1 < 0 || row_1 >= UISettings::GAME_LIST_TEXT_LENGTH) { row_1 = 2; } UISettings::values.game_list_row_1 = UISettings::GameListText{row_1}; int row_2 = ReadSetting("row2", 0).toInt(); - if (row_2 < -1 || row_2 > 3) { + if (row_2 < -1 || row_2 >= UISettings::GAME_LIST_TEXT_LENGTH) { row_2 = 0; } UISettings::values.game_list_row_2 = UISettings::GameListText{row_2}; diff --git a/src/citra_qt/configuration/configure_ui.ui b/src/citra_qt/configuration/configure_ui.ui index 82a5a4283..c9a0a659e 100644 --- a/src/citra_qt/configuration/configure_ui.ui +++ b/src/citra_qt/configuration/configure_ui.ui @@ -131,12 +131,12 @@ - Title Name (long) + Title ID - Title ID + Title Name (long) @@ -176,12 +176,12 @@ - Title Name (long) + Title ID - Title ID + Title Name (long) diff --git a/src/citra_qt/uisettings.h b/src/citra_qt/uisettings.h index eaef36f3e..e94b94d20 100644 --- a/src/citra_qt/uisettings.h +++ b/src/citra_qt/uisettings.h @@ -50,9 +50,11 @@ enum class GameListText { FileName, ///< Display the file name of the entry FullPath, ///< Display the full path of the entry TitleName, ///< Display the name of the title - LongTitleName, ///< Display the long name of the title TitleID, ///< Display the title ID + LongTitleName, ///< Display the long name of the title }; +// The length of the GameListText, excluding NoText +constexpr int GAME_LIST_TEXT_LENGTH = 5; struct Values { QByteArray geometry; From 1f1ac98f10ea77c5bc9a477642266a39b33c720a Mon Sep 17 00:00:00 2001 From: vitor-k Date: Thu, 5 Sep 2019 22:54:39 -0300 Subject: [PATCH 3/5] Fix clang format for long-title --- src/citra_qt/game_list_p.h | 2 +- src/citra_qt/uisettings.h | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/citra_qt/game_list_p.h b/src/citra_qt/game_list_p.h index 3411445e7..82c7fcaad 100644 --- a/src/citra_qt/game_list_p.h +++ b/src/citra_qt/game_list_p.h @@ -77,7 +77,7 @@ static QString GetQStringShortTitleFromSMDH(const Loader::SMDH& smdh, * @return QString long title */ static QString GetQStringLongTitleFromSMDH(const Loader::SMDH& smdh, - Loader::SMDH::TitleLanguage language) { + Loader::SMDH::TitleLanguage language) { return QString::fromUtf16(smdh.GetLongTitle(language).data()); } diff --git a/src/citra_qt/uisettings.h b/src/citra_qt/uisettings.h index e94b94d20..c33db6e75 100644 --- a/src/citra_qt/uisettings.h +++ b/src/citra_qt/uisettings.h @@ -46,11 +46,11 @@ 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 }; // The length of the GameListText, excluding NoText From 719912786a51f5e36d87e9c5aa19e8ecdb065fe1 Mon Sep 17 00:00:00 2001 From: vitor-k Date: Sat, 7 Sep 2019 00:15:07 -0300 Subject: [PATCH 4/5] UISettings::GameListText Append a value to the enum to function as length counter. Also remove magic numbers where possible, by using the enum instead. --- src/citra_qt/configuration/config.cpp | 18 ++++++++++-------- src/citra_qt/uisettings.h | 3 +-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/citra_qt/configuration/config.cpp b/src/citra_qt/configuration/config.cpp index 6b214216e..c96d8d86b 100644 --- a/src/citra_qt/configuration/config.cpp +++ b/src/citra_qt/configuration/config.cpp @@ -306,17 +306,19 @@ void Config::ReadValues() { } UISettings::values.game_list_icon_size = UISettings::GameListIconSize{icon_size}; - int row_1 = ReadSetting("row1", 2).toInt(); - if (row_1 < 0 || row_1 >= UISettings::GAME_LIST_TEXT_LENGTH) { - row_1 = 2; + UISettings::GameListText row_1 = UISettings::GameListText{ + ReadSetting("row1", static_cast(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 >= UISettings::GAME_LIST_TEXT_LENGTH) { - row_2 = 0; + UISettings::GameListText row_2 = UISettings::GameListText{ + ReadSetting("row2", static_cast(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(); diff --git a/src/citra_qt/uisettings.h b/src/citra_qt/uisettings.h index c33db6e75..31be267c6 100644 --- a/src/citra_qt/uisettings.h +++ b/src/citra_qt/uisettings.h @@ -52,9 +52,8 @@ enum class GameListText { 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. }; -// The length of the GameListText, excluding NoText -constexpr int GAME_LIST_TEXT_LENGTH = 5; struct Values { QByteArray geometry; From 966d128025d888c6afb406f02ab6a2360f4643e7 Mon Sep 17 00:00:00 2001 From: vitor-k Date: Sun, 8 Sep 2019 17:06:19 -0300 Subject: [PATCH 5/5] Remove newlines from the long title in row2 --- src/citra_qt/game_list_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/citra_qt/game_list_p.h b/src/citra_qt/game_list_p.h index 82c7fcaad..1bb26f759 100644 --- a/src/citra_qt/game_list_p.h +++ b/src/citra_qt/game_list_p.h @@ -220,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 {