diff options
Diffstat (limited to 'launcher/minecraft/PackProfile.cpp')
-rw-r--r-- | launcher/minecraft/PackProfile.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/launcher/minecraft/PackProfile.cpp b/launcher/minecraft/PackProfile.cpp index 43fa3f8d..2028b236 100644 --- a/launcher/minecraft/PackProfile.cpp +++ b/launcher/minecraft/PackProfile.cpp @@ -49,6 +49,7 @@ #include "minecraft/OneSixVersionFormat.h" #include "FileSystem.h" #include "minecraft/MinecraftInstance.h" +#include "minecraft/ProfileUtils.h" #include "Json.h" #include "PackProfile.h" @@ -737,6 +738,11 @@ void PackProfile::installCustomJar(QString selectedFile) installCustomJar_internal(selectedFile); } +void PackProfile::installComponents(QStringList selectedFiles) +{ + installComponents_internal(selectedFiles); +} + void PackProfile::installAgents(QStringList selectedFiles) { installAgents_internal(selectedFiles); @@ -939,6 +945,32 @@ bool PackProfile::installCustomJar_internal(QString filepath) return true; } +bool PackProfile::installComponents_internal(QStringList filepaths) +{ + const QString patchDir = FS::PathCombine(d->m_instance->instanceRoot(), "patches"); + if (!FS::ensureFolderPathExists(patchDir)) + return false; + + for (const QString& source : filepaths) { + const QFileInfo sourceInfo(source); + + auto versionFile = ProfileUtils::parseJsonFile(sourceInfo, false); + const QString target = FS::PathCombine(patchDir, versionFile->uid + ".json"); + + if (!QFile::copy(source, target)) + { + return false; + } + + appendComponent(new Component(this, versionFile->uid, versionFile)); + } + + scheduleSave(); + invalidateLaunchProfile(); + + return true; +} + bool PackProfile::installAgents_internal(QStringList filepaths) { // FIXME code duplication |