mirror of
https://github.com/UltimMC/Launcher.git
synced 2026-01-01 21:18:15 +00:00
Revert "Merge pull request #9 from MultiMC/develop"
This reverts commitccc86e4e02, reversing changes made to306c655ab5.
This commit is contained in:
@@ -60,8 +60,7 @@ bool TechnicPage::shouldDisplay() const
|
||||
|
||||
void TechnicPage::openedImpl()
|
||||
{
|
||||
suggestCurrent();
|
||||
triggerSearch();
|
||||
dialog->setSuggestedPack();
|
||||
}
|
||||
|
||||
void TechnicPage::triggerSearch() {
|
||||
@@ -96,7 +95,8 @@ void TechnicPage::suggestCurrent()
|
||||
return;
|
||||
}
|
||||
|
||||
QString editedLogoName = "technic_" + current.logoName.section(".", 0, 0);
|
||||
QString editedLogoName;
|
||||
editedLogoName = "technic_" + current.logoName.section(".", 0, 0);
|
||||
model->getLogo(current.logoName, current.logoUrl, [this, editedLogoName](QString logo)
|
||||
{
|
||||
dialog->setSuggestedIconFromFile(logo, editedLogoName);
|
||||
@@ -105,66 +105,67 @@ void TechnicPage::suggestCurrent()
|
||||
if (current.metadataLoaded)
|
||||
{
|
||||
metadataLoaded();
|
||||
return;
|
||||
}
|
||||
|
||||
NetJob *netJob = new NetJob(QString("Technic::PackMeta(%1)").arg(current.name));
|
||||
std::shared_ptr<QByteArray> response = std::make_shared<QByteArray>();
|
||||
QString slug = current.slug;
|
||||
netJob->addNetAction(Net::Download::makeByteArray(QString("https://api.technicpack.net/modpack/%1?build=multimc").arg(slug), response.get()));
|
||||
QObject::connect(netJob, &NetJob::succeeded, this, [this, response, slug]
|
||||
else
|
||||
{
|
||||
if (current.slug != slug)
|
||||
NetJob *netJob = new NetJob(QString("Technic::PackMeta(%1)").arg(current.name));
|
||||
std::shared_ptr<QByteArray> response = std::make_shared<QByteArray>();
|
||||
QString slug = current.slug;
|
||||
netJob->addNetAction(Net::Download::makeByteArray(QString("https://api.technicpack.net/modpack/%1?build=multimc").arg(slug), response.get()));
|
||||
QObject::connect(netJob, &NetJob::succeeded, this, [this, response, slug]
|
||||
{
|
||||
return;
|
||||
}
|
||||
QJsonParseError parse_error;
|
||||
QJsonDocument doc = QJsonDocument::fromJson(*response, &parse_error);
|
||||
QJsonObject obj = doc.object();
|
||||
if(parse_error.error != QJsonParseError::NoError)
|
||||
{
|
||||
qWarning() << "Error while parsing JSON response from Technic at " << parse_error.offset << " reason: " << parse_error.errorString();
|
||||
qWarning() << *response;
|
||||
return;
|
||||
}
|
||||
if (!obj.contains("url"))
|
||||
{
|
||||
qWarning() << "Json doesn't contain an url key";
|
||||
return;
|
||||
}
|
||||
QJsonValueRef url = obj["url"];
|
||||
if (url.isString())
|
||||
{
|
||||
current.url = url.toString();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!obj.contains("solder"))
|
||||
if (current.slug != slug)
|
||||
{
|
||||
qWarning() << "Json doesn't contain a valid url or solder key";
|
||||
return;
|
||||
}
|
||||
QJsonValueRef solderUrl = obj["solder"];
|
||||
if (solderUrl.isString())
|
||||
QJsonParseError parse_error;
|
||||
QJsonDocument doc = QJsonDocument::fromJson(*response, &parse_error);
|
||||
QJsonObject obj = doc.object();
|
||||
if(parse_error.error != QJsonParseError::NoError)
|
||||
{
|
||||
current.url = solderUrl.toString();
|
||||
current.isSolder = true;
|
||||
qWarning() << "Error while parsing JSON response from Technic at " << parse_error.offset << " reason: " << parse_error.errorString();
|
||||
qWarning() << *response;
|
||||
return;
|
||||
}
|
||||
if (!obj.contains("url"))
|
||||
{
|
||||
qWarning() << "Json doesn't contain an url key";
|
||||
return;
|
||||
}
|
||||
QJsonValueRef url = obj["url"];
|
||||
if (url.isString())
|
||||
{
|
||||
current.url = url.toString();
|
||||
}
|
||||
else
|
||||
{
|
||||
qWarning() << "Json doesn't contain a valid url or solder key";
|
||||
return;
|
||||
if (!obj.contains("solder"))
|
||||
{
|
||||
qWarning() << "Json doesn't contain a valid url or solder key";
|
||||
return;
|
||||
}
|
||||
QJsonValueRef solderUrl = obj["solder"];
|
||||
if (solderUrl.isString())
|
||||
{
|
||||
current.url = solderUrl.toString();
|
||||
current.isSolder = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
qWarning() << "Json doesn't contain a valid url or solder key";
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
current.minecraftVersion = Json::ensureString(obj, "minecraft", QString(), "__placeholder__");
|
||||
current.websiteUrl = Json::ensureString(obj, "platformUrl", QString(), "__placeholder__");
|
||||
current.author = Json::ensureString(obj, "user", QString(), "__placeholder__");
|
||||
current.description = Json::ensureString(obj, "description", QString(), "__placeholder__");
|
||||
current.metadataLoaded = true;
|
||||
metadataLoaded();
|
||||
});
|
||||
netJob->start();
|
||||
current.minecraftVersion = Json::ensureString(obj, "minecraft", QString(), "__placeholder__");
|
||||
current.websiteUrl = Json::ensureString(obj, "platformUrl", QString(), "__placeholder__");
|
||||
current.author = Json::ensureString(obj, "user", QString(), "__placeholder__");
|
||||
current.description = Json::ensureString(obj, "description", QString(), "__placeholder__");
|
||||
current.metadataLoaded = true;
|
||||
metadataLoaded();
|
||||
});
|
||||
netJob->start();
|
||||
}
|
||||
}
|
||||
|
||||
// expects current.metadataLoaded to be true
|
||||
|
||||
Reference in New Issue
Block a user