diff options
author | Petr Mrázek <peterix@gmail.com> | 2017-12-31 01:37:50 +0100 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2017-12-31 01:37:50 +0100 |
commit | 4340068a84d1532d9f5ca4de4d12cbf1b7a7bd52 (patch) | |
tree | d19500716c8c4fe9cdec4361ffae47d47f806f0a /api | |
parent | c7032ce68ac3e48c1aace5742cc719e80dbf719b (diff) | |
download | PrismLauncher-4340068a84d1532d9f5ca4de4d12cbf1b7a7bd52.tar.gz PrismLauncher-4340068a84d1532d9f5ca4de4d12cbf1b7a7bd52.tar.bz2 PrismLauncher-4340068a84d1532d9f5ca4de4d12cbf1b7a7bd52.zip |
NOISSUE add button for creating empty, properly registered, components
Diffstat (limited to 'api')
-rw-r--r-- | api/logic/minecraft/ComponentList.cpp | 28 | ||||
-rw-r--r-- | api/logic/minecraft/ComponentList.h | 2 |
2 files changed, 30 insertions, 0 deletions
diff --git a/api/logic/minecraft/ComponentList.cpp b/api/logic/minecraft/ComponentList.cpp index 3fb04255..b4ab2151 100644 --- a/api/logic/minecraft/ComponentList.cpp +++ b/api/logic/minecraft/ComponentList.cpp @@ -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; diff --git a/api/logic/minecraft/ComponentList.h b/api/logic/minecraft/ComponentList.h index b66b3417..3b53a9fe 100644 --- a/api/logic/minecraft/ComponentList.h +++ b/api/logic/minecraft/ComponentList.h @@ -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. |