aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--launcher/CMakeLists.txt39
-rw-r--r--launcher/ModDownloadTask.cpp72
-rw-r--r--launcher/QObjectPtr.h4
-rw-r--r--launcher/ResourceDownloadTask.cpp90
-rw-r--r--launcher/ResourceDownloadTask.h (renamed from launcher/ModDownloadTask.h)24
-rw-r--r--launcher/minecraft/PackProfile.cpp28
-rw-r--r--launcher/minecraft/PackProfile.h4
-rw-r--r--launcher/modplatform/CheckUpdateTask.h14
-rw-r--r--launcher/modplatform/EnsureMetadataTask.cpp94
-rw-r--r--launcher/modplatform/EnsureMetadataTask.h16
-rw-r--r--launcher/modplatform/ModAPI.h118
-rw-r--r--launcher/modplatform/ModIndex.cpp24
-rw-r--r--launcher/modplatform/ModIndex.h40
-rw-r--r--launcher/modplatform/ResourceAPI.h177
-rw-r--r--launcher/modplatform/flame/FlameAPI.cpp39
-rw-r--r--launcher/modplatform/flame/FlameAPI.h110
-rw-r--r--launcher/modplatform/flame/FlameCheckUpdate.cpp14
-rw-r--r--launcher/modplatform/flame/FlameCheckUpdate.h2
-rw-r--r--launcher/modplatform/flame/FlameInstanceCreationTask.cpp4
-rw-r--r--launcher/modplatform/flame/FlameInstanceCreationTask.h2
-rw-r--r--launcher/modplatform/flame/FlameModIndex.cpp8
-rw-r--r--launcher/modplatform/flame/FlameModIndex.h2
-rw-r--r--launcher/modplatform/helpers/HashUtils.cpp16
-rw-r--r--launcher/modplatform/helpers/HashUtils.h10
-rw-r--r--launcher/modplatform/helpers/NetworkModAPI.cpp97
-rw-r--r--launcher/modplatform/helpers/NetworkModAPI.h17
-rw-r--r--launcher/modplatform/helpers/NetworkResourceAPI.cpp128
-rw-r--r--launcher/modplatform/helpers/NetworkResourceAPI.h22
-rw-r--r--launcher/modplatform/modrinth/ModrinthAPI.cpp73
-rw-r--r--launcher/modplatform/modrinth/ModrinthAPI.h134
-rw-r--r--launcher/modplatform/modrinth/ModrinthCheckUpdate.cpp27
-rw-r--r--launcher/modplatform/modrinth/ModrinthCheckUpdate.h4
-rw-r--r--launcher/modplatform/modrinth/ModrinthPackIndex.cpp11
-rw-r--r--launcher/modplatform/modrinth/ModrinthPackIndex.h2
-rw-r--r--launcher/modplatform/packwiz/Packwiz.cpp8
-rw-r--r--launcher/modplatform/packwiz/Packwiz.h2
-rw-r--r--launcher/net/NetAction.h4
-rw-r--r--launcher/net/NetJob.cpp5
-rw-r--r--launcher/ui/dialogs/BlockedModsDialog.cpp2
-rw-r--r--launcher/ui/dialogs/ChooseProviderDialog.cpp6
-rw-r--r--launcher/ui/dialogs/ChooseProviderDialog.h6
-rw-r--r--launcher/ui/dialogs/ModDownloadDialog.cpp202
-rw-r--r--launcher/ui/dialogs/ModDownloadDialog.h78
-rw-r--r--launcher/ui/dialogs/ModUpdateDialog.cpp44
-rw-r--r--launcher/ui/dialogs/ModUpdateDialog.h8
-rw-r--r--launcher/ui/dialogs/ResourceDownloadDialog.cpp232
-rw-r--r--launcher/ui/dialogs/ResourceDownloadDialog.h111
-rw-r--r--launcher/ui/dialogs/ReviewMessageBox.cpp28
-rw-r--r--launcher/ui/dialogs/ReviewMessageBox.h11
-rw-r--r--launcher/ui/dialogs/ReviewMessageBox.ui14
-rw-r--r--launcher/ui/pages/instance/ManagedPackPage.cpp2
-rw-r--r--launcher/ui/pages/instance/ManagedPackPage.h4
-rw-r--r--launcher/ui/pages/instance/ModFolderPage.cpp8
-rw-r--r--launcher/ui/pages/instance/ResourcePackPage.h1
-rw-r--r--launcher/ui/pages/modplatform/ModModel.cpp348
-rw-r--r--launcher/ui/pages/modplatform/ModModel.h94
-rw-r--r--launcher/ui/pages/modplatform/ModPage.cpp361
-rw-r--r--launcher/ui/pages/modplatform/ModPage.h97
-rw-r--r--launcher/ui/pages/modplatform/ResourceModel.cpp444
-rw-r--r--launcher/ui/pages/modplatform/ResourceModel.h147
-rw-r--r--launcher/ui/pages/modplatform/ResourcePage.cpp411
-rw-r--r--launcher/ui/pages/modplatform/ResourcePage.h111
-rw-r--r--launcher/ui/pages/modplatform/ResourcePage.ui (renamed from launcher/ui/pages/modplatform/ModPage.ui)18
-rw-r--r--launcher/ui/pages/modplatform/flame/FlameModModel.cpp31
-rw-r--r--launcher/ui/pages/modplatform/flame/FlameModModel.h26
-rw-r--r--launcher/ui/pages/modplatform/flame/FlameResourceModels.cpp37
-rw-r--r--launcher/ui/pages/modplatform/flame/FlameResourceModels.h30
-rw-r--r--launcher/ui/pages/modplatform/flame/FlameResourcePages.cpp (renamed from launcher/ui/pages/modplatform/flame/FlameModPage.cpp)44
-rw-r--r--launcher/ui/pages/modplatform/flame/FlameResourcePages.h (renamed from launcher/ui/pages/modplatform/flame/FlameModPage.h)43
-rw-r--r--launcher/ui/pages/modplatform/modrinth/ModrinthModel.cpp1
-rw-r--r--launcher/ui/pages/modplatform/modrinth/ModrinthResourceModels.cpp (renamed from launcher/ui/pages/modplatform/modrinth/ModrinthModModel.cpp)26
-rw-r--r--launcher/ui/pages/modplatform/modrinth/ModrinthResourceModels.h (renamed from launcher/ui/pages/modplatform/modrinth/ModrinthModModel.h)26
-rw-r--r--launcher/ui/pages/modplatform/modrinth/ModrinthResourcePages.cpp (renamed from launcher/ui/pages/modplatform/modrinth/ModrinthModPage.cpp)60
-rw-r--r--launcher/ui/pages/modplatform/modrinth/ModrinthResourcePages.h (renamed from launcher/ui/pages/modplatform/modrinth/ModrinthModPage.h)41
-rw-r--r--launcher/ui/widgets/ProgressWidget.cpp11
-rw-r--r--launcher/ui/widgets/ProgressWidget.h6
-rw-r--r--tests/CMakeLists.txt3
-rw-r--r--tests/DummyResourceAPI.h47
-rw-r--r--tests/Packwiz_test.cpp4
-rw-r--r--tests/ResourceModel_test.cpp88
80 files changed, 2892 insertions, 1905 deletions
diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt
index 65f58667..889576b0 100644
--- a/launcher/CMakeLists.txt
+++ b/launcher/CMakeLists.txt
@@ -38,9 +38,9 @@ set(CORE_SOURCES
InstanceImportTask.h
InstanceImportTask.cpp
- # Mod downloading task
- ModDownloadTask.h
- ModDownloadTask.cpp
+ # Resource downloading task
+ ResourceDownloadTask.h
+ ResourceDownloadTask.cpp
# Use tracking separate from memory management
Usable.h
@@ -473,7 +473,7 @@ set(API_SOURCES
modplatform/ModIndex.h
modplatform/ModIndex.cpp
- modplatform/ModAPI.h
+ modplatform/ResourceAPI.h
modplatform/EnsureMetadataTask.h
modplatform/EnsureMetadataTask.cpp
@@ -484,8 +484,8 @@ set(API_SOURCES
modplatform/flame/FlameAPI.cpp
modplatform/modrinth/ModrinthAPI.h
modplatform/modrinth/ModrinthAPI.cpp
- modplatform/helpers/NetworkModAPI.h
- modplatform/helpers/NetworkModAPI.cpp
+ modplatform/helpers/NetworkResourceAPI.h
+ modplatform/helpers/NetworkResourceAPI.cpp
modplatform/helpers/HashUtils.h
modplatform/helpers/HashUtils.cpp
modplatform/helpers/OverrideUtils.h
@@ -771,6 +771,11 @@ SET(LAUNCHER_SOURCES
ui/pages/modplatform/VanillaPage.cpp
ui/pages/modplatform/VanillaPage.h
+ ui/pages/modplatform/ResourcePage.cpp
+ ui/pages/modplatform/ResourcePage.h
+ ui/pages/modplatform/ResourceModel.cpp
+ ui/pages/modplatform/ResourceModel.h
+
ui/pages/modplatform/ModPage.cpp
ui/pages/modplatform/ModPage.h
ui/pages/modplatform/ModModel.cpp
@@ -803,10 +808,10 @@ SET(LAUNCHER_SOURCES
ui/pages/modplatform/flame/FlameModel.h
ui/pages/modplatform/flame/FlamePage.cpp
ui/pages/modplatform/flame/FlamePage.h
- ui/pages/modplatform/flame/FlameModModel.cpp
- ui/pages/modplatform/flame/FlameModModel.h
- ui/pages/modplatform/flame/FlameModPage.cpp
- ui/pages/modplatform/flame/FlameModPage.h
+ ui/pages/modplatform/flame/FlameResourceModels.cpp
+ ui/pages/modplatform/flame/FlameResourceModels.h
+ ui/pages/modplatform/flame/FlameResourcePages.cpp
+ ui/pages/modplatform/flame/FlameResourcePages.h
ui/pages/modplatform/modrinth/ModrinthPage.cpp
ui/pages/modplatform/modrinth/ModrinthPage.h
@@ -821,10 +826,10 @@ SET(LAUNCHER_SOURCES
ui/pages/modplatform/ImportPage.cpp
ui/pages/modplatform/ImportPage.h
- ui/pages/modplatform/modrinth/ModrinthModModel.cpp
- ui/pages/modplatform/modrinth/ModrinthModModel.h
- ui/pages/modplatform/modrinth/ModrinthModPage.cpp
- ui/pages/modplatform/modrinth/ModrinthModPage.h
+ ui/pages/modplatform/modrinth/ModrinthResourceModels.cpp
+ ui/pages/modplatform/modrinth/ModrinthResourceModels.h
+ ui/pages/modplatform/modrinth/ModrinthResourcePages.cpp
+ ui/pages/modplatform/modrinth/ModrinthResourcePages.h
# GUI - dialogs
ui/dialogs/AboutDialog.cpp
@@ -869,8 +874,8 @@ SET(LAUNCHER_SOURCES
ui/dialogs/VersionSelectDialog.h
ui/dialogs/SkinUploadDialog.cpp
ui/dialogs/SkinUploadDialog.h
- ui/dialogs/ModDownloadDialog.cpp
- ui/dialogs/ModDownloadDialog.h
+ ui/dialogs/ResourceDownloadDialog.cpp
+ ui/dialogs/ResourceDownloadDialog.h
ui/dialogs/ScrollMessageBox.cpp
ui/dialogs/ScrollMessageBox.h
ui/dialogs/BlockedModsDialog.cpp
@@ -965,7 +970,7 @@ qt_wrap_ui(LAUNCHER_UI
ui/pages/modplatform/atlauncher/AtlOptionalModDialog.ui
ui/pages/modplatform/atlauncher/AtlPage.ui
ui/pages/modplatform/VanillaPage.ui
- ui/pages/modplatform/ModPage.ui
+ ui/pages/modplatform/ResourcePage.ui
ui/pages/modplatform/flame/FlamePage.ui
ui/pages/modplatform/legacy_ftb/Page.ui
ui/pages/modplatform/ImportPage.ui
diff --git a/launcher/ModDownloadTask.cpp b/launcher/ModDownloadTask.cpp
deleted file mode 100644
index 2b0343f4..00000000
--- a/launcher/ModDownloadTask.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-// 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 "ModDownloadTask.h"
-
-#include "Application.h"
-#include "minecraft/mod/ModFolderModel.h"
-
-ModDownloadTask::ModDownloadTask(ModPlatform::IndexedPack mod, ModPlatform::IndexedVersion version, const std::shared_ptr<ModFolderModel> mods, bool is_indexed)
- : m_mod(mod), m_mod_version(version), mods(mods)
-{
- if (is_indexed) {
- m_update_task.reset(new LocalModUpdateTask(mods->indexDir(), m_mod, m_mod_version));
- connect(m_update_task.get(), &LocalModUpdateTask::hasOldMod, this, &ModDownloadTask::hasOldMod);
-
- addTask(m_update_task);
- }
-
- m_filesNetJob.reset(new NetJob(tr("Mod download"), APPLICATION->network()));
- m_filesNetJob->setStatus(tr("Downloading mod:\n%1").arg(m_mod_version.downloadUrl));
-
- m_filesNetJob->addNetAction(Net::Download::makeFile(m_mod_version.downloadUrl, mods->dir().absoluteFilePath(getFilename())));
- connect(m_filesNetJob.get(), &NetJob::succeeded, this, &ModDownloadTask::downloadSucceeded);
- connect(m_filesNetJob.get(), &NetJob::progress, this, &ModDownloadTask::downloadProgressChanged);
- connect(m_filesNetJob.get(), &NetJob::failed, this, &ModDownloadTask::downloadFailed);
-
- addTask(m_filesNetJob);
-}
-
-void ModDownloadTask::downloadSucceeded()
-{
- m_filesNetJob.reset();
- auto name = std::get<0>(to_delete);
- auto filename = std::get<1>(to_delete);
- if (!name.isEmpty() && filename != m_mod_version.fileName) {
- mods->uninstallMod(filename, true);
- }
-}
-
-void ModDownloadTask::downloadFailed(QString reason)
-{
- emitFailed(reason);
- m_filesNetJob.reset();
-}
-
-void ModDownloadTask::downloadProgressChanged(qint64 current, qint64 total)
-{
- emit progress(current, total);
-}
-
-// This indirection is done so that we don't delete a mod before being sure it was
-// downloaded successfully!
-void ModDownloadTask::hasOldMod(QString name, QString filename)
-{
- to_delete = {name, filename};
-}
diff --git a/launcher/QObjectPtr.h b/launcher/QObjectPtr.h
index b1ef1c8d..ec466096 100644
--- a/launcher/QObjectPtr.h
+++ b/launcher/QObjectPtr.h
@@ -28,6 +28,10 @@ class shared_qobject_ptr : public QSharedPointer<T> {
constexpr shared_qobject_ptr(const shared_qobject_ptr<Derived>& other) : QSharedPointer<T>(other)
{}
+ template <typename Derived>
+ constexpr shared_qobject_ptr(const QSharedPointer<Derived>& other) : QSharedPointer<T>(other)
+ {}
+
void reset() { QSharedPointer<T>::reset(); }
void reset(const shared_qobject_ptr<T>& other)
{
diff --git a/launcher/ResourceDownloadTask.cpp b/launcher/ResourceDownloadTask.cpp
new file mode 100644
index 00000000..98bcf259
--- /dev/null
+++ b/launcher/ResourceDownloadTask.cpp
@@ -0,0 +1,90 @@
+// 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/>.
+*/
+
+#include "ResourceDownloadTask.h"
+
+#include "Application.h"
+
+#include "minecraft/mod/ModFolderModel.h"
+#include "minecraft/mod/ResourceFolderModel.h"
+
+ResourceDownloadTask::ResourceDownloadTask(ModPlatform::IndexedPack pack,
+ ModPlatform::IndexedVersion version,
+ const std::shared_ptr<ResourceFolderModel> packs,
+ bool is_indexed)
+ : m_pack(std::move(pack)), m_pack_version(std::move(version)), m_pack_model(packs)
+{
+ if (auto model = dynamic_cast<ModFolderModel*>(m_pack_model.get()); model && is_indexed) {
+ m_update_task.reset(new LocalModUpdateTask(model->indexDir(), m_pack, m_pack_version));
+ connect(m_update_task.get(), &LocalModUpdateTask::hasOldMod, this, &ResourceDownloadTask::hasOldResource);
+
+ addTask(m_update_task);
+ }
+
+ m_filesNetJob.reset(new NetJob(tr("Resource download"), APPLICATION->network()));
+ m_filesNetJob->setStatus(tr("Downloading resource:\n%1").arg(m_pack_version.downloadUrl));
+
+ QDir dir { m_pack_model->dir() };
+ {
+ // FIXME: Make this more generic. May require adding additional info to IndexedVersion,
+ // or adquiring a reference to the base instance.
+ if (!m_pack_version.custom_target_folder.isEmpty()) {
+ dir.cdUp();
+ dir.cd(m_pack_version.custom_target_folder);
+ }
+ }
+
+ m_filesNetJob->addNetAction(Net::Download::makeFile(m_pack_version.downloadUrl, dir.absoluteFilePath(getFilename())));
+ connect(m_filesNetJob.get(), &NetJob::succeeded, this, &ResourceDownloadTask::downloadSucceeded);
+ connect(m_filesNetJob.get(), &NetJob::progress, this, &ResourceDownloadTask::downloadProgressChanged);
+ connect(m_filesNetJob.get(), &NetJob::failed, this, &ResourceDownloadTask::downloadFailed);
+
+ addTask(m_filesNetJob);
+}
+
+void ResourceDownloadTask::downloadSucceeded()
+{
+ m_filesNetJob.reset();
+ auto name = std::get<0>(to_delete);
+ auto filename = std::get<1>(to_delete);
+ if (!name.isEmpty() && filename != m_pack_version.fileName) {
+ if (auto model = dynamic_cast<ModFolderModel*>(m_pack_model.get()); model)
+ model->uninstallMod(filename, true);
+ else
+ m_pack_model->uninstallResource(filename);
+ }
+}
+
+void ResourceDownloadTask::downloadFailed(QString reason)
+{
+ emitFailed(reason);
+ m_filesNetJob.reset();
+}
+
+void ResourceDownloadTask::downloadProgressChanged(qint64 current, qint64 total)
+{
+ emit progress(current, total);
+}
+
+// This indirection is done so that we don't delete a mod before being sure it was
+// downloaded successfully!
+void ResourceDownloadTask::hasOldResource(QString name, QString filename)
+{
+ to_delete = { name, filename };
+}
diff --git a/launcher/ModDownloadTask.h b/launcher/ResourceDownloadTask.h
index 95020470..73ad2d07 100644
--- a/launcher/ModDownloadTask.h
+++ b/launcher/ResourceDownloadTask.h
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
-* PolyMC - Minecraft Launcher
-* Copyright (c) 2022 flowln <flowlnlnln@gmail.com>
+* 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
@@ -25,32 +25,32 @@
#include "modplatform/ModIndex.h"
#include "minecraft/mod/tasks/LocalModUpdateTask.h"
-class ModFolderModel;
+class ResourceFolderModel;
-class ModDownloadTask : public SequentialTask {
+class ResourceDownloadTask : public SequentialTask {
Q_OBJECT
public:
- explicit ModDownloadTask(ModPlatform::IndexedPack mod, ModPlatform::IndexedVersion version, const std::shared_ptr<ModFolderModel> mods, bool is_indexed = true);
- const QString& getFilename() const { return m_mod_version.fileName; }
+ 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; }
private:
- ModPlatform::IndexedPack m_mod;
- ModPlatform::IndexedVersion m_mod_version;
- const std::shared_ptr<ModFolderModel> mods;
+ ModPlatform::IndexedPack m_pack;
+ ModPlatform::IndexedVersion m_pack_version;
+ const std::shared_ptr<ResourceFolderModel> m_pack_model;
NetJob::Ptr m_filesNetJob;
LocalModUpdateTask::Ptr m_update_task;
void downloadProgressChanged(qint64 current, qint64 total);
-
void downloadFailed(QString reason);
-
void downloadSucceeded();
std::tuple<QString, QString> to_delete {"", ""};
private slots:
- void hasOldMod(QString name, QString filename);
+ void hasOldResource(QString name, QString filename);
};
diff --git a/launcher/minecraft/PackProfile.cpp b/launcher/minecraft/PackProfile.cpp
index 43fa3f8d..42021b3c 100644
--- a/launcher/minecraft/PackProfile.cpp
+++ b/launcher/minecraft/PackProfile.cpp
@@ -55,12 +55,13 @@
#include "PackProfile_p.h"
#include "ComponentUpdateTask.h"
-#include "modplatform/ModAPI.h"
+#include "Application.h"
+#include "modplatform/ResourceAPI.h"
-static const QMap<QString, ModAPI::ModLoaderType> modloaderMapping{
- {"net.minecraftforge", ModAPI::Forge},
- {"net.fabricmc.fabric-loader", ModAPI::Fabric},
- {"org.quiltmc.quilt-loader", ModAPI::Quilt}
+static const QMap<QString, ResourceAPI::ModLoaderType> modloaderMapping{
+ {"net.minecraftforge", ResourceAPI::Forge},
+ {"net.fabricmc.fabric-loader", ResourceAPI::Fabric},
+ {"org.quiltmc.quilt-loader", ResourceAPI::Quilt}
};
PackProfile::PackProfile(MinecraftInstance * instance)
@@ -1066,19 +1067,22 @@ void PackProfile::disableInteraction(bool disable)
}
}
-ModAPI::ModLoaderTypes PackProfile::getModLoaders()
+std::optional<ResourceAPI::ModLoaderTypes