diff --git a/rpcs3/Emu/GameInfo.h b/rpcs3/Emu/GameInfo.h index 2521599fda..0decbab7ac 100644 --- a/rpcs3/Emu/GameInfo.h +++ b/rpcs3/Emu/GameInfo.h @@ -4,6 +4,7 @@ struct GameInfo { std::string root; + std::string icon_path; std::string name; std::string serial; std::string app_ver; diff --git a/rpcs3/Gui/GameViewer.cpp b/rpcs3/Gui/GameViewer.cpp index 6d18ba349b..e937e58bed 100644 --- a/rpcs3/Gui/GameViewer.cpp +++ b/rpcs3/Gui/GameViewer.cpp @@ -24,7 +24,7 @@ public: bool operator()(const GameInfo& game1, const GameInfo& game2) const { // Note that the column index has to match the appropriate GameInfo member - switch (sortColumn) + switch (sortColumn - 1) // skip *icon* column { case 0: return sortAscending ? (game1.name < game2.name) : (game1.name > game2.name); case 1: return sortAscending ? (game1.serial < game2.serial) : (game1.serial > game2.serial); @@ -149,6 +149,7 @@ void GameViewer::LoadPSF() continue; GameInfo game; + game.icon_path = wxGetCwd() + m_path + m_games[i] + "/ICON0.PNG"; game.root = m_games[i]; game.serial = psf.GetString("TITLE_ID"); game.name = psf.GetString("TITLE"); diff --git a/rpcs3/Gui/GameViewer.h b/rpcs3/Gui/GameViewer.h index 80c007fff0..b18a0acc48 100644 --- a/rpcs3/Gui/GameViewer.h +++ b/rpcs3/Gui/GameViewer.h @@ -1,5 +1,6 @@ #pragma once #include +#include #include "rpcs3/Ini.h" #include "Emu/GameInfo.h" @@ -69,6 +70,7 @@ struct ColumnsArr } public: + Column* m_col_icon; Column* m_col_name; Column* m_col_serial; Column* m_col_fw; @@ -76,36 +78,46 @@ public: Column* m_col_category; Column* m_col_path; + wxImageList* m_img_list; + std::vector m_icon_indexes; + void Init() { + m_img_list = new wxImageList(80, 44); + m_columns.clear(); + m_columns.emplace_back(m_columns.size(), 100, "Icon"); m_columns.emplace_back(m_columns.size(), 160, "Name"); m_columns.emplace_back(m_columns.size(), 85, "Serial"); m_columns.emplace_back(m_columns.size(), 55, "FW"); m_columns.emplace_back(m_columns.size(), 55, "App version"); m_columns.emplace_back(m_columns.size(), 55, "Category"); m_columns.emplace_back(m_columns.size(), 160, "Path"); - m_col_name = &m_columns[0]; - m_col_serial = &m_columns[1]; - m_col_fw = &m_columns[2]; - m_col_app_ver = &m_columns[3]; - m_col_category = &m_columns[4]; - m_col_path = &m_columns[5]; + m_col_icon = &m_columns[0]; + m_col_name = &m_columns[1]; + m_col_serial = &m_columns[2]; + m_col_fw = &m_columns[3]; + m_col_app_ver = &m_columns[4]; + m_col_category = &m_columns[5]; + m_col_path = &m_columns[6]; } void Update(const std::vector& game_data) { + m_col_icon->data.clear(); m_col_name->data.clear(); m_col_serial->data.clear(); m_col_fw->data.clear(); m_col_app_ver->data.clear(); m_col_category->data.clear(); m_col_path->data.clear(); + m_icon_indexes.clear(); if(m_columns.size() == 0) return; for(const auto& game : game_data) { + m_col_icon->data.push_back(game.icon_path); m_col_name->data.push_back(game.name); m_col_serial->data.push_back(game.serial); m_col_fw->data.push_back(game.fw); @@ -113,11 +125,25 @@ public: m_col_category->data.push_back(game.category); m_col_path->data.push_back(game.root); } + + // load icons + for (const auto& path : m_col_icon->data) + { + wxImage game_icon(80, 44); + { + wxLogNull logNo; // temporary disable wx warnings ("iCCP: known incorrect sRGB profile" spamming) + if (game_icon.LoadFile(fmt::FromUTF8(path), wxBITMAP_TYPE_PNG)) + game_icon.Rescale(80, 44); + } + + m_icon_indexes.push_back(m_img_list->Add(game_icon)); + } } void Show(wxListView* list) { list->DeleteAllColumns(); + list->SetImageList(m_img_list, wxIMAGE_LIST_SMALL); std::vector c_col = GetSortedColumnsByPos(); for(u32 i=0, c=0; iDeleteAllItems(); + list->SetImageList(m_img_list, wxIMAGE_LIST_SMALL); for(int c=0; cGetColumnCount(); ++c) { Column* col = GetColumnByPos(c); @@ -147,7 +174,8 @@ public: list->SetItemData(i, i); } list->SetItem(i, c, fmt::FromUTF8(col->data[i])); - + list->SetItem(i, 0, wxEmptyString); // don't insert icon path + list->SetItemColumnImage(i, 0, m_icon_indexes[i]); } } }