summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorJosJuice <josjuice@gmail.com>2020-06-21 20:41:50 +0200
committerJosJuice <josjuice@gmail.com>2020-06-21 20:47:23 +0200
commitd494e0230c2ebfd580bb66b2a741d19ef830d658 (patch)
treeedd701dfdd98be00f0971dc747eea0dcbe5f7c71 /Source/Core
parent99822518994d62def4e336f6746d6a2e2d108fb2 (diff)
Show file format details in game properties
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/DiscIO/Blob.cpp30
-rw-r--r--Source/Core/DiscIO/Blob.h3
-rw-r--r--Source/Core/DiscIO/CISOBlob.h1
-rw-r--r--Source/Core/DiscIO/CompressedBlob.h1
-rw-r--r--Source/Core/DiscIO/DirectoryBlob.h1
-rw-r--r--Source/Core/DiscIO/DriveBlob.h1
-rw-r--r--Source/Core/DiscIO/FileBlob.h1
-rw-r--r--Source/Core/DiscIO/ScrubbedBlob.h4
-rw-r--r--Source/Core/DiscIO/TGCBlob.h1
-rw-r--r--Source/Core/DiscIO/VolumeFileBlobReader.cpp5
-rw-r--r--Source/Core/DiscIO/VolumeFileBlobReader.h1
-rw-r--r--Source/Core/DiscIO/WIABlob.cpp20
-rw-r--r--Source/Core/DiscIO/WIABlob.h1
-rw-r--r--Source/Core/DiscIO/WbfsBlob.h1
-rw-r--r--Source/Core/DolphinQt/Config/InfoWidget.cpp53
-rw-r--r--Source/Core/DolphinQt/Config/InfoWidget.h3
-rw-r--r--Source/Core/UICommon/GameFile.cpp27
-rw-r--r--Source/Core/UICommon/GameFile.h5
-rw-r--r--Source/Core/UICommon/GameFileCache.cpp2
19 files changed, 150 insertions, 11 deletions
diff --git a/Source/Core/DiscIO/Blob.cpp b/Source/Core/DiscIO/Blob.cpp
index 50146c9c91..e24c52f181 100644
--- a/Source/Core/DiscIO/Blob.cpp
+++ b/Source/Core/DiscIO/Blob.cpp
@@ -12,6 +12,7 @@
#include "Common/CDUtils.h"
#include "Common/CommonTypes.h"
#include "Common/File.h"
+#include "Common/MsgHandler.h"
#include "DiscIO/Blob.h"
#include "DiscIO/CISOBlob.h"
@@ -25,6 +26,35 @@
namespace DiscIO
{
+std::string GetName(BlobType blob_type, bool translate)
+{
+ const auto translate_str = [translate](const std::string& str) {
+ return translate ? Common::GetStringT(str.c_str()) : str;
+ };
+
+ switch (blob_type)
+ {
+ case BlobType::PLAIN:
+ return "ISO";
+ case BlobType::DIRECTORY:
+ return translate_str("Directory");
+ case BlobType::GCZ:
+ return "GCZ";
+ case BlobType::CISO:
+ return "CISO";
+ case BlobType::WBFS:
+ return "WBFS";
+ case BlobType::TGC:
+ return "TGC";
+ case BlobType::WIA:
+ return "WIA";
+ case BlobType::RVZ:
+ return "RVZ";
+ default:
+ return "";
+ }
+}
+
void SectorReader::SetSectorSize(int blocksize)
{
m_block_size = std::max(blocksize, 0);
diff --git a/Source/Core/DiscIO/Blob.h b/Source/Core/DiscIO/Blob.h
index e2a1c3c9e9..aa5274618a 100644
--- a/Source/Core/DiscIO/Blob.h
+++ b/Source/Core/DiscIO/Blob.h
@@ -41,6 +41,8 @@ enum class BlobType
RVZ,
};
+std::string GetName(BlobType blob_type, bool translate);
+
class BlobReader
{
public:
@@ -55,6 +57,7 @@ public:
// Returns 0 if the format does not use blocks
virtual u64 GetBlockSize() const = 0;
virtual bool HasFastRandomAccessInBlock() const = 0;
+ virtual std::string GetCompressionMethod() const = 0;
// NOT thread-safe - can't call this from multiple threads.
virtual bool Read(u64 offset, u64 size, u8* out_ptr) = 0;
diff --git a/Source/Core/DiscIO/CISOBlob.h b/Source/Core/DiscIO/CISOBlob.h
index 40d44aaa9d..97ef23ab5e 100644
--- a/Source/Core/DiscIO/CISOBlob.h
+++ b/Source/Core/DiscIO/CISOBlob.h
@@ -46,6 +46,7 @@ public:
u64 GetBlockSize() const override { return m_block_size; }
bool HasFastRandomAccessInBlock() const override { return true; }
+ std::string GetCompressionMethod() const override { return {}; }
bool Read(u64 offset, u64 nbytes, u8* out_ptr) override;
diff --git a/Source/Core/DiscIO/CompressedBlob.h b/Source/Core/DiscIO/CompressedBlob.h
index 602d21d91a..d1b2459145 100644
--- a/Source/Core/DiscIO/CompressedBlob.h
+++ b/Source/Core/DiscIO/CompressedBlob.h
@@ -58,6 +58,7 @@ public:
u64 GetBlockSize() const override { return m_header.block_size; }
bool HasFastRandomAccessInBlock() const override { return false; }
+ std::string GetCompressionMethod() const override { return "Deflate"; }
u64 GetBlockCompressedSize(u64 block_num) const;
bool GetBlock(u64 block_num, u8* out_ptr) override;
diff --git a/Source/Core/DiscIO/DirectoryBlob.h b/Source/Core/DiscIO/DirectoryBlob.h
index d526c26ea2..9e6a834151 100644
--- a/Source/Core/DiscIO/DirectoryBlob.h
+++ b/Source/Core/DiscIO/DirectoryBlob.h
@@ -168,6 +168,7 @@ public:
u64 GetBlockSize() const override { return 0; }
bool HasFastRandomAccessInBlock() const override { return true; }
+ std::string GetCompressionMethod() const override { return {}; }
private:
struct PartitionWithType
diff --git a/Source/Core/DiscIO/DriveBlob.h b/Source/Core/DiscIO/DriveBlob.h
index 65356feb41..ec100185e8 100644
--- a/Source/Core/DiscIO/DriveBlob.h
+++ b/Source/Core/DiscIO/DriveBlob.h
@@ -32,6 +32,7 @@ public:
u64 GetBlockSize() const override { return ECC_BLOCK_SIZE; }
bool HasFastRandomAccessInBlock() const override { return false; }
+ std::string GetCompressionMethod() const override { return {}; }
private:
DriveReader(const std::string& drive);
diff --git a/Source/Core/DiscIO/FileBlob.h b/Source/Core/DiscIO/FileBlob.h
index bb97cea7e4..d418976fa3 100644
--- a/Source/Core/DiscIO/FileBlob.h
+++ b/Source/Core/DiscIO/FileBlob.h
@@ -27,6 +27,7 @@ public:
u64 GetBlockSize() const override { return 0; }
bool HasFastRandomAccessInBlock() const override { return true; }
+ std::string GetCompressionMethod() const override { return {}; }
bool Read(u64 offset, u64 nbytes, u8* out_ptr) override;
diff --git a/Source/Core/DiscIO/ScrubbedBlob.h b/Source/Core/DiscIO/ScrubbedBlob.h
index badeb457f8..5bd8652ad5 100644
--- a/Source/Core/DiscIO/ScrubbedBlob.h
+++ b/Source/Core/DiscIO/ScrubbedBlob.h
@@ -30,6 +30,10 @@ public:
{
return m_blob_reader->HasFastRandomAccessInBlock();
}
+ std::string GetCompressionMethod() const override
+ {
+ return m_blob_reader->GetCompressionMethod();
+ }
bool Read(u64 offset, u64 size, u8* out_ptr) override;
diff --git a/Source/Core/DiscIO/TGCBlob.h b/Source/Core/DiscIO/TGCBlob.h
index b76a282d6e..101e969c89 100644
--- a/Source/Core/DiscIO/TGCBlob.h
+++ b/Source/Core/DiscIO/TGCBlob.h
@@ -50,6 +50,7 @@ public:
u64 GetBlockSize() const override { return 0; }
bool HasFastRandomAccessInBlock() const override { return true; }
+ std::string GetCompressionMethod() const override { return {}; }
bool Read(u64 offset, u64 nbytes, u8* out_ptr) override;
diff --git a/Source/Core/DiscIO/VolumeFileBlobReader.cpp b/Source/Core/DiscIO/VolumeFileBlobReader.cpp
index eb80003adc..3f50f1332d 100644
--- a/Source/Core/DiscIO/VolumeFileBlobReader.cpp
+++ b/Source/Core/DiscIO/VolumeFileBlobReader.cpp
@@ -54,6 +54,11 @@ bool VolumeFileBlobReader::HasFastRandomAccessInBlock() const
return m_volume.GetBlobReader().HasFastRandomAccessInBlock();
}
+std::string VolumeFileBlobReader::GetCompressionMethod() const
+{
+ return m_volume.GetBlobReader().GetCompressionMethod();
+}
+
bool VolumeFileBlobReader::Read(u64 offset, u64 length, u8* out_ptr)
{
if (offset + length > m_file_info->GetSize())
diff --git a/Source/Core/DiscIO/VolumeFileBlobReader.h b/Source/Core/DiscIO/VolumeFileBlobReader.h
index 8e227ece63..5cdb7baf7c 100644
--- a/Source/Core/DiscIO/VolumeFileBlobReader.h
+++ b/Source/Core/DiscIO/VolumeFileBlobReader.h
@@ -30,6 +30,7 @@ public:
u64 GetBlockSize() const override;
bool HasFastRandomAccessInBlock() const override;
+ std::string GetCompressionMethod() const override;
bool Read(u64 offset, u64 length, u8* out_ptr) override;
diff --git a/Source/Core/DiscIO/WIABlob.cpp b/Source/Core/DiscIO/WIABlob.cpp
index 6f64b3ba01..4886ceaf7c 100644
--- a/Source/Core/DiscIO/WIABlob.cpp
+++ b/Source/Core/DiscIO/WIABlob.cpp
@@ -291,6 +291,26 @@ BlobType WIARVZFileReader<RVZ>::GetBlobType() const
}
template <bool RVZ>
+std::string WIARVZFileReader<RVZ>::GetCompressionMethod() const
+{
+ switch (m_compression_type)
+ {
+ case WIARVZCompressionType::Purge:
+ return "Purge";
+ case WIARVZCompressionType::Bzip2:
+ return "bzip2";
+ case WIARVZCompressionType::LZMA:
+ return "LZMA";
+ case WIARVZCompressionType::LZMA2:
+ return "LZMA2";
+ case WIARVZCompressionType::Zstd:
+ return "Zstandard";
+ default:
+ return {};
+ }
+}
+
+template <bool RVZ>
bool WIARVZFileReader<RVZ>::Read(u64 offset, u64 size, u8* out_ptr)
{
if (offset + size > Common::swap64(m_header_1.iso_file_size))
diff --git a/Source/Core/DiscIO/WIABlob.h b/Source/Core/DiscIO/WIABlob.h
index 789a3e7dd5..8f941ce98b 100644
--- a/Source/Core/DiscIO/WIABlob.h
+++ b/Source/Core/DiscIO/WIABlob.h
@@ -56,6 +56,7 @@ public:
u64 GetBlockSize() const override { return Common::swap32(m_header_2.chunk_size); }
bool HasFastRandomAccessInBlock() const override { return false; }
+ std::string GetCompressionMethod() const override;
bool Read(u64 offset, u64 size, u8* out_ptr) override;
bool SupportsReadWiiDecrypted() const override;
diff --git a/Source/Core/DiscIO/WbfsBlob.h b/Source/Core/DiscIO/WbfsBlob.h
index 0f985fe3d4..d3bca22ecc 100644
--- a/Source/Core/DiscIO/WbfsBlob.h
+++ b/Source/Core/DiscIO/WbfsBlob.h
@@ -34,6 +34,7 @@ public:
u64 GetBlockSize() const override { return m_wbfs_sector_size; }
bool HasFastRandomAccessInBlock() const override { return true; }
+ std::string GetCompressionMethod() const override { return {}; }
bool Read(u64 offset, u64 nbytes, u8* out_ptr) override;
diff --git a/Source/Core/DolphinQt/Config/InfoWidget.cpp b/Source/Core/DolphinQt/Config/InfoWidget.cpp
index 9d7c643a14..3bcd186fb1 100644
--- a/Source/Core/DolphinQt/Config/InfoWidget.cpp
+++ b/Source/Core/DolphinQt/Config/InfoWidget.cpp
@@ -27,7 +27,8 @@ InfoWidget::InfoWidget(const UICommon::GameFile& game) : m_game(game)
{
QVBoxLayout* layout = new QVBoxLayout();
- layout->addWidget(CreateISODetails());
+ layout->addWidget(CreateFileDetails());
+ layout->addWidget(CreateGameDetails());
if (!game.GetLanguages().empty())
layout->addWidget(CreateBannerDetails());
@@ -35,20 +36,55 @@ InfoWidget::InfoWidget(const UICommon::GameFile& game) : m_game(game)
setLayout(layout);
}
-QGroupBox* InfoWidget::CreateISODetails()
+QGroupBox* InfoWidget::CreateFileDetails()
+{
+ QGroupBox* group = new QGroupBox(tr("File Details"));
+ QFormLayout* layout = new QFormLayout;
+
+ layout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
+
+ QString path = QDir::toNativeSeparators(QString::fromStdString(m_game.GetFilePath()));
+ layout->addRow(tr("Path:"), CreateValueDisplay(path));
+
+ const std::string file_size = UICommon::FormatSize(m_game.GetFileSize());
+
+ if (!m_game.ShouldShowFileFormatDetails())
+ {
+ layout->addRow(tr("File Size:"), CreateValueDisplay(file_size));
+ }
+ else
+ {
+ const QString file_format =
+ QStringLiteral("%1 (%2)")
+ .arg(QString::fromStdString(DiscIO::GetName(m_game.GetBlobType(), true)))
+ .arg(QString::fromStdString(file_size));
+ layout->addRow(tr("File Format:"), CreateValueDisplay(file_format));
+
+ QString compression = QString::fromStdString(m_game.GetCompressionMethod());
+ if (compression.isEmpty())
+ compression = tr("No Compression");
+ layout->addRow(tr("Compression:"), CreateValueDisplay(compression));
+
+ if (m_game.GetBlockSize() > 0)
+ {
+ const std::string block_size = UICommon::FormatSize(m_game.GetBlockSize(), 0);
+ layout->addRow(tr("Block Size:"), CreateValueDisplay(block_size));
+ }
+ }
+
+ group->setLayout(layout);
+ return group;
+}
+
+QGroupBox* InfoWidget::CreateGameDetails()
{
const QString UNKNOWN_NAME = tr("Unknown");
- QGroupBox* group = new QGroupBox(tr("ISO Details"));
+ QGroupBox* group = new QGroupBox(tr("Game Details"));
QFormLayout* layout = new QFormLayout;
layout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
- QLineEdit* file_path = CreateValueDisplay(
- QStringLiteral("%1 (%2)")
- .arg(QDir::toNativeSeparators(QString::fromStdString(m_game.GetFilePath())))
- .arg(QString::fromStdString(UICommon::FormatSize(m_game.GetFileSize()))));
-
const QString game_name = QString::fromStdString(m_game.GetInternalName());
bool is_disc_based = m_game.GetPlatform() == DiscIO::Platform::GameCubeDisc ||
@@ -79,7 +115,6 @@ QGroupBox* InfoWidget::CreateISODetails()
m_game.GetMakerID() + ")");
layout->addRow(tr("Name:"), internal_name);
- layout->addRow(tr("File:"), file_path);
layout->addRow(tr("Game ID:"), game_id);
layout->addRow(tr("Country:"), country);
layout->addRow(tr("Maker:"), maker);
diff --git a/Source/Core/DolphinQt/Config/InfoWidget.h b/Source/Core/DolphinQt/Config/InfoWidget.h
index c409b0eb85..e32474f996 100644
--- a/Source/Core/DolphinQt/Config/InfoWidget.h
+++ b/Source/Core/DolphinQt/Config/InfoWidget.h
@@ -26,8 +26,9 @@ private:
void ChangeLanguage();
void SaveBanner();
+ QGroupBox* CreateFileDetails();
+ QGroupBox* CreateGameDetails();
QGroupBox* CreateBannerDetails();
- QGroupBox* CreateISODetails();
QLineEdit* CreateValueDisplay(const QString& value);
QLineEdit* CreateValueDisplay(const std::string& value = "");
void CreateLanguageSelector();
diff --git a/Source/Core/UICommon/GameFile.cpp b/Source/Core/UICommon/GameFile.cpp
index ca5c53ae31..31a3fa4d26 100644
--- a/Source/Core/UICommon/GameFile.cpp
+++ b/Source/Core/UICommon/GameFile.cpp
@@ -115,6 +115,8 @@ GameFile::GameFile(std::string path) : m_file_path(std::move(path))
m_region = volume->GetRegion();
m_country = volume->GetCountry();
m_blob_type = volume->GetBlobType();
+ m_block_size = volume->GetBlobReader().GetBlockSize();
+ m_compression_method = volume->GetBlobReader().GetCompressionMethod();
m_file_size = volume->GetRawSize();
m_volume_size = volume->GetSize();
m_volume_size_is_accurate = volume->IsSizeAccurate();
@@ -320,6 +322,8 @@ void GameFile::DoState(PointerWrap& p)
p.Do(m_country);
p.Do(m_platform);
p.Do(m_blob_type);
+ p.Do(m_block_size);
+ p.Do(m_compression_method);
p.Do(m_revision);
p.Do(m_disc_number);
p.Do(m_apploader_date);
@@ -566,6 +570,29 @@ std::string GameFile::GetWiiFSPath() const
return Common::GetTitleDataPath(m_title_id, Common::FROM_CONFIGURED_ROOT);
}
+bool GameFile::ShouldShowFileFormatDetails() const
+{
+ switch (m_blob_type)
+ {
+ case DiscIO::BlobType::PLAIN:
+ break;
+ case DiscIO::BlobType::DRIVE:
+ return false;
+ default:
+ return true;
+ }
+
+ switch (m_platform)
+ {
+ case DiscIO::Platform::WiiWAD:
+ return false;
+ case DiscIO::Platform::ELFOrDOL:
+ return false;
+ default:
+ return true;
+ }
+}
+
const GameBanner& GameFile::GetBannerImage() const
{
return m_custom_banner.empty() ? m_volume_banner : m_custom_banner;
diff --git a/Source/Core/UICommon/GameFile.h b/Source/Core/UICommon/GameFile.h
index e3c29860f4..3450111238 100644
--- a/Source/Core/UICommon/GameFile.h
+++ b/Source/Core/UICommon/GameFile.h
@@ -86,6 +86,9 @@ public:
DiscIO::Country GetCountry() const { return m_country; }
DiscIO::Platform GetPlatform() const { return m_platform; }
DiscIO::BlobType GetBlobType() const { return m_blob_type; }
+ u64 GetBlockSize() const { return m_block_size; }
+ const std::string& GetCompressionMethod() const { return m_compression_method; }
+ bool ShouldShowFileFormatDetails() const;
const std::string& GetApploaderDate() const { return m_apploader_date; }
u64 GetFileSize() const { return m_file_size; }
u64 GetVolumeSize() const { return m_volume_size; }
@@ -144,6 +147,8 @@ private:
DiscIO::Country m_country{DiscIO::Country::Unknown};
DiscIO::Platform m_platform{};
DiscIO::BlobType m_blob_type{};
+ u64 m_block_size{};
+ std::string m_compression_method{};
u16 m_revision{};
u8 m_disc_number{};
std::string m_apploader_date;
diff --git a/Source/Core/UICommon/GameFileCache.cpp b/Source/Core/UICommon/GameFileCache.cpp
index 1af33ae44b..c551016d7f 100644
--- a/Source/Core/UICommon/GameFileCache.cpp
+++ b/Source/Core/UICommon/GameFileCache.cpp
@@ -27,7 +27,7 @@
namespace UICommon
{
-static constexpr u32 CACHE_REVISION = 17; // Last changed in PR 8738
+static constexpr u32 CACHE_REVISION = 18; // Last changed in PR 8891
std::vector<std::string> FindAllGamePaths(const std::vector<std::string>& directories_to_scan,
bool recursive_scan)