ISO: Move game image loading to game_list_base::IconLoadFunction

This commit is contained in:
Functionable 2025-12-13 12:05:34 +00:00 committed by Elad
parent acdb0ee729
commit 27510f5fa8
3 changed files with 18 additions and 11 deletions

View file

@ -1,6 +1,8 @@
#include "stdafx.h"
#include "game_list_base.h"
#include "Loader/ISO.h"
#include <QDir>
#include <QPainter>
@ -50,7 +52,20 @@ void game_list_base::IconLoadFunction(game_info game, qreal device_pixel_ratio,
if (game->icon.isNull() && (game->info.icon_path.empty() || !game->icon.load(QString::fromStdString(game->info.icon_path))))
{
if (game_list_log.warning)
if (game->icon_in_archive)
{
iso_archive archive(game->info.path);
auto icon_file = archive.open(game->info.icon_path);
auto icon_size = icon_file.size();
QByteArray data(icon_size, 0);
icon_file.read(data.data(), icon_size);
QImage iconImage;
if (iconImage.loadFromData(data))
{
game->icon = QPixmap::fromImage(iconImage);
}
}
else if (game_list_log.warning)
{
bool logged = false;
{

View file

@ -643,16 +643,7 @@ void game_list_frame::OnParsingFinished()
{
if (!archive->exists(game.info.icon_path)) return;
auto icon_file = archive->open(game.info.icon_path);
auto icon_size = icon_file.size();
QByteArray data(icon_size, 0);
icon_file.read(data.data(), icon_size);
QImage iconImage;
if (iconImage.loadFromData(data))
{
game.icon = QPixmap::fromImage(iconImage);
}
game.info.icon_path.clear();
game.icon_in_archive = true;
}
}

View file

@ -20,6 +20,7 @@ struct gui_game_info
bool has_custom_icon = false;
bool has_hover_gif = false;
bool has_hover_pam = false;
bool icon_in_archive = false;
movie_item_base* item = nullptr;
// Returns the visible version string in the game list