| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
#pragma once |
| 5 |
|
| 6 |
#include <array> |
| 7 |
#include <map> |
| 8 |
#include <string> |
| 9 |
#include <vector> |
| 10 |
|
| 11 |
#include "Common/CommonTypes.h" |
| 12 |
#include "Core/SyncIdentifier.h" |
| 13 |
#include "DiscIO/Blob.h" |
| 14 |
#include "DiscIO/Enums.h" |
| 15 |
|
| 16 |
class PointerWrap; |
| 17 |
|
| 18 |
namespace Core |
| 19 |
{ |
| 20 |
class TitleDatabase; |
| 21 |
} |
| 22 |
|
| 23 |
namespace UICommon |
| 24 |
{ |
| 25 |
struct GameBanner |
| 26 |
{ |
| 27 |
std::vector<u32> buffer; |
| 28 |
u32 width{}; |
| 29 |
u32 height{}; |
| 30 |
|
| 31 |
bool operator==(const GameBanner&) const = default; |
| 32 |
|
| 33 |
bool empty() const { return buffer.empty(); } |
| 34 |
void DoState(PointerWrap& p); |
| 35 |
}; |
| 36 |
|
| 37 |
struct GameCover |
| 38 |
{ |
| 39 |
std::vector<u8> buffer; |
| 40 |
bool empty() const { return buffer.empty(); } |
| 41 |
void DoState(PointerWrap& p); |
| 42 |
}; |
| 43 |
|
| 44 |
|
| 45 |
class GameFile final |
| 46 |
{ |
| 47 |
public: |
| 48 |
enum class Variant |
| 49 |
{ |
| 50 |
LongAndPossiblyCustom, |
| 51 |
LongAndNotCustom, |
| 52 |
ShortAndNotCustom, |
| 53 |
}; |
| 54 |
|
| 55 |
GameFile(); |
| 56 |
explicit GameFile(std::string path); |
| 57 |
~GameFile(); |
| 58 |
|
| 59 |
bool IsValid() const; |
| 60 |
const std::string& GetFilePath() const { return m_file_path; } |
| 61 |
const std::string& GetFileName() const { return m_file_name; } |
| 62 |
const std::string& GetName(const Core::TitleDatabase& title_database) const; |
| 63 |
const std::string& GetName(Variant variant) const; |
| 64 |
const std::string& GetMaker(Variant variant) const; |
| 65 |
const std::string& GetShortName(DiscIO::Language l) const { return Lookup(l, m_short_names); } |
| 66 |
const std::string& GetShortName() const { return LookupUsingConfigLanguage(m_short_names); } |
| 67 |
const std::string& GetLongName(DiscIO::Language l) const { return Lookup(l, m_long_names); } |
| 68 |
const std::string& GetLongName() const { return LookupUsingConfigLanguage(m_long_names); } |
| 69 |
const std::string& GetShortMaker(DiscIO::Language l) const { return Lookup(l, m_short_makers); } |
| 70 |
const std::string& GetShortMaker() const { return LookupUsingConfigLanguage(m_short_makers); } |
| 71 |
const std::string& GetLongMaker(DiscIO::Language l) const { return Lookup(l, m_long_makers); } |
| 72 |
const std::string& GetLongMaker() const { return LookupUsingConfigLanguage(m_long_makers); } |
| 73 |
const std::string& GetDescription(DiscIO::Language l) const { return Lookup(l, m_descriptions); } |
| 74 |
const std::string& GetDescription(Variant variant) const; |
| 75 |
std::vector<DiscIO::Language> GetLanguages() const; |
| 76 |
const std::string& GetInternalName() const { return m_internal_name; } |
| 77 |
const std::string& GetGameID() const { return m_game_id; } |
| 78 |
const std::string& GetGameTDBID() const { return m_gametdb_id; } |
| 79 |
u64 GetTitleID() const { return m_title_id; } |
| 80 |
const std::string& GetMakerID() const { return m_maker_id; } |
| 81 |
u16 GetRevision() const { return m_revision; } |
| 82 |
|
| 83 |
u8 GetDiscNumber() const { return m_disc_number; } |
| 84 |
bool IsTwoDiscGame() const { return m_is_two_disc_game; } |
| 85 |
std::string GetNetPlayName(const Core::TitleDatabase& title_database) const; |
| 86 |
|
| 87 |
|
| 88 |
std::array<u8, 20> GetSyncHash() const; |
| 89 |
|
| 90 |
NetPlay::SyncIdentifier GetSyncIdentifier() const; |
| 91 |
|
| 92 |
NetPlay::SyncIdentifierComparison |
| 93 |
CompareSyncIdentifier(const NetPlay::SyncIdentifier& sync_identifier) const; |
| 94 |
|
| 95 |
std::string GetWiiFSPath() const; |
| 96 |
DiscIO::Region GetRegion() const { return m_region; } |
| 97 |
DiscIO::Country GetCountry() const { return m_country; } |
| 98 |
DiscIO::Platform GetPlatform() const { return m_platform; } |
| 99 |
DiscIO::BlobType GetBlobType() const { return m_blob_type; } |
| 100 |
u64 GetBlockSize() const { return m_block_size; } |
| 101 |
const std::string& GetCompressionMethod() const { return m_compression_method; } |
| 102 |
bool ShouldShowFileFormatDetails() const; |
| 103 |
std::string GetFileFormatName() const; |
| 104 |
bool ShouldAllowConversion() const; |
| 105 |
const std::string& GetApploaderDate() const { return m_apploader_date; } |
| 106 |
u64 GetFileSize() const { return m_file_size; } |
| 107 |
u64 GetVolumeSize() const { return m_volume_size; } |
| 108 |
DiscIO::DataSizeType GetVolumeSizeType() const { return m_volume_size_type; } |
| 109 |
bool IsDatelDisc() const { return m_is_datel_disc; } |
| 110 |
bool IsNKit() const { return m_is_nkit; } |
| 111 |
bool IsModDescriptor() const; |
| 112 |
const GameBanner& GetBannerImage() const; |
| 113 |
const GameCover& GetCoverImage() const; |
| 114 |
void DoState(PointerWrap& p); |
| 115 |
bool XMLMetadataChanged(); |
| 116 |
void XMLMetadataCommit(); |
| 117 |
bool WiiBannerChanged(); |
| 118 |
void WiiBannerCommit(); |
| 119 |
bool CustomBannerChanged(); |
| 120 |
void CustomBannerCommit(); |
| 121 |
void DownloadDefaultCover(); |
| 122 |
bool DefaultCoverChanged(); |
| 123 |
void DefaultCoverCommit(); |
| 124 |
bool CustomCoverChanged(); |
| 125 |
void CustomCoverCommit(); |
| 126 |
|
| 127 |
private: |
| 128 |
DiscIO::Language GetConfigLanguage() const; |
| 129 |
static const std::string& Lookup(DiscIO::Language language, |
| 130 |
const std::map<DiscIO::Language, std::string>& strings); |
| 131 |
const std::string& |
| 132 |
LookupUsingConfigLanguage(const std::map<DiscIO::Language, std::string>& strings) const; |
| 133 |
std::string GetExtension() const; |
| 134 |
bool IsElfOrDol() const; |
| 135 |
bool ReadXMLMetadata(const std::string& path); |
| 136 |
bool ReadPNGBanner(const std::string& path); |
| 137 |
bool TryLoadGameModDescriptorBanner(); |
| 138 |
bool CheckIfTwoDiscGame(const std::string& game_id) const; |
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
bool m_valid{}; |
| 145 |
std::string m_file_path; |
| 146 |
std::string m_file_name; |
| 147 |
|
| 148 |
u64 m_file_size{}; |
| 149 |
u64 m_volume_size{}; |
| 150 |
DiscIO::DataSizeType m_volume_size_type{}; |
| 151 |
bool m_is_datel_disc{}; |
| 152 |
bool m_is_nkit{}; |
| 153 |
|
| 154 |
std::map<DiscIO::Language, std::string> m_short_names; |
| 155 |
std::map<DiscIO::Language, std::string> m_long_names; |
| 156 |
std::map<DiscIO::Language, std::string> m_short_makers; |
| 157 |
std::map<DiscIO::Language, std::string> m_long_makers; |
| 158 |
std::map<DiscIO::Language, std::string> m_descriptions; |
| 159 |
std::string m_internal_name; |
| 160 |
std::string m_game_id; |
| 161 |
std::string m_gametdb_id; |
| 162 |
u64 m_title_id{}; |
| 163 |
std::string m_maker_id; |
| 164 |
|
| 165 |
DiscIO::Region m_region{DiscIO::Region::Unknown}; |
| 166 |
DiscIO::Country m_country{DiscIO::Country::Unknown}; |
| 167 |
DiscIO::Platform m_platform{}; |
| 168 |
DiscIO::BlobType m_blob_type{}; |
| 169 |
u64 m_block_size{}; |
| 170 |
std::string m_compression_method{}; |
| 171 |
u16 m_revision{}; |
| 172 |
u8 m_disc_number{}; |
| 173 |
bool m_is_two_disc_game{}; |
| 174 |
std::string m_apploader_date; |
| 175 |
|
| 176 |
std::string m_custom_name; |
| 177 |
std::string m_custom_description; |
| 178 |
std::string m_custom_maker; |
| 179 |
GameBanner m_volume_banner{}; |
| 180 |
GameBanner m_custom_banner{}; |
| 181 |
GameCover m_default_cover{}; |
| 182 |
GameCover m_custom_cover{}; |
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
struct |
| 187 |
{ |
| 188 |
std::string custom_name; |
| 189 |
std::string custom_description; |
| 190 |
std::string custom_maker; |
| 191 |
GameBanner volume_banner; |
| 192 |
GameBanner custom_banner; |
| 193 |
GameCover default_cover; |
| 194 |
GameCover custom_cover; |
| 195 |
} m_pending{}; |
| 196 |
}; |
| 197 |
|
| 198 |
} |