ISO: Fix game movie icons

This commit is contained in:
Functionable 2025-12-08 20:42:01 +00:00 committed by Elad
parent ab45b1bf61
commit eff25ed0aa
3 changed files with 58 additions and 11 deletions

View File

@ -11,6 +11,8 @@
#include "Emu/vfs_config.h" #include "Emu/vfs_config.h"
#include "Utilities/StrUtil.h" #include "Utilities/StrUtil.h"
#include "Loader/ISO.h"
#include <QHeaderView> #include <QHeaderView>
#include <QScrollBar> #include <QScrollBar>
#include <QStringBuilder> #include <QStringBuilder>
@ -242,6 +244,12 @@ void game_list_table::populate(
custom_table_widget_item* icon_item = new custom_table_widget_item; custom_table_widget_item* icon_item = new custom_table_widget_item;
game->item = icon_item; game->item = icon_item;
if (is_file_iso(game->info.path) && !game->info.movie_path.empty()
&& !fs::exists(game->info.movie_path))
{
icon_item->set_source_path(game->info.path);
}
icon_item->set_image_change_callback([this, icon_item, game](const QVideoFrame& frame) icon_item->set_image_change_callback([this, icon_item, game](const QVideoFrame& frame)
{ {
if (!icon_item || !game) if (!icon_item || !game)

View File

@ -2,6 +2,8 @@
#include "Emu/System.h" #include "Emu/System.h"
#include "qt_video_source.h" #include "qt_video_source.h"
#include "Loader/ISO.h"
#include <QFile> #include <QFile>
qt_video_source::qt_video_source() qt_video_source::qt_video_source()
@ -19,6 +21,11 @@ void qt_video_source::set_video_path(const std::string& video_path)
m_video_path = QString::fromStdString(video_path); m_video_path = QString::fromStdString(video_path);
} }
void qt_video_source::set_source_path(const std::string& source_path)
{
m_source_path = QString::fromStdString(source_path);
}
void qt_video_source::set_active(bool active) void qt_video_source::set_active(bool active)
{ {
if (m_active.exchange(active) == active) return; if (m_active.exchange(active) == active) return;
@ -55,7 +62,7 @@ void qt_video_source::init_movie()
return; return;
} }
if (!m_image_change_callback || m_video_path.isEmpty() || !QFile::exists(m_video_path)) if (!m_image_change_callback || m_video_path.isEmpty() || (!QFile::exists(m_video_path) && m_source_path.isEmpty()))
{ {
m_video_path.clear(); m_video_path.clear();
return; return;
@ -65,8 +72,25 @@ void qt_video_source::init_movie()
if (lower.endsWith(".gif")) if (lower.endsWith(".gif"))
{ {
m_movie = std::make_unique<QMovie>(m_video_path); if (m_source_path.isEmpty())
m_video_path.clear(); {
m_movie = std::make_unique<QMovie>(m_video_path);
m_video_path.clear();
}
else
{
iso_archive archive(m_source_path.toStdString());
auto movie_file = archive.open(m_video_path.toStdString());
auto movie_size = movie_file.size();
m_video_data = QByteArray(movie_size, 0);
movie_file.read(m_video_data.data(), movie_size);
QBuffer buffer(&m_video_data);
buffer.open(QIODevice::ReadOnly);
m_movie = std::make_unique<QMovie>(&buffer);
m_video_path.clear();
}
if (!m_movie->isValid()) if (!m_movie->isValid())
{ {
@ -85,17 +109,30 @@ void qt_video_source::init_movie()
if (lower.endsWith(".pam")) if (lower.endsWith(".pam"))
{ {
// We can't set PAM files as source of the video player, so we have to feed them as raw data. // We can't set PAM files as source of the video player, so we have to feed them as raw data.
QFile file(m_video_path); if (m_source_path.isEmpty())
if (!file.open(QFile::OpenModeFlag::ReadOnly))
{ {
return; QFile file(m_video_path);
} if (!file.open(QFile::OpenModeFlag::ReadOnly))
{
return;
}
// TODO: Decode the pam properly before pushing it to the player // TODO: Decode the pam properly before pushing it to the player
m_video_data = file.readAll(); m_video_data = file.readAll();
if (m_video_data.isEmpty()) if (m_video_data.isEmpty())
{
return;
}
}
else
{ {
return; auto source_path = m_source_path.toStdString();
auto video_path = m_video_path.toStdString();
iso_archive archive(source_path.c_str());
auto movie_file = archive.open(video_path);
auto movie_size = movie_file.size();
m_video_data = QByteArray(movie_size, 0);
movie_file.read(m_video_data.data(), movie_size);
} }
m_video_buffer = std::make_unique<QBuffer>(&m_video_data); m_video_buffer = std::make_unique<QBuffer>(&m_video_data);

View File

@ -17,6 +17,7 @@ public:
qt_video_source(); qt_video_source();
virtual ~qt_video_source(); virtual ~qt_video_source();
void set_source_path(const std::string& source_path);
void set_video_path(const std::string& video_path) override; void set_video_path(const std::string& video_path) override;
const QString& video_path() const { return m_video_path; } const QString& video_path() const { return m_video_path; }
@ -43,6 +44,7 @@ protected:
atomic_t<bool> m_has_new = false; atomic_t<bool> m_has_new = false;
QString m_video_path; QString m_video_path;
QString m_source_path; // path of the source archive
QByteArray m_video_data{}; QByteArray m_video_data{};
QImage m_image{}; QImage m_image{};
std::vector<u8> m_image_path; std::vector<u8> m_image_path;