示例#1
0
void LegacyUpdate::fmllibsFinished()
{
	legacyDownloadJob.reset();
	if(!fmlLibsToProcess.isEmpty())
	{
		setStatus(tr("Copying FML libraries into the instance..."));
		LegacyInstance *inst = (LegacyInstance *)m_inst;
		auto metacache = MMC->metacache();
		int index = 0;
		for (auto &lib : fmlLibsToProcess)
		{
			progress(index, fmlLibsToProcess.size());
			auto entry = metacache->resolveEntry("fmllibs", lib.name);
			auto path = PathCombine(inst->libDir(), lib.name);
			if(!ensureFilePathExists(path))
			{
				emitFailed(tr("Failed creating FML library folder inside the instance."));
				return;
			}
			if (!QFile::copy(entry->getFullPath(), PathCombine(inst->libDir(), lib.name)))
			{
				emitFailed(tr("Failed copying Forge/FML library: %1.").arg(lib.name));
				return;
			}
			index++;
		}
		progress(index, fmlLibsToProcess.size());
	}
	lwjglStart();
}
示例#2
0
void LegacyUpdate::executeTask()
{
	/*
	if(m_only_prepare)
	{
		// FIXME: think this through some more.
		LegacyInstance *inst = (LegacyInstance *)m_inst;
		if (!inst->shouldUpdate() || inst->shouldUseCustomBaseJar())
		{
			ModTheJar();
		}
		else
		{
			emitSucceeded();
		}
	}
	else
	{
		*/
	lwjglStart();
	//}
}
示例#3
0
void LegacyUpdate::fmllibsStart()
{
	// Get the mod list
	LegacyInstance *inst = (LegacyInstance *)m_inst;
	auto modList = inst->jarModList();

	bool forge_present = false;

	QString version = inst->intendedVersionId();
	if (!fmlLibsMapping.contains(version))
	{
		lwjglStart();
		return;
	}

	auto &libList = fmlLibsMapping[version];

	// determine if we need some libs for FML or forge
	setStatus(tr("Checking for FML libraries..."));
	for (unsigned i = 0; i < modList->size(); i++)
	{
		auto &mod = modList->operator[](i);

		// do not use disabled mods.
		if (!mod.enabled())
			continue;

		if (mod.type() != Mod::MOD_ZIPFILE)
			continue;

		if (mod.mmc_id().contains("forge", Qt::CaseInsensitive))
		{
			forge_present = true;
			break;
		}
		if (mod.mmc_id().contains("fml", Qt::CaseInsensitive))
		{
			forge_present = true;
			break;
		}
	}
	// we don't...
	if (!forge_present)
	{
		lwjglStart();
		return;
	}

	// now check the lib folder inside the instance for files.
	for (auto &lib : libList)
	{
		QFileInfo libInfo(PathCombine(inst->libDir(), lib.name));
		if (libInfo.exists())
			continue;
		fmlLibsToProcess.append(lib);
	}

	// if everything is in place, there's nothing to do here...
	if (fmlLibsToProcess.isEmpty())
	{
		lwjglStart();
		return;
	}

	// download missing libs to our place
	setStatus(tr("Dowloading FML libraries..."));
	auto dljob = new NetJob("FML libraries");
	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;
		dljob->addNetAction(CacheDownload::make(QUrl(urlString), entry));
	}

	connect(dljob, SIGNAL(succeeded()), SLOT(fmllibsFinished()));
	connect(dljob, SIGNAL(failed()), SLOT(fmllibsFailed()));
	connect(dljob, SIGNAL(progress(qint64, qint64)), SIGNAL(progress(qint64, qint64)));
	legacyDownloadJob.reset(dljob);
	legacyDownloadJob->start();
}