NOISSUE add button for creating empty, properly registered, components

This commit is contained in:
Petr Mrázek
2017-12-31 01:37:50 +01:00
parent c7032ce68a
commit 4340068a84
9 changed files with 318 additions and 0 deletions

View File

@ -971,6 +971,34 @@ void ComponentList::installCustomJar(QString selectedFile)
installCustomJar_internal(selectedFile);
}
bool ComponentList::installEmpty(const QString& uid, const QString& name)
{
QString patchDir = FS::PathCombine(d->m_instance->instanceRoot(), "patches");
if(!FS::ensureFolderPathExists(patchDir))
{
return false;
}
auto f = std::make_shared<VersionFile>();
f->name = name;
f->uid = uid;
f->version = "1";
QString patchFileName = FS::PathCombine(patchDir, uid + ".json");
QFile file(patchFileName);
if (!file.open(QFile::WriteOnly))
{
qCritical() << "Error opening" << file.fileName()
<< "for reading:" << file.errorString();
return false;
}
file.write(OneSixVersionFormat::versionFileToJson(f).toJson());
file.close();
appendComponent(new Component(this, f->uid, f));
scheduleSave();
invalidateLaunchProfile();
return true;
}
bool ComponentList::removeComponent_internal(ComponentPtr patch)
{
bool ok = true;

View File

@ -103,6 +103,8 @@ public:
bool setComponentVersion(const QString &uid, const QString &version, bool important = false);
bool installEmpty(const QString &uid, const QString &name);
QString patchFilePathForUid(const QString &uid) const;
/// if there is a save scheduled, do it now.