mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 14:49:42 -06:00
GameList: Show game mod descriptor .json files in game list.
This commit is contained in:
@ -43,6 +43,7 @@
|
||||
#include "DiscIO/Blob.h"
|
||||
#include "DiscIO/DiscExtractor.h"
|
||||
#include "DiscIO/Enums.h"
|
||||
#include "DiscIO/GameModDescriptor.h"
|
||||
#include "DiscIO/Volume.h"
|
||||
#include "DiscIO/WiiSaveBanner.h"
|
||||
|
||||
@ -163,6 +164,32 @@ GameFile::GameFile(std::string path) : m_file_path(std::move(path))
|
||||
m_platform = DiscIO::Platform::ELFOrDOL;
|
||||
m_blob_type = DiscIO::BlobType::DIRECTORY;
|
||||
}
|
||||
|
||||
if (!IsValid() && GetExtension() == ".json")
|
||||
{
|
||||
auto descriptor = DiscIO::ParseGameModDescriptorFile(m_file_path);
|
||||
if (descriptor)
|
||||
{
|
||||
GameFile proxy(descriptor->base_file);
|
||||
if (proxy.IsValid())
|
||||
{
|
||||
m_valid = true;
|
||||
m_file_size = File::GetSize(m_file_path);
|
||||
m_long_names.emplace(DiscIO::Language::English, std::move(descriptor->display_name));
|
||||
m_internal_name = proxy.GetInternalName();
|
||||
m_game_id = proxy.GetGameID();
|
||||
m_gametdb_id = proxy.GetGameTDBID();
|
||||
m_title_id = proxy.GetTitleID();
|
||||
m_maker_id = proxy.GetMakerID();
|
||||
m_region = proxy.GetRegion();
|
||||
m_country = proxy.GetCountry();
|
||||
m_platform = proxy.GetPlatform();
|
||||
m_revision = proxy.GetRevision();
|
||||
m_disc_number = proxy.GetDiscNumber();
|
||||
m_blob_type = DiscIO::BlobType::MOD_DESCRIPTOR;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GameFile::~GameFile() = default;
|
||||
@ -470,6 +497,18 @@ bool GameFile::ReadPNGBanner(const std::string& path)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GameFile::TryLoadGameModDescriptorBanner()
|
||||
{
|
||||
if (m_blob_type != DiscIO::BlobType::MOD_DESCRIPTOR)
|
||||
return false;
|
||||
|
||||
auto descriptor = DiscIO::ParseGameModDescriptorFile(m_file_path);
|
||||
if (!descriptor)
|
||||
return false;
|
||||
|
||||
return ReadPNGBanner(descriptor->banner);
|
||||
}
|
||||
|
||||
bool GameFile::CustomBannerChanged()
|
||||
{
|
||||
std::string path, name;
|
||||
@ -482,8 +521,12 @@ bool GameFile::CustomBannerChanged()
|
||||
// Homebrew Channel icon naming. Typical for DOLs and ELFs, but we also support it for volumes.
|
||||
if (!ReadPNGBanner(path + "icon.png"))
|
||||
{
|
||||
// If no custom icon is found, go back to the non-custom one.
|
||||
m_pending.custom_banner = {};
|
||||
// If it's a game mod descriptor file, it may specify its own custom banner.
|
||||
if (!TryLoadGameModDescriptorBanner())
|
||||
{
|
||||
// If no custom icon is found, go back to the non-custom one.
|
||||
m_pending.custom_banner = {};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -499,6 +542,8 @@ const std::string& GameFile::GetName(const Core::TitleDatabase& title_database)
|
||||
{
|
||||
if (!m_custom_name.empty())
|
||||
return m_custom_name;
|
||||
if (IsModDescriptor())
|
||||
return GetName(Variant::LongAndPossiblyCustom);
|
||||
|
||||
const std::string& database_name = title_database.GetTitleName(m_gametdb_id, GetConfigLanguage());
|
||||
return database_name.empty() ? GetName(Variant::LongAndPossiblyCustom) : database_name;
|
||||
@ -652,6 +697,7 @@ bool GameFile::ShouldShowFileFormatDetails() const
|
||||
case DiscIO::BlobType::PLAIN:
|
||||
break;
|
||||
case DiscIO::BlobType::DRIVE:
|
||||
case DiscIO::BlobType::MOD_DESCRIPTOR:
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
@ -699,6 +745,11 @@ bool GameFile::ShouldAllowConversion() const
|
||||
return DiscIO::IsDisc(m_platform) && m_volume_size_is_accurate;
|
||||
}
|
||||
|
||||
bool GameFile::IsModDescriptor() const
|
||||
{
|
||||
return m_blob_type == DiscIO::BlobType::MOD_DESCRIPTOR;
|
||||
}
|
||||
|
||||
const GameBanner& GameFile::GetBannerImage() const
|
||||
{
|
||||
return m_custom_banner.empty() ? m_volume_banner : m_custom_banner;
|
||||
|
@ -107,6 +107,7 @@ public:
|
||||
bool IsVolumeSizeAccurate() const { return m_volume_size_is_accurate; }
|
||||
bool IsDatelDisc() const { return m_is_datel_disc; }
|
||||
bool IsNKit() const { return m_is_nkit; }
|
||||
bool IsModDescriptor() const;
|
||||
const GameBanner& GetBannerImage() const;
|
||||
const GameCover& GetCoverImage() const;
|
||||
void DoState(PointerWrap& p);
|
||||
@ -132,6 +133,7 @@ private:
|
||||
bool IsElfOrDol() const;
|
||||
bool ReadXMLMetadata(const std::string& path);
|
||||
bool ReadPNGBanner(const std::string& path);
|
||||
bool TryLoadGameModDescriptorBanner();
|
||||
|
||||
// IMPORTANT: Nearly all data members must be save/restored in DoState.
|
||||
// If anything is changed, make sure DoState handles it properly and
|
||||
|
@ -27,13 +27,14 @@
|
||||
|
||||
namespace UICommon
|
||||
{
|
||||
static constexpr u32 CACHE_REVISION = 20; // Last changed in PR 9461
|
||||
static constexpr u32 CACHE_REVISION = 21; // Last changed in PR 10187
|
||||
|
||||
std::vector<std::string> FindAllGamePaths(const std::vector<std::string>& directories_to_scan,
|
||||
bool recursive_scan)
|
||||
{
|
||||
static const std::vector<std::string> search_extensions = {
|
||||
".gcm", ".tgc", ".iso", ".ciso", ".gcz", ".wbfs", ".wia", ".rvz", ".wad", ".dol", ".elf"};
|
||||
static const std::vector<std::string> search_extensions = {".gcm", ".tgc", ".iso", ".ciso",
|
||||
".gcz", ".wbfs", ".wia", ".rvz",
|
||||
".wad", ".dol", ".elf", ".json"};
|
||||
|
||||
// TODO: We could process paths iteratively as they are found
|
||||
return Common::DoFileSearch(directories_to_scan, search_extensions, recursive_scan);
|
||||
|
Reference in New Issue
Block a user