Begin the transformation!
Nuke all the things.
This commit is contained in:
		@@ -29,7 +29,7 @@ class BaseInstaller
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
	BaseInstaller();
 | 
			
		||||
 | 
			
		||||
	virtual ~BaseInstaller(){};
 | 
			
		||||
	bool isApplied(OneSixInstance *on);
 | 
			
		||||
 | 
			
		||||
	virtual bool add(OneSixInstance *to);
 | 
			
		||||
 
 | 
			
		||||
@@ -16,6 +16,8 @@
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
#include <memory>
 | 
			
		||||
#include <QString>
 | 
			
		||||
#include <QMetaType>
 | 
			
		||||
 | 
			
		||||
/*!
 | 
			
		||||
 * An abstract base class for versions.
 | 
			
		||||
@@ -52,4 +54,4 @@ struct BaseVersion
 | 
			
		||||
 | 
			
		||||
typedef std::shared_ptr<BaseVersion> BaseVersionPtr;
 | 
			
		||||
 | 
			
		||||
Q_DECLARE_METATYPE(BaseVersionPtr)
 | 
			
		||||
Q_DECLARE_METATYPE(BaseVersionPtr)
 | 
			
		||||
 
 | 
			
		||||
@@ -23,7 +23,6 @@
 | 
			
		||||
#include "LegacyFTBInstance.h"
 | 
			
		||||
#include "OneSixInstance.h"
 | 
			
		||||
#include "OneSixFTBInstance.h"
 | 
			
		||||
#include "NostalgiaInstance.h"
 | 
			
		||||
#include "OneSixInstance.h"
 | 
			
		||||
#include "BaseVersion.h"
 | 
			
		||||
#include "MinecraftVersion.h"
 | 
			
		||||
@@ -51,7 +50,7 @@ InstanceFactory::InstLoadError InstanceFactory::loadInstance(InstancePtr &inst,
 | 
			
		||||
	QString inst_type = m_settings->get("InstanceType").toString();
 | 
			
		||||
 | 
			
		||||
	// FIXME: replace with a map lookup, where instance classes register their types
 | 
			
		||||
	if (inst_type == "OneSix")
 | 
			
		||||
	if (inst_type == "OneSix" || inst_type == "Nostalgia")
 | 
			
		||||
	{
 | 
			
		||||
		inst.reset(new OneSixInstance(instDir, m_settings, this));
 | 
			
		||||
	}
 | 
			
		||||
@@ -59,10 +58,6 @@ InstanceFactory::InstLoadError InstanceFactory::loadInstance(InstancePtr &inst,
 | 
			
		||||
	{
 | 
			
		||||
		inst.reset(new LegacyInstance(instDir, m_settings, this));
 | 
			
		||||
	}
 | 
			
		||||
	else if (inst_type == "Nostalgia")
 | 
			
		||||
	{
 | 
			
		||||
		inst.reset(new NostalgiaInstance(instDir, m_settings, this));
 | 
			
		||||
	}
 | 
			
		||||
	else if (inst_type == "LegacyFTB")
 | 
			
		||||
	{
 | 
			
		||||
		inst.reset(new LegacyFTBInstance(instDir, m_settings, this));
 | 
			
		||||
@@ -98,55 +93,26 @@ InstanceFactory::InstCreateError InstanceFactory::createInstance(InstancePtr &in
 | 
			
		||||
 | 
			
		||||
	if (type == NormalInst)
 | 
			
		||||
	{
 | 
			
		||||
		switch (mcVer->type)
 | 
			
		||||
		{
 | 
			
		||||
		case MinecraftVersion::Legacy:
 | 
			
		||||
			// TODO new instance type
 | 
			
		||||
			m_settings->set("InstanceType", "Legacy");
 | 
			
		||||
			inst.reset(new LegacyInstance(instDir, m_settings, this));
 | 
			
		||||
			inst->setIntendedVersionId(version->descriptor());
 | 
			
		||||
			inst->setShouldUseCustomBaseJar(false);
 | 
			
		||||
			break;
 | 
			
		||||
		case MinecraftVersion::OneSix:
 | 
			
		||||
			m_settings->set("InstanceType", "OneSix");
 | 
			
		||||
			inst.reset(new OneSixInstance(instDir, m_settings, this));
 | 
			
		||||
			inst->setIntendedVersionId(version->descriptor());
 | 
			
		||||
			inst->setShouldUseCustomBaseJar(false);
 | 
			
		||||
			break;
 | 
			
		||||
		case MinecraftVersion::Nostalgia:
 | 
			
		||||
			m_settings->set("InstanceType", "Nostalgia");
 | 
			
		||||
			inst.reset(new NostalgiaInstance(instDir, m_settings, this));
 | 
			
		||||
			inst->setIntendedVersionId(version->descriptor());
 | 
			
		||||
			inst->setShouldUseCustomBaseJar(false);
 | 
			
		||||
			break;
 | 
			
		||||
		default:
 | 
			
		||||
		{
 | 
			
		||||
			delete m_settings;
 | 
			
		||||
			return InstanceFactory::NoSuchVersion;
 | 
			
		||||
		}
 | 
			
		||||
		}
 | 
			
		||||
		m_settings->set("InstanceType", "OneSix");
 | 
			
		||||
		inst.reset(new OneSixInstance(instDir, m_settings, this));
 | 
			
		||||
		inst->setIntendedVersionId(version->descriptor());
 | 
			
		||||
		inst->setShouldUseCustomBaseJar(false);
 | 
			
		||||
	}
 | 
			
		||||
	else if (type == FTBInstance)
 | 
			
		||||
	{
 | 
			
		||||
		switch (mcVer->type)
 | 
			
		||||
		if(mcVer->usesLegacyLauncher())
 | 
			
		||||
		{
 | 
			
		||||
		case MinecraftVersion::Legacy:
 | 
			
		||||
			m_settings->set("InstanceType", "LegacyFTB");
 | 
			
		||||
			inst.reset(new LegacyFTBInstance(instDir, m_settings, this));
 | 
			
		||||
			inst->setIntendedVersionId(version->descriptor());
 | 
			
		||||
			inst->setShouldUseCustomBaseJar(false);
 | 
			
		||||
			break;
 | 
			
		||||
		case MinecraftVersion::OneSix:
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			m_settings->set("InstanceType", "OneSixFTB");
 | 
			
		||||
			inst.reset(new OneSixFTBInstance(instDir, m_settings, this));
 | 
			
		||||
			inst->setIntendedVersionId(version->descriptor());
 | 
			
		||||
			inst->setShouldUseCustomBaseJar(false);
 | 
			
		||||
			break;
 | 
			
		||||
		default:
 | 
			
		||||
		{
 | 
			
		||||
			delete m_settings;
 | 
			
		||||
			return InstanceFactory::NoSuchVersion;
 | 
			
		||||
		}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	else
 | 
			
		||||
 
 | 
			
		||||
@@ -29,8 +29,6 @@
 | 
			
		||||
#include "logic/LegacyUpdate.h"
 | 
			
		||||
#include "logic/icons/IconList.h"
 | 
			
		||||
 | 
			
		||||
#include "gui/dialogs/LegacyModEditDialog.h"
 | 
			
		||||
 | 
			
		||||
LegacyInstance::LegacyInstance(const QString &rootDir, SettingsObject *settings,
 | 
			
		||||
							   QObject *parent)
 | 
			
		||||
	: BaseInstance(new LegacyInstancePrivate(), rootDir, settings, parent)
 | 
			
		||||
@@ -138,7 +136,7 @@ std::shared_ptr<ModList> LegacyInstance::texturePackList()
 | 
			
		||||
 | 
			
		||||
QDialog *LegacyInstance::createModEditDialog(QWidget *parent)
 | 
			
		||||
{
 | 
			
		||||
	return new LegacyModEditDialog(this, parent);
 | 
			
		||||
	return nullptr;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QString LegacyInstance::jarModsDir() const
 | 
			
		||||
@@ -280,10 +278,7 @@ QString LegacyInstance::getStatusbarDescription()
 | 
			
		||||
{
 | 
			
		||||
	if (flags().contains(VersionBrokenFlag))
 | 
			
		||||
	{
 | 
			
		||||
		return "Legacy : " + intendedVersionId() + " (broken)";
 | 
			
		||||
		return tr("Legacy : %1 (broken)").arg(intendedVersionId());
 | 
			
		||||
	}
 | 
			
		||||
	if (shouldUpdate())
 | 
			
		||||
		return "Legacy : " + currentVersionId() + " -> " + intendedVersionId();
 | 
			
		||||
	else
 | 
			
		||||
		return "Legacy : " + currentVersionId();
 | 
			
		||||
	return tr("Legacy : %1").arg(intendedVersionId());
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -30,52 +30,6 @@
 | 
			
		||||
 | 
			
		||||
LegacyUpdate::LegacyUpdate(BaseInstance *inst, QObject *parent) : Task(parent), m_inst(inst)
 | 
			
		||||
{
 | 
			
		||||
	// 1.3 - 1.3.2
 | 
			
		||||
	auto libs13 = QList<FMLlib>{
 | 
			
		||||
		{"argo-2.25.jar", "bb672829fde76cb163004752b86b0484bd0a7f4b", false},
 | 
			
		||||
		{"guava-12.0.1.jar", "b8e78b9af7bf45900e14c6f958486b6ca682195f", false},
 | 
			
		||||
		{"asm-all-4.0.jar", "98308890597acb64047f7e896638e0d98753ae82", false}};
 | 
			
		||||
 | 
			
		||||
	fmlLibsMapping["1.3.2"] = libs13;
 | 
			
		||||
 | 
			
		||||
	auto libs14 = QList<FMLlib>{
 | 
			
		||||
		{"argo-2.25.jar", "bb672829fde76cb163004752b86b0484bd0a7f4b", false},
 | 
			
		||||
		{"guava-12.0.1.jar", "b8e78b9af7bf45900e14c6f958486b6ca682195f", false},
 | 
			
		||||
		{"asm-all-4.0.jar", "98308890597acb64047f7e896638e0d98753ae82", false},
 | 
			
		||||
		{"bcprov-jdk15on-147.jar", "b6f5d9926b0afbde9f4dbe3db88c5247be7794bb", false}};
 | 
			
		||||
 | 
			
		||||
	fmlLibsMapping["1.4"] = libs14;
 | 
			
		||||
	fmlLibsMapping["1.4.1"] = libs14;
 | 
			
		||||
	fmlLibsMapping["1.4.2"] = libs14;
 | 
			
		||||
	fmlLibsMapping["1.4.3"] = libs14;
 | 
			
		||||
	fmlLibsMapping["1.4.4"] = libs14;
 | 
			
		||||
	fmlLibsMapping["1.4.5"] = libs14;
 | 
			
		||||
	fmlLibsMapping["1.4.6"] = libs14;
 | 
			
		||||
	fmlLibsMapping["1.4.7"] = libs14;
 | 
			
		||||
 | 
			
		||||
	fmlLibsMapping["1.5"] = QList<FMLlib>{
 | 
			
		||||
		{"argo-small-3.2.jar", "58912ea2858d168c50781f956fa5b59f0f7c6b51", false},
 | 
			
		||||
		{"guava-14.0-rc3.jar", "931ae21fa8014c3ce686aaa621eae565fefb1a6a", false},
 | 
			
		||||
		{"asm-all-4.1.jar", "054986e962b88d8660ae4566475658469595ef58", false},
 | 
			
		||||
		{"bcprov-jdk15on-148.jar", "960dea7c9181ba0b17e8bab0c06a43f0a5f04e65", true},
 | 
			
		||||
		{"deobfuscation_data_1.5.zip", "5f7c142d53776f16304c0bbe10542014abad6af8", false},
 | 
			
		||||
		{"scala-library.jar", "458d046151ad179c85429ed7420ffb1eaf6ddf85", true}};
 | 
			
		||||
 | 
			
		||||
	fmlLibsMapping["1.5.1"] = QList<FMLlib>{
 | 
			
		||||
		{"argo-small-3.2.jar", "58912ea2858d168c50781f956fa5b59f0f7c6b51", false},
 | 
			
		||||
		{"guava-14.0-rc3.jar", "931ae21fa8014c3ce686aaa621eae565fefb1a6a", false},
 | 
			
		||||
		{"asm-all-4.1.jar", "054986e962b88d8660ae4566475658469595ef58", false},
 | 
			
		||||
		{"bcprov-jdk15on-148.jar", "960dea7c9181ba0b17e8bab0c06a43f0a5f04e65", true},
 | 
			
		||||
		{"deobfuscation_data_1.5.1.zip", "22e221a0d89516c1f721d6cab056a7e37471d0a6", false},
 | 
			
		||||
		{"scala-library.jar", "458d046151ad179c85429ed7420ffb1eaf6ddf85", true}};
 | 
			
		||||
 | 
			
		||||
	fmlLibsMapping["1.5.2"] = QList<FMLlib>{
 | 
			
		||||
		{"argo-small-3.2.jar", "58912ea2858d168c50781f956fa5b59f0f7c6b51", false},
 | 
			
		||||
		{"guava-14.0-rc3.jar", "931ae21fa8014c3ce686aaa621eae565fefb1a6a", false},
 | 
			
		||||
		{"asm-all-4.1.jar", "054986e962b88d8660ae4566475658469595ef58", false},
 | 
			
		||||
		{"bcprov-jdk15on-148.jar", "960dea7c9181ba0b17e8bab0c06a43f0a5f04e65", true},
 | 
			
		||||
		{"deobfuscation_data_1.5.2.zip", "446e55cd986582c70fcf12cb27bc00114c5adfd9", false},
 | 
			
		||||
		{"scala-library.jar", "458d046151ad179c85429ed7420ffb1eaf6ddf85", true}};
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void LegacyUpdate::executeTask()
 | 
			
		||||
@@ -110,6 +64,7 @@ void LegacyUpdate::fmllibsStart()
 | 
			
		||||
	bool forge_present = false;
 | 
			
		||||
 | 
			
		||||
	QString version = inst->intendedVersionId();
 | 
			
		||||
	auto & fmlLibsMapping = g_forgeData.fmlLibsMapping;
 | 
			
		||||
	if (!fmlLibsMapping.contains(version))
 | 
			
		||||
	{
 | 
			
		||||
		lwjglStart();
 | 
			
		||||
@@ -152,7 +107,7 @@ void LegacyUpdate::fmllibsStart()
 | 
			
		||||
	// now check the lib folder inside the instance for files.
 | 
			
		||||
	for (auto &lib : libList)
 | 
			
		||||
	{
 | 
			
		||||
		QFileInfo libInfo(PathCombine(inst->libDir(), lib.name));
 | 
			
		||||
		QFileInfo libInfo(PathCombine(inst->libDir(), lib.filename));
 | 
			
		||||
		if (libInfo.exists())
 | 
			
		||||
			continue;
 | 
			
		||||
		fmlLibsToProcess.append(lib);
 | 
			
		||||
@@ -171,9 +126,9 @@ void LegacyUpdate::fmllibsStart()
 | 
			
		||||
	auto metacache = MMC->metacache();
 | 
			
		||||
	for (auto &lib : fmlLibsToProcess)
 | 
			
		||||
	{
 | 
			
		||||
		auto entry = metacache->resolveEntry("fmllibs", lib.name);
 | 
			
		||||
		QString urlString = lib.ours ? URLConstants::FMLLIBS_OUR_BASE_URL + lib.name
 | 
			
		||||
									 : URLConstants::FMLLIBS_FORGE_BASE_URL + lib.name;
 | 
			
		||||
		auto entry = metacache->resolveEntry("fmllibs", lib.filename);
 | 
			
		||||
		QString urlString = lib.ours ? URLConstants::FMLLIBS_OUR_BASE_URL + lib.filename
 | 
			
		||||
									 : URLConstants::FMLLIBS_FORGE_BASE_URL + lib.filename;
 | 
			
		||||
		dljob->addNetAction(CacheDownload::make(QUrl(urlString), entry));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -196,16 +151,16 @@ void LegacyUpdate::fmllibsFinished()
 | 
			
		||||
		for (auto &lib : fmlLibsToProcess)
 | 
			
		||||
		{
 | 
			
		||||
			progress(index, fmlLibsToProcess.size());
 | 
			
		||||
			auto entry = metacache->resolveEntry("fmllibs", lib.name);
 | 
			
		||||
			auto path = PathCombine(inst->libDir(), lib.name);
 | 
			
		||||
			auto entry = metacache->resolveEntry("fmllibs", lib.filename);
 | 
			
		||||
			auto path = PathCombine(inst->libDir(), lib.filename);
 | 
			
		||||
			if(!ensureFilePathExists(path))
 | 
			
		||||
			{
 | 
			
		||||
				emitFailed(tr("Failed creating FML library folder inside the instance."));
 | 
			
		||||
				return;
 | 
			
		||||
			}
 | 
			
		||||
			if (!QFile::copy(entry->getFullPath(), PathCombine(inst->libDir(), lib.name)))
 | 
			
		||||
			if (!QFile::copy(entry->getFullPath(), PathCombine(inst->libDir(), lib.filename)))
 | 
			
		||||
			{
 | 
			
		||||
				emitFailed(tr("Failed copying Forge/FML library: %1.").arg(lib.name));
 | 
			
		||||
				emitFailed(tr("Failed copying Forge/FML library: %1.").arg(lib.filename));
 | 
			
		||||
				return;
 | 
			
		||||
			}
 | 
			
		||||
			index++;
 | 
			
		||||
@@ -265,8 +220,6 @@ void LegacyUpdate::lwjglStart()
 | 
			
		||||
	connect(rep, SIGNAL(downloadProgress(qint64, qint64)), SIGNAL(progress(qint64, qint64)));
 | 
			
		||||
	connect(worker.get(), SIGNAL(finished(QNetworkReply *)),
 | 
			
		||||
			SLOT(lwjglFinished(QNetworkReply *)));
 | 
			
		||||
	// connect(rep, SIGNAL(error(QNetworkReply::NetworkError)),
 | 
			
		||||
	// SLOT(downloadError(QNetworkReply::NetworkError)));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void LegacyUpdate::lwjglFinished(QNetworkReply *reply)
 | 
			
		||||
 
 | 
			
		||||
@@ -21,19 +21,13 @@
 | 
			
		||||
 | 
			
		||||
#include "logic/net/NetJob.h"
 | 
			
		||||
#include "logic/tasks/Task.h"
 | 
			
		||||
#include "logic/forge/ForgeData.h"
 | 
			
		||||
 | 
			
		||||
class MinecraftVersion;
 | 
			
		||||
class BaseInstance;
 | 
			
		||||
class QuaZip;
 | 
			
		||||
class Mod;
 | 
			
		||||
 | 
			
		||||
struct FMLlib
 | 
			
		||||
{
 | 
			
		||||
	QString name;
 | 
			
		||||
	QString checksum;
 | 
			
		||||
	bool ours;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
class LegacyUpdate : public Task
 | 
			
		||||
{
 | 
			
		||||
	Q_OBJECT
 | 
			
		||||
@@ -84,5 +78,4 @@ private:
 | 
			
		||||
	NetJobPtr legacyDownloadJob;
 | 
			
		||||
	BaseInstance *m_inst = nullptr;
 | 
			
		||||
	QList<FMLlib> fmlLibsToProcess;
 | 
			
		||||
	QMap<QString, QList<FMLlib>> fmlLibsMapping;
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
@@ -17,6 +17,7 @@
 | 
			
		||||
 | 
			
		||||
#include "BaseVersion.h"
 | 
			
		||||
#include <QStringList>
 | 
			
		||||
#include <QSet>
 | 
			
		||||
 | 
			
		||||
struct MinecraftVersion : public BaseVersion
 | 
			
		||||
{
 | 
			
		||||
@@ -29,13 +30,8 @@ struct MinecraftVersion : public BaseVersion
 | 
			
		||||
	/// The URL that this version will be downloaded from. maybe.
 | 
			
		||||
	QString download_url;
 | 
			
		||||
 | 
			
		||||
	/// This version's type. Used internally to identify what kind of version this is.
 | 
			
		||||
	enum VersionType
 | 
			
		||||
	{
 | 
			
		||||
		OneSix,
 | 
			
		||||
		Legacy,
 | 
			
		||||
		Nostalgia
 | 
			
		||||
	} type;
 | 
			
		||||
	/// extra features enabled for this Minecraft version. Mostly for compatibility
 | 
			
		||||
	QSet <QString> features;
 | 
			
		||||
 | 
			
		||||
	/// is this the latest version?
 | 
			
		||||
	bool is_latest = false;
 | 
			
		||||
@@ -47,6 +43,11 @@ struct MinecraftVersion : public BaseVersion
 | 
			
		||||
 | 
			
		||||
	QString m_descriptor;
 | 
			
		||||
 | 
			
		||||
	bool usesLegacyLauncher()
 | 
			
		||||
	{
 | 
			
		||||
		return features.contains("legacy");
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	virtual QString descriptor()
 | 
			
		||||
	{
 | 
			
		||||
		return m_descriptor;
 | 
			
		||||
@@ -59,31 +60,21 @@ struct MinecraftVersion : public BaseVersion
 | 
			
		||||
 | 
			
		||||
	virtual QString typeString() const
 | 
			
		||||
	{
 | 
			
		||||
		QStringList pre_final;
 | 
			
		||||
		if (is_latest == true)
 | 
			
		||||
		if (is_latest && is_snapshot)
 | 
			
		||||
		{
 | 
			
		||||
			pre_final.append("Latest");
 | 
			
		||||
			return QObject::tr("Latest snapshot");
 | 
			
		||||
		}
 | 
			
		||||
		switch (type)
 | 
			
		||||
		else if(is_latest)
 | 
			
		||||
		{
 | 
			
		||||
		case OneSix:
 | 
			
		||||
			pre_final.append("OneSix");
 | 
			
		||||
			break;
 | 
			
		||||
		case Legacy:
 | 
			
		||||
			pre_final.append("Legacy");
 | 
			
		||||
			break;
 | 
			
		||||
		case Nostalgia:
 | 
			
		||||
			pre_final.append("Nostalgia");
 | 
			
		||||
			break;
 | 
			
		||||
 | 
			
		||||
		default:
 | 
			
		||||
			pre_final.append(QString("Type(%1)").arg(type));
 | 
			
		||||
			break;
 | 
			
		||||
			return QObject::tr("Latest release");
 | 
			
		||||
		}
 | 
			
		||||
		if (is_snapshot == true)
 | 
			
		||||
		else if(is_snapshot)
 | 
			
		||||
		{
 | 
			
		||||
			pre_final.append("Snapshot");
 | 
			
		||||
			return QObject::tr("Old snapshot");
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			return QObject::tr("Regular release");
 | 
			
		||||
		}
 | 
			
		||||
		return pre_final.join(' ');
 | 
			
		||||
	}
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
@@ -1,36 +0,0 @@
 | 
			
		||||
/* Copyright 2013 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 "NostalgiaInstance.h"
 | 
			
		||||
 | 
			
		||||
NostalgiaInstance::NostalgiaInstance(const QString &rootDir, SettingsObject *settings,
 | 
			
		||||
									 QObject *parent)
 | 
			
		||||
	: OneSixInstance(rootDir, settings, parent)
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QString NostalgiaInstance::getStatusbarDescription()
 | 
			
		||||
{
 | 
			
		||||
	if (flags().contains(VersionBrokenFlag))
 | 
			
		||||
	{
 | 
			
		||||
		return "Nostalgia : " + intendedVersionId() + " (broken)";
 | 
			
		||||
	}
 | 
			
		||||
	return "Nostalgia : " + intendedVersionId();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool NostalgiaInstance::menuActionEnabled(QString action_name) const
 | 
			
		||||
{
 | 
			
		||||
	return false;
 | 
			
		||||
}
 | 
			
		||||
@@ -1,29 +0,0 @@
 | 
			
		||||
/* Copyright 2013 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 "OneSixInstance.h"
 | 
			
		||||
 | 
			
		||||
class NostalgiaInstance : public OneSixInstance
 | 
			
		||||
{
 | 
			
		||||
	Q_OBJECT
 | 
			
		||||
public:
 | 
			
		||||
	explicit NostalgiaInstance(const QString &rootDir, SettingsObject *settings,
 | 
			
		||||
							   QObject *parent = 0);
 | 
			
		||||
	virtual ~NostalgiaInstance() {};
 | 
			
		||||
	virtual QString getStatusbarDescription();
 | 
			
		||||
	virtual bool menuActionEnabled(QString action_name) const;
 | 
			
		||||
};
 | 
			
		||||
@@ -3,8 +3,8 @@
 | 
			
		||||
#include "VersionFinal.h"
 | 
			
		||||
#include "OneSixLibrary.h"
 | 
			
		||||
#include "tasks/SequentialTask.h"
 | 
			
		||||
#include "ForgeInstaller.h"
 | 
			
		||||
#include "lists/ForgeVersionList.h"
 | 
			
		||||
#include "forge/ForgeInstaller.h"
 | 
			
		||||
#include "forge/ForgeVersionList.h"
 | 
			
		||||
#include "OneSixInstance_p.h"
 | 
			
		||||
#include "OneSixVersionBuilder.h"
 | 
			
		||||
#include "MultiMC.h"
 | 
			
		||||
 
 | 
			
		||||
@@ -26,7 +26,7 @@
 | 
			
		||||
#include "MultiMC.h"
 | 
			
		||||
#include "icons/IconList.h"
 | 
			
		||||
#include "MinecraftProcess.h"
 | 
			
		||||
#include "gui/dialogs/OneSixModEditDialog.h"
 | 
			
		||||
#include "gui/dialogs/InstanceEditDialog.h"
 | 
			
		||||
#include <MMCError.h>
 | 
			
		||||
 | 
			
		||||
OneSixInstance::OneSixInstance(const QString &rootDir, SettingsObject *settings, QObject *parent)
 | 
			
		||||
@@ -36,7 +36,6 @@ OneSixInstance::OneSixInstance(const QString &rootDir, SettingsObject *settings,
 | 
			
		||||
	d->m_settings->registerSetting("IntendedVersion", "");
 | 
			
		||||
	d->m_settings->registerSetting("ShouldUpdate", false);
 | 
			
		||||
	d->version.reset(new VersionFinal(this, this));
 | 
			
		||||
	d->vanillaVersion.reset(new VersionFinal(this, this));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void OneSixInstance::init()
 | 
			
		||||
@@ -260,6 +259,17 @@ std::shared_ptr<ModList> OneSixInstance::loaderModList()
 | 
			
		||||
	return d->loader_mod_list;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
std::shared_ptr<ModList> OneSixInstance::coreModList()
 | 
			
		||||
{
 | 
			
		||||
	I_D(OneSixInstance);
 | 
			
		||||
	if (!d->core_mod_list)
 | 
			
		||||
	{
 | 
			
		||||
		d->core_mod_list.reset(new ModList(coreModsDir()));
 | 
			
		||||
	}
 | 
			
		||||
	d->core_mod_list->update();
 | 
			
		||||
	return d->core_mod_list;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
std::shared_ptr<ModList> OneSixInstance::resourcePackList()
 | 
			
		||||
{
 | 
			
		||||
	I_D(OneSixInstance);
 | 
			
		||||
@@ -273,7 +283,7 @@ std::shared_ptr<ModList> OneSixInstance::resourcePackList()
 | 
			
		||||
 | 
			
		||||
QDialog *OneSixInstance::createModEditDialog(QWidget *parent)
 | 
			
		||||
{
 | 
			
		||||
	return new OneSixModEditDialog(this, parent);
 | 
			
		||||
	return new InstanceEditDialog(this, parent);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool OneSixInstance::setIntendedVersionId(QString version)
 | 
			
		||||
@@ -307,10 +317,13 @@ bool OneSixInstance::shouldUpdate() const
 | 
			
		||||
 | 
			
		||||
bool OneSixInstance::versionIsCustom()
 | 
			
		||||
{
 | 
			
		||||
	QDir patches(PathCombine(instanceRoot(), "patches/"));
 | 
			
		||||
	return (patches.exists() && patches.count() >= 0)
 | 
			
		||||
			|| QFile::exists(PathCombine(instanceRoot(), "custom.json"))
 | 
			
		||||
			|| QFile::exists(PathCombine(instanceRoot(), "user.json"));
 | 
			
		||||
	I_D(const OneSixInstance);
 | 
			
		||||
	auto ver = d->version;
 | 
			
		||||
	if(ver)
 | 
			
		||||
	{
 | 
			
		||||
		return !ver->isVanilla();
 | 
			
		||||
	}
 | 
			
		||||
	return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool OneSixInstance::versionIsFTBPack()
 | 
			
		||||
@@ -335,15 +348,13 @@ void OneSixInstance::reloadVersion()
 | 
			
		||||
 | 
			
		||||
	try
 | 
			
		||||
	{
 | 
			
		||||
		d->version->reload(false, externalPatches());
 | 
			
		||||
		d->vanillaVersion->reload(true, externalPatches());
 | 
			
		||||
		d->version->reload(externalPatches());
 | 
			
		||||
		d->m_flags.remove(VersionBrokenFlag);
 | 
			
		||||
		emit versionReloaded();
 | 
			
		||||
	}
 | 
			
		||||
	catch(MMCError & error)
 | 
			
		||||
	{
 | 
			
		||||
		d->version->clear();
 | 
			
		||||
		d->vanillaVersion->clear();
 | 
			
		||||
		d->m_flags.insert(VersionBrokenFlag);
 | 
			
		||||
		//TODO: rethrow to show some error message(s)?
 | 
			
		||||
		emit versionReloaded();
 | 
			
		||||
@@ -355,7 +366,6 @@ void OneSixInstance::clearVersion()
 | 
			
		||||
{
 | 
			
		||||
	I_D(OneSixInstance);
 | 
			
		||||
	d->version->clear();
 | 
			
		||||
	d->vanillaVersion->clear();
 | 
			
		||||
	emit versionReloaded();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -365,12 +375,6 @@ std::shared_ptr<VersionFinal> OneSixInstance::getFullVersion() const
 | 
			
		||||
	return d->version;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
std::shared_ptr<VersionFinal> OneSixInstance::getVanillaVersion() const
 | 
			
		||||
{
 | 
			
		||||
	I_D(const OneSixInstance);
 | 
			
		||||
	return d->vanillaVersion;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QString OneSixInstance::defaultBaseJar() const
 | 
			
		||||
{
 | 
			
		||||
	return "versions/" + intendedVersionId() + "/" + intendedVersionId() + ".jar";
 | 
			
		||||
@@ -396,16 +400,24 @@ bool OneSixInstance::menuActionEnabled(QString action_name) const
 | 
			
		||||
 | 
			
		||||
QString OneSixInstance::getStatusbarDescription()
 | 
			
		||||
{
 | 
			
		||||
	QString descr = "OneSix : " + intendedVersionId();
 | 
			
		||||
	QStringList traits;
 | 
			
		||||
	if (versionIsCustom())
 | 
			
		||||
	{
 | 
			
		||||
		descr += " (custom)";
 | 
			
		||||
		traits.append(tr("custom"));
 | 
			
		||||
	}
 | 
			
		||||
	if (flags().contains(VersionBrokenFlag))
 | 
			
		||||
	{
 | 
			
		||||
		descr += " (broken)";
 | 
			
		||||
		traits.append(tr("broken"));
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	if(traits.size())
 | 
			
		||||
	{
 | 
			
		||||
		return tr("Minecraft %1 (%2)").arg(intendedVersionId()).arg(traits.join(", "));
 | 
			
		||||
	}
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
		return tr("Minecraft %1").arg(intendedVersionId());
 | 
			
		||||
	}
 | 
			
		||||
	return descr;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QDir OneSixInstance::librariesPath() const
 | 
			
		||||
@@ -449,6 +461,11 @@ QString OneSixInstance::loaderModsDir() const
 | 
			
		||||
	return PathCombine(minecraftRoot(), "mods");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QString OneSixInstance::coreModsDir() const
 | 
			
		||||
{
 | 
			
		||||
	return PathCombine(minecraftRoot(), "coremods");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QString OneSixInstance::resourcePacksDir() const
 | 
			
		||||
{
 | 
			
		||||
	return PathCombine(minecraftRoot(), "resourcepacks");
 | 
			
		||||
@@ -458,3 +475,8 @@ QString OneSixInstance::instanceConfigFolder() const
 | 
			
		||||
{
 | 
			
		||||
	return PathCombine(minecraftRoot(), "config");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QString OneSixInstance::jarModsDir() const
 | 
			
		||||
{
 | 
			
		||||
	return PathCombine(instanceRoot(), "jarmods");
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -32,11 +32,14 @@ public:
 | 
			
		||||
 | 
			
		||||
	//////  Mod Lists  //////
 | 
			
		||||
	std::shared_ptr<ModList> loaderModList();
 | 
			
		||||
	std::shared_ptr<ModList> coreModList();
 | 
			
		||||
	std::shared_ptr<ModList> resourcePackList();
 | 
			
		||||
 | 
			
		||||
	////// Directories //////
 | 
			
		||||
	////// Directories and files //////
 | 
			
		||||
	QString jarModsDir() const;
 | 
			
		||||
	QString resourcePacksDir() const;
 | 
			
		||||
	QString loaderModsDir() const;
 | 
			
		||||
	QString coreModsDir() const;
 | 
			
		||||
	virtual QString instanceConfigFolder() const override;
 | 
			
		||||
 | 
			
		||||
	virtual std::shared_ptr<Task> doUpdate() override;
 | 
			
		||||
@@ -60,14 +63,16 @@ public:
 | 
			
		||||
	 * throws various exceptions :3
 | 
			
		||||
	 */
 | 
			
		||||
	void reloadVersion();
 | 
			
		||||
	
 | 
			
		||||
	/// clears all version information in preparation for an update
 | 
			
		||||
	void clearVersion();
 | 
			
		||||
	
 | 
			
		||||
	/// get the current full version info
 | 
			
		||||
	std::shared_ptr<VersionFinal> getFullVersion() const;
 | 
			
		||||
	/// gets the current version info, but only for version.json
 | 
			
		||||
	std::shared_ptr<VersionFinal> getVanillaVersion() const;
 | 
			
		||||
	
 | 
			
		||||
	/// is the current version original, or custom?
 | 
			
		||||
	virtual bool versionIsCustom() override;
 | 
			
		||||
	
 | 
			
		||||
	/// does this instance have an FTB pack patch inside?
 | 
			
		||||
	bool versionIsFTBPack();
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -24,7 +24,8 @@ class OneSixInstancePrivate : public BaseInstancePrivate
 | 
			
		||||
