aboutsummaryrefslogtreecommitdiff
path: root/launcher/minecraft/mod/tasks
diff options
context:
space:
mode:
Diffstat (limited to 'launcher/minecraft/mod/tasks')
-rw-r--r--launcher/minecraft/mod/tasks/BasicFolderLoadTask.h12
-rw-r--r--launcher/minecraft/mod/tasks/LocalModParseTask.cpp33
-rw-r--r--launcher/minecraft/mod/tasks/LocalModUpdateTask.h30
-rw-r--r--launcher/minecraft/mod/tasks/LocalResourcePackParseTask.cpp10
-rw-r--r--launcher/minecraft/mod/tasks/LocalResourcePackParseTask.h2
-rw-r--r--launcher/minecraft/mod/tasks/LocalResourceParse.cpp38
-rw-r--r--launcher/minecraft/mod/tasks/LocalTexturePackParseTask.cpp13
-rw-r--r--launcher/minecraft/mod/tasks/LocalTexturePackParseTask.h2
-rw-r--r--launcher/minecraft/mod/tasks/LocalWorldSaveParseTask.cpp8
-rw-r--r--launcher/minecraft/mod/tasks/LocalWorldSaveParseTask.h2
-rw-r--r--launcher/minecraft/mod/tasks/ModFolderLoadTask.cpp79
-rw-r--r--launcher/minecraft/mod/tasks/ModFolderLoadTask.h82
12 files changed, 149 insertions, 162 deletions
diff --git a/launcher/minecraft/mod/tasks/BasicFolderLoadTask.h b/launcher/minecraft/mod/tasks/BasicFolderLoadTask.h
index 3ee7e2e0..23a2b649 100644
--- a/launcher/minecraft/mod/tasks/BasicFolderLoadTask.h
+++ b/launcher/minecraft/mod/tasks/BasicFolderLoadTask.h
@@ -26,12 +26,14 @@ class BasicFolderLoadTask : public Task {
public:
BasicFolderLoadTask(QDir dir) : Task(nullptr, false), m_dir(dir), m_result(new Result), m_thread_to_spawn_into(thread())
{
- m_create_func = [](QFileInfo const& entry) -> Resource::Ptr {
- return makeShared<Resource>(entry);
- };
+ m_create_func = [](QFileInfo const& entry) -> Resource::Ptr { return makeShared<Resource>(entry); };
}
BasicFolderLoadTask(QDir dir, std::function<Resource::Ptr(QFileInfo const&)> create_function)
- : Task(nullptr, false), m_dir(dir), m_result(new Result), m_create_func(std::move(create_function)), m_thread_to_spawn_into(thread())
+ : Task(nullptr, false)
+ , m_dir(dir)
+ , m_result(new Result)
+ , m_create_func(std::move(create_function))
+ , m_thread_to_spawn_into(thread())
{}
[[nodiscard]] bool canAbort() const override { return true; }
@@ -59,7 +61,7 @@ class BasicFolderLoadTask : public Task {
emitSucceeded();
}
-private:
+ private:
QDir m_dir;
ResultPtr m_result;
diff --git a/launcher/minecraft/mod/tasks/LocalModParseTask.cpp b/launcher/minecraft/mod/tasks/LocalModParseTask.cpp
index 264019f8..75bb6d25 100644
--- a/launcher/minecraft/mod/tasks/LocalModParseTask.cpp
+++ b/launcher/minecraft/mod/tasks/LocalModParseTask.cpp
@@ -1,9 +1,9 @@
#include "LocalModParseTask.h"
+#include <qdcss.h>
#include <quazip/quazip.h>
#include <quazip/quazipfile.h>
#include <toml++/toml.h>
-#include <qdcss.h>
#include <QJsonArray>
#include <QJsonDocument>
#include <QJsonObject>
@@ -181,7 +181,7 @@ ModDetails ReadMCModTOML(QByteArray contents)
QString license = "";
if (auto licenseDatum = tomlData["license"].as_string()) {
license = QString::fromStdString(licenseDatum->get());
- } else if (auto licenseDatum =(*modsTable)["license"].as_string()) {
+ } else if (auto licenseDatum = (*modsTable)["license"].as_string()) {
license = QString::fromStdString(licenseDatum->get());
}
if (!license.isEmpty())
@@ -190,7 +190,7 @@ ModDetails ReadMCModTOML(QByteArray contents)
QString logoFile = "";
if (auto logoFileDatum = tomlData["logoFile"].as_string()) {
logoFile = QString::fromStdString(logoFileDatum->get());
- } else if (auto logoFileDatum =(*modsTable)["logoFile"].as_string()) {
+ } else if (auto logoFileDatum = (*modsTable)["logoFile"].as_string()) {
logoFile = QString::fromStdString(logoFileDatum->get());
}
details.icon_file = logoFile;
@@ -271,7 +271,7 @@ ModDetails ReadFabricModInfo(QByteArray contents)
if (largest > 0) {
auto key = QString::number(largest) + "x" + QString::number(largest);
details.icon_file = obj.value(key).toString();
- } else { // parsing the sizes failed
+ } else { // parsing the sizes failed
// take the first
for (auto i : obj) {
details.icon_file = i.toString();
@@ -358,7 +358,7 @@ ModDetails ReadQuiltModInfo(QByteArray contents)
if (largest > 0) {
auto key = QString::number(largest) + "x" + QString::number(largest);
details.icon_file = obj.value(key).toString();
- } else { // parsing the sizes failed
+ } else { // parsing the sizes failed
// take the first
for (auto i : obj) {
details.icon_file = i.toString();
@@ -369,12 +369,11 @@ ModDetails ReadQuiltModInfo(QByteArray contents)
details.icon_file = icon.toString();
}
}
-
}
return details;
}
-ModDetails ReadForgeInfo(QString fileName)
+ModDetails ReadForgeInfo(QByteArray contents)
{
ModDetails details;
// Read the data
@@ -382,7 +381,7 @@ ModDetails ReadForgeInfo(QString fileName)
details.mod_id = "Forge";
details.homeurl = "http://www.minecraftforge.net/forum/";
INIFile ini;
- if (!ini.loadFile(fileName))
+ if (!ini.loadFile(contents))
return details;
QString major = ini.get("forge.major.number", "0").toString();
@@ -554,7 +553,7 @@ bool processZIP(Mod& mod, ProcessingLevel level)
return false;
}
- details = ReadForgeInfo(file.getFileName());
+ details = ReadForgeInfo(file.readAll());
file.close();
zip.close();
@@ -659,7 +658,8 @@ bool processIconPNG(const Mod& mod, QByteArray&& raw_data)
return true;
}
-bool loadIconFile(const Mod& mod) {
+bool loadIconFile(const Mod& mod)
+{
if (mod.iconPath().isEmpty()) {
qWarning() << "No Iconfile set, be sure to parse the mod first";
return false;
@@ -671,15 +671,14 @@ bool loadIconFile(const Mod& mod) {
};
switch (mod.type()) {
- case ResourceType::FOLDER:
- {
+ case ResourceType::FOLDER: {
QFileInfo icon_info(FS::PathCombine(mod.fileinfo().filePath(), mod.iconPath()));
if (icon_info.exists() && icon_info.isFile()) {
QFile icon(icon_info.filePath());
if (!icon.open(QIODevice::ReadOnly))
return false;
auto data = icon.readAll();
-
+
bool icon_result = ModUtils::processIconPNG(mod, std::move(data));
icon.close();
@@ -689,8 +688,7 @@ bool loadIconFile(const Mod& mod) {
}
}
}
- case ResourceType::ZIPFILE:
- {
+ case ResourceType::ZIPFILE: {
QuaZip zip(mod.fileinfo().filePath());
if (!zip.open(QuaZip::mdUnzip))
return false;
@@ -716,9 +714,8 @@ bool loadIconFile(const Mod& mod) {
return png_invalid(); // could not set icon as current file.
}
}
- case ResourceType::LITEMOD:
- {
- return false; // can lightmods even have icons?
+ case ResourceType::LITEMOD: {
+ return false; // can lightmods even have icons?
}
default:
qWarning() << "Invalid type for mod, can not load icon.";
diff --git a/launcher/minecraft/mod/tasks/LocalModUpdateTask.h b/launcher/minecraft/mod/tasks/LocalModUpdateTask.h
index 1d2f06a6..08099929 100644
--- a/launcher/minecraft/mod/tasks/LocalModUpdateTask.h
+++ b/launcher/minecraft/mod/tasks/LocalModUpdateTask.h
@@ -1,20 +1,20 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
-* PolyMC - Minecraft Launcher
-* Copyright (c) 2022 flowln <flowlnlnln@gmail.com>
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, version 3.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <https://www.gnu.org/licenses/>.
-*/
+ * Prism Launcher - Minecraft Launcher
+ * Copyright (c) 2022 flowln <flowlnlnln@gmail.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
#pragma once
diff --git a/launcher/minecraft/mod/tasks/LocalResourcePackParseTask.cpp b/launcher/minecraft/mod/tasks/LocalResourcePackParseTask.cpp
index a67c56a8..73cbf891 100644
--- a/launcher/minecraft/mod/tasks/LocalResourcePackParseTask.cpp
+++ b/launcher/minecraft/mod/tasks/LocalResourcePackParseTask.cpp
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (c) 2022 flowln <flowlnlnln@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
@@ -207,15 +207,14 @@ bool processPackPNG(const ResourcePack& pack, QByteArray&& raw_data)
}
bool processPackPNG(const ResourcePack& pack)
-{
+{
auto png_invalid = [&pack]() {
qWarning() << "Resource pack at" << pack.fileinfo().filePath() << "does not have a valid pack.png";
return false;
};
switch (pack.type()) {
- case ResourceType::FOLDER:
- {
+ case ResourceType::FOLDER: {
QFileInfo image_file_info(FS::PathCombine(pack.fileinfo().filePath(), "pack.png"));
if (image_file_info.exists() && image_file_info.isFile()) {
QFile pack_png_file(image_file_info.filePath());
@@ -234,8 +233,7 @@ bool processPackPNG(const ResourcePack& pack)
return png_invalid(); // pack.png does not exists or is not a valid file.
}
}
- case ResourceType::ZIPFILE:
- {
+ case ResourceType::ZIPFILE: {
Q_ASSERT(pack.type() == ResourceType::ZIPFILE);
QuaZip zip(pack.fileinfo().filePath());
diff --git a/launcher/minecraft/mod/tasks/LocalResourcePackParseTask.h b/launcher/minecraft/mod/tasks/LocalResourcePackParseTask.h
index 58d90b3b..5199bf3f 100644
--- a/launcher/minecraft/mod/tasks/LocalResourcePackParseTask.h
+++ b/launcher/minecraft/mod/tasks/LocalResourcePackParseTask.h
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (c) 2022 flowln <flowlnlnln@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
diff --git a/launcher/minecraft/mod/tasks/LocalResourceParse.cpp b/launcher/minecraft/mod/tasks/LocalResourceParse.cpp
index 4d760df2..d5a09083 100644
--- a/launcher/minecraft/mod/tasks/LocalResourceParse.cpp
+++ b/launcher/minecraft/mod/tasks/LocalResourceParse.cpp
@@ -19,7 +19,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-#include <QObject>
+#include <QObject>
#include "LocalResourceParse.h"
@@ -30,21 +30,23 @@
#include "LocalTexturePackParseTask.h"
#include "LocalWorldSaveParseTask.h"
-
-static const QMap<PackedResourceType, QString> s_packed_type_names = {
- {PackedResourceType::ResourcePack, QObject::tr("resource pack")},
- {PackedResourceType::TexturePack, QObject::tr("texture pack")},
- {PackedResourceType::DataPack, QObject::tr("data pack")},
- {PackedResourceType::ShaderPack, QObject::tr("shader pack")},
- {PackedResourceType::WorldSave, QObject::tr("world save")},
- {PackedResourceType::Mod , QObject::tr("mod")},
- {PackedResourceType::UNKNOWN, QObject::tr("unknown")}
-};
+static const QMap<PackedResourceType, QString> s_packed_type_names = { { PackedResourceType::ResourcePack, QObject::tr("resource pack") },
+ { PackedResourceType::TexturePack, QObject::tr("texture pack") },
+ { PackedResourceType::DataPack, QObject::tr("data pack") },
+ { PackedResourceType::ShaderPack, QObject::tr("shader pack") },
+ { PackedResourceType::WorldSave, QObject::tr("world save") },
+ { PackedResourceType::Mod, QObject::tr("mod") },
+ { PackedResourceType::UNKNOWN, QObject::tr("unknown") } };
namespace ResourceUtils {
-PackedResourceType identify(QFileInfo file){
+PackedResourceType identify(QFileInfo file)
+{
if (file.exists() && file.isFile()) {
- if (ResourcePackUtils::validate(file)) {
+ if (ModUtils::validate(file)) {
+ // mods can contain resource and data packs so they must be tested first
+ qDebug() << file.fileName() << "is a mod";
+ return PackedResourceType::Mod;
+ } else if (ResourcePackUtils::validate(file)) {
qDebug() << file.fileName() << "is a resource pack";
return PackedResourceType::ResourcePack;
} else if (TexturePackUtils::validate(file)) {
@@ -53,9 +55,6 @@ PackedResourceType identify(QFileInfo file){
} else if (DataPackUtils::validate(file)) {
qDebug() << file.fileName() << "is a data pack";
return PackedResourceType::DataPack;
- } else if (ModUtils::validate(file)) {
- qDebug() << file.fileName() << "is a mod";
- return PackedResourceType::Mod;
} else if (WorldSaveUtils::validate(file)) {
qDebug() << file.fileName() << "is a world save";
return PackedResourceType::WorldSave;
@@ -63,7 +62,7 @@ PackedResourceType identify(QFileInfo file){
qDebug() << file.fileName() << "is a shader pack";
return PackedResourceType::ShaderPack;
} else {
- qDebug() << "Can't Identify" << file.fileName() ;
+ qDebug() << "Can't Identify" << file.fileName();
}
} else {
qDebug() << "Can't find" << file.absolutePath();
@@ -71,8 +70,9 @@ PackedResourceType identify(QFileInfo file){
return PackedResourceType::UNKNOWN;
}
-QString getPackedTypeName(PackedResourceType type) {
+QString getPackedTypeName(PackedResourceType type)
+{
return s_packed_type_names.constFind(type).value();
}
-}
+} // namespace ResourceUtils
diff --git a/launcher/minecraft/mod/tasks/LocalTexturePackParseTask.cpp b/launcher/minecraft/mod/tasks/LocalTexturePackParseTask.cpp
index a72e8115..887a1062 100644
--- a/launcher/minecraft/mod/tasks/LocalTexturePackParseTask.cpp
+++ b/launcher/minecraft/mod/tasks/LocalTexturePackParseTask.cpp
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (c) 2022 flowln <flowlnlnln@gmail.com>
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
*
@@ -161,15 +161,14 @@ bool processPackPNG(const TexturePack& pack, QByteArray&& raw_data)
}
bool processPackPNG(const TexturePack& pack)
-{
+{
auto png_invalid = [&pack]() {
qWarning() << "Texture pack at" << pack.fileinfo().filePath() << "does not have a valid pack.png";
return false;
};
switch (pack.type()) {
- case ResourceType::FOLDER:
- {
+ case ResourceType::FOLDER: {
QFileInfo image_file_info(FS::PathCombine(pack.fileinfo().filePath(), "pack.png"));
if (image_file_info.exists() && image_file_info.isFile()) {
QFile pack_png_file(image_file_info.filePath());
@@ -188,8 +187,7 @@ bool processPackPNG(const TexturePack& pack)
return png_invalid(); // pack.png does not exists or is not a valid file.
}
}
- case ResourceType::ZIPFILE:
- {
+ case ResourceType::ZIPFILE: {
Q_ASSERT(pack.type() == ResourceType::ZIPFILE);
QuaZip zip(pack.fileinfo().filePath());
@@ -232,8 +230,7 @@ bool validate(QFileInfo file)
} // namespace TexturePackUtils
-LocalTexturePackParseTask::LocalTexturePackParseTask(int token, TexturePack& rp)
- : Task(nullptr, false), m_token(token), m_texture_pack(rp)
+LocalTexturePackParseTask::LocalTexturePackParseTask(int token, TexturePack& rp) : Task(nullptr, false), m_token(token), m_texture_pack(rp)
{}
bool LocalTexturePackParseTask::abort()
diff --git a/launcher/minecraft/mod/tasks/LocalTexturePackParseTask.h b/launcher/minecraft/mod/tasks/LocalTexturePackParseTask.h
index 6b91565a..1341590f 100644
--- a/launcher/minecraft/mod/tasks/LocalTexturePackParseTask.h
+++ b/launcher/minecraft/mod/tasks/LocalTexturePackParseTask.h
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (c) 2022 flowln <flowlnlnln@gmail.com>
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
*
diff --git a/launcher/minecraft/mod/tasks/LocalWorldSaveParseTask.cpp b/launcher/minecraft/mod/tasks/LocalWorldSaveParseTask.cpp
index cbc8f8ce..9d564ddb 100644
--- a/launcher/minecraft/mod/tasks/LocalWorldSaveParseTask.cpp
+++ b/launcher/minecraft/mod/tasks/LocalWorldSaveParseTask.cpp
@@ -50,8 +50,8 @@ bool process(WorldSave& pack, ProcessingLevel level)
/// @param dir the path to check
/// @param saves used in recursive call if a "saves" dir was found
/// @return std::tuple of (
-/// bool <found level.dat>,
-/// QString <name of folder containing level.dat>,
+/// bool <found level.dat>,
+/// QString <name of folder containing level.dat>,
/// bool <saves folder found>
/// )
static std::tuple<bool, QString, bool> contains_level_dat(QDir dir, bool saves = false)
@@ -101,8 +101,8 @@ bool processFolder(WorldSave& save, ProcessingLevel level)
/// @brief checks a folder structure to see if it contains a level.dat
/// @param zip the zip file to check
/// @return std::tuple of (
-/// bool <found level.dat>,
-/// QString <name of folder containing level.dat>,
+/// bool <found level.dat>,
+/// QString <name of folder containing level.dat>,
/// bool <saves folder found>
/// )
static std::tuple<bool, QString, bool> contains_level_dat(QuaZip& zip)
diff --git a/launcher/minecraft/mod/tasks/LocalWorldSaveParseTask.h b/launcher/minecraft/mod/tasks/LocalWorldSaveParseTask.h
index 9dcdca2b..12f677b0 100644
--- a/launcher/minecraft/mod/tasks/LocalWorldSaveParseTask.h
+++ b/launcher/minecraft/mod/tasks/LocalWorldSaveParseTask.h
@@ -39,7 +39,7 @@ bool processFolder(WorldSave& pack, ProcessingLevel level = ProcessingLevel::Ful
bool validate(QFileInfo file);
-} // namespace WorldSaveUtils
+} // namespace WorldSaveUtils
class LocalWorldSaveParseTask : public Task {
Q_OBJECT
diff --git a/launcher/minecraft/mod/tasks/ModFolderLoadTask.cpp b/launcher/minecraft/mod/tasks/ModFolderLoadTask.cpp
index 3677a1dc..9f79ba09 100644
--- a/launcher/minecraft/mod/tasks/ModFolderLoadTask.cpp
+++ b/launcher/minecraft/mod/tasks/ModFolderLoadTask.cpp
@@ -1,38 +1,38 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
-* PolyMC - Minecraft Launcher
-* Copyright (c) 2022 flowln <flowlnlnln@gmail.com>
-* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, version 3.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <https://www.gnu.org/licenses/>.
-*
-* This file incorporates work covered by the following copyright and
-* permission notice:
-*
-* Copyright 2013-2021 MultiMC Contributors
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ * Prism Launcher - Minecraft Launcher
+ * Copyright (c) 2022 flowln <flowlnlnln@gmail.com>
+ * Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * This file incorporates work covered by the following copyright and
+ * permission notice:
+ *
+ * Copyright 2013-2021 MultiMC Contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#include "ModFolderLoadTask.h"
@@ -70,13 +70,11 @@ void ModFolderLoadTask::executeTask()
m_result->mods[mod->internal_id()]->setStatus(ModStatus::Installed);
// Delete the object we just created, since a valid one is already in the mods list.
delete mod;
- }
- else {
+ } else {
m_result->mods[mod->internal_id()].reset(std::move(mod));
m_result->mods[mod->internal_id()]->setStatus(ModStatus::NoMetadata);
}
- }
- else {
+ } else {
QString chopped_id = mod->internal_id().chopped(9);
if (m_result->mods.contains(chopped_id)) {
m_result->mods[mod->internal_id()].reset(std::move(mod));
@@ -88,8 +86,7 @@ void ModFolderLoadTask::executeTask()
m_result->mods[mod->internal_id()]->setStatus(ModStatus::Installed);
m_result->mods.remove(chopped_id);
}
- }
- else {
+ } else {
m_result->mods[mod->internal_id()].reset(std::move(mod));
m_result->mods[mod->internal_id()]->setStatus(ModStatus::NoMetadata);
}
@@ -103,7 +100,7 @@ void ModFolderLoadTask::executeTask()
while (iter.hasNext()) {
auto mod = iter.next().value();
if (mod->status() == ModStatus::NotInstalled) {
- mod->destroy(m_index_dir, false);
+ mod->destroy(m_index_dir, false, false);
iter.remove();
}
}
@@ -124,7 +121,7 @@ void ModFolderLoadTask::getFromMetadata()
for (auto entry : m_index_dir.entryList(QDir::Files)) {
auto metadata = Metadata::get(m_index_dir, entry);
- if(!metadata.isValid()){
+ if (!metadata.isValid()) {
return;
}
diff --git a/launcher/minecraft/mod/tasks/ModFolderLoadTask.h b/launcher/minecraft/mod/tasks/ModFolderLoadTask.h
index af5f58a5..4200ef6d 100644
--- a/launcher/minecraft/mod/tasks/ModFolderLoadTask.h
+++ b/launcher/minecraft/mod/tasks/ModFolderLoadTask.h
@@ -1,38 +1,38 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
-* PolyMC - Minecraft Launcher
-* Copyright (c) 2022 flowln <flowlnlnln@gmail.com>
-* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, version 3.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <https://www.gnu.org/licenses/>.
-*
-* This file incorporates work covered by the following copyright and
-* permission notice:
-*
-* Copyright 2013-2021 MultiMC Contributors
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ * Prism Launcher - Minecraft Launcher
+ * Copyright (c) 2022 flowln <flowlnlnln@gmail.com>
+ * Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * This file incorporates work covered by the following copyright and
+ * permission notice:
+ *
+ * Copyright 2013-2021 MultiMC Contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#pragma once
@@ -44,19 +44,16 @@
#include "minecraft/mod/Mod.h"
#include "tasks/Task.h"
-class ModFolderLoadTask : public Task
-{
+class ModFolderLoadTask : public Task {
Q_OBJECT
-public:
+ public:
struct Result {
QMap<QString, Mod::Ptr> mods;
};
using ResultPtr = std::shared_ptr<Result>;
- ResultPtr result() const {
- return m_result;
- }
+ ResultPtr result() const { return m_result; }
-public:
+ public:
ModFolderLoadTask(QDir mods_dir, QDir index_dir, bool is_indexed, bool clean_orphan = false);
[[nodiscard]] bool canAbort() const override { return true; }
@@ -66,13 +63,12 @@ public:
return true;
}
-
void executeTask() override;
-private:
+ private:
void getFromMetadata();
-private:
+ private:
QDir m_mods_dir, m_index_dir;
bool m_is_indexed;
bool m_clean_orphan;