diff options
author | Trial97 <alexandru.tripon97@gmail.com> | 2023-08-17 00:25:38 +0300 |
---|---|---|
committer | Trial97 <alexandru.tripon97@gmail.com> | 2023-08-17 00:25:38 +0300 |
commit | f8ffb146194d6dd4de79a217b616d2d11aeb26d2 (patch) | |
tree | a3869364d2d25f918d44db2f2aac020140aacd68 /launcher/ui | |
parent | 5e2d1ffdfbb3f673c063029c9a6c55071cba160a (diff) | |
parent | bad44ea264eab5ce896f51a981cf1659f2755716 (diff) | |
download | PrismLauncher-f8ffb146194d6dd4de79a217b616d2d11aeb26d2.tar.gz PrismLauncher-f8ffb146194d6dd4de79a217b616d2d11aeb26d2.tar.bz2 PrismLauncher-f8ffb146194d6dd4de79a217b616d2d11aeb26d2.zip |
Merge branch 'curseforge-url-handle' of github.com:Trial97/PrismLauncher into curseforge-url-handle
Diffstat (limited to 'launcher/ui')
-rw-r--r-- | launcher/ui/MainWindow.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index 067108f2..6736e912 100644 --- a/launcher/ui/MainWindow.cpp +++ b/launcher/ui/MainWindow.cpp @@ -43,6 +43,8 @@ #include "FileSystem.h" #include "MainWindow.h" +#include "modplatform/ModIndex.h" +#include "modplatform/flame/FlameModIndex.h" #include "ui/dialogs/ExportToModListDialog.h" #include "ui_MainWindow.h" @@ -980,6 +982,7 @@ void MainWindow::processURLs(QList<QUrl> urls) if (url.scheme().isEmpty()) url.setScheme("file"); + ModPlatform::IndexedVersion version; QMap<QString, QString> extra_info; QUrl local_url; if (!url.isLocalFile()) { // download the remote resource and identify @@ -1000,20 +1003,19 @@ void MainWindow::processURLs(QList<QUrl> urls) auto api = FlameAPI(); auto job = api.getFile(addonId, fileId, array); - QString resource_name; - connect(job.get(), &Task::failed, this, [this](QString reason) { CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show(); }); - connect(job.get(), &Task::succeeded, this, [this, array, addonId, fileId, &dl_url, &resource_name] { + connect(job.get(), &Task::succeeded, this, [this, array, addonId, fileId, &dl_url, &version] { qDebug() << "Returned CFURL Json:\n" << array->toStdString().c_str(); auto doc = Json::requireDocument(*array); auto data = Json::ensureObject(Json::ensureObject(doc.object()), "data"); // No way to find out if it's a mod or a modpack before here // And also we need to check if it ends with .zip, instead of any better way - auto fileName = Json::ensureString(data, "fileName"); + version = FlameMod::loadIndexedPackVersion(data); + auto fileName = version.fileName; // Have to use ensureString then use QUrl to get proper url encoding - dl_url = QUrl(Json::ensureString(data, "downloadUrl", "", "downloadUrl")); + dl_url = QUrl(version.downloadUrl); if (!dl_url.isValid()) { CustomMessageBox::selectable( this, tr("Error"), @@ -1024,7 +1026,6 @@ void MainWindow::processURLs(QList<QUrl> urls) } QFileInfo dl_file(dl_url.fileName()); - resource_name = Json::ensureString(data, "displayName", dl_file.completeBaseName(), "displayName"); }); { // drop stack @@ -1099,7 +1100,7 @@ void MainWindow::processURLs(QList<QUrl> urls) qWarning() << "Importing of Data Packs not supported at this time. Ignoring" << localFileName; break; case PackedResourceType::Mod: - minecraftInst->loaderModList()->installMod(localFileName); + minecraftInst->loaderModList()->installMod(localFileName, version); break; case PackedResourceType::ShaderPack: minecraftInst->shaderPackList()->installResource(localFileName); |