2016-10-02 23:55:54 +01:00
|
|
|
#include "InstanceImportTask.h"
|
|
|
|
#include "BaseInstance.h"
|
|
|
|
#include "BaseInstanceProvider.h"
|
|
|
|
#include "FileSystem.h"
|
|
|
|
#include "Env.h"
|
|
|
|
#include "MMCZip.h"
|
|
|
|
#include "NullInstance.h"
|
|
|
|
#include "settings/INISettingsObject.h"
|
|
|
|
#include "icons/IIconList.h"
|
2016-10-26 17:12:33 +01:00
|
|
|
#include <QtConcurrentRun>
|
2017-04-21 21:23:31 +01:00
|
|
|
|
2017-04-22 17:51:04 +01:00
|
|
|
// FIXME: this does not belong here, it's Minecraft/Flame specific
|
2017-07-24 08:01:37 +01:00
|
|
|
#include "minecraft/MinecraftInstance.h"
|
2017-10-11 22:04:24 +01:00
|
|
|
#include "minecraft/ComponentList.h"
|
2018-03-16 22:33:58 +00:00
|
|
|
#include "modplatform/flame/FileResolvingTask.h"
|
|
|
|
#include "modplatform/flame/PackManifest.h"
|
2017-04-20 04:22:04 +01:00
|
|
|
#include "Json.h"
|
2016-10-02 23:55:54 +01:00
|
|
|
|
2018-03-19 01:36:12 +00:00
|
|
|
InstanceImportTask::InstanceImportTask(const QUrl sourceUrl)
|
2016-10-02 23:55:54 +01:00
|
|
|
{
|
|
|
|
m_sourceUrl = sourceUrl;
|
|
|
|
}
|
|
|
|
|
|
|
|
void InstanceImportTask::executeTask()
|
|
|
|
{
|
|
|
|
InstancePtr newInstance;
|
|
|
|
|
|
|
|
if (m_sourceUrl.isLocalFile())
|
|
|
|
{
|
|
|
|
m_archivePath = m_sourceUrl.toLocalFile();
|
2017-09-04 07:17:25 +01:00
|
|
|
processZipPack();
|
2016-10-02 23:55:54 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-05-03 22:11:52 +01:00
|
|
|
setStatus(tr("Downloading modpack:\n%1").arg(m_sourceUrl.toString()));
|
2016-10-02 23:55:54 +01:00
|
|
|
m_downloadRequired = true;
|
|
|
|
|
|
|
|
const QString path = m_sourceUrl.host() + '/' + m_sourceUrl.path();
|
|
|
|
auto entry = ENV.metacache()->resolveEntry("general", path);
|
|
|
|
entry->setStale(true);
|
|
|
|
m_filesNetJob.reset(new NetJob(tr("Modpack download")));
|
|
|
|
m_filesNetJob->addNetAction(Net::Download::makeCached(m_sourceUrl, entry));
|
|
|
|
m_archivePath = entry->getFullPath();
|
|
|
|
auto job = m_filesNetJob.get();
|
|
|
|
connect(job, &NetJob::succeeded, this, &InstanceImportTask::downloadSucceeded);
|
|
|
|
connect(job, &NetJob::progress, this, &InstanceImportTask::downloadProgressChanged);
|
|
|
|
connect(job, &NetJob::failed, this, &InstanceImportTask::downloadFailed);
|
|
|
|
m_filesNetJob->start();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void InstanceImportTask::downloadSucceeded()
|
|
|
|
{
|
2017-09-04 07:17:25 +01:00
|
|
|
processZipPack();
|
2017-04-21 21:23:31 +01:00
|
|
|
m_filesNetJob.reset();
|
2016-10-02 23:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void InstanceImportTask::downloadFailed(QString reason)
|
|
|
|
{
|
|
|
|
emitFailed(reason);
|
2017-04-21 21:23:31 +01:00
|
|
|
m_filesNetJob.reset();
|
2016-10-02 23:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void InstanceImportTask::downloadProgressChanged(qint64 current, qint64 total)
|
|
|
|
{
|
|
|
|
setProgress(current / 2, total);
|
|
|
|
}
|
|
|
|
|
2017-09-04 07:17:25 +01:00
|
|
|
void InstanceImportTask::processZipPack()
|
2016-10-02 23:55:54 +01:00
|
|
|
{
|
2017-05-03 22:11:52 +01:00
|
|
|
setStatus(tr("Extracting modpack"));
|
2016-10-26 17:12:33 +01:00
|
|
|
QDir extractDir(m_stagingPath);
|
2017-04-21 21:30:39 +01:00
|
|
|
qDebug() << "Attempting to create instance from" << m_archivePath;
|
2016-10-26 17:12:33 +01:00
|
|
|
|
2017-09-04 07:17:25 +01:00
|
|
|
// open the zip and find relevant files in it
|
|
|
|
m_packZip.reset(new QuaZip(m_archivePath));
|
|
|
|
if (!m_packZip->open(QuaZip::mdUnzip))
|
|
|
|
{
|
|
|
|
emitFailed(tr("Unable to open supplied modpack zip file."));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringList blacklist = {"instance.cfg", "manifest.json"};
|
|
|
|
QString mmcFound = MMCZip::findFolderOfFileInZip(m_packZip.get(), "instance.cfg");
|
|
|
|
QString flameFound = MMCZip::findFolderOfFileInZip(m_packZip.get(), "manifest.json");
|
|
|
|
QString root;
|
|
|
|
if(!mmcFound.isNull())
|
|
|
|
{
|
|
|
|
// process as MultiMC instance/pack
|
|
|
|
qDebug() << "MultiMC:" << mmcFound;
|
|
|
|
root = mmcFound;
|
|
|
|
m_modpackType = ModpackType::MultiMC;
|
|
|
|
}
|
2017-09-26 00:39:39 +01:00
|
|
|
else if(!flameFound.isNull())
|
2017-09-04 07:17:25 +01:00
|
|
|
{
|
|
|
|
// process as Flame pack
|
|
|
|
qDebug() << "Flame:" << flameFound;
|
|
|
|
root = flameFound;
|
|
|
|
m_modpackType = ModpackType::Flame;
|
|
|
|
}
|
2017-09-26 00:39:39 +01:00
|
|
|
|
2017-09-04 07:17:25 +01:00
|
|
|
if(m_modpackType == ModpackType::Unknown)
|
|
|
|
{
|
|
|
|
emitFailed(tr("Archive does not contain a recognized modpack type."));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// make sure we extract just the pack
|
|
|
|
m_extractFuture = QtConcurrent::run(QThreadPool::globalInstance(), MMCZip::extractSubDir, m_packZip.get(), root, extractDir.absolutePath());
|
2016-10-26 17:12:33 +01:00
|
|
|
connect(&m_extractFutureWatcher, &QFutureWatcher<QStringList>::finished, this, &InstanceImportTask::extractFinished);
|
|
|
|
connect(&m_extractFutureWatcher, &QFutureWatcher<QStringList>::canceled, this, &InstanceImportTask::extractAborted);
|
|
|
|
m_extractFutureWatcher.setFuture(m_extractFuture);
|
|
|
|
}
|
|
|
|
|
|
|
|
void InstanceImportTask::extractFinished()
|
|
|
|
{
|
2017-09-04 07:17:25 +01:00
|
|
|
m_packZip.reset();
|
2016-10-26 17:12:33 +01:00
|
|
|
if (m_extractFuture.result().isEmpty())
|
2016-10-02 23:55:54 +01:00
|
|
|
{
|
|
|
|
emitFailed(tr("Failed to extract modpack"));
|
|
|
|
return;
|
|
|
|
}
|
2016-10-26 17:12:33 +01:00
|
|
|
QDir extractDir(m_stagingPath);
|
2017-04-21 21:23:31 +01:00
|
|
|
|
2017-04-21 21:30:39 +01:00
|
|
|
qDebug() << "Fixing permissions for extracted pack files...";
|
2017-04-21 21:23:31 +01:00
|
|
|
QDirIterator it(extractDir, QDirIterator::Subdirectories);
|
|
|
|
while (it.hasNext())
|
|
|
|
{
|
|
|
|
auto filepath = it.next();
|
|
|
|
QFileInfo file(filepath);
|
|
|
|
auto permissions = QFile::permissions(filepath);
|
|
|
|
auto origPermissions = permissions;
|
|
|
|
if(file.isDir())
|
|
|
|
{
|
|
|
|
// Folder +rwx for current user
|
|
|
|
permissions |= QFileDevice::Permission::ReadUser | QFileDevice::Permission::WriteUser | QFileDevice::Permission::ExeUser;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// File +rw for current user
|
|
|
|
permissions |= QFileDevice::Permission::ReadUser | QFileDevice::Permission::WriteUser;
|
|
|
|
}
|
|
|
|
if(origPermissions != permissions)
|
|
|
|
{
|
|
|
|
if(!QFile::setPermissions(filepath, permissions))
|
|
|
|
{
|
2017-12-30 17:57:46 +00:00
|
|
|
logWarning(tr("Could not fix permissions for %1").arg(filepath));
|
2017-04-21 21:23:31 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
qDebug() << "Fixed" << filepath;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-04 07:17:25 +01:00
|
|
|
switch(m_modpackType)
|
2017-04-20 04:22:04 +01:00
|
|
|
{
|
2017-09-04 07:17:25 +01:00
|
|
|
case ModpackType::Flame:
|
|
|
|
processFlame();
|
|
|
|
return;
|
|
|
|
case ModpackType::MultiMC:
|
|
|
|
processMultiMC();
|
|
|
|
return;
|
|
|
|
case ModpackType::Unknown:
|
|
|
|
emitFailed(tr("Archive does not contain a recognized modpack type."));
|
|
|
|
return;
|
2017-04-20 04:22:04 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void InstanceImportTask::extractAborted()
|
|
|
|
{
|
|
|
|
emitFailed(tr("Instance import has been aborted."));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-09-04 07:17:25 +01:00
|
|
|
void InstanceImportTask::processFlame()
|
2017-04-20 04:22:04 +01:00
|
|
|
{
|
2017-04-22 04:20:06 +01:00
|
|
|
const static QMap<QString,QString> forgemap = {
|
|
|
|
{"1.2.5", "3.4.9.171"},
|
|
|
|
{"1.4.2", "6.0.1.355"},
|
|
|
|
{"1.4.7", "6.6.2.534"},
|
|
|
|
{"1.5.2", "7.8.1.737"}
|
|
|
|
};
|
2017-04-22 17:51:04 +01:00
|
|
|
Flame::Manifest pack;
|
2017-04-20 04:22:04 +01:00
|
|
|
try
|
|
|
|
{
|
2017-09-04 07:17:25 +01:00
|
|
|
QString configPath = FS::PathCombine(m_stagingPath, "manifest.json");
|
|
|
|
Flame::loadManifest(pack, configPath);
|
2017-09-26 00:37:50 +01:00
|
|
|
QFile::remove(configPath);
|
2017-04-20 04:22:04 +01:00
|
|
|
}
|
|
|
|
catch (JSONValidationError & e)
|
|
|
|
{
|
2017-04-22 17:51:04 +01:00
|
|
|
emitFailed(tr("Could not understand pack manifest:\n") + e.cause());
|
2016-10-02 23:55:54 +01:00
|
|
|
return;
|
|
|
|
}
|
2017-04-21 21:23:31 +01:00
|
|
|
if(!pack.overrides.isEmpty())
|
|
|
|
{
|
2017-09-04 07:17:25 +01:00
|
|
|
QString overridePath = FS::PathCombine(m_stagingPath, pack.overrides);
|
2017-09-26 00:36:52 +01:00
|
|
|
if (QFile::exists(overridePath))
|
2017-04-21 21:23:31 +01:00
|
|
|
{
|
2017-09-26 00:36:52 +01:00
|
|
|
QString mcPath = FS::PathCombine(m_stagingPath, "minecraft");
|
|
|
|
if (!QFile::rename(overridePath, mcPath))
|
|
|
|
{
|
|
|
|
emitFailed(tr("Could not rename the overrides folder:\n") + pack.overrides);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-12-30 17:57:46 +00:00
|
|
|
logWarning(tr("The specified overrides folder (%1) is missing. Maybe the modpack was already used before?").arg(pack.overrides));
|
2017-04-21 21:23:31 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QString forgeVersion;
|
|
|
|
for(auto &loader: pack.minecraft.modLoaders)
|
|
|
|
{
|
|
|
|
auto id = loader.id;
|
|
|
|
if(id.startsWith("forge-"))
|
|
|
|
{
|
|
|
|
id.remove("forge-");
|
|
|
|
forgeVersion = id;
|
|
|
|
continue;
|
|
|
|
}
|
2017-12-30 17:57:46 +00:00
|
|
|
logWarning(tr("Unknown mod loader in manifest: %1").arg(id));
|
2017-04-21 21:23:31 +01:00
|
|
|
}
|
|
|
|
|
2017-09-04 07:17:25 +01:00
|
|
|
QString configPath = FS::PathCombine(m_stagingPath, "instance.cfg");
|
2017-04-20 04:22:04 +01:00
|
|
|
auto instanceSettings = std::make_shared<INISettingsObject>(configPath);
|
|
|
|
instanceSettings->registerSetting("InstanceType", "Legacy");
|
|
|
|
instanceSettings->set("InstanceType", "OneSix");
|
2017-07-24 08:01:37 +01:00
|
|
|
MinecraftInstance instance(m_globalSettings, instanceSettings, m_stagingPath);
|
2017-04-22 04:20:06 +01:00
|
|
|
auto mcVersion = pack.minecraft.version;
|
2017-04-22 17:51:04 +01:00
|
|
|
// Hack to correct some 'special sauce'...
|
2017-04-22 04:20:06 +01:00
|
|
|
if(mcVersion.endsWith('.'))
|
|
|
|
{
|
|
|
|
mcVersion.remove(QRegExp("[.]+$"));
|
2017-12-30 17:57:46 +00:00
|
|
|
logWarning(tr("Mysterious trailing dots removed from Minecraft version while importing pack."));
|
2017-04-22 04:20:06 +01:00
|
|
|
}
|
2017-11-11 00:38:31 +00:00
|
|
|
auto components = instance.getComponentList();
|
|
|
|
components->buildingFromScratch();
|
|
|
|
components->setComponentVersion("net.minecraft", mcVersion, true);
|
2017-04-21 21:23:31 +01:00
|
|
|
if(!forgeVersion.isEmpty())
|
|
|
|
{
|
2017-04-22 04:20:06 +01:00
|
|
|
// FIXME: dirty, nasty, hack. Proper solution requires dependency resolution and knowledge of the metadata.
|
|
|
|
if(forgeVersion == "recommended")
|
|
|
|
{
|
|
|
|
if(forgemap.contains(mcVersion))
|
|
|
|
{
|
|
|
|
forgeVersion = forgemap[mcVersion];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-12-30 17:57:46 +00:00
|
|
|
logWarning(tr("Could not map recommended forge version for Minecraft %1").arg(mcVersion));
|
2017-04-22 04:20:06 +01:00
|
|
|
}
|
|
|
|
}
|
2017-11-11 00:38:31 +00:00
|
|
|
components->setComponentVersion("net.minecraftforge", forgeVersion);
|
2017-04-21 21:23:31 +01:00
|
|
|
}
|
2017-04-22 04:20:06 +01:00
|
|
|
if (m_instIcon != "default")
|
|
|
|
{
|
|
|
|
instance.setIconKey(m_instIcon);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(pack.name.contains("Direwolf20"))
|
|
|
|
{
|
|
|
|
instance.setIconKey("steve");
|
|
|
|
}
|
|
|
|
else if(pack.name.contains("FTB") || pack.name.contains("Feed The Beast"))
|
|
|
|
{
|
|
|
|
instance.setIconKey("ftb_logo");
|
|
|
|
}
|
2017-04-22 17:51:04 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// default to something other than the MultiMC default to distinguish these
|
|
|
|
instance.setIconKey("flame");
|
|
|
|
}
|
2017-04-22 04:20:06 +01:00
|
|
|
}
|
|
|
|
instance.init();
|
2017-09-04 07:17:25 +01:00
|
|
|
QString jarmodsPath = FS::PathCombine(m_stagingPath, "minecraft", "jarmods");
|
2017-04-22 04:20:06 +01:00
|
|
|
QFileInfo jarmodsInfo(jarmodsPath);
|
|
|
|
if(jarmodsInfo.isDir())
|
|
|
|
{
|
|
|
|
// install all the jar mods
|
|
|
|
qDebug() << "Found jarmods:";
|
|
|
|
QDir jarmodsDir(jarmodsPath);
|
|
|
|
QStringList jarMods;
|
|
|
|
for (auto info: jarmodsDir.entryInfoList(QDir::NoDotAndDotDot | QDir::Files))
|
|
|
|
{
|
|
|
|
qDebug() << info.fileName();
|
|
|
|
jarMods.push_back(info.absoluteFilePath());
|
|
|
|
}
|
2017-10-11 22:04:24 +01:00
|
|
|
auto profile = instance.getComponentList();
|
2017-04-22 04:20:06 +01:00
|
|
|
profile->installJarMods(jarMods);
|
|
|
|
// nuke the original files
|
|
|
|
FS::deletePath(jarmodsPath);
|
|
|
|
}
|
2017-04-20 04:22:04 +01:00
|
|
|
instance.setName(m_instName);
|
2017-04-22 17:51:04 +01:00
|
|
|
m_modIdResolver.reset(new Flame::FileResolvingTask(pack));
|
|
|
|
connect(m_modIdResolver.get(), &Flame::FileResolvingTask::succeeded, [&]()
|
2017-04-20 04:22:04 +01:00
|
|
|
{
|
2017-04-22 17:51:04 +01:00
|
|
|
auto results = m_modIdResolver->getResults();
|
|
|
|
m_filesNetJob.reset(new NetJob(tr("Mod download")));
|
2017-04-21 21:23:31 +01:00
|
|
|
for(auto result: results.files)
|
|
|
|
{
|
2017-09-25 07:06:23 +01:00
|
|
|
QString filename = result.fileName;
|
|
|
|
if(!result.required)
|
|
|
|
{
|
|
|
|
filename += ".disabled";
|
|
|
|
}
|
2017-12-30 17:57:46 +00:00
|
|
|
|
|
|
|
auto relpath = FS::PathCombine("minecraft", result.targetFolder, filename);
|
|
|
|
auto path = FS::PathCombine(m_stagingPath , relpath);
|
|
|
|
|
|
|
|
switch(result.type)
|
|
|
|
{
|
|
|
|
case Flame::File::Type::Folder:
|
|
|
|
{
|
|
|
|
logWarning(tr("This 'Folder' may need extracting: %1").arg(relpath));
|
|
|
|
// fall-through intentional, we treat these as plain old mods and dump them wherever.
|
|
|
|
}
|
|
|
|
case Flame::File::Type::SingleFile:
|
|
|
|
case Flame::File::Type::Mod:
|
|
|
|
{
|
2018-01-21 02:49:54 +00:00
|
|
|
qDebug() << "Will download" << result.url << "to" << path;
|
2017-12-30 17:57:46 +00:00
|
|
|
auto dl = Net::Download::makeFile(result.url, path);
|
|
|
|
m_filesNetJob->addNetAction(dl);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Flame::File::Type::Modpack:
|
|
|
|
logWarning(tr("Nesting modpacks in modpacks is not implemented, nothing was downloaded: %1").arg(relpath));
|
|
|
|
break;
|
|
|
|
case Flame::File::Type::Cmod2:
|
|
|
|
case Flame::File::Type::Ctoc:
|
|
|
|
case Flame::File::Type::Unknown:
|
|
|
|
logWarning(tr("Unrecognized/unhandled PackageType for: %1").arg(relpath));
|
|
|
|
break;
|
|
|
|
}
|
2017-04-21 21:23:31 +01:00
|
|
|
}
|
2017-04-22 17:51:04 +01:00
|
|
|
m_modIdResolver.reset();
|
2017-04-21 21:23:31 +01:00
|
|
|
connect(m_filesNetJob.get(), &NetJob::succeeded, this, [&]()
|
|
|
|
{
|
|
|
|
m_filesNetJob.reset();
|
|
|
|
emitSucceeded();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
connect(m_filesNetJob.get(), &NetJob::failed, [&](QString reason)
|
|
|
|
{
|
|
|
|
m_filesNetJob.reset();
|
|
|
|
emitFailed(reason);
|
|
|
|
});
|
|
|
|
connect(m_filesNetJob.get(), &NetJob::progress, [&](qint64 current, qint64 total)
|
|
|
|
{
|
|
|
|
setProgress(current, total);
|
|
|
|
});
|
2017-05-03 22:11:52 +01:00
|
|
|
setStatus(tr("Downloading mods..."));
|
2017-04-21 21:23:31 +01:00
|
|
|
m_filesNetJob->start();
|
2017-04-20 04:22:04 +01:00
|
|
|
}
|
2017-04-21 21:23:31 +01:00
|
|
|
);
|
2017-04-22 17:51:04 +01:00
|
|
|
connect(m_modIdResolver.get(), &Flame::FileResolvingTask::failed, [&](QString reason)
|
2017-04-20 04:22:04 +01:00
|
|
|
{
|
2017-04-22 17:51:04 +01:00
|
|
|
m_modIdResolver.reset();
|
|
|
|
emitFailed(tr("Unable to resolve mod IDs:\n") + reason);
|
2017-04-21 21:23:31 +01:00
|
|
|
});
|
2017-04-22 17:51:04 +01:00
|
|
|
connect(m_modIdResolver.get(), &Flame::FileResolvingTask::progress, [&](qint64 current, qint64 total)
|
2017-04-21 21:23:31 +01:00
|
|
|
{
|
|
|
|
setProgress(current, total);
|
|
|
|
});
|
2017-04-22 17:51:04 +01:00
|
|
|
connect(m_modIdResolver.get(), &Flame::FileResolvingTask::status, [&](QString status)
|
2017-04-21 21:23:31 +01:00
|
|
|
{
|
2017-05-03 22:11:52 +01:00
|
|
|
setStatus(status);
|
2017-04-21 21:23:31 +01:00
|
|
|
});
|
2017-04-22 17:51:04 +01:00
|
|
|
m_modIdResolver->start();
|
2017-04-20 04:22:04 +01:00
|
|
|
}
|
|
|
|
|
2017-09-04 07:17:25 +01:00
|
|
|
void InstanceImportTask::processMultiMC()
|
2017-04-20 04:22:04 +01:00
|
|
|
{
|
2016-10-02 23:55:54 +01:00
|
|
|
// FIXME: copy from FolderInstanceProvider!!! FIX IT!!!
|
2017-09-04 07:17:25 +01:00
|
|
|
QString configPath = FS::PathCombine(m_stagingPath, "instance.cfg");
|
|
|
|
auto instanceSettings = std::make_shared<INISettingsObject>(configPath);
|
2016-10-02 23:55:54 +01:00
|
|
|
instanceSettings->registerSetting("InstanceType", "Legacy");
|
|
|
|
|
2017-09-04 07:17:25 +01:00
|
|
|
NullInstance instance(m_globalSettings, instanceSettings, m_stagingPath);
|
2016-10-02 23:55:54 +01:00
|
|
|
|
|
|
|
// reset time played on import... because packs.
|
|
|
|
instance.resetTimePlayed();
|
|
|
|
|
|
|
|
// set a new nice name
|
|
|
|
instance.setName(m_instName);
|
|
|
|
|
|
|
|
// if the icon was specified by user, use that. otherwise pull icon from the pack
|
|
|
|
if (m_instIcon != "default")
|
|
|
|
{
|
|
|
|
instance.setIconKey(m_instIcon);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_instIcon = instance.iconKey();
|
|
|
|
auto importIconPath = FS::PathCombine(instance.instanceRoot(), m_instIcon + ".png");
|
|
|
|
if (QFile::exists(importIconPath))
|
|
|
|
{
|
|
|
|
// import icon
|
|
|
|
auto iconList = ENV.icons();
|
|
|
|
if (iconList->iconFileExists(m_instIcon))
|
|
|
|
{
|
|
|
|
iconList->deleteIcon(m_instIcon);
|
|
|
|
}
|
|
|
|
iconList->installIcons({importIconPath});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
emitSucceeded();
|
|
|
|
}
|