Qt: Properly use ICON1.PAM from game data dir if available

Fixes hover movie for disc games that have game data installed.
This commit is contained in:
Megamouse 2023-12-02 23:14:14 +01:00
parent c245637c38
commit a97bad97ae
4 changed files with 23 additions and 18 deletions

View File

@ -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";
}
};

View File

@ -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<gui_game_info>(std::move(info)));
};

View File

@ -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)

View File

@ -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);