diff options
| author | Anthony <Helios747@users.noreply.github.com> | 2019-02-03 12:34:11 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-02-03 12:34:11 -0800 |
| commit | 227a26490d3e130a3cafbead528e2a174f2ccb66 (patch) | |
| tree | b8c1b028ed8ccac2e38fa9c14b143b518a865cf9 /Source | |
| parent | eee24cd1ceb7006dee3f0015d957d8d14b3a5f1e (diff) | |
| parent | b6863ff0a206a2e44efa98960defc409ade99841 (diff) | |
Merge pull request #7773 from spycrab/rp_compression
ResourcePacks: Support compression
Diffstat (limited to 'Source')
| -rw-r--r-- | Source/Core/UICommon/ResourcePack/Manifest.cpp | 10 | ||||
| -rw-r--r-- | Source/Core/UICommon/ResourcePack/Manifest.h | 2 | ||||
| -rw-r--r-- | Source/Core/UICommon/ResourcePack/ResourcePack.cpp | 4 |
3 files changed, 14 insertions, 2 deletions
diff --git a/Source/Core/UICommon/ResourcePack/Manifest.cpp b/Source/Core/UICommon/ResourcePack/Manifest.cpp index 37101b2639..9c2bc6883e 100644 --- a/Source/Core/UICommon/ResourcePack/Manifest.cpp +++ b/Source/Core/UICommon/ResourcePack/Manifest.cpp @@ -29,6 +29,7 @@ Manifest::Manifest(const std::string& json) picojson::value& authors = out.get("authors"); picojson::value& description = out.get("description"); picojson::value& website = out.get("website"); + picojson::value& compressed = out.get("compressed"); if (!name.is<std::string>() || !id.is<std::string>() || !version.is<std::string>()) { @@ -58,6 +59,9 @@ Manifest::Manifest(const std::string& json) if (website.is<std::string>()) m_website = website.to_str(); + + if (compressed.is<bool>()) + m_compressed = compressed.get<bool>(); } bool Manifest::IsValid() const @@ -99,4 +103,10 @@ const std::optional<std::string>& Manifest::GetWebsite() const { return m_website; } + +bool Manifest::IsCompressed() const +{ + return m_compressed; +} + } // namespace ResourcePack diff --git a/Source/Core/UICommon/ResourcePack/Manifest.h b/Source/Core/UICommon/ResourcePack/Manifest.h index 0c3622c9eb..57f0182c70 100644 --- a/Source/Core/UICommon/ResourcePack/Manifest.h +++ b/Source/Core/UICommon/ResourcePack/Manifest.h @@ -15,6 +15,7 @@ public: explicit Manifest(const std::string& text); bool IsValid() const; + bool IsCompressed() const; const std::string& GetName() const; const std::string& GetVersion() const; @@ -27,6 +28,7 @@ public: private: bool m_valid = true; + bool m_compressed = false; std::string m_name; std::string m_version; diff --git a/Source/Core/UICommon/ResourcePack/ResourcePack.cpp b/Source/Core/UICommon/ResourcePack/ResourcePack.cpp index 6f20c59ca9..92282626d5 100644 --- a/Source/Core/UICommon/ResourcePack/ResourcePack.cpp +++ b/Source/Core/UICommon/ResourcePack/ResourcePack.cpp @@ -126,8 +126,8 @@ ResourcePack::ResourcePack(const std::string& path) : m_path(path) if (filename.compare(0, 9, "textures/") != 0 || texture_info.uncompressed_size == 0) continue; - // If a texture is compressed, abort. - if (texture_info.compression_method != 0) + // If a texture is compressed and the manifest doesn't state that, abort. + if (!m_manifest->IsCompressed() && texture_info.compression_method != 0) { m_valid = false; m_error = "Texture " + filename + " is compressed!"; |
