aboutsummaryrefslogtreecommitdiff
path: root/launcher
diff options
context:
space:
mode:
Diffstat (limited to 'launcher')
-rw-r--r--launcher/CMakeLists.txt4
-rw-r--r--launcher/ResourceDownloadTask.h51
-rw-r--r--launcher/minecraft/mod/MetadataHandler.h57
-rw-r--r--launcher/minecraft/mod/tasks/GetModDependenciesTask.cpp132
-rw-r--r--launcher/minecraft/mod/tasks/GetModDependenciesTask.h65
-rw-r--r--launcher/minecraft/mod/tasks/LocalModGetAllTask.cpp52
-rw-r--r--launcher/minecraft/mod/tasks/LocalModGetAllTask.h45
-rw-r--r--launcher/minecraft/mod/tasks/LocalModUpdateTask.cpp33
-rw-r--r--launcher/modplatform/ModIndex.h9
-rw-r--r--launcher/modplatform/ResourceAPI.h24
-rw-r--r--launcher/modplatform/flame/FlameAPI.h15
-rw-r--r--launcher/modplatform/flame/FlameModIndex.cpp78
-rw-r--r--launcher/modplatform/flame/FlameModIndex.h6
-rw-r--r--launcher/modplatform/flame/FlamePackIndex.h10
-rw-r--r--launcher/modplatform/helpers/NetworkResourceAPI.cpp49
-rw-r--r--launcher/modplatform/helpers/NetworkResourceAPI.h2
-rw-r--r--launcher/modplatform/modrinth/ModrinthAPI.h35
-rw-r--r--launcher/modplatform/modrinth/ModrinthPackIndex.cpp41
-rw-r--r--launcher/modplatform/modrinth/ModrinthPackIndex.h3
-rw-r--r--launcher/modplatform/packwiz/Packwiz.cpp11
-rw-r--r--launcher/modplatform/packwiz/Packwiz.h57
-rw-r--r--launcher/ui/dialogs/ResourceDownloadDialog.cpp37
-rw-r--r--launcher/ui/pages/modplatform/ModModel.cpp16
-rw-r--r--launcher/ui/pages/modplatform/ModModel.h2
-rw-r--r--launcher/ui/pages/modplatform/ResourceModel.cpp50
-rw-r--r--launcher/ui/pages/modplatform/ResourceModel.h8
-rw-r--r--launcher/ui/pages/modplatform/ResourcePackModel.h1
-rw-r--r--launcher/ui/pages/modplatform/ResourcePage.cpp8
-rw-r--r--launcher/ui/pages/modplatform/ResourcePage.h6
-rw-r--r--launcher/ui/pages/modplatform/ShaderPackModel.h1
-rw-r--r--launcher/ui/pages/modplatform/flame/FlameResourceModels.cpp17
-rw-r--r--launcher/ui/pages/modplatform/flame/FlameResourceModels.h3
-rw-r--r--launcher/ui/pages/modplatform/modrinth/ModrinthResourceModels.cpp26
-rw-r--r--launcher/ui/pages/modplatform/modrinth/ModrinthResourceModels.h4
34 files changed, 780 insertions, 178 deletions
diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt
index 074570e3..fca8c914 100644
--- a/launcher/CMakeLists.txt
+++ b/launcher/CMakeLists.txt
@@ -359,6 +359,10 @@ set(MINECRAFT_SOURCES
minecraft/mod/tasks/LocalWorldSaveParseTask.cpp
minecraft/mod/tasks/LocalResourceParse.h
minecraft/mod/tasks/LocalResourceParse.cpp
+ minecraft/mod/tasks/GetModDependenciesTask.h
+ minecraft/mod/tasks/GetModDependenciesTask.cpp
+ minecraft/mod/tasks/LocalModGetAllTask.h
+ minecraft/mod/tasks/LocalModGetAllTask.cpp
# Assets
minecraft/AssetsUtils.h
diff --git a/launcher/ResourceDownloadTask.h b/launcher/ResourceDownloadTask.h
index 73ad2d07..f2118524 100644
--- a/launcher/ResourceDownloadTask.h
+++ b/launcher/ResourceDownloadTask.h
@@ -1,41 +1,45 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
-* Prism Launcher - Minecraft Launcher
-* Copyright (c) 2022-2023 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/>.
-*/
+ * Prism Launcher - Minecraft Launcher
+ * Copyright (c) 2022-2023 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/>.
+ */
#pragma once
#include "net/NetJob.h"
#include "tasks/SequentialTask.h"
-#include "modplatform/ModIndex.h"
#include "minecraft/mod/tasks/LocalModUpdateTask.h"
+#include "modplatform/ModIndex.h"
class ResourceFolderModel;
class ResourceDownloadTask : public SequentialTask {
Q_OBJECT
-public:
- explicit ResourceDownloadTask(ModPlatform::IndexedPack pack, ModPlatform::IndexedVersion version, const std::shared_ptr<ResourceFolderModel> packs, bool is_indexed = true);
+ public:
+ explicit ResourceDownloadTask(ModPlatform::IndexedPack pack,
+ ModPlatform::IndexedVersion version,
+ const std::shared_ptr<ResourceFolderModel> packs,
+ bool is_indexed = true);
const QString& getFilename() const { return m_pack_version.fileName; }
const QString& getCustomPath() const { return m_pack_version.custom_target_folder; }
const QVariant& getVersionID() const { return m_pack_version.fileId; }
+ const ModPlatform::IndexedVersion& getVersion() const { return m_pack_version; }
-private:
+ private:
ModPlatform::IndexedPack m_pack;
ModPlatform::IndexedVersion m_pack_version;
const std::shared_ptr<ResourceFolderModel> m_pack_model;
@@ -47,11 +51,8 @@ private:
void downloadFailed(QString reason);
void downloadSucceeded();
- std::tuple<QString, QString> to_delete {"", ""};
+ std::tuple<QString, QString> to_delete{ "", "" };
-private slots:
+ private slots:
void hasOldResource(QString name, QString filename);
};
-
-
-
diff --git a/launcher/minecraft/mod/MetadataHandler.h b/launcher/minecraft/mod/MetadataHandler.h
index 39723b49..f7f08a79 100644
--- a/launcher/minecraft/mod/MetadataHandler.h
+++ b/launcher/minecraft/mod/MetadataHandler.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/>.
-*/
+ * 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/>.
+ */
#pragma once
@@ -42,28 +42,15 @@ class Metadata {
return Packwiz::V1::createModFormat(index_dir, internal_mod, mod_slug);
}
- static void update(QDir& index_dir, ModStruct& mod)
- {
- Packwiz::V1::updateModIndex(index_dir, mod);
- }
+ static void update(QDir& index_dir, ModStruct& mod) { Packwiz::V1::updateModIndex(index_dir, mod); }
- static void remove(QDir& index_dir, QString mod_slug)
- {
- Packwiz::V1::deleteModIndex(index_dir, mod_slug);
- }
+ static void remove(QDir& index_dir, QString mod_slug) { Packwiz::V1::deleteModIndex(index_dir, mod_slug); }
- static void remove(QDir& index_dir, QVariant& mod_id)
- {
- Packwiz::V1::deleteModIndex(index_dir, mod_id);
- }
+ static void remove(QDir& index_dir, QVariant& mod_id) { Packwiz::V1::deleteModIndex(index_dir, mod_id); }
- static auto get(QDir& index_dir, QString mod_slug) -> ModStruct
- {
- return Packwiz::V1::getIndexForMod(index_dir, mod_slug);
- }
+ static auto get(QDir& index_dir, QString mod_slug) -> ModStruct { return Packwiz::V1::getIndexForMod(index_dir, mod_slug); }
- static auto get(QDir& index_dir, QVariant& mod_id) -> ModStruct
- {
- return Packwiz::V1::getIndexForMod(index_dir, mod_id);
- }
+ static auto get(QDir& index_dir, QVariant& mod_id) -> ModStruct { return Packwiz::V1::getIndexForMod(index_dir, mod_id); }
+
+ static auto getAll(QDir& index_dir) -> QList<ModStruct> { return Packwiz::V1::getAllMods(index_dir); }
};
diff --git a/launcher/minecraft/mod/tasks/GetModDependenciesTask.cpp b/launcher/minecraft/mod/tasks/GetModDependenciesTask.cpp
new file mode 100644
index 00000000..7f184765
--- /dev/null
+++ b/launcher/minecraft/mod/tasks/GetModDependenciesTask.cpp
@@ -0,0 +1,132 @@
+// 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/>.
+ */
+
+#include "GetModDependenciesTask.h"
+
+#include <QDebug>
+#include "QObjectPtr.h"
+#include "minecraft/mod/MetadataHandler.h"
+#include "minecraft/mod/tasks/LocalModGetAllTask.h"
+#include "modplatform/ModIndex.h"
+#include "tasks/ConcurrentTask.h"
+#include "tasks/SequentialTask.h"
+
+GetModDependenciesTask::GetModDependenciesTask(QDir index_dir, QList<ModPlatform::IndexedVersion> selected, NewDependecyVersionAPITask api)
+ : m_selected(selected), m_getDependenciesVersionAPI(api)
+{
+ m_getAllMods = makeShared<LocalModGetAllTask>(index_dir);
+ m_getNetworkDep = makeShared<SequentialTask>(this, "GetDepInfo");
+ connect(m_getNetworkDep.get(), &Task::finished, &loop, &QEventLoop::quit);
+ QObject::connect(m_getAllMods.get(), &LocalModGetAllTask::getAllMods, [this](QList<Metadata::ModStruct> mods) {
+ m_mods = mods;
+ prepareDependecies();
+ });
+}
+
+void GetModDependenciesTask::executeTask()
+{
+ setStatus(tr("Geting all mods"));
+ m_getAllMods->start();
+ loop.exec();
+ emitSucceeded();
+}
+
+auto GetModDependenciesTask::abort() -> bool
+{
+ emitAborted();
+ return true;
+}
+
+void GetModDependenciesTask::prepareDependecies()
+{
+ auto c_dependencies = getDependenciesForVersions(m_selected);
+ if (c_dependencies.length() == 0) {
+ m_getNetworkDep->start();
+ return;
+ }
+ for (auto dep : c_dependencies) {
+ auto task =
+ m_getDependenciesVersionAPI(dep, [this](const ModPlatform::IndexedVersion& new_version) { addDependecies(new_version, 20); });
+ m_getNetworkDep->addTask(task);
+ }
+ m_getNetworkDep->start();
+}
+
+void GetModDependenciesTask::addDependecies(const ModPlatform::IndexedVersion& new_version, int level)
+{
+ // some mutex?
+ m_dependencies.append(new_version);
+ auto c_dependencies = getDependenciesForVersion(new_version);
+ if (c_dependencies.length() == 0) {
+ return;
+ }
+ if (level == 0) {
+ qWarning() << "Dependency cycle exeeded";
+ return;
+ }
+ for (auto dep : c_dependencies) {
+ auto task = m_getDependenciesVersionAPI(
+ dep, [this, level](const ModPlatform::IndexedVersion& new_versions) { addDependecies(new_versions, level - 1); });
+ m_getNetworkDep->addTask(task);
+ }
+};
+
+QList<ModPlatform::Dependency> GetModDependenciesTask::getDependenciesForVersions(const QList<ModPlatform::IndexedVersion>& selected)
+{
+ auto c_dependencies = QList<ModPlatform::Dependency>();
+ for (auto version : selected) {
+ for (auto ver_dep : version.dependencies) {
+ if (ver_dep.type == ModPlatform::DependencyType::REQUIRED) {
+ if (auto dep = std::find_if(c_dependencies.begin(), c_dependencies.end(),
+ [&ver_dep](const auto& i) { return i.addonId == ver_dep.addonId; });
+ dep == c_dependencies.end()) { // check the current dependency list
+ if (auto dep = std::find_if(selected.begin(), selected.end(),
+ [&ver_dep](const auto& i) { return i.addonId == ver_dep.addonId; });
+ dep == selected.end()) { // check the selected versions
+ if (auto dep = std::find_if(m_mods.begin(), m_mods.end(),
+ [&ver_dep](const auto& i) { return i.project_id == ver_dep.addonId; });
+ dep == m_mods.end()) { // check the existing mods
+ c_dependencies.append(ver_dep);
+ }
+ }
+ }
+ }
+ }
+ }
+ return c_dependencies;
+};
+
+QList<ModPlatform::Dependency> GetModDependenciesTask::getDependenciesForVersion(const ModPlatform::IndexedVersion& version)
+{
+ auto c_dependencies = QList<ModPlatform::Dependency>();
+ for (auto ver_dep : version.dependencies) {
+ if (ver_dep.type == ModPlatform::DependencyType::REQUIRED) {
+ if (auto dep = std::find_if(c_dependencies.begin(), c_dependencies.end(),
+ [&ver_dep](const auto& i) { return i.addonId == ver_dep.addonId; });
+ dep == c_dependencies.end()) { // check the current dependency list
+ if (auto dep =
+ std::find_if(m_mods.begin(), m_mods.end(), [&ver_dep](const auto& i) { return i.project_id == ver_dep.addonId; });
+ dep == m_mods.end()) { // check the existing mods
+ c_dependencies.append(ver_dep);
+ }
+ }
+ }
+ }
+ return c_dependencies;
+}; \ No newline at end of file
diff --git a/launcher/minecraft/mod/tasks/GetModDependenciesTask.h b/launcher/minecraft/mod/tasks/GetModDependenciesTask.h
new file mode 100644
index 00000000..7f7e1fb1
--- /dev/null
+++ b/launcher/minecraft/mod/tasks/GetModDependenciesTask.h
@@ -0,0 +1,65 @@
+// 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/>.
+ */
+
+#pragma once
+
+#include <QDir>
+#include <QEventLoop>
+#include <functional>
+
+#include "minecraft/mod/MetadataHandler.h"
+#include "minecraft/mod/tasks/LocalModGetAllTask.h"
+#include "modplatform/ModIndex.h"
+#include "tasks/SequentialTask.h"
+#include "tasks/Task.h"
+
+class GetModDependenciesTask : public Task {
+ Q_OBJECT
+ public:
+ using Ptr = shared_qobject_ptr<GetModDependenciesTask>;
+ using LocalModGetAllTaskPtr = shared_qobject_ptr<LocalModGetAllTask>;
+
+ using NewDependecyVersionAPITask =
+ std::function<Task::Ptr(const ModPlatform::Dependency&, std::function<void(const ModPlatform::IndexedVersion&)>)>;
+
+ explicit GetModDependenciesTask(QDir index_dir, QList<ModPlatform::IndexedVersion> selected, NewDependecyVersionAPITask api);
+
+ auto canAbort() const -> bool override { return true; }
+ auto abort() -> bool override;
+
+ auto getDependecies() const -> QList<ModPlatform::IndexedVersion> { return m_dependencies; }
+
+ protected slots:
+ //! Entry point for tasks.
+ void executeTask() override;
+
+ void prepareDependecies();
+ void addDependecies(const ModPlatform::IndexedVersion&, int);
+ QList<ModPlatform::Dependency> getDependenciesForVersions(const QList<ModPlatform::IndexedVersion>&);
+ QList<ModPlatform::Dependency> getDependenciesForVersion(const ModPlatform::IndexedVersion&);
+
+ private:
+ QList<ModPlatform::IndexedVersion> m_selected;
+ QList<ModPlatform::IndexedVersion> m_dependencies;
+ QList<Metadata::ModStruct> m_mods;
+
+ LocalModGetAllTaskPtr m_getAllMods = nullptr;
+ NewDependecyVersionAPITask m_getDependenciesVersionAPI;
+ SequentialTask::Ptr m_getNetworkDep;
+ QEventLoop loop;
+};
diff --git a/launcher/minecraft/mod/tasks/LocalModGetAllTask.cpp b/launcher/minecraft/mod/tasks/LocalModGetAllTask.cpp
new file mode 100644
index 00000000..67058807
--- /dev/null
+++ b/launcher/minecraft/mod/tasks/LocalModGetAllTask.cpp
@@ -0,0 +1,52 @@
+// 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/>.
+ */
+
+#include "LocalModGetAllTask.h"
+
+#include "FileSystem.h"
+#include "minecraft/mod/MetadataHandler.h"
+
+#ifdef Q_OS_WIN32
+#include <windows.h>
+#endif
+
+LocalModGetAllTask::LocalModGetAllTask(QDir index_dir) : m_index_dir(index_dir)
+{
+ // Ensure a '.index' folder exists in the mods folder, and create it if it does not
+ if (!FS::ensureFolderPathExists(index_dir.path())) {
+ emitFailed(QString("Unable to create index for all mods!"));
+ }
+
+#ifdef Q_OS_WIN32
+ SetFileAttributesW(index_dir.path().toStdWString().c_str(), FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_NOT_CONTENT_INDEXED);
+#endif
+}
+
+void LocalModGetAllTask::executeTask()
+{
+ setStatus(tr("Geting all mods"));
+ emit getAllMods(Metadata::getAll(m_index_dir));
+ emitSucceeded();
+}
+
+auto LocalModGetAllTask::abort() -> bool
+{
+ emitAborted();
+ return true;
+}
diff --git a/launcher/minecraft/mod/tasks/LocalModGetAllTask.h b/launcher/minecraft/mod/tasks/LocalModGetAllTask.h
new file mode 100644
index 00000000..bf4b78b7
--- /dev/null
+++ b/launcher/minecraft/mod/tasks/LocalModGetAllTask.h
@@ -0,0 +1,45 @@
+// 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/>.
+ */
+
+#pragma once
+
+#include <QDir>
+
+#include "minecraft/mod/MetadataHandler.h"
+#include "tasks/Task.h"
+
+class LocalModGetAllTask : public Task {
+ Q_OBJECT
+ public:
+ using Ptr = shared_qobject_ptr<LocalModGetAllTask>;
+
+ explicit LocalModGetAllTask(QDir index_dir);
+
+ auto canAbort() const -> bool override { return true; }
+ auto abort() -> bool override;
+
+ protected slots:
+ //! Entry point for tasks.
+ void executeTask() override;
+
+ signals:
+ void getAllMods(QList<Metadata::ModStruct>);
+
+ private:
+ QDir m_index_dir;
+};
diff --git a/launcher/minecraft/mod/tasks/LocalModUpdateTask.cpp b/launcher/minecraft/mod/tasks/LocalModUpdateTask.cpp
index cc4e252c..6b139ca1 100644
--- a/launcher/minecraft/mod/tasks/LocalModUpdateTask.cpp
+++ b/launcher/minecraft/mod/tasks/LocalModUpdateTask.cpp
@@ -1,25 +1,24 @@
// 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/>.
-*/
+ * 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/>.
+ */
#include "LocalModUpdateTask.h"
-#include "Application.h"
#include "FileSystem.h"
#include "minecraft/mod/MetadataHandler.h"
diff --git a/launcher/modplatform/ModIndex.h b/launcher/modplatform/ModIndex.h
index 40f1efc4..ffa3a3ab 100644
--- a/launcher/modplatform/ModIndex.h
+++ b/launcher/modplatform/ModIndex.h
@@ -32,6 +32,8 @@ enum class ResourceProvider { MODRINTH, FLAME };
enum class ResourceType { MOD, RESOURCE_PACK, SHADER_PACK };
+enum class DependencyType { REQUIRED, OPTIONAL, INCOMPATIBLE, EMBEDDED, TOOL, INCLUDE };
+
class ProviderCapabilities {
public:
auto name(ResourceProvider) -> const char*;
@@ -51,6 +53,12 @@ struct DonationData {
QString url;
};
+struct Dependency {
+ QVariant addonId;
+ DependencyType type;
+ QString version;
+};
+
struct IndexedVersion {
QVariant addonId;
QVariant fileId;
@@ -65,6 +73,7 @@ struct IndexedVersion {
QString hash;
bool is_preferred = true;
QString changelog;
+ QList<Dependency> dependencies;
// For internal use, not provided by APIs
bool is_currently_selected = false;
diff --git a/launcher/modplatform/ResourceAPI.h b/launcher/modplatform/ResourceAPI.h
index 34f33779..c23444b3 100644
--- a/launcher/modplatform/ResourceAPI.h
+++ b/launcher/modplatform/ResourceAPI.h
@@ -111,6 +111,24 @@ class ResourceAPI {
std::function<void(QJsonDocument&, ModPlatform::IndexedPack)> on_succeed;
};
+ struct DependencySearchArgs {
+ ModPlatform::Dependency dependency;
+ Version mcVersion;
+ ModLoaderTypes loader;
+
+ DependencySearchArgs(DependencySearchArgs const&) = default;
+ void operator=(DependencySearchArgs other)
+ {
+ dependency = other.dependency;
+ mcVersion = other.mcVersion;
+ loader = other.loader;
+ }
+ };
+
+ struct DependencySearchCallbacks {
+ std::function<void(QJsonDocument&, const ModPlatform::Dependency&)> on_succeed;
+ };
+
public:
/** Gets a list of available sorting methods for this API. */
[[nodiscard]] virtual auto getSortingMethods() const -> QList<SortingMethod> = 0;
@@ -143,6 +161,12 @@ class ResourceAPI {
return nullptr;
}
+ [[nodiscard]] virtual Task::Ptr getDependencyVersion(DependencySearchArgs&&, DependencySearchCallbacks&&) const
+ {
+ qWarning() << "TODO";
+ return nullptr;
+ }
+
static auto getModLoaderString(ModLoaderType type) -> const QString
{
switch (type) {
diff --git a/launcher/modplatform/flame/FlameAPI.h b/launcher/modplatform/flame/FlameAPI.h
index 5811d717..91993e64 100644
--- a/launcher/modplatform/flame/FlameAPI.h
+++ b/launcher/modplatform/flame/FlameAPI.h
@@ -41,14 +41,15 @@ class FlameAPI : public NetworkResourceAPI {
return 4;
// TODO: remove this once Quilt drops official Fabric support
if (loaders & Quilt) // NOTE: Most if not all Fabric mods should work *currently*
- return 4; // Quilt would probably be 5
+ return 4; // Quilt would probably be 5
return 0;
}
private:
[[nodiscard]] std::optional<QString> getSearchURL(SearchArgs const& args) const override
{
- auto gameVersionStr = args.versions.has_value() ? QString("gameVersion=%1").arg(args.versions.value().front().toString()) : QString();
+ auto gameVersionStr =
+ args.versions.has_value() ? QString("gameVersion=%1").arg(args.versions.value().front().toString()) : QString();
QStringList get_arguments;
get_arguments.append(QString("classId=%1").arg(getClassId(args.type)));
@@ -73,7 +74,7 @@ class FlameAPI : public NetworkResourceAPI {
[[nodiscard]] std::optional<QString> getVersionsURL(VersionSearchArgs const& args) const override
{
- QString url{QString("https://api.curseforge.com/v1/mods/%1/files?pageSize=10000&").arg(args.pack.addonId.toString())};
+ QString url{ QString("https://api.curseforge.com/v1/mods/%1/files?pageSize=10000&").arg(args.pack.addonId.toString()) };
QStringList get_parameters;
if (args.mcVersions.has_value())
@@ -83,4 +84,12 @@ class FlameAPI : public NetworkResourceAPI {
return url + get_parameters.join('&');
};
+
+ [[nodiscard]] std::optional<QString> getDependecyURL(DependencySearchArgs const& args) const override
+ {
+ return QString("https://api.curseforge.com/v1/mods/%1/files?pageSize=10000&gameVersion=%2&modLoaderType=%")
+ .arg(args.dependency.addonId.toString())
+ .arg(args.mcVersion.toString())
+ .arg(getMappedModLoader(args.loader));
+ };
};
diff --git a/launcher/modplatform/flame/FlameModIndex.cpp b/launcher/modplatform/flame/FlameModIndex.cpp
index 7498e830..120bfc91 100644
--- a/