mirror of
https://github.com/MultiMC/MultiMC5.git
synced 2024-09-03 21:49:13 +00:00
NOISSUE remove liteloader and forge
This commit is contained in:
parent
f6eb8fa1e4
commit
40cf38bc32
@ -296,22 +296,10 @@ set(MINECRAFT_SOURCES
|
||||
minecraft/AssetsUtils.cpp
|
||||
|
||||
# Forge and all things forge related
|
||||
minecraft/forge/ForgeVersion.h
|
||||
minecraft/forge/ForgeVersion.cpp
|
||||
minecraft/forge/ForgeVersionList.h
|
||||
minecraft/forge/ForgeVersionList.cpp
|
||||
minecraft/forge/ForgeXzDownload.h
|
||||
minecraft/forge/ForgeXzDownload.cpp
|
||||
minecraft/forge/LegacyForge.h
|
||||
minecraft/forge/LegacyForge.cpp
|
||||
minecraft/forge/ForgeInstaller.h
|
||||
minecraft/forge/ForgeInstaller.cpp
|
||||
|
||||
# Liteloader and related things
|
||||
minecraft/liteloader/LiteLoaderInstaller.h
|
||||
minecraft/liteloader/LiteLoaderInstaller.cpp
|
||||
minecraft/liteloader/LiteLoaderVersionList.h
|
||||
minecraft/liteloader/LiteLoaderVersionList.cpp
|
||||
# Skin upload utilities
|
||||
minecraft/SkinUpload.cpp
|
||||
minecraft/SkinUpload.h
|
||||
)
|
||||
|
@ -621,6 +621,11 @@ void MinecraftProfile::installJarMods(QStringList selectedFiles)
|
||||
m_strategy->installJarMods(selectedFiles);
|
||||
}
|
||||
|
||||
void MinecraftProfile::installVersion(BaseVersionPtr version)
|
||||
{
|
||||
// TODO: implement
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO: get rid of this. Get rid of all order numbers.
|
||||
*/
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "Library.h"
|
||||
#include "VersionFile.h"
|
||||
#include "JarMod.h"
|
||||
#include "BaseVersion.h"
|
||||
#include "MojangDownloadInfo.h"
|
||||
|
||||
#include "multimc_logic_export.h"
|
||||
@ -58,6 +59,9 @@ public:
|
||||
/// install more jar mods
|
||||
void installJarMods(QStringList selectedFiles);
|
||||
|
||||
/// install more jar mods
|
||||
void installVersion(BaseVersionPtr version);
|
||||
|
||||
/// DEPRECATED, remove ASAP
|
||||
int getFreeOrderNumber();
|
||||
|
||||
|
@ -1,465 +0,0 @@
|
||||
/* Copyright 2013-2017 MultiMC Contributors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ForgeInstaller.h"
|
||||
#include "ForgeVersionList.h"
|
||||
|
||||
#include "minecraft/MinecraftProfile.h"
|
||||
#include "minecraft/GradleSpecifier.h"
|
||||
#include "net/HttpMetaCache.h"
|
||||
#include "tasks/Task.h"
|
||||
#include "minecraft/onesix/OneSixInstance.h"
|
||||
#include <minecraft/onesix/OneSixVersionFormat.h>
|
||||
#include "minecraft/VersionFilterData.h"
|
||||
#include "Env.h"
|
||||
#include "Exception.h"
|
||||
#include <FileSystem.h>
|
||||
|
||||
#include <quazip.h>
|
||||
#include <quazipfile.h>
|
||||
#include <QStringList>
|
||||
#include <QRegularExpression>
|
||||
#include <QRegularExpressionMatch>
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonArray>
|
||||
#include <QSaveFile>
|
||||
#include <QCryptographicHash>
|
||||
|
||||
ForgeInstaller::ForgeInstaller() : BaseInstaller()
|
||||
{
|
||||
}
|
||||
|
||||
void ForgeInstaller::prepare(const QString &filename, const QString &universalUrl)
|
||||
{
|
||||
VersionFilePtr newVersion;
|
||||
m_universal_url = universalUrl;
|
||||
|
||||
QuaZip zip(filename);
|
||||
if (!zip.open(QuaZip::mdUnzip))
|
||||
return;
|
||||
|
||||
QuaZipFile file(&zip);
|
||||
|
||||
// read the install profile
|
||||
if (!zip.setCurrentFile("install_profile.json"))
|
||||
return;
|
||||
|
||||
QJsonParseError jsonError;
|
||||
if (!file.open(QIODevice::ReadOnly))
|
||||
return;
|
||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(file.readAll(), &jsonError);
|
||||
file.close();
|
||||
if (jsonError.error != QJsonParseError::NoError)
|
||||
return;
|
||||
|
||||
if (!jsonDoc.isObject())
|
||||
return;
|
||||
|
||||
QJsonObject root = jsonDoc.object();
|
||||
|
||||
auto installVal = root.value("install");
|
||||
auto versionInfoVal = root.value("versionInfo");
|
||||
if (!installVal.isObject() || !versionInfoVal.isObject())
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
newVersion = OneSixVersionFormat::versionFileFromJson(QJsonDocument(versionInfoVal.toObject()), QString(), false);
|
||||
}
|
||||
catch(Exception &err)
|
||||
{
|
||||
qWarning() << "Forge: Fatal error while parsing version file:" << err.what();
|
||||
return;
|
||||
}
|
||||
|
||||
for(auto problem: newVersion->getProblems())
|
||||
{
|
||||
qWarning() << "Forge: Problem found: " << problem.getDescription();
|
||||
}
|
||||
if(newVersion->getProblemSeverity() == ProblemSeverity::PROBLEM_ERROR)
|
||||
{
|
||||
qWarning() << "Forge: Errors found while parsing version file";
|
||||
return;
|
||||
}
|
||||
|
||||
QJsonObject installObj = installVal.toObject();
|
||||
QString libraryName = installObj.value("path").toString();
|
||||
internalPath = installObj.value("filePath").toString();
|
||||
m_forgeVersionString = installObj.value("version").toString().remove("Forge", Qt::CaseInsensitive).trimmed();
|
||||
|
||||
// where do we put the library? decode the mojang path
|
||||
GradleSpecifier lib(libraryName);
|
||||
|
||||
auto cacheentry = ENV.metacache()->resolveEntry("libraries", lib.toPath());
|
||||
finalPath = "libraries/" + lib.toPath();
|
||||
if (!FS::ensureFilePathExists(finalPath))
|
||||
return;
|
||||
|
||||
if (!zip.setCurrentFile(internalPath))
|
||||
return;
|
||||
if (!file.open(QIODevice::ReadOnly))
|
||||
return;
|
||||
{
|
||||
QByteArray data = file.readAll();
|
||||
// extract file
|
||||
QSaveFile extraction(finalPath);
|
||||
if (!extraction.open(QIODevice::WriteOnly))
|
||||
return;
|
||||
if (extraction.write(data) != data.size())
|
||||
return;
|
||||
if (!extraction.commit())
|
||||
return;
|
||||
QCryptographicHash md5sum(QCryptographicHash::Md5);
|
||||
md5sum.addData(data);
|
||||
|
||||
cacheentry->setStale(false);
|
||||
cacheentry->setMD5Sum(md5sum.result().toHex().constData());
|
||||
ENV.metacache()->updateEntry(cacheentry);
|
||||
}
|
||||
file.close();
|
||||
|
||||
m_forge_json = newVersion;
|
||||
}
|
||||
|
||||
bool ForgeInstaller::add(OneSixInstance *to)
|
||||
{
|
||||
return false;
|
||||
// TODO: move to python code.
|
||||
/*
|
||||
if (!BaseInstaller::add(to))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_forge_json)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// A blacklist
|
||||
QSet<QString> blacklist{"authlib", "realms"};
|
||||
QList<QString> xzlist{"org.scala-lang", "com.typesafe"};
|
||||
|
||||
// get the minecraft version from the instance
|
||||
VersionFilePtr minecraft;
|
||||
auto minecraftPatch = to->getMinecraftProfile()->versionPatch("net.minecraft");
|
||||
if(minecraftPatch)
|
||||
{
|
||||
minecraft = std::dynamic_pointer_cast<VersionFile>(minecraftPatch);
|
||||
if(!minecraft)
|
||||
{
|
||||
auto mcWrap = std::dynamic_pointer_cast<MinecraftVersion>(minecraftPatch);
|
||||
if(mcWrap)
|
||||
{
|
||||
minecraft = mcWrap->getVersionFile();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// for each library in the version we are adding (except for the blacklisted)
|
||||
QMutableListIterator<LibraryPtr> iter(m_forge_json->libraries);
|
||||
while (iter.hasNext())
|
||||
{
|
||||
auto library = iter.next();
|
||||
QString libName = library->artifactId();
|
||||
QString libVersion = library->version();
|
||||
QString rawName = library->rawName();
|
||||
|
||||
// ignore lwjgl libraries.
|
||||
if (g_VersionFilterData.lwjglWhitelist.contains(library->artifactPrefix()))
|
||||
{
|
||||
iter.remove();
|
||||
continue;
|
||||
}
|
||||
// ignore other blacklisted (realms, authlib)
|
||||
if (blacklist.contains(libName))
|
||||
{
|
||||
iter.remove();
|
||||
continue;
|
||||
}
|
||||
// if minecraft version was found, ignore everything that is already in the minecraft version
|
||||
if(minecraft)
|
||||
{
|
||||
bool found = false;
|
||||
for (auto & lib: minecraft->libraries)
|
||||
{
|
||||
if(library->artifactPrefix() == lib->artifactPrefix() && library->version() == lib->version())
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found)
|
||||
continue;
|
||||
}
|
||||
|
||||
// if this is the actual forge lib, set an absolute url for the download
|
||||
if (m_forge_version->type == ForgeVersion::Gradle)
|
||||
{
|
||||
if (libName == "forge")
|
||||
{
|
||||
library->setClassifier("universal");
|
||||
}
|
||||
else if (libName == "minecraftforge")
|
||||
{
|
||||
QString forgeCoord("net.minecraftforge:forge:%1:universal");
|
||||
// using insane form of the MC version...
|
||||
QString longVersion = m_forge_version->mcver + "-" + m_forge_version->jobbuildver;
|
||||
GradleSpecifier spec(forgeCoord.arg(longVersion));
|
||||
library->setRawName(spec);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (libName.contains("minecraftforge"))
|
||||
{
|
||||
library->setAbsoluteUrl(m_universal_url);
|
||||
}
|
||||
}
|
||||
|
||||
// mark bad libraries based on the xzlist above
|
||||
for (auto entry : xzlist)
|
||||
{
|
||||
qDebug() << "Testing " << rawName << " : " << entry;
|
||||
if (rawName.startsWith(entry))
|
||||
{
|
||||
library->setHint("forge-pack-xz");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
QString &args = m_forge_json->minecraftArguments;
|
||||
QStringList tweakers;
|
||||
{
|
||||
QRegularExpression expression("--tweakClass ([a-zA-Z0-9\\.]*)");
|
||||
QRegularExpressionMatch match = expression.match(args);
|
||||
while (match.hasMatch())
|
||||
{
|
||||
tweakers.append(match.captured(1));
|
||||
args.remove(match.capturedStart(), match.capturedLength());
|
||||
match = expression.match(args);
|
||||
}
|
||||
if(tweakers.size())
|
||||
{
|
||||
args.operator=(args.trimmed());
|
||||
m_forge_json->addTweakers = tweakers;
|
||||
}
|
||||
}
|
||||
if(minecraft && args == minecraft->minecraftArguments)
|
||||
{
|
||||
args.clear();
|
||||
}
|
||||
|
||||
m_forge_json->name = "Forge";
|
||||
m_forge_json->fileId = id();
|
||||
m_forge_json->version = m_forgeVersionString;
|
||||
m_forge_json->dependsOnMinecraftVersion = to->intendedVersionId();
|
||||
m_forge_json->order = 5;
|
||||
|
||||
// reset some things we do not want to be passed along.
|
||||
m_forge_json->m_releaseTime = QDateTime();
|
||||
m_forge_json->m_updateTime = QDateTime();
|
||||
m_forge_json->minimumLauncherVersion = -1;
|
||||
m_forge_json->type.clear();
|
||||
m_forge_json->minecraftArguments.clear();
|
||||
m_forge_json->minecraftVersion.clear();
|
||||
|
||||
QSaveFile file(filename(to->instanceRoot()));
|
||||
if (!file.open(QFile::WriteOnly))
|
||||
{
|
||||
qCritical() << "Error opening" << file.fileName()
|
||||
<< "for reading:" << file.errorString();
|
||||
return false;
|
||||
}
|
||||
file.write(OneSixVersionFormat::versionFileToJson(m_forge_json, true).toJson());
|
||||
file.commit();
|
||||
|
||||
return true;
|
||||
*/
|
||||
}
|
||||
|
||||
bool ForgeInstaller::addLegacy(OneSixInstance *to)
|
||||
{
|
||||
return false;
|
||||
//FIXME: move to python code.
|
||||
/*
|
||||
if (!BaseInstaller::add(to))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
auto entry = ENV.metacache()->resolveEntry("minecraftforge", m_forge_version->filename());
|
||||
finalPath = FS::PathCombine(to->jarModsDir(), m_forge_version->filename());
|
||||
if (!FS::ensureFilePathExists(finalPath))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!QFile::copy(entry->getFullPath(), finalPath))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
QJsonObject obj;
|
||||
obj.insert("order", 5);
|
||||
{
|
||||
QJsonArray jarmodsPlus;
|
||||
{
|
||||
QJsonObject libObj;
|
||||
libObj.insert("name", m_forge_version->universal_filename);
|
||||
jarmodsPlus.append(libObj);
|
||||
}
|
||||
obj.insert("+jarMods", jarmodsPlus);
|
||||
}
|
||||
|
||||
obj.insert("name", QString("Forge"));
|
||||
obj.insert("fileId", id());
|
||||
obj.insert("version", m_forge_version->jobbuildver);
|
||||
obj.insert("mcVersion", to->intendedVersionId());
|
||||
if (g_VersionFilterData.fmlLibsMapping.contains(m_forge_version->mcver))
|
||||
{
|
||||
QJsonArray traitsPlus;
|
||||
traitsPlus.append(QString("legacyFML"));
|
||||
obj.insert("+traits", traitsPlus);
|
||||
}
|
||||
auto fullversion = to->getMinecraftProfile();
|
||||
fullversion->remove("net.minecraftforge");
|
||||
|
||||
QFile file(filename(to->instanceRoot()));
|
||||
if (!file.open(QFile::WriteOnly))
|
||||
{
|
||||
qCritical() << "Error opening" << file.fileName()
|
||||
<< "for reading:" << file.errorString();
|
||||
return false;
|
||||
}
|
||||
file.write(QJsonDocument(obj).toJson());
|
||||
file.close();
|
||||
return true;
|
||||
*/
|
||||
}
|
||||
|
||||
class ForgeInstallTask : public Task
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ForgeInstallTask(ForgeInstaller *installer, OneSixInstance *instance,
|
||||
BaseVersionPtr version, QObject *parent = 0)
|
||||
: Task(parent), m_installer(installer), m_instance(instance), m_version(version)
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
void executeTask() override
|
||||
{
|
||||
setStatus(tr("Installing Forge..."));
|
||||
ForgeVersionPtr forgeVersion = std::dynamic_pointer_cast<ForgeVersion>(m_version);
|
||||
if (!forgeVersion)
|
||||
{
|
||||
emitFailed(tr("Unknown error occured"));
|
||||
return;
|
||||
}
|
||||
prepare(forgeVersion);
|
||||
}
|
||||
void prepare(ForgeVersionPtr forgeVersion)
|
||||
{
|
||||
auto entry = ENV.metacache()->resolveEntry("minecraftforge", forgeVersion->filename());
|
||||
auto installFunction = [this, entry, forgeVersion]()
|
||||
{
|
||||
if (!install(entry, forgeVersion))
|
||||
{
|
||||
qCritical() << "Failure installing Forge";
|
||||
emitFailed(tr("Failure to install Forge"));
|
||||
}
|
||||
else
|
||||
{
|
||||
reload();
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* HACK IF the local non-stale file is too small, mark is as stale
|
||||
*
|
||||
* This fixes some problems with bad files acquired because of unhandled HTTP redirects
|
||||
* in old versions of MultiMC.
|
||||
*/
|
||||
if (!entry->isStale())
|
||||
{
|
||||
QFileInfo localFile(entry->getFullPath());
|
||||
if (localFile.size() <= 0x4000)
|
||||
{
|
||||
entry->setStale(true);
|
||||
}
|
||||
}
|
||||
|
||||
if (entry->isStale())
|
||||
{
|
||||
NetJob *fjob = new NetJob("Forge download");
|
||||
fjob->addNetAction(Net::Download::makeCached(forgeVersion->url(), entry));
|
||||
connect(fjob, &NetJob::progress, this, &Task::setProgress);
|
||||
connect(fjob, &NetJob::status, this, &Task::setStatus);
|
||||
connect(fjob, &NetJob::failed, [this](QString reason)
|
||||
{ emitFailed(tr("Failure to download Forge:\n%1").arg(reason)); });
|
||||
connect(fjob, &NetJob::succeeded, installFunction);
|
||||
fjob->start();
|
||||
}
|
||||
else
|
||||
{
|
||||
installFunction();
|
||||
}
|
||||
}
|
||||
bool install(const std::shared_ptr<MetaEntry> &entry, const ForgeVersionPtr &forgeVersion)
|
||||
{
|
||||
if (forgeVersion->usesInstaller())
|
||||
{
|
||||
QString forgePath = entry->getFullPath();
|
||||
m_installer->prepare(forgePath, forgeVersion->universal_url);
|
||||
return m_installer->add(m_instance);
|
||||
}
|
||||
else
|
||||
return m_installer->addLegacy(m_instance);
|
||||
}
|
||||
void reload()
|
||||
{
|
||||
try
|
||||
{
|
||||
m_instance->reloadProfile();
|
||||
emitSucceeded();
|
||||
}
|
||||
catch (Exception &e)
|
||||
{
|
||||
emitFailed(e.cause());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
emitFailed(tr("Failed to load the version description file for reasons unknown."));
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
ForgeInstaller *m_installer;
|
||||
OneSixInstance *m_instance;
|
||||
BaseVersionPtr m_version;
|
||||
};
|
||||
|
||||
Task *ForgeInstaller::createInstallTask(OneSixInstance *instance,
|
||||
BaseVersionPtr version, QObject *parent)
|
||||
{
|
||||
if (!version)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
m_forge_version = std::dynamic_pointer_cast<ForgeVersion>(version);
|
||||
return new ForgeInstallTask(this, instance, version, parent);
|
||||
}
|
||||
|
||||
#include "ForgeInstaller.moc"
|
@ -1,52 +0,0 @@
|
||||
/* Copyright 2013-2017 MultiMC Contributors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "BaseInstaller.h"
|
||||
|
||||
#include <QString>
|
||||
#include <memory>
|
||||
|
||||
#include "multimc_logic_export.h"
|
||||
|
||||
class VersionFile;
|
||||
class ForgeInstallTask;
|
||||
struct ForgeVersion;
|
||||
|
||||
class MULTIMC_LOGIC_EXPORT ForgeInstaller : public BaseInstaller
|
||||
{
|
||||
friend class ForgeInstallTask;
|
||||
public:
|
||||
ForgeInstaller();
|
||||
virtual ~ForgeInstaller(){}
|
||||
virtual Task *createInstallTask(OneSixInstance *instance, BaseVersionPtr version, QObject *parent) override;
|
||||
virtual QString id() const override { return "net.minecraftforge"; }
|
||||
|
||||
protected:
|
||||
void prepare(const QString &filename, const QString &universalUrl);
|
||||
bool add(OneSixInstance *to) override;
|
||||
bool addLegacy(OneSixInstance *to);
|
||||
|
||||
private:
|
||||
// the parsed version json, read from the installer
|
||||
std::shared_ptr<VersionFile> m_forge_json;
|
||||
// the actual forge version
|
||||
std::shared_ptr<ForgeVersion> m_forge_version;
|
||||
QString internalPath;
|
||||
QString finalPath;
|
||||
QString m_forgeVersionString;
|
||||
QString m_universal_url;
|
||||
};
|
@ -1,55 +0,0 @@
|
||||
#include "ForgeVersion.h"
|
||||
#include "minecraft/VersionFilterData.h"
|
||||
#include <QObject>
|
||||
|
||||
QString ForgeVersion::name()
|
||||
{
|
||||
return "Forge " + jobbuildver;
|
||||
}
|
||||
|
||||
QString ForgeVersion::descriptor()
|
||||
{
|
||||
return universal_filename;
|
||||
}
|
||||
|
||||
QString ForgeVersion::typeString() const
|
||||
{
|
||||
if (is_recommended)
|
||||
return QObject::tr("Recommended");
|
||||
return QString();
|
||||
}
|
||||
|
||||
bool ForgeVersion::operator<(BaseVersion &a)
|
||||
{
|
||||
ForgeVersion *pa = dynamic_cast<ForgeVersion *>(&a);
|
||||
if (!pa)
|
||||
return true;
|
||||
return m_buildnr < pa->m_buildnr;
|
||||
}
|
||||
|
||||
bool ForgeVersion::operator>(BaseVersion &a)
|
||||
{
|
||||
ForgeVersion *pa = dynamic_cast<ForgeVersion *>(&a);
|
||||
if (!pa)
|
||||
return false;
|
||||
return m_buildnr > pa->m_buildnr;
|
||||
}
|
||||
|
||||
bool ForgeVersion::usesInstaller()
|
||||
{
|
||||
if(installer_url.isEmpty())
|
||||
return false;
|
||||
if(g_VersionFilterData.forgeInstallerBlacklist.contains(mcver))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
QString ForgeVersion::filename()
|
||||
{
|
||||
return usesInstaller() ? installer_filename : universal_filename;
|
||||
}
|
||||
|
||||
QString ForgeVersion::url()
|
||||
{
|
||||
return usesInstaller() ? installer_url : universal_url;
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
#pragma once
|
||||
#include <QString>
|
||||
#include <memory>
|
||||
#include "BaseVersion.h"
|
||||
|
||||
struct ForgeVersion;
|
||||
typedef std::shared_ptr<ForgeVersion> ForgeVersionPtr;
|
||||
|
||||
struct ForgeVersion : public BaseVersion
|
||||
{
|
||||
virtual QString descriptor() override;
|
||||
virtual QString name() override;
|
||||
virtual QString typeString() const override;
|
||||
virtual bool operator<(BaseVersion &a) override;
|
||||
virtual bool operator>(BaseVersion &a) override;
|
||||
|
||||
QString filename();
|
||||
QString url();
|
||||
|
||||
enum
|
||||
{
|
||||
Invalid,
|
||||
Legacy,
|
||||
Gradle
|
||||
} type = Invalid;
|
||||
|
||||
bool usesInstaller();
|
||||
|
||||
int m_buildnr = 0;
|
||||
QString branch;
|
||||
QString universal_url;
|
||||
QString changelog_url;
|
||||
QString installer_url;
|
||||
QString jobbuildver;
|
||||
QString mcver;
|
||||
QString mcver_sane;
|
||||
QString universal_filename;
|
||||
QString installer_filename;
|
||||
bool is_recommended = false;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(ForgeVersionPtr)
|
@ -1,333 +0,0 @@
|
||||
/* Copyright 2013-2017 MultiMC Contributors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ForgeVersionList.h"
|
||||
#include "ForgeVersion.h"
|
||||
|
||||
#include "net/NetJob.h"
|
||||
#include "net/URLConstants.h"
|
||||
#include "Env.h"
|
||||
|
||||
#include <QtNetwork>
|
||||
#include <QtXml>
|
||||
#include <QRegExp>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
ForgeVersionList::ForgeVersionList(QObject *parent) : BaseVersionList(parent)
|
||||
{
|
||||
}
|
||||
|
||||
Task *ForgeVersionList::getLoadTask()
|
||||
{
|
||||
return new ForgeListLoadTask(this);
|
||||
}
|
||||
|
||||
bool ForgeVersionList::isLoaded()
|
||||
{
|
||||
return m_loaded;
|
||||
}
|
||||
|
||||
const BaseVersionPtr ForgeVersionList::at(int i) const
|
||||
{
|
||||
return m_vlist.at(i);
|
||||
}
|
||||
|
||||
int ForgeVersionList::count() const
|
||||
{
|
||||
return m_vlist.count();
|
||||
}
|
||||
|
||||
int ForgeVersionList::columnCount(const QModelIndex &parent) const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
QVariant ForgeVersionList::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return QVariant();
|
||||
|
||||
if (index.row() > count())
|
||||
return QVariant();
|
||||
|
||||
auto version = std::dynamic_pointer_cast<ForgeVersion>(m_vlist[index.row()]);
|
||||
switch (role)
|
||||
{
|
||||
case VersionPointerRole:
|
||||
return qVariantFromValue(m_vlist[index.row()]);
|
||||
|
||||
case VersionRole:
|
||||
return version->name();
|
||||
|
||||
case VersionIdRole:
|
||||
return version->descriptor();
|
||||
|
||||
case ParentGameVersionRole:
|
||||
return version->mcver_sane;
|
||||
|
||||
case RecommendedRole:
|
||||
return version->is_recommended;
|
||||
|
||||
case BranchRole:
|
||||
return version->branch;
|
||||
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
}
|
||||
|
||||
BaseVersionList::RoleList ForgeVersionList::providesRoles() const
|
||||
{
|
||||
return {VersionPointerRole, VersionRole, VersionIdRole, ParentGameVersionRole, RecommendedRole, BranchRole};
|
||||
}
|
||||
|
||||
BaseVersionPtr ForgeVersionList::getLatestStable() const
|
||||
{
|
||||
return BaseVersionPtr();
|
||||
}
|
||||
|
||||
void ForgeVersionList::updateListData(QList<BaseVersionPtr> versions)
|
||||
{
|
||||
beginResetModel();
|
||||
m_vlist = versions;
|
||||
m_loaded = true;
|
||||
endResetModel();
|
||||
// NOW SORT!!
|
||||
// sort();
|
||||
}
|
||||
|
||||
void ForgeVersionList::sortVersions()
|
||||
{
|
||||
// NO-OP for now
|
||||
}
|
||||
|
||||
ForgeListLoadTask::ForgeListLoadTask(ForgeVersionList *vlist) : Task()
|
||||
{
|
||||
m_list = vlist;
|
||||
}
|
||||
|
||||
void ForgeListLoadTask::executeTask()
|
||||
{
|
||||
setStatus(tr("Fetching Forge version lists..."));
|
||||
auto job = new NetJob("Version index");
|
||||
// we do not care if the version is stale or not.
|
||||
auto forgeListEntry = ENV.metacache()->resolveEntry("minecraftforge", "list.json");
|
||||
auto gradleForgeListEntry = ENV.metacache()->resolveEntry("minecraftforge", "json");
|
||||
|
||||
// verify by poking the server.
|
||||
forgeListEntry->setStale(true);
|
||||
gradleForgeListEntry->setStale(true);
|
||||
|
||||
job->addNetAction(listDownload = Net::Download::makeCached(QUrl(URLConstants::FORGE_LEGACY_URL),forgeListEntry));
|
||||
job->addNetAction(gradleListDownload = Net::Download::makeCached(QUrl(URLConstants::FORGE_GRADLE_URL), gradleForgeListEntry));
|
||||
|
||||
connect(listDownload.get(), SIGNAL(failed(int)), SLOT(listFailed()));
|
||||
connect(gradleListDownload.get(), SIGNAL(failed(int)), SLOT(gradleListFailed()));
|
||||
|
||||
listJob.reset(job);
|
||||
connect(listJob.get(), SIGNAL(succeeded()), SLOT(listDownloaded()));
|
||||
connect(listJob.get(), SIGNAL(progress(qint64, qint64)), SIGNAL(progress(qint64, qint64)));
|
||||
listJob->start();
|
||||
}
|
||||
|
||||
bool ForgeListLoadTask::abort()
|
||||
{
|
||||
return listJob->abort();
|
||||
}
|
||||
|
||||
bool ForgeListLoadTask::parseForgeGradleList(QList<BaseVersionPtr> &out)
|
||||
{
|
||||
QMap<int, std::shared_ptr<ForgeVersion>> lookup;
|
||||
QByteArray data;
|
||||
{
|
||||
auto filename = gradleListDownload->getTargetFilepath();
|
||||
QFile listFile(filename);
|
||||
if (!listFile.open(QIODevice::ReadOnly))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
data = listFile.readAll();
|
||||
gradleListDownload.reset();
|
||||
}
|
||||
|
||||
QJsonParseError jsonError;
|
||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &jsonError);
|
||||
|
||||
if (jsonError.error != QJsonParseError::NoError)
|
||||
{
|
||||
emitFailed("Error parsing gradle version list JSON:" + jsonError.errorString());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!jsonDoc.isObject())
|
||||
{
|
||||
emitFailed("Error parsing gradle version list JSON: JSON root is not an object");
|
||||
return false;
|
||||
}
|
||||
|
||||
QJsonObject root = jsonDoc.object();
|
||||
|
||||
// we probably could hard code these, but it might still be worth doing it this way
|
||||
const QString webpath = root.value("webpath").toString();
|
||||
const QString artifact = root.value("artifact").toString();
|
||||
|
||||
QJsonObject numbers = root.value("number").toObject();
|
||||
for (auto it = numbers.begin(); it != numbers.end(); ++it)
|
||||
{
|
||||
QJsonObject number = it.value().toObject();
|
||||
std::shared_ptr<ForgeVersion> fVersion(new ForgeVersion());
|
||||
fVersion->m_buildnr = number.value("build").toDouble();
|
||||
if(fVersion->m_buildnr >= 953 && fVersion->m_buildnr <= 965)
|
||||
{
|
||||
qDebug() << fVersion->m_buildnr;
|
||||
}
|
||||
fVersion->jobbuildver = number.value("version").toString();
|
||||
fVersion->branch = number.value("branch").toString("");
|
||||
fVersion->mcver = number.value("mcversion").toString();
|
||||
fVersion->universal_filename = "";
|
||||
fVersion->installer_filename = "";
|
||||
// HACK: here, we fix the minecraft version used by forge.
|
||||
// HACK: this will inevitably break (later)
|
||||
// FIXME: replace with a dictionary
|
||||
fVersion->mcver_sane = fVersion->mcver;
|
||||
fVersion->mcver_sane.replace("_pre", "-pre");
|
||||
|
||||
QString universal_filename, installer_filename;
|
||||
QJsonArray files = number.value("files").toArray();
|
||||
for (auto fIt = files.begin(); fIt != files.end(); ++fIt)
|
||||
{
|
||||
// TODO with gradle we also get checksums, use them
|
||||
QJsonArray file = (*fIt).toArray();
|
||||
if (file.size() < 3)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
QString extension = file.at(0).toString();
|
||||
QString part = file.at(1).toString();
|
||||
QString checksum = file.at(2).toString();
|
||||
|
||||
// insane form of mcver is used here
|
||||
QString longVersion = fVersion->mcver + "-" + fVersion->jobbuildver;
|
||||
if (!fVersion->branch.isEmpty())
|
||||
{
|
||||
longVersion = longVersion + "-" + fVersion->branch;
|
||||
}
|
||||
QString filename = artifact + "-" + longVersion + "-" + part + "." + extension;
|
||||
|
||||
QString url = QString("%1/%2/%3")
|
||||
.arg(webpath)
|
||||
.arg(longVersion)
|
||||
.arg(filename);
|
||||
|
||||
if (part == "installer")
|
||||
{
|
||||
fVersion->installer_url = url;
|
||||
installer_filename = filename;
|
||||
}
|
||||
else if (part == "universal" || part == "client")
|
||||
{
|
||||
fVersion->universal_url = url;
|
||||
universal_filename = filename;
|
||||
}
|
||||
else if (part == "changelog")
|
||||
{
|
||||
fVersion->changelog_url = url;
|
||||
}
|
||||
}
|
||||
if (fVersion->installer_url.isEmpty() && fVersion->universal_url.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
fVersion->universal_filename = universal_filename;
|
||||
fVersion->installer_filename = installer_filename;
|
||||
fVersion->type = ForgeVersion::Gradle;
|
||||
out.append(fVersion);
|
||||
lookup[fVersion->m_buildnr] = fVersion;
|
||||
}
|
||||
QJsonObject promos = root.value("promos").toObject();
|
||||
for (auto it = promos.begin(); it != promos.end(); ++it)
|
||||
{
|
||||
QString key = it.key();
|
||||
int build = it.value().toInt();
|
||||
QRegularExpression regexp("^(?<mcversion>[0-9]+(.[0-9]+)*)-(?<label>[a-z]+)$");
|
||||
auto match = regexp.match(key);
|
||||
if(!match.hasMatch())
|
||||
{
|
||||
qDebug() << key << "doesn't match." << "build" << build;
|
||||
continue;
|
||||
}
|
||||
|
||||
QString label = match.captured("label");
|
||||
if(label != "recommended")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
QString mcversion = match.captured("mcversion");
|
||||
qDebug() << "Forge build" << build << "is the" << label << "for Minecraft" << mcversion << QString("<%1>").arg(key);
|
||||
lookup[build]->is_recommended = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void ForgeListLoadTask::listDownloaded()
|
||||
{
|
||||
QList<BaseVersionPtr> list;
|
||||
bool ret = true;
|
||||
|
||||
if (!parseForgeGradleList(list))
|
||||
{
|
||||
ret = false;
|
||||
}
|
||||
|
||||
if (!ret)
|
||||
{
|
||||
return;
|
||||
}
|
||||
std::sort(list.begin(), list.end(), [](const BaseVersionPtr & l, const BaseVersionPtr & r)
|
||||
{ return (*l > *r); });
|
||||
|
||||
m_list->updateListData(list);
|
||||
|
||||
emitSucceeded();
|
||||
return;
|
||||
}
|
||||
|
||||
void ForgeListLoadTask::listFailed()
|
||||
{
|
||||
auto &reply = listDownload->m_reply;
|
||||
if (reply)
|
||||
{
|
||||
qCritical() << "Getting forge version list failed: " << reply->errorString();
|
||||
}
|
||||
else
|
||||
{
|
||||
qCritical() << "Getting forge version list failed for reasons unknown.";
|
||||
}
|
||||
}
|
||||
|
||||
void ForgeListLoadTask::gradleListFailed()
|
||||
{
|
||||
auto &reply = gradleListDownload->m_reply;
|
||||
if (reply)
|
||||
{
|
||||
qCritical() << "Getting forge version list failed: " << reply->errorString();
|
||||
}
|
||||
else
|
||||
{
|
||||
qCritical() << "Getting forge version list failed for reasons unknown.";
|
||||
}
|
||||
}
|
@ -1,90 +0,0 @@
|
||||
/* Copyright 2013-2017 MultiMC Contributors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ForgeVersion.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QAbstractListModel>
|
||||
#include <QUrl>
|
||||
#include <QNetworkReply>
|
||||
|
||||
#include "BaseVersionList.h"
|
||||
#include "tasks/Task.h"
|
||||
#include "net/NetJob.h"
|
||||
|
||||
#include "multimc_logic_export.h"
|
||||
|
||||
class MULTIMC_LOGIC_EXPORT ForgeVersionList : public BaseVersionList
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
friend class ForgeListLoadTask;
|
||||
|
||||
explicit ForgeVersionList(QObject *parent = 0);
|
||||
|
||||
virtual Task *getLoadTask() override;
|
||||
virtual bool isLoaded() override;
|
||||
virtual const BaseVersionPtr at(int i) const override;
|
||||
virtual int count() const override;
|
||||
virtual void sortVersions() override;
|
||||
|
||||
virtual BaseVersionPtr getLatestStable() const override;
|
||||
|
||||
ForgeVersionPtr findVersionByVersionNr(QString version);
|
||||
|
||||
virtual QVariant data(const QModelIndex &index, int role) const override;
|
||||
virtual RoleList providesRoles() const override;
|
||||
|
||||
virtual int columnCount(const QModelIndex &parent) const override;
|
||||
|
||||
protected:
|
||||
QList<BaseVersionPtr> m_vlist;
|
||||
|
||||
bool m_loaded = false;
|
||||
|
||||
protected
|
||||
slots:
|
||||
virtual void updateListData(QList<BaseVersionPtr> versions) override;
|
||||
};
|
||||
|
||||
class ForgeListLoadTask : public Task
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ForgeListLoadTask(ForgeVersionList *vlist);
|
||||
|
||||
virtual void executeTask();
|
||||
virtual bool abort();
|
||||
|
||||
protected
|
||||
slots:
|
||||
void listDownloaded();
|
||||
void listFailed();
|
||||
void gradleListFailed();
|
||||
|
||||
protected:
|
||||
NetJobPtr listJob;
|
||||
ForgeVersionList *m_list;
|
||||
|
||||
Net::Download::Ptr listDownload;
|
||||
Net::Download::Ptr gradleListDownload;
|
||||
|
||||
private:
|
||||
bool parseForgeList(QList<BaseVersionPtr> &out);
|
||||
bool parseForgeGradleList(QList<BaseVersionPtr> &out);
|
||||
};
|
@ -1,56 +0,0 @@
|
||||
/* Copyright 2013-2017 MultiMC Contributors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "LegacyForge.h"
|
||||
|
||||
MinecraftForge::MinecraftForge(const QString &file) : Mod(file)
|
||||
{
|
||||
}
|
||||
|
||||
bool MinecraftForge::FixVersionIfNeeded(QString newVersion)
|
||||
{/*
|
||||
wxString reportedVersion = GetModVersion();
|
||||
if(reportedVersion == "..." || reportedVersion.empty())
|
||||
{
|
||||
std::auto_ptr<wxFFileInputStream> in(new wxFFileInputStream("forge.zip"));
|
||||
wxTempFileOutputStream out("forge.zip");
|
||||
wxTextOutputStream textout(out);
|
||||
wxZipInputStream inzip(*in);
|
||||
wxZipOutputStream outzip(out);
|
||||
std::auto_ptr<wxZipEntry> entry;
|
||||
// preserve metadata
|
||||
outzip.CopyArchiveMetaData(inzip);
|
||||
// copy all entries
|
||||
while (entry.reset(inzip.GetNextEntry()), entry.get() != NULL)
|
||||
if (!outzip.CopyEntry(entry.release(), inzip))
|
||||
return false;
|
||||
// release last entry
|
||||
in.reset();
|
||||
outzip.PutNextEntry("forgeversion.properties");
|
||||
|
||||
wxStringTokenizer tokenizer(newVersion,".");
|
||||
wxString verFile;
|
||||
verFile << wxString("forge.major.number=") << tokenizer.GetNextToken() << "\n";
|
||||
verFile << wxString("forge.minor.number=") << tokenizer.GetNextToken() << "\n";
|
||||
verFile << wxString("forge.revision.number=") << tokenizer.GetNextToken() << "\n";
|
||||
verFile << wxString("forge.build.number=") << tokenizer.GetNextToken() << "\n";
|
||||
auto buf = verFile.ToUTF8();
|
||||
outzip.Write(buf.data(), buf.length());
|
||||
// check if we succeeded
|
||||
return inzip.Eof() && outzip.Close() && out.Commit();
|
||||
}
|
||||
*/
|
||||
return true;
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
/* Copyright 2013-2017 MultiMC Contributors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "minecraft/Mod.h"
|
||||
|
||||
class MinecraftForge : public Mod
|
||||
{
|
||||
public:
|
||||
MinecraftForge(const QString &file);
|
||||
bool FixVersionIfNeeded(QString newVersion);
|
||||
};
|
@ -1,106 +0,0 @@
|
||||
/* Copyright 2013-2017 MultiMC Contributors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "LiteLoaderInstaller.h"
|
||||
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include "minecraft/MinecraftProfile.h"
|
||||
#include "minecraft/Library.h"
|
||||
#include "minecraft/onesix/OneSixInstance.h"
|
||||
#include <minecraft/onesix/OneSixVersionFormat.h>
|
||||
#include "minecraft/liteloader/LiteLoaderVersionList.h"
|
||||
#include "Exception.h"
|
||||
|
||||
LiteLoaderInstaller::LiteLoaderInstaller() : BaseInstaller()
|
||||
{
|
||||
}
|
||||
|
||||
void LiteLoaderInstaller::prepare(LiteLoaderVersionPtr version)
|
||||
{
|
||||
m_version = version;
|
||||
}
|
||||
bool LiteLoaderInstaller::add(OneSixInstance *to)
|
||||
{
|
||||
if (!BaseInstaller::add(to))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
QFile file(filename(to->instanceRoot()));
|
||||
if (!file.open(QFile::WriteOnly))
|
||||
{
|
||||
qCritical() << "Error opening" << file.fileName()
|
||||
<< "for reading:" << file.errorString();
|
||||
return false;
|
||||
}
|
||||
file.write(OneSixVersionFormat::versionFileToJson(m_version->getVersionFile(), true).toJson());
|
||||
file.close();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
class LiteLoaderInstallTask : public Task
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
LiteLoaderInstallTask(LiteLoaderInstaller *installer, OneSixInstance *instance, BaseVersionPtr version, QObject *parent)
|
||||
: Task(parent), m_installer(installer), m_instance(instance), m_version(version)
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
void executeTask() override
|
||||
{
|
||||
LiteLoaderVersionPtr liteloaderVersion = std::dynamic_pointer_cast<LiteLoaderVersion>(m_version);
|
||||
if (!liteloaderVersion)
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_installer->prepare(liteloaderVersion);
|
||||
if (!m_installer->add(m_instance))
|
||||
{
|
||||
emitFailed(tr("For reasons unknown, the LiteLoader installation failed. Check your MultiMC log files for details."));
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
m_instance->reloadProfile();
|
||||
emitSucceeded();
|
||||
}
|
||||
catch (Exception &e)
|
||||
{
|
||||
emitFailed(e.cause());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
emitFailed(tr("Failed to load the version description file for reasons unknown."));
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
LiteLoaderInstaller *m_installer;
|
||||
OneSixInstance *m_instance;
|
||||
BaseVersionPtr m_version;
|
||||
};
|
||||
|
||||
Task *LiteLoaderInstaller::createInstallTask(OneSixInstance *instance, BaseVersionPtr version, QObject *parent)
|
||||
{
|
||||
return new LiteLoaderInstallTask(this, instance, version, parent);
|
||||
}
|
||||
|
||||
#include "LiteLoaderInstaller.moc"
|
@ -1,39 +0,0 @@
|
||||
/* Copyright 2013-2017 MultiMC Contributors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
#include <QMap>
|
||||
|
||||
#include "BaseInstaller.h"
|
||||
#include "LiteLoaderVersionList.h"
|
||||
|
||||
#include "multimc_logic_export.h"
|
||||
|
||||
class MULTIMC_LOGIC_EXPORT LiteLoaderInstaller : public BaseInstaller
|
||||
{
|
||||
public:
|
||||
LiteLoaderInstaller();
|
||||
|
||||
void prepare(LiteLoaderVersionPtr version);
|
||||
bool add(OneSixInstance *to) override;
|
||||
virtual QString id() const override { return "com.mumfrey.liteloader"; }
|
||||
|
||||
Task *createInstallTask(OneSixInstance *instance, BaseVersionPtr version, QObject *parent) override;
|
||||
|
||||
private:
|
||||
LiteLoaderVersionPtr m_version;
|
||||
};
|
@ -1,332 +0,0 @@
|
||||
/* Copyright 2013-2017 MultiMC Contributors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "LiteLoaderVersionList.h"
|
||||
#include <minecraft/onesix/OneSixVersionFormat.h>
|
||||
#include "Env.h"
|
||||
#include "net/URLConstants.h"
|
||||
#include "Exception.h"
|
||||
|
||||
#include <QtXml>
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonValue>
|
||||
#include <QJsonParseError>
|
||||
|
||||
#include <QtAlgorithms>
|
||||
|
||||
#include <QtNetwork>
|
||||
|
||||
LiteLoaderVersionList::LiteLoaderVersionList(QObject *parent) : BaseVersionList(parent)
|
||||
{
|
||||
}
|
||||
|
||||
Task *LiteLoaderVersionList::getLoadTask()
|
||||
{
|
||||
return new LLListLoadTask(this);
|
||||
}
|
||||
|
||||
bool LiteLoaderVersionList::isLoaded()
|
||||
{
|
||||
return m_loaded;
|
||||
}
|
||||
|
||||
const BaseVersionPtr LiteLoaderVersionList::at(int i) const
|
||||
{
|
||||
return m_vlist.at(i);
|
||||
}
|
||||
|
||||
int LiteLoaderVersionList::count() const
|
||||
{
|
||||
return m_vlist.count();
|
||||
}
|
||||
|
||||
static bool cmpVersions(BaseVersionPtr first, BaseVersionPtr second)
|
||||
{
|
||||
auto left = std::dynamic_pointer_cast<LiteLoaderVersion>(first);
|
||||
auto right = std::dynamic_pointer_cast<LiteLoaderVersion>(second);
|
||||
return left->timestamp > right->timestamp;
|
||||
}
|
||||
|
||||
VersionFilePtr LiteLoaderVersion::getVersionFile()
|
||||
{
|
||||
auto f = std::make_shared<VersionFile>();
|
||||
f->mainClass = "net.minecraft.launchwrapper.Launch";
|
||||
f->addTweakers += tweakClass;
|
||||
f->order = 10;
|
||||
f->libraries = libraries;
|
||||
f->name = "LiteLoader";
|
||||
f->fileId = "com.mumfrey.liteloader";
|
||||
f->version = version;
|
||||
f->minecraftVersion = mcVersion;
|
||||
return f;
|
||||
}
|
||||
|
||||
void LiteLoaderVersionList::sortVersions()
|
||||
{
|
||||
beginResetModel();
|
||||
std::sort(m_vlist.begin(), m_vlist.end(), cmpVersions);
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
QVariant LiteLoaderVersionList::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return QVariant();
|
||||
|
||||
if (index.row() > count())
|
||||
return QVariant();
|
||||
|
||||
auto version = std::dynamic_pointer_cast<LiteLoaderVersion>(m_vlist[index.row()]);
|
||||
switch (role)
|
||||
{
|
||||
case VersionPointerRole:
|
||||
return qVariantFromValue(m_vlist[index.row()]);
|
||||
|
||||
case VersionRole:
|
||||
return version->name();
|
||||
|
||||
case VersionIdRole:
|
||||
return version->descriptor();
|
||||
|
||||
case ParentGameVersionRole:
|
||||
return version->mcVersion;
|
||||
|
||||
case LatestRole:
|
||||
return version->isLatest;
|
||||
|
||||
case RecommendedRole:
|
||||
return version->isRecommended;
|
||||
|
||||
case TypeRole:
|
||||
return version->isSnapshot ? tr("Snapshot") : tr("Release");
|
||||
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
}
|
||||
|
||||
BaseVersionList::RoleList LiteLoaderVersionList::providesRoles() const
|
||||
{
|
||||
return {VersionPointerRole, VersionRole, VersionIdRole, ParentGameVersionRole, RecommendedRole, LatestRole, TypeRole};
|
||||
}
|
||||
|
||||
BaseVersionPtr LiteLoaderVersionList::getLatestStable() const
|
||||
{
|
||||
for (int i = 0; i < m_vlist.length(); i++)
|
||||
{
|
||||
auto ver = std::dynamic_pointer_cast<LiteLoaderVersion>(m_vlist.at(i));
|
||||
if (ver->isRecommended)
|
||||
{
|
||||
return m_vlist.at(i);
|
||||
}
|
||||
}
|
||||
return BaseVersionPtr();
|
||||
}
|
||||
|
||||
void LiteLoaderVersionList::updateListData(QList<BaseVersionPtr> versions)
|
||||
{
|
||||
beginResetModel();
|
||||
m_vlist = versions;
|
||||
m_loaded = true;
|
||||
std::sort(m_vlist.begin(), m_vlist.end(), cmpVersions);
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
LLListLoadTask::LLListLoadTask(LiteLoaderVersionList *vlist)
|
||||
{
|
||||
m_list = vlist;
|
||||
}
|
||||
|
||||
LLListLoadTask::~LLListLoadTask()
|
||||
{
|
||||
}
|
||||
|
||||
void LLListLoadTask::executeTask()
|
||||
{
|
||||
setStatus(tr("Loading LiteLoader version list..."));
|
||||
auto job = new NetJob("Version index");
|
||||
// we do not care if the version is stale or not.
|
||||
auto liteloaderEntry = ENV.metacache()->resolveEntry("liteloader", "versions.json");
|
||||
|
||||
// verify by poking the server.
|
||||
liteloaderEntry->setStale(true);
|
||||
|
||||
job->addNetAction(listDownload = Net::Download::makeCached(QUrl(URLConstants::LITELOADER_URL), liteloaderEntry));
|
||||
|
||||
connect(listDownload.get(), SIGNAL(failed(int)), SLOT(listFailed()));
|
||||
|
||||
listJob.reset(job);
|
||||
connect(listJob.get(), SIGNAL(succeeded()), SLOT(listDownloaded()));
|
||||
connect(listJob.get(), SIGNAL(progress(qint64, qint64)), SIGNAL(progress(qint64, qint64)));
|
||||
listJob->start();
|
||||
}
|
||||
|
||||
void LLListLoadTask::listFailed()
|
||||
{
|
||||
emitFailed("Failed to load LiteLoader version list.");
|
||||
return;
|
||||
}
|
||||
|
||||
void LLListLoadTask::listDownloaded()
|
||||
{
|
||||
QByteArray data;
|
||||
{
|
||||
auto filename = listDownload->getTargetFilepath();
|
||||
QFile listFile(filename);
|
||||
if (!listFile.open(QIODevice::ReadOnly))
|
||||
{
|
||||
emitFailed("Failed to open the LiteLoader version list.");
|
||||
return;
|
||||
}
|
||||
data = listFile.readAll();
|
||||
listFile.close();
|
||||
listDownload.reset();
|
||||
}
|
||||
|
||||
QJsonParseError jsonError;
|
||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &jsonError);
|
||||
|
||||
if (jsonError.error != QJsonParseError::NoError)
|
||||
{
|
||||
emitFailed("Error parsing version list JSON:" + jsonError.errorString());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!jsonDoc.isObject())
|
||||
{
|
||||
emitFailed("Error parsing version list JSON: jsonDoc is not an object");
|
||||
return;
|
||||
}
|
||||
|
||||
const QJsonObject root = jsonDoc.object();
|
||||
|
||||
// Now, get the array of versions.
|
||||
if (!root.value("versions").isObject())
|
||||
{
|
||||
emitFailed("Error parsing version list JSON: missing 'versions' object");
|
||||
return;
|
||||
}
|
||||
|
||||
auto meta = root.value("meta").toObject();
|
||||
QString description = meta.value("description").toString(tr("This is a lightweight loader for mods that don't change game mechanics."));
|
||||
QString defaultUrl = meta.value("url").toString("http://dl.liteloader.com");
|
||||
QString authors = meta.value("authors").toString("Mumfrey");
|
||||
auto versions = root.value("versions").toObject();
|
||||
|
||||
QList<BaseVersionPtr> tempList;
|
||||
for (auto vIt = versions.begin(); vIt != versions.end(); ++vIt)
|
||||
{
|
||||
const QString mcVersion = vIt.key();
|
||||
const QJsonObject versionObject = vIt.value().toObject();
|
||||
|
||||
auto processArtefacts = [&](QJsonObject artefacts, bool notSnapshots, std::shared_ptr<LiteLoaderVersion> &latest)
|
||||
{
|
||||
QString latestVersion;
|
||||
QList<BaseVersionPtr> perMcVersionList;
|
||||
for (auto aIt = artefacts.begin(); aIt != artefacts.end(); ++aIt)
|
||||
{
|
||||
const QString identifier = aIt.key();
|
||||
const QJsonObject artefact = aIt.value().toObject();
|
||||
if (identifier == "latest")
|
||||
{
|
||||
latestVersion = artefact.value("version").toString();
|
||||
continue;
|
||||
}
|
||||
LiteLoaderVersionPtr version(new LiteLoaderVersion());
|
||||
version->version = artefact.value("version").toString();
|
||||
version->mcVersion = mcVersion;
|
||||
version->md5 = artefact.value("md5").toString();
|
||||
version->timestamp = artefact.value("timestamp").toString().toLong();
|
||||
version->tweakClass = artefact.value("tweakClass").toString();
|
||||
version->authors = authors;
|
||||
version->description = description;
|
||||
version->defaultUrl = defaultUrl;
|
||||
version->isSnapshot = !notSnapshots;
|
||||
const QJsonArray libs = artefact.value("libraries").toArray();
|
||||
for (auto lIt = libs.begin(); lIt != libs.end(); ++lIt)
|
||||
{
|
||||
auto libobject = (*lIt).toObject();
|
||||
try
|
||||
{
|
||||
auto lib = OneSixVersionFormat::libraryFromJson(libobject, "versions.json");
|
||||
// hack to make liteloader 1.7.10_00 work
|
||||
if(lib->rawName() == GradleSpecifier("org.ow2.asm:asm-all:5.0.3"))
|
||||
{
|
||||
lib->setRepositoryURL("http://repo.maven.apache.org/maven2/");
|
||||
}
|
||||
version->libraries.append(lib);
|
||||
}
|
||||
catch (Exception &e)
|
||||
{
|
||||
qCritical() << "Couldn't read JSON object:";
|
||||
continue; // FIXME: ignores bad libraries and continues loading
|
||||
}
|
||||
}
|
||||
auto liteloaderLib = std::make_shared<Library>("com.mumfrey:liteloader:" + version->version);
|
||||
liteloaderLib->setRepositoryURL("http://dl.liteloader.com/versions/");
|
||||
if(!notSnapshots)
|
||||
{
|
||||
liteloaderLib->setHint("always-stale");
|
||||
}
|
||||
version->libraries.append(liteloaderLib);
|
||||
perMcVersionList.append(version);
|
||||
}
|
||||
if(notSnapshots)
|
||||
{
|
||||
for (auto version : perMcVersionList)
|
||||
{
|
||||
auto v = std::dynamic_pointer_cast<LiteLoaderVersion>(version);
|
||||
if(v->version == latestVersion)
|
||||
{
|
||||
latest = v;
|
||||
}
|
||||
}
|
||||
}
|
||||
tempList.append(perMcVersionList);
|
||||
};
|
||||
|
||||
std::shared_ptr<LiteLoaderVersion> latestSnapshot;
|
||||
std::shared_ptr<LiteLoaderVersion> latestRelease;
|
||||
// are there actually released versions for this mc version?
|
||||
if(versionObject.contains("artefacts"))
|
||||
{
|
||||
const QJsonObject artefacts = versionObject.value("artefacts").toObject().value("com.mumfrey:liteloader").toObject();
|
||||
processArtefacts(artefacts, true, latestRelease);
|
||||
}
|
||||
if(versionObject.contains("snapshots"))
|
||||
{
|
||||
QJsonObject artefacts = versionObject.value("snapshots").toObject().value("com.mumfrey:liteloader").toObject();
|
||||
processArtefacts(artefacts, false, latestSnapshot);
|
||||
}
|
||||
if(latestSnapshot)
|
||||
{
|
||||
latestSnapshot->isLatest = true;
|
||||
}
|
||||
else if(latestRelease)
|
||||
{
|
||||
latestRelease->isLatest = true;
|
||||
}
|
||||
if(latestRelease)
|
||||
{
|
||||
latestRelease->isRecommended = true;
|
||||
}
|
||||
}
|
||||
m_list->updateListData(tempList);
|
||||
|
||||
emitSucceeded();
|
||||
}
|
@ -1,123 +0,0 @@
|
||||
/* Copyright 2013-2017 MultiMC Contributors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include "BaseVersion.h"
|
||||
#include "BaseVersionList.h"
|
||||
#include "tasks/Task.h"
|
||||
#include "net/NetJob.h"
|
||||
#include <minecraft/Library.h>
|
||||
#include <minecraft/VersionFile.h>
|
||||
|
||||
#include "multimc_logic_export.h"
|
||||
|
||||
class LLListLoadTask;
|
||||
class QNetworkReply;
|
||||
|
||||
class LiteLoaderVersion : public BaseVersion
|
||||
{
|
||||
public:
|
||||
QString descriptor() override
|
||||
{
|
||||
if (isLatest)
|
||||
{
|
||||
return QObject::tr("Latest");
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
QString typeString() const override
|
||||
{
|
||||
return mcVersion;
|
||||
}
|
||||
QString name() override
|
||||
{
|
||||
return version;
|
||||
}
|
||||
VersionFilePtr getVersionFile();
|
||||
|
||||
// important info
|
||||
QString version;
|
||||
QString mcVersion;
|
||||
QString md5;
|
||||
long timestamp = 0;
|
||||
bool isLatest = false;
|
||||
bool isRecommended = false;
|
||||
bool isSnapshot = false;
|
||||
|
||||
QString tweakClass;
|
||||
QList<LibraryPtr> libraries;
|
||||
|
||||
// meta
|
||||
QString defaultUrl;
|
||||
QString description;
|
||||
QString authors;
|
||||
};
|
||||
typedef std::shared_ptr<LiteLoaderVersion> LiteLoaderVersionPtr;
|
||||
|
||||
class MULTIMC_LOGIC_EXPORT LiteLoaderVersionList : public BaseVersionList
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
friend class LLListLoadTask;
|
||||
|
||||
explicit LiteLoaderVersionList(QObject *parent = 0);
|
||||
|
||||
Task *getLoadTask() override;
|
||||
bool isLoaded() override;
|
||||
const BaseVersionPtr at(int i) const override;
|
||||
int count() const override;
|
||||
void sortVersions() override;
|
||||
QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const override;
|
||||
RoleList providesRoles() const override;
|
||||
|
||||
virtual BaseVersionPtr getLatestStable() const override;
|
||||
|
||||
protected:
|
||||
QList<BaseVersionPtr> m_vlist;
|
||||
|
||||
bool m_loaded = false;
|
||||
|
||||
protected
|
||||
slots:
|
||||
void updateListData(QList<BaseVersionPtr> versions) override;
|
||||
};
|
||||
|
||||
class LLListLoadTask : public Task
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit LLListLoadTask(LiteLoaderVersionList *vlist);
|
||||
~LLListLoadTask();
|
||||
|
||||
virtual void executeTask();
|
||||
|
||||
protected
|
||||
slots:
|
||||
void listDownloaded();
|
||||
void listFailed();
|
||||
|
||||
protected:
|
||||
NetJobPtr listJob;
|
||||
Net::Download::Ptr listDownload;
|
||||
LiteLoaderVersionList *m_list;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(LiteLoaderVersionPtr)
|
@ -42,8 +42,6 @@
|
||||
#include "icons/IconList.h"
|
||||
//FIXME: get rid of this
|
||||
#include "minecraft/legacy/LwjglVersionList.h"
|
||||
#include "minecraft/liteloader/LiteLoaderVersionList.h"
|
||||
#include "minecraft/forge/ForgeVersionList.h"
|
||||
|
||||
#include "net/HttpMetaCache.h"
|
||||
#include "net/URLConstants.h"
|
||||
@ -868,26 +866,6 @@ std::shared_ptr<LWJGLVersionList> MultiMC::lwjgllist()
|
||||
return m_lwjgllist;
|
||||
}
|
||||
|
||||
std::shared_ptr<ForgeVersionList> MultiMC::forgelist()
|
||||
{
|
||||
if (!m_forgelist)
|
||||
{
|
||||
m_forgelist.reset(new ForgeVersionList());
|
||||
ENV.registerVersionList("net.minecraftforge", m_forgelist);
|
||||
}
|
||||
return m_forgelist;
|
||||
}
|
||||
|
||||
std::shared_ptr<LiteLoaderVersionList> MultiMC::liteloaderlist()
|
||||
{
|
||||
if (!m_liteloaderlist)
|
||||
{
|
||||
m_liteloaderlist.reset(new LiteLoaderVersionList());
|
||||
ENV.registerVersionList("com.mumfrey.liteloader", m_liteloaderlist);
|
||||
}
|
||||
return m_liteloaderlist;
|
||||
}
|
||||
|
||||
std::shared_ptr<JavaInstallList> MultiMC::javalist()
|
||||
{
|
||||
if (!m_javalist)
|
||||
|
@ -25,8 +25,6 @@ class InstanceList;
|
||||
class MojangAccountList;
|
||||
class IconList;
|
||||
class QNetworkAccessManager;
|
||||
class ForgeVersionList;
|
||||
class LiteLoaderVersionList;
|
||||
class JavaInstallList;
|
||||
class UpdateChecker;
|
||||
class BaseProfilerFactory;
|
||||
@ -96,8 +94,6 @@ public:
|
||||
|
||||
std::shared_ptr<TranslationsModel> translations();
|
||||
std::shared_ptr<LWJGLVersionList> lwjgllist();
|
||||
std::shared_ptr<ForgeVersionList> forgelist();
|
||||
std::shared_ptr<LiteLoaderVersionList> liteloaderlist();
|
||||
std::shared_ptr<JavaInstallList> javalist();
|
||||
|
||||
std::shared_ptr<InstanceList> instances() const
|
||||
@ -200,8 +196,6 @@ private:
|
||||
std::shared_ptr<UpdateChecker> m_updateChecker;
|
||||
std::shared_ptr<MojangAccountList> m_accounts;
|
||||
std::shared_ptr<LWJGLVersionList> m_lwjgllist;
|
||||
std::shared_ptr<ForgeVersionList> m_forgelist;
|
||||
std::shared_ptr<LiteLoaderVersionList> m_liteloaderlist;
|
||||
std::shared_ptr<JavaInstallList> m_javalist;
|
||||
std::shared_ptr<TranslationsModel> m_translations;
|
||||
std::shared_ptr<GenericPageProvider> m_globalSettingsProvider;
|
||||
|
@ -36,10 +36,6 @@
|
||||
#include <QUrl>
|
||||
|
||||
#include "minecraft/MinecraftProfile.h"
|
||||
#include "minecraft/forge/ForgeVersionList.h"
|
||||
#include "minecraft/forge/ForgeInstaller.h"
|
||||
#include "minecraft/liteloader/LiteLoaderVersionList.h"
|
||||
#include "minecraft/liteloader/LiteLoaderInstaller.h"
|
||||
#include "minecraft/auth/MojangAccountList.h"
|
||||
#include "minecraft/Mod.h"
|
||||
#include "icons/IconList.h"
|
||||
@ -375,16 +371,18 @@ int VersionPage::doUpdate()
|
||||
|
||||
void VersionPage::on_forgeBtn_clicked()
|
||||
{
|
||||
VersionSelectDialog vselect(MMC->forgelist().get(), tr("Select Forge version"), this);
|
||||
auto vlist = ENV.getVersionList("net.minecraftforge");
|
||||
if(!vlist)
|
||||
{
|
||||
return;
|
||||
}
|
||||
VersionSelectDialog vselect(vlist.get(), tr("Select Forge version"), this);
|
||||
vselect.setExactFilter(BaseVersionList::ParentGameVersionRole, m_inst->currentVersionId());
|
||||
vselect.setEmptyString(tr("No Forge versions are currently available for Minecraft ") +
|
||||
m_inst->currentVersionId());
|
||||
vselect.setEmptyString(tr("No Forge versions are currently available for Minecraft ") + m_inst->currentVersionId());
|
||||
vselect.setEmptyErrorString(tr("Couldn't load or download the Forge version lists!"));
|
||||
if (vselect.exec() && vselect.selectedVersion())
|
||||
{
|
||||
ProgressDialog dialog(this);
|
||||
dialog.execWithTask(
|
||||
ForgeInstaller().createInstallTask(m_inst, vselect.selectedVersion(), this));
|
||||
m_profile->installVersion(vselect.selectedVersion());
|
||||
preselect(m_profile->rowCount(QModelIndex())-1);
|
||||
m_container->refreshContainer();
|
||||
}
|
||||
@ -392,17 +390,18 @@ void VersionPage::on_forgeBtn_clicked()
|
||||
|
||||
void VersionPage::on_liteloaderBtn_clicked()
|
||||
{
|
||||
VersionSelectDialog vselect(MMC->liteloaderlist().get(), tr("Select LiteLoader version"),
|
||||
this);
|
||||
auto vlist = ENV.getVersionList("com.liteloader");
|
||||
if(!vlist)
|
||||
{
|
||||
return;
|
||||
}
|
||||
VersionSelectDialog vselect(vlist.get(), tr("Select LiteLoader version"), this);
|
||||
vselect.setExactFilter(BaseVersionList::ParentGameVersionRole, m_inst->currentVersionId());
|
||||
vselect.setEmptyString(tr("No LiteLoader versions are currently available for Minecraft ") +
|
||||
m_inst->currentVersionId());
|
||||
vselect.setEmptyString(tr("No LiteLoader versions are currently available for Minecraft ") + m_inst->currentVersionId());
|
||||
vselect.setEmptyErrorString(tr("Couldn't load or download the LiteLoader version lists!"));
|
||||
if (vselect.exec() && vselect.selectedVersion())
|
||||
{
|
||||
ProgressDialog dialog(this);
|
||||
dialog.execWithTask(
|
||||
LiteLoaderInstaller().createInstallTask(m_inst, vselect.selectedVersion(), this));
|
||||
m_profile->installVersion(vselect.selectedVersion());
|
||||
preselect(m_profile->rowCount(QModelIndex())-1);
|
||||
m_container->refreshContainer();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user