Beispiel #1
0
bool CModManager::doInstallMod(QString modname, QString archivePath)
{
	QString destDir = CLauncherDirs::get().modsPath() + "/";

	if (!QFile(archivePath).exists())
		return addError(modname, "Mod archive is missing");

	if (QDir(destDir + modname).exists()) // FIXME: recheck wog/vcmi data behavior - they have bits of data in our trunk
		return addError(modname, "Mod with such name is already installed");

	if (localMods.contains(modname))
		return addError(modname, "Mod with such name is already installed");

	QString modDirName = detectModArchive(archivePath, modname);
	if (!modDirName.size())
		return addError(modname, "Mod archive is invalid or corrupted");

	if (!ZipArchive::extract(archivePath.toUtf8().data(), destDir.toUtf8().data()))
	{
		QDir(destDir + modDirName).removeRecursively();
		return addError(modname, "Failed to extract mod data");
	}

	QJsonObject json = JsonFromFile(destDir + modDirName + "/mod.json");

	localMods.insert(modname, json);
	modList->setLocalModList(localMods);

	return true;
}
Beispiel #2
0
void LoadSampleSet(std::string json_path, SampleSet& out) {
  static Json::Value json;
  JsonFromFile(json, json_path);
  LoadSampleSetFromJson(json, out);
}
Beispiel #3
0
void CModManager::loadRepository(QString file)
{
	modList->addRepository(JsonFromFile(file));
}
Beispiel #4
0
void CModManager::loadModSettings()
{
	modSettings = JsonFromFile(settingsPath());
	modList->setModSettings(modSettings["activeMods"].toObject());
}