2017-12-31 12:33:36 -07:00
|
|
|
// Copyright 2008 Dolphin Emulator Project
|
2021-07-04 19:22:19 -06:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2017-12-31 12:33:36 -07:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2020-06-07 14:58:03 -06:00
|
|
|
#include <array>
|
2017-12-31 12:33:36 -07:00
|
|
|
#include <map>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "Common/CommonTypes.h"
|
2020-06-07 14:58:03 -06:00
|
|
|
#include "Core/SyncIdentifier.h"
|
2018-06-01 06:19:16 -06:00
|
|
|
#include "DiscIO/Blob.h"
|
|
|
|
#include "DiscIO/Enums.h"
|
2017-12-31 12:33:36 -07:00
|
|
|
|
|
|
|
class PointerWrap;
|
|
|
|
|
|
|
|
namespace Core
|
|
|
|
{
|
|
|
|
class TitleDatabase;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace UICommon
|
|
|
|
{
|
|
|
|
struct GameBanner
|
|
|
|
{
|
2019-05-28 05:00:04 -06:00
|
|
|
std::vector<u32> buffer;
|
2018-03-10 14:41:49 -07:00
|
|
|
u32 width{};
|
|
|
|
u32 height{};
|
2017-12-31 12:33:36 -07:00
|
|
|
bool empty() const { return buffer.empty(); }
|
|
|
|
void DoState(PointerWrap& p);
|
|
|
|
};
|
|
|
|
|
2018-07-29 19:16:37 -06:00
|
|
|
struct GameCover
|
|
|
|
{
|
2019-05-28 05:00:04 -06:00
|
|
|
std::vector<u8> buffer;
|
2018-07-29 19:16:37 -06:00
|
|
|
bool empty() const { return buffer.empty(); }
|
|
|
|
void DoState(PointerWrap& p);
|
|
|
|
};
|
|
|
|
|
2018-03-10 14:41:49 -07:00
|
|
|
bool operator==(const GameBanner& lhs, const GameBanner& rhs);
|
|
|
|
bool operator!=(const GameBanner& lhs, const GameBanner& rhs);
|
|
|
|
|
2017-12-31 12:33:36 -07:00
|
|
|
// This class caches the metadata of a DiscIO::Volume (or a DOL/ELF file).
|
|
|
|
class GameFile final
|
|
|
|
{
|
|
|
|
public:
|
2019-09-25 03:36:45 -06:00
|
|
|
enum class Variant
|
|
|
|
{
|
|
|
|
LongAndPossiblyCustom,
|
|
|
|
LongAndNotCustom,
|
|
|
|
ShortAndNotCustom,
|
|
|
|
};
|
|
|
|
|
2019-05-28 03:53:36 -06:00
|
|
|
GameFile();
|
2019-05-28 04:57:46 -06:00
|
|
|
explicit GameFile(std::string path);
|
2019-05-28 03:53:36 -06:00
|
|
|
~GameFile();
|
2017-12-31 12:33:36 -07:00
|
|
|
|
|
|
|
bool IsValid() const;
|
|
|
|
const std::string& GetFilePath() const { return m_file_path; }
|
|
|
|
const std::string& GetFileName() const { return m_file_name; }
|
2018-06-03 04:07:53 -06:00
|
|
|
const std::string& GetName(const Core::TitleDatabase& title_database) const;
|
2019-09-25 03:36:45 -06:00
|
|
|
const std::string& GetName(Variant variant) const;
|
|
|
|
const std::string& GetMaker(Variant variant) const;
|
2017-12-31 12:33:36 -07:00
|
|
|
const std::string& GetShortName(DiscIO::Language l) const { return Lookup(l, m_short_names); }
|
|
|
|
const std::string& GetShortName() const { return LookupUsingConfigLanguage(m_short_names); }
|
|
|
|
const std::string& GetLongName(DiscIO::Language l) const { return Lookup(l, m_long_names); }
|
|
|
|
const std::string& GetLongName() const { return LookupUsingConfigLanguage(m_long_names); }
|
|
|
|
const std::string& GetShortMaker(DiscIO::Language l) const { return Lookup(l, m_short_makers); }
|
|
|
|
const std::string& GetShortMaker() const { return LookupUsingConfigLanguage(m_short_makers); }
|
|
|
|
const std::string& GetLongMaker(DiscIO::Language l) const { return Lookup(l, m_long_makers); }
|
|
|
|
const std::string& GetLongMaker() const { return LookupUsingConfigLanguage(m_long_makers); }
|
|
|
|
const std::string& GetDescription(DiscIO::Language l) const { return Lookup(l, m_descriptions); }
|
2019-09-25 03:36:45 -06:00
|
|
|
const std::string& GetDescription(Variant variant) const;
|
2017-12-31 12:33:36 -07:00
|
|
|
std::vector<DiscIO::Language> GetLanguages() const;
|
|
|
|
const std::string& GetInternalName() const { return m_internal_name; }
|
|
|
|
const std::string& GetGameID() const { return m_game_id; }
|
2019-02-23 09:49:06 -07:00
|
|
|
const std::string& GetGameTDBID() const { return m_gametdb_id; }
|
2017-12-31 12:33:36 -07:00
|
|
|
u64 GetTitleID() const { return m_title_id; }
|
|
|
|
const std::string& GetMakerID() const { return m_maker_id; }
|
|
|
|
u16 GetRevision() const { return m_revision; }
|
|
|
|
// 0 is the first disc, 1 is the second disc
|
|
|
|
u8 GetDiscNumber() const { return m_disc_number; }
|
2020-06-10 10:49:22 -06:00
|
|
|
std::string GetNetPlayName(const Core::TitleDatabase& title_database) const;
|
2020-06-07 14:58:03 -06:00
|
|
|
|
|
|
|
// This function is slow
|
|
|
|
std::array<u8, 20> GetSyncHash() const;
|
|
|
|
// This function is slow
|
|
|
|
NetPlay::SyncIdentifier GetSyncIdentifier() const;
|
|
|
|
// This function is slow if all of game_id, revision, disc_number, is_datel are identical
|
|
|
|
NetPlay::SyncIdentifierComparison
|
|
|
|
CompareSyncIdentifier(const NetPlay::SyncIdentifier& sync_identifier) const;
|
|
|
|
|
2017-12-31 12:33:36 -07:00
|
|
|
std::string GetWiiFSPath() const;
|
|
|
|
DiscIO::Region GetRegion() const { return m_region; }
|
|
|
|
DiscIO::Country GetCountry() const { return m_country; }
|
|
|
|
DiscIO::Platform GetPlatform() const { return m_platform; }
|
|
|
|
DiscIO::BlobType GetBlobType() const { return m_blob_type; }
|
2020-06-21 12:41:50 -06:00
|
|
|
u64 GetBlockSize() const { return m_block_size; }
|
|
|
|
const std::string& GetCompressionMethod() const { return m_compression_method; }
|
|
|
|
bool ShouldShowFileFormatDetails() const;
|
2020-07-19 13:18:42 -06:00
|
|
|
std::string GetFileFormatName() const;
|
2020-06-27 04:35:18 -06:00
|
|
|
bool ShouldAllowConversion() const;
|
2017-12-31 12:33:36 -07:00
|
|
|
const std::string& GetApploaderDate() const { return m_apploader_date; }
|
|
|
|
u64 GetFileSize() const { return m_file_size; }
|
|
|
|
u64 GetVolumeSize() const { return m_volume_size; }
|
2022-08-01 03:53:30 -06:00
|
|
|
DiscIO::DataSizeType GetVolumeSizeType() const { return m_volume_size_type; }
|
2020-04-11 05:06:45 -06:00
|
|
|
bool IsDatelDisc() const { return m_is_datel_disc; }
|
2021-10-02 03:09:36 -06:00
|
|
|
bool IsNKit() const { return m_is_nkit; }
|
2021-10-25 18:01:16 -06:00
|
|
|
bool IsModDescriptor() const;
|
2018-03-10 14:41:49 -07:00
|
|
|
const GameBanner& GetBannerImage() const;
|
2018-07-29 19:16:37 -06:00
|
|
|
const GameCover& GetCoverImage() const;
|
2017-12-31 12:33:36 -07:00
|
|
|
void DoState(PointerWrap& p);
|
2019-08-13 10:01:27 -06:00
|
|
|
bool XMLMetadataChanged();
|
|
|
|
void XMLMetadataCommit();
|
2018-03-10 14:41:49 -07:00
|
|
|
bool WiiBannerChanged();
|
|
|
|
void WiiBannerCommit();
|
|
|
|
bool CustomBannerChanged();
|
|
|
|
void CustomBannerCommit();
|
2018-07-29 19:16:37 -06:00
|
|
|
void DownloadDefaultCover();
|
|
|
|
bool DefaultCoverChanged();
|
|
|
|
void DefaultCoverCommit();
|
|
|
|
bool CustomCoverChanged();
|
|
|
|
void CustomCoverCommit();
|
2017-12-31 12:33:36 -07:00
|
|
|
|
|
|
|
private:
|
2019-02-23 11:18:16 -07:00
|
|
|
DiscIO::Language GetConfigLanguage() const;
|
2017-12-31 12:33:36 -07:00
|
|
|
static const std::string& Lookup(DiscIO::Language language,
|
|
|
|
const std::map<DiscIO::Language, std::string>& strings);
|
|
|
|
const std::string&
|
|
|
|
LookupUsingConfigLanguage(const std::map<DiscIO::Language, std::string>& strings) const;
|
2020-07-19 13:18:42 -06:00
|
|
|
std::string GetExtension() const;
|
2017-12-31 12:33:36 -07:00
|
|
|
bool IsElfOrDol() const;
|
2019-08-13 10:01:27 -06:00
|
|
|
bool ReadXMLMetadata(const std::string& path);
|
2018-03-10 14:41:49 -07:00
|
|
|
bool ReadPNGBanner(const std::string& path);
|
2021-10-25 18:01:16 -06:00
|
|
|
bool TryLoadGameModDescriptorBanner();
|
2017-12-31 12:33:36 -07:00
|
|
|
|
|
|
|
// IMPORTANT: Nearly all data members must be save/restored in DoState.
|
|
|
|
// If anything is changed, make sure DoState handles it properly and
|
|
|
|
// CACHE_REVISION in GameFileCache.cpp is incremented.
|
|
|
|
|
|
|
|
bool m_valid{};
|
2019-05-28 05:00:04 -06:00
|
|
|
std::string m_file_path;
|
|
|
|
std::string m_file_name;
|
2017-12-31 12:33:36 -07:00
|
|
|
|
|
|
|
u64 m_file_size{};
|
|
|
|
u64 m_volume_size{};
|
2022-08-01 03:53:30 -06:00
|
|
|
DiscIO::DataSizeType m_volume_size_type{};
|
2020-04-11 05:06:45 -06:00
|
|
|
bool m_is_datel_disc{};
|
2020-10-06 05:00:58 -06:00
|
|
|
bool m_is_nkit{};
|
2017-12-31 12:33:36 -07:00
|
|
|
|
2019-05-28 05:00:04 -06:00
|
|
|
std::map<DiscIO::Language, std::string> m_short_names;
|
|
|
|
std::map<DiscIO::Language, std::string> m_long_names;
|
|
|
|
std::map<DiscIO::Language, std::string> m_short_makers;
|
|
|
|
std::map<DiscIO::Language, std::string> m_long_makers;
|
|
|
|
std::map<DiscIO::Language, std::string> m_descriptions;
|
|
|
|
std::string m_internal_name;
|
|
|
|
std::string m_game_id;
|
|
|
|
std::string m_gametdb_id;
|
2017-12-31 12:33:36 -07:00
|
|
|
u64 m_title_id{};
|
2019-05-28 05:00:04 -06:00
|
|
|
std::string m_maker_id;
|
2017-12-31 12:33:36 -07:00
|
|
|
|
2019-05-28 03:51:47 -06:00
|
|
|
DiscIO::Region m_region{DiscIO::Region::Unknown};
|
|
|
|
DiscIO::Country m_country{DiscIO::Country::Unknown};
|
2017-12-31 12:33:36 -07:00
|
|
|
DiscIO::Platform m_platform{};
|
|
|
|
DiscIO::BlobType m_blob_type{};
|
2020-06-21 12:41:50 -06:00
|
|
|
u64 m_block_size{};
|
|
|
|
std::string m_compression_method{};
|
2017-12-31 12:33:36 -07:00
|
|
|
u16 m_revision{};
|
|
|
|
u8 m_disc_number{};
|
2019-05-28 05:00:04 -06:00
|
|
|
std::string m_apploader_date;
|
2017-12-31 12:33:36 -07:00
|
|
|
|
2019-08-13 10:01:27 -06:00
|
|
|
std::string m_custom_name;
|
|
|
|
std::string m_custom_description;
|
|
|
|
std::string m_custom_maker;
|
2017-12-31 12:33:36 -07:00
|
|
|
GameBanner m_volume_banner{};
|
2018-03-10 14:41:49 -07:00
|
|
|
GameBanner m_custom_banner{};
|
2018-07-29 19:16:37 -06:00
|
|
|
GameCover m_default_cover{};
|
|
|
|
GameCover m_custom_cover{};
|
2017-12-31 12:33:36 -07:00
|
|
|
|
|
|
|
// The following data members allow GameFileCache to construct updated versions
|
|
|
|
// of GameFiles in a threadsafe way. They should not be handled in DoState.
|
|
|
|
struct
|
|
|
|
{
|
2019-08-13 10:01:27 -06:00
|
|
|
std::string custom_name;
|
|
|
|
std::string custom_description;
|
|
|
|
std::string custom_maker;
|
2017-12-31 12:33:36 -07:00
|
|
|
GameBanner volume_banner;
|
2018-03-10 14:41:49 -07:00
|
|
|
GameBanner custom_banner;
|
2018-07-29 19:16:37 -06:00
|
|
|
GameCover default_cover;
|
|
|
|
GameCover custom_cover;
|
2017-12-31 12:33:36 -07:00
|
|
|
} m_pending{};
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace UICommon
|