From 3e6d62ae9e19ae3c0c5c237ecd33c9cc06beae26 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sun, 6 Sep 2015 18:03:02 +0200 Subject: [PATCH] DolphinQt: Support banners in Homebrew Channel format HBC uses files named icon.png for icons. This change makes Dolphin support that file name, and also [executable file name].png in case someone wants to have multiple files in one folder. The HBC banner support is mainly intended for DOL and ELF files, but it can also be used to override banners of disc images, something that wasn't possible in the past. That sure was simple compared to the wx version of this commit... --- Source/Core/DolphinQt/GameList/GameFile.cpp | 14 +++++++++++++- Source/Core/DolphinQt/GameList/GameFile.h | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Source/Core/DolphinQt/GameList/GameFile.cpp b/Source/Core/DolphinQt/GameList/GameFile.cpp index 7e22d389c9..a3f2d40d8c 100644 --- a/Source/Core/DolphinQt/GameList/GameFile.cpp +++ b/Source/Core/DolphinQt/GameList/GameFile.cpp @@ -73,7 +73,8 @@ GameFile::GameFile(const QString& fileName) : m_file_name(fileName) { QFileInfo info(m_file_name); - m_folder_name = info.absoluteDir().dirName(); + QDir directory = info.absoluteDir(); + m_folder_name = directory.dirName(); if (LoadFromCache()) { @@ -140,6 +141,16 @@ GameFile::GameFile(const QString& fileName) m_file_size = info.size(); m_platform = DiscIO::IVolume::ELF_DOL; } + + // PNG files can optionally be used as banners. Typical for DOLs and ELFs, but also works with + // volumes. icon.png is the file name used by Homebrew Channel. The ability to use a PNG file + // with the same name as the main file is provided as an alternative for those who want to have + // multiple files in one folder instead of having a Homebrew Channel-style folder structure. + QImage banner(directory.filePath(info.baseName() + SL(".png"))); + if (banner.isNull()) + banner.load(directory.filePath(SL("icon.png"))); + if (!banner.isNull()) + m_banner = QPixmap::fromImage(banner); } bool GameFile::LoadFromCache() @@ -259,6 +270,7 @@ QString GameFile::CreateCacheFilename() const return fullname; } +// Outputs to m_banner void GameFile::ReadBanner(const DiscIO::IVolume& volume) { int width, height; diff --git a/Source/Core/DolphinQt/GameList/GameFile.h b/Source/Core/DolphinQt/GameList/GameFile.h index 8fe94b67a9..635cb553e9 100644 --- a/Source/Core/DolphinQt/GameList/GameFile.h +++ b/Source/Core/DolphinQt/GameList/GameFile.h @@ -81,5 +81,6 @@ private: bool IsElfOrDol() const; QString CreateCacheFilename() const; + // Outputs to m_banner void ReadBanner(const DiscIO::IVolume& volume); };