Esempio n. 1
0
InstanceFactory::InstCreateError InstanceFactory::createInstance(InstancePtr &inst, BaseVersionPtr version,
								const QString &instDir, const InstanceFactory::InstType type)
{
	QDir rootDir(instDir);

	QLOG_DEBUG() << instDir.toUtf8();
	if (!rootDir.exists() && !rootDir.mkpath("."))
	{
		return InstanceFactory::CantCreateDir;
	}
	auto mcVer = std::dynamic_pointer_cast<MinecraftVersion>(version);
	if (!mcVer)
		return InstanceFactory::NoSuchVersion;

	auto m_settings = new INISettingsObject(PathCombine(instDir, "instance.cfg"));
	m_settings->registerSetting("InstanceType", "Legacy");

	if (type == NormalInst)
	{
		m_settings->set("InstanceType", "OneSix");
		inst.reset(new OneSixInstance(instDir, m_settings, this));
		inst->setIntendedVersionId(version->descriptor());
		inst->setShouldUseCustomBaseJar(false);
	}
	else if (type == FTBInstance)
	{
		if(mcVer->usesLegacyLauncher())
		{
			m_settings->set("InstanceType", "LegacyFTB");
			inst.reset(new LegacyFTBInstance(instDir, m_settings, this));
			inst->setIntendedVersionId(version->descriptor());
			inst->setShouldUseCustomBaseJar(false);
		}
		else
		{
			m_settings->set("InstanceType", "OneSixFTB");
			inst.reset(new OneSixFTBInstance(instDir, m_settings, this));
			inst->setIntendedVersionId(version->descriptor());
			inst->setShouldUseCustomBaseJar(false);
		}
	}
	else
	{
		delete m_settings;
		return InstanceFactory::NoSuchVersion;
	}

	inst->init();

	// FIXME: really, how do you even know?
	return InstanceFactory::NoCreateError;
}
Esempio n. 2
0
InstanceFactory::InstCreateError InstanceFactory::createInstance( BaseInstance*& inst, BaseVersionPtr version, const QString& instDir )
{
	QDir rootDir(instDir);
	
	QLOG_DEBUG() << instDir.toUtf8();
	if (!rootDir.exists() && !rootDir.mkpath("."))
	{
		return InstanceFactory::CantCreateDir;
	}
	auto mcVer = std::dynamic_pointer_cast<MinecraftVersion>(version);
	if(!mcVer)
		return InstanceFactory::NoSuchVersion;
	
	auto m_settings = new INISettingsObject(PathCombine(instDir, "instance.cfg"));
	m_settings->registerSetting(new Setting("InstanceType", "Legacy"));
	
	switch(mcVer->type)
	{
		case MinecraftVersion::Legacy:
			m_settings->set("InstanceType", "Legacy");
			inst = new LegacyInstance(instDir, m_settings, this);
			inst->setIntendedVersionId(version->descriptor());
			inst->setShouldUseCustomBaseJar(false);
			break;
		case MinecraftVersion::OneSix:
			m_settings->set("InstanceType", "OneSix");
			inst = new OneSixInstance(instDir, m_settings, this);
			inst->setIntendedVersionId(version->descriptor());
			inst->setShouldUseCustomBaseJar(false);
			break;
		case MinecraftVersion::Nostalgia:
			m_settings->set("InstanceType", "Nostalgia");
			inst = new NostalgiaInstance(instDir, m_settings, this);
			inst->setIntendedVersionId(version->descriptor());
			inst->setShouldUseCustomBaseJar(false);
			break;
		default:
		{
			delete m_settings;
			return InstanceFactory::NoSuchVersion;
		}
	}
	
	//FIXME: really, how do you even know?
	return InstanceFactory::NoCreateError;
}