From b1bdc6f745d607af4dc1bb592003a538ee03f058 Mon Sep 17 00:00:00 2001 From: Ryan Cao <70191398+ryanccn@users.noreply.github.com> Date: Sat, 19 Nov 2022 23:38:05 +0800 Subject: fix resource packs and add support for texture packs Signed-off-by: Ryan Cao <70191398+ryanccn@users.noreply.github.com> --- launcher/minecraft/mod/ResourcePack.cpp | 5 +++++ launcher/minecraft/mod/ResourcePack.h | 2 ++ launcher/minecraft/mod/TexturePack.cpp | 5 +++++ launcher/minecraft/mod/TexturePack.h | 2 ++ 4 files changed, 14 insertions(+) (limited to 'launcher/minecraft/mod') diff --git a/launcher/minecraft/mod/ResourcePack.cpp b/launcher/minecraft/mod/ResourcePack.cpp index 3fc10a2f..9f46cd2c 100644 --- a/launcher/minecraft/mod/ResourcePack.cpp +++ b/launcher/minecraft/mod/ResourcePack.cpp @@ -114,3 +114,8 @@ bool ResourcePack::applyFilter(QRegularExpression filter) const return Resource::applyFilter(filter); } + +bool ResourcePack::valid() const +{ + return m_pack_format != 0; +} diff --git a/launcher/minecraft/mod/ResourcePack.h b/launcher/minecraft/mod/ResourcePack.h index 03121908..7cb414d8 100644 --- a/launcher/minecraft/mod/ResourcePack.h +++ b/launcher/minecraft/mod/ResourcePack.h @@ -42,6 +42,8 @@ class ResourcePack : public Resource { /** Thread-safe. */ void setImage(QImage new_image); + bool valid() const override; + [[nodiscard]] auto compare(Resource const& other, SortType type) const -> std::pair override; [[nodiscard]] bool applyFilter(QRegularExpression filter) const override; diff --git a/launcher/minecraft/mod/TexturePack.cpp b/launcher/minecraft/mod/TexturePack.cpp index 796eb69d..99d55584 100644 --- a/launcher/minecraft/mod/TexturePack.cpp +++ b/launcher/minecraft/mod/TexturePack.cpp @@ -62,3 +62,8 @@ QPixmap TexturePack::image(QSize size) TexturePackUtils::process(*this); return image(size); } + +bool TexturePack::valid() const +{ + return m_description != nullptr; +} diff --git a/launcher/minecraft/mod/TexturePack.h b/launcher/minecraft/mod/TexturePack.h index 6aa5e18e..81bd5c69 100644 --- a/launcher/minecraft/mod/TexturePack.h +++ b/launcher/minecraft/mod/TexturePack.h @@ -48,6 +48,8 @@ class TexturePack : public Resource { /** Thread-safe. */ void setImage(QImage new_image); + bool valid() const override; + protected: mutable QMutex m_data_lock; -- cgit