aboutsummaryrefslogtreecommitdiff
path: root/launcher/minecraft/mod/tasks/LocalTexturePackParseTask.cpp
diff options
context:
space:
mode:
authorSefa Eyeoglu <contact@scrumplex.net>2022-12-14 23:22:27 +0100
committerSefa Eyeoglu <contact@scrumplex.net>2022-12-14 23:22:27 +0100
commit849b92665e0762a38a7e17403015e2b037318aec (patch)
tree2fbeac111297727aa6613aacc08e80dcec5c3724 /launcher/minecraft/mod/tasks/LocalTexturePackParseTask.cpp
parentfdbd8d9d2b2e04cd68fd800882309b40c05aba2c (diff)
parentd193ed9eebb392b259edb88a227dce4cee773df6 (diff)
downloadPrismLauncher-849b92665e0762a38a7e17403015e2b037318aec.tar.gz
PrismLauncher-849b92665e0762a38a7e17403015e2b037318aec.tar.bz2
PrismLauncher-849b92665e0762a38a7e17403015e2b037318aec.zip
Merge branch 'develop' into remove-updater
Diffstat (limited to 'launcher/minecraft/mod/tasks/LocalTexturePackParseTask.cpp')
-rw-r--r--launcher/minecraft/mod/tasks/LocalTexturePackParseTask.cpp27
1 files changed, 20 insertions, 7 deletions
diff --git a/launcher/minecraft/mod/tasks/LocalTexturePackParseTask.cpp b/launcher/minecraft/mod/tasks/LocalTexturePackParseTask.cpp
index bf1e308f..adb19aca 100644
--- a/launcher/minecraft/mod/tasks/LocalTexturePackParseTask.cpp
+++ b/launcher/minecraft/mod/tasks/LocalTexturePackParseTask.cpp
@@ -28,14 +28,14 @@
namespace TexturePackUtils {
-bool process(TexturePack& pack)
+bool process(TexturePack& pack, ProcessingLevel level)
{
switch (pack.type()) {
case ResourceType::FOLDER:
- TexturePackUtils::processFolder(pack);
+ TexturePackUtils::processFolder(pack, level);
return true;
case ResourceType::ZIPFILE:
- TexturePackUtils::processZIP(pack);
+ TexturePackUtils::processZIP(pack, level);
return true;
default:
qWarning() << "Invalid type for resource pack parse task!";
@@ -43,7 +43,7 @@ bool process(TexturePack& pack)
}
}
-void processFolder(TexturePack& pack)
+void processFolder(TexturePack& pack, ProcessingLevel level)
{
Q_ASSERT(pack.type() == ResourceType::FOLDER);
@@ -60,6 +60,9 @@ void processFolder(TexturePack& pack)
mcmeta_file.close();
}
+ if (level == ProcessingLevel::BasicInfoOnly)
+ return;
+
QFileInfo image_file_info(FS::PathCombine(pack.fileinfo().filePath(), "pack.png"));
if (image_file_info.isFile()) {
QFile mcmeta_file(image_file_info.filePath());
@@ -74,7 +77,7 @@ void processFolder(TexturePack& pack)
}
}
-void processZIP(TexturePack& pack)
+void processZIP(TexturePack& pack, ProcessingLevel level)
{
Q_ASSERT(pack.type() == ResourceType::ZIPFILE);
@@ -98,6 +101,11 @@ void processZIP(TexturePack& pack)
file.close();
}
+ if (level == ProcessingLevel::BasicInfoOnly) {
+ zip.close();
+ return;
+ }
+
if (zip.setCurrentFile("pack.png")) {
if (!file.open(QIODevice::ReadOnly)) {
qCritical() << "Failed to open file in zip.";
@@ -129,6 +137,13 @@ void processPackPNG(TexturePack& pack, QByteArray&& raw_data)
qWarning() << "Failed to parse pack.png.";
}
}
+
+bool validate(QFileInfo file)
+{
+ TexturePack rp{ file };
+ return TexturePackUtils::process(rp, ProcessingLevel::BasicInfoOnly) && rp.valid();
+}
+
} // namespace TexturePackUtils
LocalTexturePackParseTask::LocalTexturePackParseTask(int token, TexturePack& rp)
@@ -143,8 +158,6 @@ bool LocalTexturePackParseTask::abort()
void LocalTexturePackParseTask::executeTask()
{
- Q_ASSERT(m_texture_pack.valid());
-
if (!TexturePackUtils::process(m_texture_pack))
return;