public:
 | 
			
		||||
	virtual ~OneSixInstancePrivate() {};
 | 
			
		||||
	std::shared_ptr<VersionFinal> version;
 | 
			
		||||
	std::shared_ptr<VersionFinal> vanillaVersion;
 | 
			
		||||
	std::shared_ptr<ModList> jar_mod_list;
 | 
			
		||||
	std::shared_ptr<ModList> loader_mod_list;
 | 
			
		||||
	std::shared_ptr<ModList> core_mod_list;
 | 
			
		||||
	std::shared_ptr<ModList> resource_pack_list;
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
@@ -41,7 +41,7 @@ private:
 | 
			
		||||
	// custom values
 | 
			
		||||
	/// absolute URL. takes precedence over m_download_path, if defined
 | 
			
		||||
	QString m_absolute_url;
 | 
			
		||||
	/// download hint - how to actually get the library
 | 
			
		||||
	/// type hint - modifies how the library is treated
 | 
			
		||||
	QString m_hint;
 | 
			
		||||
 | 
			
		||||
	// derived values used for real things
 | 
			
		||||
 
 | 
			
		||||
@@ -28,7 +28,7 @@
 | 
			
		||||
#include "VersionFinal.h"
 | 
			
		||||
#include "OneSixLibrary.h"
 | 
			
		||||
