From a97bad97aec4b630cc609d5396bb47906ab1c66c Mon Sep 17 00:00:00 2001 From: Megamouse Date: Sat, 2 Dec 2023 23:14:14 +0100 Subject: [PATCH] Qt: Properly use ICON1.PAM from game data dir if available Fixes hover movie for disc games that have game data installed. --- rpcs3/Emu/GameInfo.h | 10 +--------- rpcs3/rpcs3qt/game_list_frame.cpp | 27 ++++++++++++++++++++------- rpcs3/rpcs3qt/game_list_grid.cpp | 2 +- rpcs3/rpcs3qt/game_list_table.cpp | 2 +- 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/rpcs3/Emu/GameInfo.h b/rpcs3/Emu/GameInfo.h index d5ed2f6c08..5fec2b637e 100644 --- a/rpcs3/Emu/GameInfo.h +++ b/rpcs3/Emu/GameInfo.h @@ -7,6 +7,7 @@ struct GameInfo { std::string path; std::string icon_path; + std::string movie_path; std::string name = "Unknown"; std::string serial = "Unknown"; @@ -22,13 +23,4 @@ struct GameInfo u32 resolution = 0; u64 size_on_disk = umax; - - std::string get_pam_path() const - { - if (icon_path.empty()) - { - return {}; - } - return icon_path.substr(0, icon_path.find_last_of("/")) + "/ICON1.PAM"; - } }; diff --git a/rpcs3/rpcs3qt/game_list_frame.cpp b/rpcs3/rpcs3qt/game_list_frame.cpp index a182961352..3cd39a267f 100644 --- a/rpcs3/rpcs3qt/game_list_frame.cpp +++ b/rpcs3/rpcs3qt/game_list_frame.cpp @@ -473,9 +473,9 @@ void game_list_frame::OnParsingFinished() sort(m_path_entries.begin(), m_path_entries.end(), [](const path_entry& l, const path_entry& r){return l.path < r.path;}); m_path_entries.erase(unique(m_path_entries.begin(), m_path_entries.end(), [](const path_entry& l, const path_entry& r){return l.path == r.path;}), m_path_entries.end()); - const std::string game_icon_path = m_play_hover_movies ? fs::get_config_dir() + "/Icons/game_icons/" : ""; + const std::string game_icon_path = fs::get_config_dir() + "/Icons/game_icons/"; - const auto add_game = [this, dev_flash, cat_unknown_localized = sstr(localized.category.unknown), cat_unknown = sstr(cat::cat_unknown), game_icon_path](const std::string& dir_or_elf) + const auto add_game = [this, dev_flash, cat_unknown_localized = sstr(localized.category.unknown), cat_unknown = sstr(cat::cat_unknown), game_icon_path, _hdd, play_hover_movies = m_play_hover_movies, show_custom_icons = m_show_custom_icons](const std::string& dir_or_elf) { GameInfo game{}; game.path = dir_or_elf; @@ -535,20 +535,27 @@ void game_list_frame::OnParsingFinished() game.bootable = psf::get_integer(psf, "BOOTABLE", 0); game.attr = psf::get_integer(psf, "ATTRIBUTE", 0); game.icon_path = sfo_dir + "/ICON0.PNG"; + game.movie_path = sfo_dir + "/ICON1.PAM"; if (game.category == "DG") { - std::string latest_icon = rpcs3::utils::get_hdd0_dir() + "game/" + game.serial + "/ICON0.PNG"; - if (fs::is_file(latest_icon)) + const std::string game_data_dir = _hdd + "game/" + game.serial; + + if (std::string latest_icon = game_data_dir + "/ICON0.PNG"; fs::is_file(latest_icon)) { game.icon_path = std::move(latest_icon); } + + if (std::string latest_movie = game_data_dir + "/ICON1.PAM"; fs::is_file(latest_movie)) + { + game.movie_path = std::move(latest_movie); + } } } - if (m_show_custom_icons) + if (show_custom_icons) { - if (std::string icon_path = fs::get_config_dir() + "/Icons/game_icons/" + game.serial + "/ICON0.PNG"; fs::is_file(icon_path)) + if (std::string icon_path = game_icon_path + game.serial + "/ICON0.PNG"; fs::is_file(icon_path)) { game.icon_path = std::move(icon_path); } @@ -614,7 +621,13 @@ void game_list_frame::OnParsingFinished() info.hasCustomConfig = fs::is_file(rpcs3::utils::get_custom_config_path(info.info.serial)); info.hasCustomPadConfig = fs::is_file(rpcs3::utils::get_custom_input_config_path(info.info.serial)); info.has_hover_gif = fs::is_file(game_icon_path + info.info.serial + "/hover.gif"); - info.has_hover_pam = fs::is_file(info.info.get_pam_path()); + info.has_hover_pam = fs::is_file(info.info.movie_path); + + // Free some memory + if (!info.has_hover_pam) + { + info.info.movie_path.clear(); + } m_games.push(std::make_shared(std::move(info))); }; diff --git a/rpcs3/rpcs3qt/game_list_grid.cpp b/rpcs3/rpcs3qt/game_list_grid.cpp index 2758d00e5b..f1b82a494e 100644 --- a/rpcs3/rpcs3qt/game_list_grid.cpp +++ b/rpcs3/rpcs3qt/game_list_grid.cpp @@ -107,7 +107,7 @@ void game_list_grid::populate( } else if (play_hover_movies && game->has_hover_pam) { - item->set_movie_path(QString::fromStdString(game->info.get_pam_path())); + item->set_movie_path(QString::fromStdString(game->info.movie_path)); } if (selected_item_id == game->info.path + game->info.icon_path) diff --git a/rpcs3/rpcs3qt/game_list_table.cpp b/rpcs3/rpcs3qt/game_list_table.cpp index f1598e95cf..064fced957 100644 --- a/rpcs3/rpcs3qt/game_list_table.cpp +++ b/rpcs3/rpcs3qt/game_list_table.cpp @@ -289,7 +289,7 @@ void game_list_table::populate( } else if (play_hover_movies && game->has_hover_pam) { - icon_item->set_movie_path(QString::fromStdString(game->info.get_pam_path())); + icon_item->set_movie_path(QString::fromStdString(game->info.movie_path)); } icon_item->setData(Qt::UserRole, index, true);