Merge pull request #1532 from Trial97/curseforge-url-handle
This commit is contained in:
@ -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"
|
||||
|
||||
@ -924,6 +926,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
|
||||
@ -949,20 +952,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"),
|
||||
@ -973,7 +975,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
|
||||
@ -1048,7 +1049,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);
|
||||
|
Reference in New Issue
Block a user