#include "OneSixInstance.h"
 | 
			
		||||
#include "net/ForgeMirrors.h"
 | 
			
		||||
#include "logic/forge/ForgeMirrors.h"
 | 
			
		||||
#include "net/URLConstants.h"
 | 
			
		||||
#include "assets/AssetsUtils.h"
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -38,13 +38,12 @@ OneSixVersionBuilder::OneSixVersionBuilder()
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void OneSixVersionBuilder::build(VersionFinal *version, OneSixInstance *instance,
 | 
			
		||||
								 const bool onlyVanilla, const QStringList &external)
 | 
			
		||||
void OneSixVersionBuilder::build(VersionFinal *version, OneSixInstance *instance, const QStringList &external)
 | 
			
		||||
{
 | 
			
		||||
	OneSixVersionBuilder builder;
 | 
			
		||||
	builder.m_version = version;
 | 
			
		||||
	builder.m_instance = instance;
 | 
			
		||||
	builder.buildInternal(onlyVanilla, external);
 | 
			
		||||
	builder.buildInternal(external);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void OneSixVersionBuilder::readJsonAndApplyToVersion(VersionFinal *version,
 | 
			
		||||
@@ -56,7 +55,7 @@ void OneSixVersionBuilder::readJsonAndApplyToVersion(VersionFinal *version,
 | 
			
		||||
	builder.readJsonAndApply(obj);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void OneSixVersionBuilder::buildInternal(const bool onlyVanilla, const QStringList &external)
 | 
			
		||||
void OneSixVersionBuilder::buildInternal(const QStringList &external)
 | 
			
		||||
{
 | 
			
		||||
	m_version->versionFiles.clear();
 | 
			
		||||
 | 
			
		||||
@@ -111,9 +110,6 @@ void OneSixVersionBuilder::buildInternal(const bool onlyVanilla, const QStringLi
 | 
			
		||||
			// QObject::tr("Error while applying %1. Please check MultiMC-0.log for more
 | 
			
		||||
			// info.").arg(root.absoluteFilePath("version.json")));
 | 
			
		||||
 | 
			
		||||
			if (onlyVanilla)
 | 
			
		||||
				break;
 | 
			
		||||
 | 
			
		||||
			// patches/
 | 
			
		||||
			// load all, put into map for ordering, apply in the right order
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -28,8 +28,7 @@ class OneSixVersionBuilder
 | 
			
		||||
{
 | 
			
		||||
	OneSixVersionBuilder();
 | 
			
		||||
public:
 | 
			
		||||
	static void build(VersionFinal *version, OneSixInstance *instance, const bool onlyVanilla,
 | 
			
		||||
					  const QStringList &external);
 | 
			
		||||
	static void build(VersionFinal *version, OneSixInstance *instance, const QStringList &external);
 | 
			
		||||
	static void readJsonAndApplyToVersion(VersionFinal *version, const QJsonObject &obj);
 | 
			
		||||
 | 
			
		||||
	static QMap<QString, int> readOverrideOrders(OneSixInstance *instance);
 | 
			
		||||
@@ -39,7 +38,7 @@ private:
 | 
			
		||||
	VersionFinal *m_version;
 | 
			
		||||
	OneSixInstance *m_instance;
 | 
			
		||||
 | 
			
		||||
	void buildInternal(const bool onlyVanilla, const QStringList &external);
 | 
			
		||||
	void buildInternal(const QStringList& external);
 | 
			
		||||
	void readJsonAndApply(const QJsonObject &obj);
 | 
			
		||||
 | 
			
		||||
	VersionFilePtr parseJsonFile(const QFileInfo &fileInfo, const bool requireOrder,
 | 
			
		||||
 
 | 
			
		||||
@@ -13,6 +13,43 @@ using namespace MMCJson;
 | 
			
		||||
 | 
			
		||||
#define CURRENT_MINIMUM_LAUNCHER_VERSION 14
 | 
			
		||||
 | 
			
		||||
JarmodPtr Jarmod::fromJson(const QJsonObject &libObj, const QString &filename)
 | 
			
		||||
{
 | 
			
		||||
	JarmodPtr out(new Jarmod());
 | 
			
		||||
	if (!libObj.contains("name"))
 | 
			
		||||
	{
 | 
			
		||||
		throw JSONValidationError(filename +
 | 
			
		||||
								  "contains a jarmod that doesn't have a 'name' field");
 | 
			
		||||
	}
 | 
			
		||||
	out->name = libObj.value("name").toString();
 | 
			
		||||
 | 
			
		||||
	auto readString = [libObj, filename](const QString & key, QString & variable)
 | 
			
		||||
	{
 | 
			
		||||
		if (libObj.contains(key))
 | 
			
		||||
		{
 | 
			
		||||
			QJsonValue val = libObj.value(key);
 | 
			
		||||
			if (!val.isString())
 | 
			
		||||
			{
 | 
			
		||||
				QLOG_WARN() << key << "is not a string in" << filename << "(skipping)";
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				variable = val.toString();
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	readString("url", out->baseurl);
 | 
			
		||||
	readString("MMC-absoluteUrl", out->absoluteUrl);
 | 
			
		||||
	if(!out->baseurl.isEmpty() && out->absoluteUrl.isEmpty())
 | 
			
		||||
	{
 | 
			
		||||
		out->absoluteUrl = out->baseurl + out->name;
 | 
			
		||||
	}
 | 
			
		||||
	return out;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
RawLibraryPtr RawLibrary::fromJson(const QJsonObject &libObj, const QString &filename)
 | 
			
		||||
{
 | 
			
		||||
	RawLibraryPtr out(new RawLibrary());
 | 
			
		||||
@@ -165,6 +202,14 @@ VersionFilePtr VersionFile::fromJson(const QJsonDocument &doc, const QString &fi
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (root.contains("+traits"))
 | 
			
		||||
	{
 | 
			
		||||
		for (auto tweakerVal : ensureArray(root.value("+traits")))
 | 
			
		||||
		{
 | 
			
		||||
			out->traits.insert(ensureString(tweakerVal));
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (root.contains("libraries"))
 | 
			
		||||
	{
 | 
			
		||||
		// FIXME: This should be done when applying.
 | 
			
		||||
@@ -188,6 +233,18 @@ VersionFilePtr VersionFile::fromJson(const QJsonDocument &doc, const QString &fi
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (root.contains("+jarMods"))
 | 
			
		||||
	{
 | 
			
		||||
		for (auto libVal : ensureArray(root.value("+jarMods")))
 | 
			
		||||
		{
 | 
			
		||||
			QJsonObject libObj = ensureObject(libVal);
 | 
			
		||||
			// parse the jarmod
 | 
			
		||||
			auto lib = Jarmod::fromJson(libObj, filename);
 | 
			
		||||
			// and add to jar mods
 | 
			
		||||
			out->jarMods.append(lib);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (root.contains("+libraries"))
 | 
			
		||||
	{
 | 
			
		||||
		for (auto libVal : ensureArray(root.value("+libraries")))
 | 
			
		||||
@@ -258,6 +315,7 @@ VersionFilePtr VersionFile::fromJson(const QJsonDocument &doc, const QString &fi
 | 
			
		||||
			out->addLibs.append(lib);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (root.contains("-libraries"))
 | 
			
		||||
	{
 | 
			
		||||
		for (auto libVal : ensureArray(root.value("-libraries")))
 | 
			
		||||
@@ -309,6 +367,16 @@ int VersionFile::findLibrary(QList<OneSixLibraryPtr> haystack, const QString &ne
 | 
			
		||||
	return retval;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool VersionFile::isVanilla()
 | 
			
		||||
{
 | 
			
		||||
	return fileId == "org.multimc.version.json";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool VersionFile::hasJarMods()
 | 
			
		||||
{
 | 
			
		||||
	return !jarMods.isEmpty();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void VersionFile::applyTo(VersionFinal *version)
 | 
			
		||||
{
 | 
			
		||||
	if (minimumLauncherVersion != -1)
 | 
			
		||||
@@ -338,6 +406,10 @@ void VersionFile::applyTo(VersionFinal *version)
 | 
			
		||||
	}
 | 
			
		||||
	if (!processArguments.isNull())
 | 
			
		||||
	{
 | 
			
		||||
		if(isVanilla())
 | 
			
		||||
		{
 | 
			
		||||
			version->vanillaProcessArguments = processArguments;
 | 
			
		||||
		}
 | 
			
		||||
		version->processArguments = processArguments;
 | 
			
		||||
	}
 | 
			
		||||
	if (!type.isNull())
 | 
			
		||||
@@ -362,6 +434,10 @@ void VersionFile::applyTo(VersionFinal *version)
 | 
			
		||||
	}
 | 
			
		||||
	if (!overwriteMinecraftArguments.isNull())
 | 
			
		||||
	{
 | 
			
		||||
		if(isVanilla())
 | 
			
		||||
		{
 | 
			
		||||
			version->vanillaMinecraftArguments = overwriteMinecraftArguments;
 | 
			
		||||
		}
 | 
			
		||||
		version->minecraftArguments = overwriteMinecraftArguments;
 | 
			
		||||
	}
 | 
			
		||||
	if (!addMinecraftArguments.isNull())
 | 
			
		||||
@@ -384,13 +460,17 @@ void VersionFile::applyTo(VersionFinal *version)
 | 
			
		||||
	{
 | 
			
		||||
		version->tweakers.removeAll(tweaker);
 | 
			
		||||
	}
 | 
			
		||||
	version->jarMods.append(jarMods);
 | 
			
		||||
	if (shouldOverwriteLibs)
 | 
			
		||||
	{
 | 
			
		||||
		version->libraries.clear();
 | 
			
		||||
		QList<OneSixLibraryPtr> libs;
 | 
			
		||||
		for (auto lib : overwriteLibs)
 | 
			
		||||
		{
 | 
			
		||||
			version->libraries.append(createLibrary(lib));
 | 
			
		||||
			libs.append(createLibrary(lib));
 | 
			
		||||
		}
 | 
			
		||||
		if(isVanilla())
 | 
			
		||||
			version->vanillaLibraries = libs;
 | 
			
		||||
		version->libraries = libs;
 | 
			
		||||
	}
 | 
			
		||||
	for (auto lib : addLibs)
 | 
			
		||||
	{
 | 
			
		||||
 
 | 
			
		||||
@@ -81,6 +81,18 @@ struct RawLibrary
 | 
			
		||||
	static RawLibraryPtr fromJson(const QJsonObject &libObj, const QString &filename);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct Jarmod;
 | 
			
		||||
typedef std::shared_ptr<Jarmod> JarmodPtr;
 | 
			
		||||
struct Jarmod
 | 
			
		||||
{
 | 
			
		||||
	QString name;
 | 
			
		||||
	QString baseurl;
 | 
			
		||||
	QString hint;
 | 
			
		||||
	QString absoluteUrl;
 | 
			
		||||
	
 | 
			
		||||
	static JarmodPtr fromJson(const QJsonObject &libObj, const QString &filename);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct VersionFile;
 | 
			
		||||
typedef std::shared_ptr<VersionFile> VersionFilePtr;
 | 
			
		||||
struct VersionFile
 | 
			
		||||
@@ -92,7 +104,8 @@ public: /* methods */
 | 
			
		||||
	static OneSixLibraryPtr createLibrary(RawLibraryPtr lib);
 | 
			
		||||
	int findLibrary(QList<OneSixLibraryPtr> haystack, const QString &needle);
 | 
			
		||||
	void applyTo(VersionFinal *version);
 | 
			
		||||
 | 
			
		||||
	bool isVanilla();
 | 
			
		||||
	bool hasJarMods();
 | 
			
		||||
public: /* data */
 | 
			
		||||
	int order = 0;
 | 
			
		||||
	QString name;
 | 
			
		||||
@@ -124,4 +137,8 @@ public: /* data */
 | 
			
		||||
	QList<RawLibraryPtr> overwriteLibs;
 | 
			
		||||
	QList<RawLibraryPtr> addLibs;
 | 
			
		||||
	QList<QString> removeLibs;
 | 
			
		||||
 | 
			
		||||
	QSet<QString> traits;
 | 
			
		||||
 | 
			
		||||
	QList<JarmodPtr> jarMods;
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
@@ -21,16 +21,7 @@
 | 
			
		||||
 | 
			
		||||
#include "OneSixVersionBuilder.h"
 | 
			
		||||
#include "OneSixInstance.h"
 | 
			
		||||
 | 
			
		||||
template <typename A, typename B> QMap<A, B> invert(const QMap<B, A> &in)
 | 
			
		||||
{
 | 
			
		||||
	QMap<A, B> out;
 | 
			
		||||
	for (auto it = in.begin(); it != in.end(); ++it)
 | 
			
		||||
	{
 | 
			
		||||
		out.insert(it.value(), it.key());
 | 
			
		||||
	}
 | 
			
		||||
	return out;
 | 
			
		||||
}
 | 
			
		||||
#include <pathutils.h>
 | 
			
		||||
 | 
			
		||||
VersionFinal::VersionFinal(OneSixInstance *instance, QObject *parent)
 | 
			
		||||
	: QAbstractListModel(parent), m_instance(instance)
 | 
			
		||||
@@ -38,11 +29,10 @@ VersionFinal::VersionFinal(OneSixInstance *instance, QObject *parent)
 | 
			
		||||
	clear();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void VersionFinal::reload(const bool onlyVanilla, const QStringList &external)
 | 
			
		||||
void VersionFinal::reload(const QStringList &external)
 | 
			
		||||
{
 | 
			
		||||
	//FIXME: source of epic failure.
 | 
			
		||||
	beginResetModel();
 | 
			
		||||
	OneSixVersionBuilder::build(this, m_instance, onlyVanilla, external);
 | 
			
		||||
	OneSixVersionBuilder::build(this, m_instance, external);
 | 
			
		||||
	reapply(true);
 | 
			
		||||
	endResetModel();
 | 
			
		||||
}
 | 
			
		||||
@@ -60,6 +50,8 @@ void VersionFinal::clear()
 | 
			
		||||
	mainClass.clear();
 | 
			
		||||
	libraries.clear();
 | 
			
		||||
	tweakers.clear();
 | 
			
		||||
	jarMods.clear();
 | 
			
		||||
	traits.clear();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool VersionFinal::canRemove(const int index) const
 | 
			
		||||
@@ -119,6 +111,11 @@ VersionFilePtr VersionFinal::versionFile(const QString &id)
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool VersionFinal::hasJarMods()
 | 
			
		||||
{
 | 
			
		||||
	return !jarMods.isEmpty();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool VersionFinal::hasFtbPack()
 | 
			
		||||
{
 | 
			
		||||
	return versionFile("org.multimc.ftb.pack.json") != nullptr;
 | 
			
		||||
@@ -129,6 +126,36 @@ bool VersionFinal::removeFtbPack()
 | 
			
		||||
	return remove("org.multimc.ftb.pack.json");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool VersionFinal::isVanilla()
 | 
			
		||||
{
 | 
			
		||||
	QDir patches(PathCombine(m_instance->instanceRoot(), "patches/"));
 | 
			
		||||
	return versionFiles.size() > 1 || QFile::exists(PathCombine(m_instance->instanceRoot(), "custom.json"));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool VersionFinal::revertToVanilla()
 | 
			
		||||
{
 | 
			
		||||
	beginResetModel();
 | 
			
		||||
	auto it = versionFiles.begin();
 | 
			
		||||
	while (it != versionFiles.end())
 | 
			
		||||
	{
 | 
			
		||||
		if ((*it)->fileId != "org.multimc.version.json")
 | 
			
		||||
		{
 | 
			
		||||
			QFile::remove((*it)->filename);
 | 
			
		||||
			it = versionFiles.erase(it);
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
			it++;
 | 
			
		||||
	}
 | 
			
		||||
	reapply(true);
 | 
			
		||||
	endResetModel();
 | 
			
		||||
	return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool VersionFinal::usesLegacyCustomJson()
 | 
			
		||||
{
 | 
			
		||||
	return QFile::exists(PathCombine(m_instance->instanceRoot(), "custom.json"));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QList<std::shared_ptr<OneSixLibrary> > VersionFinal::getActiveNormalLibs()
 | 
			
		||||
{
 | 
			
		||||
	QList<std::shared_ptr<OneSixLibrary> > output;
 | 
			
		||||
@@ -229,15 +256,6 @@ int VersionFinal::columnCount(const QModelIndex &parent) const
 | 
			
		||||
	return 2;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool VersionFinal::isCustom()
 | 
			
		||||
{
 | 
			
		||||
	return QDir(m_instance->instanceRoot()).exists("custom.json");
 | 
			
		||||
}
 | 
			
		||||
bool VersionFinal::revertToBase()
 | 
			
		||||
{
 | 
			
		||||
	return QDir(m_instance->instanceRoot()).remove("custom.json");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QMap<QString, int> VersionFinal::getExistingOrder() const
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
@@ -356,8 +374,10 @@ void VersionFinal::finalize()
 | 
			
		||||
	{
 | 
			
		||||
		assets = "legacy";
 | 
			
		||||
	}
 | 
			
		||||
	if (minecraftArguments.isEmpty())
 | 
			
		||||
	auto finalizeArguments = [&]( QString & minecraftArguments, const QString & processArguments ) -> void
 | 
			
		||||
	{
 | 
			
		||||
		if (!minecraftArguments.isEmpty())
 | 
			
		||||
			return;
 | 
			
		||||
		QString toCompare = processArguments.toLower();
 | 
			
		||||
		if (toCompare == "legacy")
 | 
			
		||||
		{
 | 
			
		||||
@@ -370,8 +390,11 @@ void VersionFinal::finalize()
 | 
			
		||||
		else if (toCompare == "username_session_version")
 | 
			
		||||
		{
 | 
			
		||||
			minecraftArguments = "--username ${auth_player_name} "
 | 
			
		||||
								 "--session ${auth_session} "
 | 
			
		||||
								 "--version ${profile_name}";
 | 
			
		||||
								"--session ${auth_session} "
 | 
			
		||||
								"--version ${profile_name}";
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	};
 | 
			
		||||
	finalizeArguments(vanillaMinecraftArguments, vanillaProcessArguments);
 | 
			
		||||
	finalizeArguments(minecraftArguments, processArguments);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -38,22 +38,29 @@ public:
 | 
			
		||||
	virtual int columnCount(const QModelIndex &parent) const;
 | 
			
		||||
	virtual Qt::ItemFlags flags(const QModelIndex &index) const;
 | 
			
		||||
 | 
			
		||||
	void reload(const bool onlyVanilla = false, const QStringList &external = QStringList());
 | 
			
		||||
	void reload(const QStringList &external = QStringList());
 | 
			
		||||
	void clear();
 | 
			
		||||
 | 
			
		||||
	bool canRemove(const int index) const;
 | 
			
		||||
 | 
			
		||||
	QString versionFileId(const int index) const;
 | 
			
		||||
 | 
			
		||||
	// does this instance have an all overriding custom.json
 | 
			
		||||
	bool isCustom();
 | 
			
		||||
	// remove custom.json
 | 
			
		||||
	bool revertToBase();
 | 
			
		||||
	// does this instance have an FTB pack patch file?
 | 
			
		||||
	// is this version unmodded vanilla minecraft?
 | 
			
		||||
	bool isVanilla();
 | 
			
		||||
	// remove any customizations on top of vanilla
 | 
			
		||||
	bool revertToVanilla();
 | 
			
		||||
	
 | 
			
		||||
	// does this version have an FTB pack patch file?
 | 
			
		||||
	bool hasFtbPack();
 | 
			
		||||
	// remove FTB pack
 | 
			
		||||
	bool removeFtbPack();
 | 
			
		||||
	
 | 
			
		||||
	// does this version have any jar mods?
 | 
			
		||||
	bool hasJarMods();
 | 
			
		||||
	
 | 
			
		||||
	// does this version still use a legacy custom.json file?
 | 
			
		||||
	bool usesLegacyCustomJson();
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
	enum MoveDirection { MoveUp, MoveDown };
 | 
			
		||||
	void move(const int index, const MoveDirection direction);
 | 
			
		||||
@@ -91,6 +98,8 @@ public:
 | 
			
		||||
	 * ex: "username_session_version"
 | 
			
		||||
	 */
 | 
			
		||||
	QString processArguments;
 | 
			
		||||
	/// Same as above, but only for vanilla
 | 
			
		||||
	QString vanillaProcessArguments;
 | 
			
		||||
	/**
 | 
			
		||||
	 * arguments that should be used for launching minecraft
 | 
			
		||||
	 *
 | 
			
		||||
@@ -98,6 +107,8 @@ public:
 | 
			
		||||
	 *      --version ${version_name} --gameDir ${game_directory} --assetsDir ${game_assets}"
 | 
			
		||||
	 */
 | 
			
		||||
	QString minecraftArguments;
 | 
			
		||||
	/// Same as above, but only for vanilla
 | 
			
		||||
	QString vanillaMinecraftArguments;
 | 
			
		||||
	/**
 | 
			
		||||
	 * the minimum launcher version required by this version ... current is 4 (at point of
 | 
			
		||||
	 * writing)
 | 
			
		||||
@@ -114,6 +125,15 @@ public:
 | 
			
		||||
 | 
			
		||||
	/// the list of libs - both active and inactive, native and java
 | 
			
		||||
	QList<std::shared_ptr<OneSixLibrary>> libraries;
 | 
			
		||||
	
 | 
			
		||||
	/// same, but only vanilla.
 | 
			
		||||
	QList<std::shared_ptr<OneSixLibrary>> vanillaLibraries;
 | 
			
		||||
 | 
			
		||||
	/// traits, collected from all the version files (version files can only add)
 | 
			
		||||
	QSet<QString> traits;
 | 
			
		||||
 | 
			
		||||
	/// A list of jar mods. version files can add those.
 | 
			
		||||
	QList<JarmodPtr> jarMods;
 | 
			
		||||
 | 
			
		||||
	/*
 | 
			
		||||
	FIXME: add support for those rules here? Looks like a pile of quick hacks to me though.
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										62
									
								
								logic/forge/ForgeData.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										62
									
								
								logic/forge/ForgeData.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,62 @@
 | 
			
		||||
#include "ForgeData.h"
 | 
			
		||||
 | 
			
		||||
extern ForgeData g_forgeData = ForgeData();
 | 
			
		||||
 | 
			
		||||
ForgeData::ForgeData()
 | 
			
		||||
{
 | 
			
		||||
	// 1.3.*
 | 
			
		||||
	auto libs13 =
 | 
			
		||||
		QList<FMLlib>{{"argo-2.25.jar", "bb672829fde76cb163004752b86b0484bd0a7f4b", false},
 | 
			
		||||
					  {"guava-12.0.1.jar", "b8e78b9af7bf45900e14c6f958486b6ca682195f", false},
 | 
			
		||||
					  {"asm-all-4.0.jar", "98308890597acb64047f7e896638e0d98753ae82", false}};
 | 
			
		||||
 | 
			
		||||
	fmlLibsMapping["1.3.2"] = libs13;
 | 
			
		||||
 | 
			
		||||
	// 1.4.*
 | 
			
		||||
	auto libs14 = QList<FMLlib>{
 | 
			
		||||
		{"argo-2.25.jar", "bb672829fde76cb163004752b86b0484bd0a7f4b", false},
 | 
			
		||||
		{"guava-12.0.1.jar", "b8e78b9af7bf45900e14c6f958486b6ca682195f", false},
 | 
			
		||||
		{"asm-all-4.0.jar", "98308890597acb64047f7e896638e0d98753ae82", false},
 | 
			
		||||
		{"bcprov-jdk15on-147.jar", "b6f5d9926b0afbde9f4dbe3db88c5247be7794bb", false}};
 | 
			
		||||
 | 
			
		||||
	fmlLibsMapping["1.4"] = libs14;
 | 
			
		||||
	fmlLibsMapping["1.4.1"] = libs14;
 | 
			
		||||
	fmlLibsMapping["1.4.2"] = libs14;
 | 
			
		||||
	fmlLibsMapping["1.4.3"] = libs14;
 | 
			
		||||
	fmlLibsMapping["1.4.4"] = libs14;
 | 
			
		||||
	fmlLibsMapping["1.4.5"] = libs14;
 | 
			
		||||
	fmlLibsMapping["1.4.6"] = libs14;
 | 
			
		||||
	fmlLibsMapping["1.4.7"] = libs14;
 | 
			
		||||
 | 
			
		||||
	// 1.5
 | 
			
		||||
	fmlLibsMapping["1.5"] = QList<FMLlib>{
 | 
			
		||||
		{"argo-small-3.2.jar", "58912ea2858d168c50781f956fa5b59f0f7c6b51", false},
 | 
			
		||||
		{"guava-14.0-rc3.jar", "931ae21fa8014c3ce686aaa621eae565fefb1a6a", false},
 | 
			
		||||
		{"asm-all-4.1.jar", "054986e962b88d8660ae4566475658469595ef58", false},
 | 
			
		||||
		{"bcprov-jdk15on-148.jar", "960dea7c9181ba0b17e8bab0c06a43f0a5f04e65", true},
 | 
			
		||||
		{"deobfuscation_data_1.5.zip", "5f7c142d53776f16304c0bbe10542014abad6af8", false},
 | 
			
		||||
		{"scala-library.jar", "458d046151ad179c85429ed7420ffb1eaf6ddf85", true}};
 | 
			
		||||
 | 
			
		||||
	// 1.5.1
 | 
			
		||||
	fmlLibsMapping["1.5.1"] = QList<FMLlib>{
 | 
			
		||||
		{"argo-small-3.2.jar", "58912ea2858d168c50781f956fa5b59f0f7c6b51", false},
 | 
			
		||||
		{"guava-14.0-rc3.jar", "931ae21fa8014c3ce686aaa621eae565fefb1a6a", false},
 | 
			
		||||
		{"asm-all-4.1.jar", "054986e962b88d8660ae4566475658469595ef58", false},
 | 
			
		||||
		{"bcprov-jdk15on-148.jar", "960dea7c9181ba0b17e8bab0c06a43f0a5f04e65", true},
 | 
			
		||||
		{"deobfuscation_data_1.5.1.zip", "22e221a0d89516c1f721d6cab056a7e37471d0a6", false},
 | 
			
		||||
		{"scala-library.jar", "458d046151ad179c85429ed7420ffb1eaf6ddf85", true}};
 | 
			
		||||
 | 
			
		||||
	// 1.5.2
 | 
			
		||||
	fmlLibsMapping["1.5.2"] = QList<FMLlib>{
 | 
			
		||||
		{"argo-small-3.2.jar", "58912ea2858d168c50781f956fa5b59f0f7c6b51", false},
 | 
			
		||||
		{"guava-14.0-rc3.jar", "931ae21fa8014c3ce686aaa621eae565fefb1a6a", false},
 | 
			
		||||
		{"asm-all-4.1.jar", "054986e962b88d8660ae4566475658469595ef58", false},
 | 
			
		||||
		{"bcprov-jdk15on-148.jar", "960dea7c9181ba0b17e8bab0c06a43f0a5f04e65", true},
 | 
			
		||||
		{"deobfuscation_data_1.5.2.zip", "446e55cd986582c70fcf12cb27bc00114c5adfd9", false},
 | 
			
		||||
		{"scala-library.jar", "458d046151ad179c85429ed7420ffb1eaf6ddf85", true}};
 | 
			
		||||
	
 | 
			
		||||
	// don't use installers for those.
 | 
			
		||||
	forgeInstallerBlacklist = QSet<QString>({
 | 
			
		||||
		"1.5.2"
 | 
			
		||||
	});
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										21
									
								
								logic/forge/ForgeData.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								logic/forge/ForgeData.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,21 @@
 | 
			
		||||
#pragma once
 | 
			
		||||
#include <QMap>
 | 
			
		||||
#include <QString>
 | 
			
		||||
#include <QSet>
 | 
			
		||||
 | 
			
		||||
struct FMLlib
 | 
			
		||||
{
 | 
			
		||||
	QString filename;
 | 
			
		||||
	QString checksum;
 | 
			
		||||
	bool ours;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct ForgeData
 | 
			
		||||
{
 | 
			
		||||
	ForgeData();
 | 
			
		||||
	// mapping between minecraft versions and FML libraries required
 | 
			
		||||
	QMap<QString, QList<FMLlib>> fmlLibsMapping;
 | 
			
		||||
	// set of minecraft versions for which using forge installers is blacklisted
 | 
			
		||||
	QSet<QString> forgeInstallerBlacklist;
 | 
			
		||||
};
 | 
			
		||||
extern ForgeData g_forgeData;
 | 
			
		||||
@@ -14,9 +14,15 @@
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "ForgeInstaller.h"
 | 
			
		||||
#include "VersionFinal.h"
 | 
			
		||||
#include "OneSixLibrary.h"
 | 
			
		||||
#include "net/HttpMetaCache.h"
 | 
			
		||||
#include "logic/VersionFinal.h"
 | 
			
		||||
#include "logic/OneSixLibrary.h"
 | 
			
		||||
#include "logic/net/HttpMetaCache.h"
 | 
			
		||||
#include "logic/tasks/Task.h"
 | 
			
		||||
#include "logic/OneSixInstance.h"
 | 
			
		||||
#include "logic/forge/ForgeVersionList.h"
 | 
			
		||||
#include "ForgeData.h"
 | 
			
		||||
#include "gui/dialogs/ProgressDialog.h"
 | 
			
		||||
 | 
			
		||||
#include <quazip.h>
 | 
			
		||||
#include <quazipfile.h>
 | 
			
		||||
#include <pathutils.h>
 | 
			
		||||
@@ -24,18 +30,12 @@
 | 
			
		||||
#include <QRegularExpression>
 | 
			
		||||
#include <QRegularExpressionMatch>
 | 
			
		||||
#include "MultiMC.h"
 | 
			
		||||
#include "tasks/Task.h"
 | 
			
		||||
#include "OneSixInstance.h"
 | 
			
		||||
#include "lists/ForgeVersionList.h"
 | 
			
		||||
#include "gui/dialogs/ProgressDialog.h"
 | 
			
		||||
 | 
			
		||||
#include <QJsonDocument>
 | 
			
		||||
#include <QJsonArray>
 | 
			
		||||
#include <QSaveFile>
 | 
			
		||||
#include <QCryptographicHash>
 | 
			
		||||
 | 
			
		||||
ForgeInstaller::ForgeInstaller()
 | 
			
		||||
	: BaseInstaller()
 | 
			
		||||
ForgeInstaller::ForgeInstaller() : BaseInstaller()
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
void ForgeInstaller::prepare(const QString &filename, const QString &universalUrl)
 | 
			
		||||
@@ -115,8 +115,8 @@ void ForgeInstaller::prepare(const QString &filename, const QString &universalUr
 | 
			
		||||
	}
 | 
			
		||||
	file.close();
 | 
			
		||||
 | 
			
		||||
	m_forge_version = newVersion;
 | 
			
		||||
	realVersionId = m_forge_version->id = installObj.value("minecraft").toString();
 | 
			
		||||
	m_forge_json = newVersion;
 | 
			
		||||
	realVersionId = m_forge_json->id = installObj.value("minecraft").toString();
 | 
			
		||||
}
 | 
			
		||||
bool ForgeInstaller::add(OneSixInstance *to)
 | 
			
		||||
{
 | 
			
		||||
@@ -128,7 +128,7 @@ bool ForgeInstaller::add(OneSixInstance *to)
 | 
			
		||||
	QJsonObject obj;
 | 
			
		||||
	obj.insert("order", 5);
 | 
			
		||||
 | 
			
		||||
	if (!m_forge_version)
 | 
			
		||||
	if (!m_forge_json)
 | 
			
		||||
		return false;
 | 
			
		||||
	int sliding_insert_window = 0;
 | 
			
		||||
	{
 | 
			
		||||
@@ -136,7 +136,7 @@ bool ForgeInstaller::add(OneSixInstance *to)
 | 
			
		||||
 | 
			
		||||
		// for each library in the version we are adding (except for the blacklisted)
 | 
			
		||||
		QSet<QString> blacklist{"lwjgl", "lwjgl_util", "lwjgl-platform"};
 | 
			
		||||
		for (auto lib : m_forge_version->libraries)
 | 
			
		||||
		for (auto lib : m_forge_json->libraries)
 | 
			
		||||
		{
 | 
			
		||||
			QString libName = lib->name();
 | 
			
		||||
			// WARNING: This could actually break.
 | 
			
		||||
@@ -157,7 +157,7 @@ bool ForgeInstaller::add(OneSixInstance *to)
 | 
			
		||||
			bool found = false;
 | 
			
		||||
			bool equals = false;
 | 
			
		||||
			// find an entry that matches this one
 | 
			
		||||
			for (auto tolib : to->getVanillaVersion()->libraries)
 | 
			
		||||
			for (auto tolib : to->getFullVersion()->vanillaLibraries)
 | 
			
		||||
			{
 | 
			
		||||
				if (tolib->name() != libName)
 | 
			
		||||
					continue;
 | 
			
		||||
@@ -187,8 +187,8 @@ bool ForgeInstaller::add(OneSixInstance *to)
 | 
			
		||||
			librariesPlus.prepend(libObj);
 | 
			
		||||
		}
 | 
			
		||||
		obj.insert("+libraries", librariesPlus);
 | 
			
		||||
		obj.insert("mainClass", m_forge_version->mainClass);
 | 
			
		||||
		QString args = m_forge_version->minecraftArguments;
 | 
			
		||||
		obj.insert("mainClass", m_forge_json->mainClass);
 | 
			
		||||
		QString args = m_forge_json->minecraftArguments;
 | 
			
		||||
		QStringList tweakers;
 | 
			
		||||
		{
 | 
			
		||||
			QRegularExpression expression("--tweakClass ([a-zA-Z0-9\\.]*)");
 | 
			
		||||
@@ -200,7 +200,7 @@ bool ForgeInstaller::add(OneSixInstance *to)
 | 
			
		||||
				match = expression.match(args);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		if (!args.isEmpty() && args != to->getVanillaVersion()->minecraftArguments)
 | 
			
		||||
		if (!args.isEmpty() && args != to->getFullVersion()->vanillaMinecraftArguments)
 | 
			
		||||
		{
 | 
			
		||||
			obj.insert("minecraftArguments", args);
 | 
			
		||||
		}
 | 
			
		||||
@@ -208,10 +208,10 @@ bool ForgeInstaller::add(OneSixInstance *to)
 | 
			
		||||
		{
 | 
			
		||||
			obj.insert("+tweakers", QJsonArray::fromStringList(tweakers));
 | 
			
		||||
		}
 | 
			
		||||
		if (!m_forge_version->processArguments.isEmpty() &&
 | 
			
		||||
			m_forge_version->processArguments != to->getVanillaVersion()->processArguments)
 | 
			
		||||
		if (!m_forge_json->processArguments.isEmpty() &&
 | 
			
		||||
			m_forge_json->processArguments != to->getFullVersion()->vanillaProcessArguments)
 | 
			
		||||
		{
 | 
			
		||||
			obj.insert("processArguments", m_forge_version->processArguments);
 | 
			
		||||
			obj.insert("processArguments", m_forge_json->processArguments);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -233,11 +233,54 @@ bool ForgeInstaller::add(OneSixInstance *to)
 | 
			
		||||
	return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool ForgeInstaller::addLegacy(OneSixInstance *to)
 | 
			
		||||
{
 | 
			
		||||
	if (!BaseInstaller::add(to))
 | 
			
		||||
	{
 | 
			
		||||
		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_forgeData.fmlLibsMapping.contains(m_forge_version->mcver))
 | 
			
		||||
	{
 | 
			
		||||
		QJsonArray traitsPlus;
 | 
			
		||||
		traitsPlus.append(QString("legacyFML"));
 | 
			
		||||
		obj.insert("+traits", traitsPlus);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	QFile file(filename(to->instanceRoot()));
 | 
			
		||||
	if (!file.open(QFile::WriteOnly))
 | 
			
		||||
	{
 | 
			
		||||
		QLOG_ERROR() << "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)
 | 
			
		||||
	ForgeInstallTask(ForgeInstaller *installer, OneSixInstance *instance,
 | 
			
		||||
					 BaseVersionPtr version, QObject *parent = 0)
 | 
			
		||||
		: Task(parent), m_installer(installer), m_instance(instance), m_version(version)
 | 
			
		||||
	{
 | 
			
		||||
	}
 | 
			
		||||
@@ -245,57 +288,60 @@ public:
 | 
			
		||||
protected:
 | 
			
		||||
	void executeTask() override
 | 
			
		||||
	{
 | 
			
		||||
		setStatus(tr("Installing forge..."));
 | 
			
		||||
		ForgeVersionPtr forgeVersion = std::dynamic_pointer_cast<ForgeVersion>(m_version);
 | 
			
		||||
		if (!forgeVersion)
 | 
			
		||||
		{
 | 
			
		||||
			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 =
 | 
			
		||||
			MMC->metacache()->resolveEntry("minecraftforge", forgeVersion->filename());
 | 
			
		||||
		auto installFunction = [this, entry, forgeVersion]()
 | 
			
		||||
		{
 | 
			
		||||
			if (!install(entry, forgeVersion))
 | 
			
		||||
			{
 | 
			
		||||
				emitFailed(tr("Unknown error occured"));
 | 
			
		||||
				return;
 | 
			
		||||
			}
 | 
			
		||||
			auto entry = MMC->metacache()->resolveEntry("minecraftforge", forgeVersion->filename);
 | 
			
		||||
			if (entry->stale)
 | 
			
		||||
			{
 | 
			
		||||
				NetJob *fjob = new NetJob("Forge download");
 | 
			
		||||
				fjob->addNetAction(CacheDownload::make(forgeVersion->installer_url, entry));
 | 
			
		||||
				connect(fjob, &NetJob::progress, [this](qint64 current, qint64 total){setProgress(100 * current / qMax((qint64)1, total));});
 | 
			
		||||
				connect(fjob, &NetJob::status, [this](const QString &msg){setStatus(msg);});
 | 
			
		||||
				connect(fjob, &NetJob::failed, [this](){emitFailed(tr("Failure to download forge"));});
 | 
			
		||||
				connect(fjob, &NetJob::succeeded, [this, entry, forgeVersion]()
 | 
			
		||||
				{
 | 
			
		||||
					if (!install(entry, forgeVersion))
 | 
			
		||||
					{
 | 
			
		||||
						QLOG_ERROR() << "Failure installing forge";
 | 
			
		||||
						emitFailed(tr("Failure to install forge"));
 | 
			
		||||
					}
 | 
			
		||||
					else
 | 
			
		||||
					{
 | 
			
		||||
						reload();
 | 
			
		||||
					}
 | 
			
		||||
				});
 | 
			
		||||
				fjob->start();
 | 
			
		||||
				QLOG_ERROR() << "Failure installing forge";
 | 
			
		||||
				emitFailed(tr("Failure to install forge"));
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				if (!install(entry, forgeVersion))
 | 
			
		||||
				{
 | 
			
		||||
					QLOG_ERROR() << "Failure installing forge";
 | 
			
		||||
					emitFailed(tr("Failure to install forge"));
 | 
			
		||||
				}
 | 
			
		||||
				else
 | 
			
		||||
				{
 | 
			
		||||
					reload();
 | 
			
		||||
				}
 | 
			
		||||
				reload();
 | 
			
		||||
			}
 | 
			
		||||
		};
 | 
			
		||||
		
 | 
			
		||||
		if (entry->stale)
 | 
			
		||||
		{
 | 
			
		||||
			NetJob *fjob = new NetJob("Forge download");
 | 
			
		||||
			fjob->addNetAction(CacheDownload::make(forgeVersion->url(), entry));
 | 
			
		||||
			connect(fjob, &NetJob::progress, [this](qint64 current, qint64 total)
 | 
			
		||||
			{ setProgress(100 * current / qMax((qint64)1, total)); });
 | 
			
		||||
			connect(fjob, &NetJob::status, [this](const QString & msg)
 | 
			
		||||
			{ setStatus(msg); });
 | 
			
		||||
			connect(fjob, &NetJob::failed, [this]()
 | 
			
		||||
			{ emitFailed(tr("Failure to download forge")); });
 | 
			
		||||
			connect(fjob, &NetJob::succeeded, installFunction);
 | 
			
		||||
			fjob->start();
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			installFunction();
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	bool install(const std::shared_ptr<MetaEntry> &entry, const ForgeVersionPtr &forgeVersion)
 | 
			
		||||
	{
 | 
			
		||||
		QString forgePath = entry->getFullPath();
 | 
			
		||||
		m_installer->prepare(forgePath, forgeVersion->universal_url);
 | 
			
		||||
		return m_installer->add(m_instance);
 | 
			
		||||
		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()
 | 
			
		||||
	{
 | 
			
		||||
@@ -320,8 +366,14 @@ private:
 | 
			
		||||
	BaseVersionPtr m_version;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
ProgressProvider *ForgeInstaller::createInstallTask(OneSixInstance *instance, BaseVersionPtr version, QObject *parent)
 | 
			
		||||
ProgressProvider *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);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -15,28 +15,34 @@
 | 
			
		||||
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
#include "BaseInstaller.h"
 | 
			
		||||
#include "logic/BaseInstaller.h"
 | 
			
		||||
 | 
			
		||||
#include <QString>
 | 
			
		||||
#include <memory>
 | 
			
		||||
 | 
			
		||||
class VersionFinal;
 | 
			
		||||
class ForgeInstallTask;
 | 
			
		||||
class ForgeVersion;
 | 
			
		||||
 | 
			
		||||
class ForgeInstaller : public BaseInstaller
 | 
			
		||||
{
 | 
			
		||||
	friend class ForgeInstallTask;
 | 
			
		||||
public:
 | 
			
		||||
	ForgeInstaller();
 | 
			
		||||
	virtual ~ForgeInstaller(){};
 | 
			
		||||
	virtual ProgressProvider *createInstallTask(OneSixInstance *instance, BaseVersionPtr version, QObject *parent) override;
 | 
			
		||||
 | 
			
		||||
protected:
 | 
			
		||||
	virtual QString id() const override { return "net.minecraftforge"; }
 | 
			
		||||
	void prepare(const QString &filename, const QString &universalUrl);
 | 
			
		||||
	bool add(OneSixInstance *to) override;
 | 
			
		||||
 | 
			
		||||
	QString id() const override { return "net.minecraftforge"; }
 | 
			
		||||
 | 
			
		||||
	ProgressProvider *createInstallTask(OneSixInstance *instance, BaseVersionPtr version, QObject *parent) override;
 | 
			
		||||
	bool addLegacy(OneSixInstance *to);
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
	// the version, read from the installer
 | 
			
		||||
	std::shared_ptr<VersionFinal> m_forge_version;
 | 
			
		||||
	// the parsed version json, read from the installer
 | 
			
		||||
	std::shared_ptr<VersionFinal> m_forge_json;
 | 
			
		||||
	// the actual forge version
 | 
			
		||||
	std::shared_ptr<ForgeVersion> m_forge_version;
 | 
			
		||||
	QString internalPath;
 | 
			
		||||
	QString finalPath;
 | 
			
		||||
	QString realVersionId;
 | 
			
		||||
@@ -15,10 +15,10 @@
 | 
			
		||||
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
#include "NetAction.h"
 | 
			
		||||
#include "HttpMetaCache.h"
 | 
			
		||||
#include "ForgeXzDownload.h"
 | 
			
		||||
#include "NetJob.h"
 | 
			
		||||
#include "logic/net/NetAction.h"
 | 
			
		||||
#include "logic/net/HttpMetaCache.h"
 | 
			
		||||
#include "logic/net/NetJob.h"
 | 
			
		||||
#include "logic/forge/ForgeXzDownload.h"
 | 
			
		||||
#include <QFile>
 | 
			
		||||
#include <QTemporaryFile>
 | 
			
		||||
typedef std::shared_ptr<class ForgeMirrors> ForgeMirrorsPtr;
 | 
			
		||||
							
								
								
									
										55
									
								
								logic/forge/ForgeVersion.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										55
									
								
								logic/forge/ForgeVersion.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,55 @@
 | 
			
		||||
#include "ForgeVersion.h"
 | 
			
		||||
#include "ForgeData.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_forgeData.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;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										31
									
								
								logic/forge/ForgeVersion.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								logic/forge/ForgeVersion.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,31 @@
 | 
			
		||||
#pragma once
 | 
			
		||||
#include <QString>
 | 
			
		||||
#include <memory>
 | 
			
		||||
#include "logic/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();
 | 
			
		||||
	
 | 
			
		||||
	bool usesInstaller();
 | 
			
		||||
 | 
			
		||||
	int m_buildnr = 0;
 | 
			
		||||
	QString universal_url;
 | 
			
		||||
	QString changelog_url;
 | 
			
		||||
	QString installer_url;
 | 
			
		||||
	QString jobbuildver;
 | 
			
		||||
	QString mcver;
 | 
			
		||||
	QString universal_filename;
 | 
			
		||||
	QString installer_filename;
 | 
			
		||||
	bool is_recommended = false;
 | 
			
		||||
};
 | 
			
		||||
@@ -13,9 +13,10 @@
 | 
			
		||||
 * limitations under the License.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "ForgeVersionList.h"
 | 
			
		||||
#include <logic/net/NetJob.h>
 | 
			
		||||
#include <logic/net/URLConstants.h>
 | 
			
		||||
#include "logic/forge/ForgeVersionList.h"
 | 
			
		||||
#include "logic/forge/ForgeVersion.h"
 | 
			
		||||
#include "logic/net/NetJob.h"
 | 
			
		||||
#include "logic/net/URLConstants.h"
 | 
			
		||||
#include "MultiMC.h"
 | 
			
		||||
 | 
			
		||||
#include <QtNetwork>
 | 
			
		||||
@@ -236,7 +237,7 @@ bool ForgeListLoadTask::parseForgeList(QList<BaseVersionPtr> &out)
 | 
			
		||||
		if (!build_nr)
 | 
			
		||||
			continue;
 | 
			
		||||
		QJsonArray files = obj.value("files").toArray();
 | 
			
		||||
		QString url, jobbuildver, mcver, buildtype, filename;
 | 
			
		||||
		QString url, jobbuildver, mcver, buildtype, universal_filename;
 | 
			
		||||
		QString changelog_url, installer_url;
 | 
			
		||||
		QString installer_filename;
 | 
			
		||||
		bool valid = false;
 | 
			
		||||
@@ -254,7 +255,7 @@ bool ForgeListLoadTask::parseForgeList(QList<BaseVersionPtr> &out)
 | 
			
		||||
				url = file.value("url").toString();
 | 
			
		||||
				jobbuildver = file.value("jobbuildver").toString();
 | 
			
		||||
				int lastSlash = url.lastIndexOf('/');
 | 
			
		||||
				filename = url.mid(lastSlash + 1);
 | 
			
		||||
				universal_filename = url.mid(lastSlash + 1);
 | 
			
		||||
				valid = true;
 | 
			
		||||
			}
 | 
			
		||||
			else if (buildtype == "changelog")
 | 
			
		||||
@@ -282,14 +283,8 @@ bool ForgeListLoadTask::parseForgeList(QList<BaseVersionPtr> &out)
 | 
			
		||||
			fVersion->installer_url = installer_url;
 | 
			
		||||
			fVersion->jobbuildver = jobbuildver;
 | 
			
		||||
			fVersion->mcver = mcver;
 | 
			
		||||
			if (installer_filename.isEmpty())
 | 
			
		||||
			{
 | 
			
		||||
				fVersion->filename = filename;
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				fVersion->filename = installer_filename;
 | 
			
		||||
			}
 | 
			
		||||
			fVersion->installer_filename = installer_filename;
 | 
			
		||||
			fVersion->universal_filename = universal_filename;
 | 
			
		||||
			fVersion->m_buildnr = build_nr;
 | 
			
		||||
			out.append(fVersion);
 | 
			
		||||
		}
 | 
			
		||||
@@ -342,7 +337,7 @@ bool ForgeListLoadTask::parseForgeGradleList(QList<BaseVersionPtr> &out)
 | 
			
		||||
		fVersion->m_buildnr = number.value("build").toDouble();
 | 
			
		||||
		fVersion->jobbuildver = number.value("version").toString();
 | 
			
		||||
		fVersion->mcver = number.value("mcversion").toString();
 | 
			
		||||
		fVersion->filename = "";
 | 
			
		||||
		fVersion->universal_filename = "";
 | 
			
		||||
		QString filename, installer_filename;
 | 
			
		||||
		QJsonArray files = number.value("files").toArray();
 | 
			
		||||
		for (auto fIt = files.begin(); fIt != files.end(); ++fIt)
 | 
			
		||||
@@ -380,7 +375,8 @@ bool ForgeListLoadTask::parseForgeGradleList(QList<BaseVersionPtr> &out)
 | 
			
		||||
		{
 | 
			
		||||
			continue;
 | 
			
		||||
		}
 | 
			
		||||
		fVersion->filename = fVersion->installer_url.isEmpty() ? filename : installer_filename;
 | 
			
		||||
		fVersion->universal_filename = filename;
 | 
			
		||||
		fVersion->installer_filename = installer_filename;
 | 
			
		||||
		out.append(fVersion);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -18,57 +18,12 @@
 | 
			
		||||
#include <QObject>
 | 
			
		||||
#include <QAbstractListModel>
 | 
			
		||||
#include <QUrl>
 | 
			
		||||
 | 
			
		||||
#include <QNetworkReply>
 | 
			
		||||
#include "BaseVersionList.h"
 | 
			
		||||
 | 
			
		||||
#include "logic/lists/BaseVersionList.h"
 | 
			
		||||
#include "logic/tasks/Task.h"
 | 
			
		||||
#include "logic/net/NetJob.h"
 | 
			
		||||
 | 
			
		||||
class ForgeVersion;
 | 
			
		||||
typedef std::shared_ptr<ForgeVersion> ForgeVersionPtr;
 | 
			
		||||
 | 
			
		||||
struct ForgeVersion : public BaseVersion
 | 
			
		||||
{
 | 
			
		||||
	virtual QString descriptor() override
 | 
			
		||||
	{
 | 
			
		||||
		return filename;
 | 
			
		||||
	}
 | 
			
		||||
	;
 | 
			
		||||
	virtual QString name() override
 | 
			
		||||
	{
 | 
			
		||||
		return "Forge " + jobbuildver;
 | 
			
		||||
	}
 | 
			
		||||
	;
 | 
			
		||||
	virtual QString typeString() const override
 | 
			
		||||
	{
 | 
			
		||||
		if (installer_url.isEmpty())
 | 
			
		||||
			return "Universal";
 | 
			
		||||
		else
 | 
			
		||||
			return "Installer";
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	virtual bool operator<(BaseVersion &a) override
 | 
			
		||||
	{
 | 
			
		||||
		ForgeVersion *pa = dynamic_cast<ForgeVersion *>(&a);
 | 
			
		||||
		if(!pa)
 | 
			
		||||
			return true;
 | 
			
		||||
		return m_buildnr < pa->m_buildnr;
 | 
			
		||||
	}
 | 
			
		||||
	virtual bool operator>(BaseVersion &a) override
 | 
			
		||||
	{
 | 
			
		||||
		ForgeVersion *pa = dynamic_cast<ForgeVersion *>(&a);
 | 
			
		||||
		if(!pa)
 | 
			
		||||
			return false;
 | 
			
		||||
		return m_buildnr > pa->m_buildnr;
 | 
			
		||||
	}
 | 
			
		||||
	int m_buildnr = 0;
 | 
			
		||||
	QString universal_url;
 | 
			
		||||
	QString changelog_url;
 | 
			
		||||
	QString installer_url;
 | 
			
		||||
	QString jobbuildver;
 | 
			
		||||
	QString mcver;
 | 
			
		||||
	QString filename;
 | 
			
		||||
};
 | 
			
		||||
#include "logic/forge/ForgeVersion.h"
 | 
			
		||||
 | 
			
		||||
class ForgeVersionList : public BaseVersionList
 | 
			
		||||
{
 | 
			
		||||
@@ -15,8 +15,8 @@
 | 
			
		||||
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
#include "NetAction.h"
 | 
			
		||||
#include "HttpMetaCache.h"
 | 
			
		||||
#include "logic/net/NetAction.h"
 | 
			
		||||
#include "logic/net/HttpMetaCache.h"
 | 
			
		||||
#include <QFile>
 | 
			
		||||
#include <QTemporaryFile>
 | 
			
		||||
#include "ForgeMirror.h"
 | 
			
		||||
@@ -15,7 +15,7 @@
 | 
			
		||||
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
#include "Mod.h"
 | 
			
		||||
#include "logic/Mod.h"
 | 
			
		||||
 | 
			
		||||
class MinecraftForge : public Mod
 | 
			
		||||
{
 | 
			
		||||
@@ -212,6 +212,7 @@ void MCVListLoadTask::list_downloaded()
 | 
			
		||||
	{
 | 
			
		||||
		bool is_snapshot = false;
 | 
			
		||||
		bool is_latest = false;
 | 
			
		||||
		bool legacyLaunch = false;
 | 
			
		||||
 | 
			
		||||
		// Load the version info.
 | 
			
		||||
		if (!versions[i].isObject())
 | 
			
		||||
@@ -236,32 +237,28 @@ void MCVListLoadTask::list_downloaded()
 | 
			
		||||
			// FIXME: log this somewhere
 | 
			
		||||
			continue;
 | 
			
		||||
		}
 | 
			
		||||
		// Parse the type.
 | 
			
		||||
		MinecraftVersion::VersionType versionType;
 | 
			
		||||
		// OneSix or Legacy. use filter to determine type
 | 
			
		||||
		if (versionTypeStr == "release")
 | 
			
		||||
		{
 | 
			
		||||
			versionType = legacyWhitelist.contains(versionID) ? MinecraftVersion::Legacy
 | 
			
		||||
															  : MinecraftVersion::OneSix;
 | 
			
		||||
			legacyLaunch = legacyWhitelist.contains(versionID);
 | 
			
		||||
			is_latest = (versionID == latestReleaseID);
 | 
			
		||||
			is_snapshot = false;
 | 
			
		||||
		}
 | 
			
		||||
		else if (versionTypeStr == "snapshot") // It's a snapshot... yay
 | 
			
		||||
		{
 | 
			
		||||
			versionType = legacyWhitelist.contains(versionID) ? MinecraftVersion::Legacy
 | 
			
		||||
															  : MinecraftVersion::OneSix;
 | 
			
		||||
			legacyLaunch = legacyWhitelist.contains(versionID);
 | 
			
		||||
			is_latest = (versionID == latestSnapshotID);
 | 
			
		||||
			is_snapshot = true;
 | 
			
		||||
		}
 | 
			
		||||
		else if (versionTypeStr == "old_alpha")
 | 
			
		||||
		{
 | 
			
		||||
			versionType = MinecraftVersion::Nostalgia;
 | 
			
		||||
			legacyLaunch = false;
 | 
			
		||||
			is_latest = false;
 | 
			
		||||
			is_snapshot = false;
 | 
			
		||||
		}
 | 
			
		||||
		else if (versionTypeStr == "old_beta")
 | 
			
		||||
		{
 | 
			
		||||
			versionType = MinecraftVersion::Legacy;
 | 
			
		||||
			legacyLaunch = true;
 | 
			
		||||
			is_latest = false;
 | 
			
		||||
			is_snapshot = false;
 | 
			
		||||
		}
 | 
			
		||||
@@ -280,7 +277,8 @@ void MCVListLoadTask::list_downloaded()
 | 
			
		||||
		mcVersion->download_url = dlUrl;
 | 
			
		||||
		mcVersion->is_latest = is_latest;
 | 
			
		||||
		mcVersion->is_snapshot = is_snapshot;
 | 
			
		||||
		mcVersion->type = versionType;
 | 
			
		||||
		if(legacyLaunch)
 | 
			
		||||
			mcVersion->features.insert("legacy");
 | 
			
		||||
		tempList.append(mcVersion);
 | 
			
		||||
	}
 | 
			
		||||
	m_list->updateListData(tempList);
 | 
			
		||||
 
 | 
			
		||||
@@ -20,11 +20,11 @@
 | 
			
		||||
 | 
			
		||||
#include "logger/QsLog.h"
 | 
			
		||||
 | 
			
		||||
#include "VersionFinal.h"
 | 
			
		||||
#include "OneSixLibrary.h"
 | 
			
		||||
#include "OneSixInstance.h"
 | 
			
		||||
#include "logic/VersionFinal.h"
 | 
			
		||||
#include "logic/OneSixLibrary.h"
 | 
			
		||||
#include "logic/OneSixInstance.h"
 | 
			
		||||
#include "MultiMC.h"
 | 
			
		||||
#include "lists/LiteLoaderVersionList.h"
 | 
			
		||||
#include "logic/liteloader/LiteLoaderVersionList.h"
 | 
			
		||||
 | 
			
		||||
LiteLoaderInstaller::LiteLoaderInstaller() : BaseInstaller()
 | 
			
		||||
{
 | 
			
		||||
@@ -15,12 +15,11 @@
 | 
			
		||||
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
#include "BaseInstaller.h"
 | 
			
		||||
 | 
			
		||||
#include <QString>
 | 
			
		||||
#include <QMap>
 | 
			
		||||
 | 
			
		||||
#include "logic/lists/LiteLoaderVersionList.h"
 | 
			
		||||
#include "logic/BaseInstaller.h"
 | 
			
		||||
#include "logic/liteloader/LiteLoaderVersionList.h"
 | 
			
		||||
 | 
			
		||||
class LiteLoaderInstaller : public BaseInstaller
 | 
			
		||||
{
 | 
			
		||||
@@ -19,10 +19,10 @@
 | 
			
		||||
 | 
			
		||||
#include <QString>
 | 
			
		||||
#include <QStringList>
 | 
			
		||||
#include "BaseVersionList.h"
 | 
			
		||||
#include "logic/lists/BaseVersionList.h"
 | 
			
		||||
#include "logic/tasks/Task.h"
 | 
			
		||||
#include "logic/BaseVersion.h"
 | 
			
		||||
#include <logic/net/NetJob.h>
 | 
			
		||||
#include "logic/net/NetJob.h"
 | 
			
		||||
 | 
			
		||||
class LLListLoadTask;
 | 
			
		||||
class QNetworkReply;
 | 
			
		||||
@@ -21,7 +21,7 @@
 | 
			
		||||
#include "MD5EtagDownload.h"
 | 
			
		||||
#include "CacheDownload.h"
 | 
			
		||||
#include "HttpMetaCache.h"
 | 
			
		||||
#include "ForgeXzDownload.h"
 | 
			
		||||
//#include "logic/forge/ForgeXzDownload.h"
 | 
			
		||||
#include "logic/tasks/ProgressProvider.h"
 | 
			
		||||
 | 
			
		||||
class NetJob;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user