From f671840a18918eb7e27a7a94bc55948c4646320a Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sat, 16 May 2020 20:03:01 +1000 Subject: [PATCH] Qt: Add compatibility stars to game list --- src/duckstation-qt/gamelistwidget.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/duckstation-qt/gamelistwidget.cpp b/src/duckstation-qt/gamelistwidget.cpp index 583e19a62..bf2e56ae6 100644 --- a/src/duckstation-qt/gamelistwidget.cpp +++ b/src/duckstation-qt/gamelistwidget.cpp @@ -18,14 +18,15 @@ public: Column_Code, Column_Title, Column_FileTitle, - Column_Region, Column_Size, + Column_Region, + Column_Compatibility, Column_Count }; static inline constexpr std::array s_column_names = { - {"Type", "Code", "Title", "File Title", "Region", "Size"}}; + {"Type", "Code", "Title", "File Title", "Size", "Region", "Compatibility"}}; static std::optional getColumnIdForName(std::string_view name) { @@ -119,6 +120,9 @@ public: case Column_Region: return static_cast(ge.region); + case Column_Compatibility: + return static_cast(ge.compatibility_rating); + case Column_Size: return static_cast(ge.total_size); @@ -157,6 +161,13 @@ public: } } + case Column_Compatibility: + { + return m_compatibiliy_pixmaps[static_cast( + (ge.compatibility_rating >= GameListCompatibilityRating::Count) ? GameListCompatibilityRating::Unknown : + ge.compatibility_rating)]; + } + default: return {}; } @@ -204,6 +215,9 @@ private: m_region_jp_pixmap.load(QStringLiteral(":/icons/flag-jp.png")); m_region_us_pixmap.load(QStringLiteral(":/icons/flag-us.png")); m_region_eu_pixmap.load(QStringLiteral(":/icons/flag-eu.png")); + + for (int i = 0; i < static_cast(GameListCompatibilityRating::Count); i++) + m_compatibiliy_pixmaps[i].load(QStringLiteral(":/icons/star-%1.png").arg(i)); } GameList* m_game_list; @@ -214,6 +228,8 @@ private: QPixmap m_region_jp_pixmap; QPixmap m_region_eu_pixmap; QPixmap m_region_us_pixmap; + + std::array(GameListCompatibilityRating::Count)> m_compatibiliy_pixmaps; }; class GameListSortModel final : public QSortFilterProxyModel @@ -359,7 +375,7 @@ void GameListWidget::resizeEvent(QResizeEvent* event) void GameListWidget::resizeTableViewColumnsToFit() { - QtUtils::ResizeColumnsForTableView(m_table_view, {32, 80, -1, -1, 60, 100}); + QtUtils::ResizeColumnsForTableView(m_table_view, {32, 80, -1, -1, 100, 60, 100}); } static QString getColumnVisibilitySettingsKeyName(int column)