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
diff --git a/launcher/minecraft/PackProfile.h b/launcher/minecraft/PackProfile.h
index 2330cca1..35af9a56 100644
--- a/launcher/minecraft/PackProfile.h
+++ b/launcher/minecraft/PackProfile.h
@@ -86,6 +86,9 @@ public:
/// install a jar/zip as a replacement for the main jar
void installCustomJar(QString selectedFile);
+ /// install MMC/Prism component files
+ void installComponents(QStringList selectedFiles);
+
/// install Java agent files
void installAgents(QStringList selectedFiles);
@@ -171,6 +174,7 @@ private:
bool load();
bool installJarMods_internal(QStringList filepaths);
bool installCustomJar_internal(QString filepath);
+ bool installComponents_internal(QStringList filepaths);
bool installAgents_internal(QStringList filepaths);
bool removeComponent_internal(ComponentPtr patch);
diff --git a/launcher/ui/pages/instance/VersionPage.cpp b/launcher/ui/pages/instance/VersionPage.cpp
index d200652a..07a97813 100644
--- a/launcher/ui/pages/instance/VersionPage.cpp
+++ b/launcher/ui/pages/instance/VersionPage.cpp
@@ -282,6 +282,7 @@ void VersionPage::updateButtons(int row)
ui->actionRevert->setEnabled(controlsEnabled && patch && patch->isRevertible());
ui->actionDownload_All->setEnabled(controlsEnabled);
ui->actionAdd_Empty->setEnabled(controlsEnabled);
+ ui->actionImport_Components->setEnabled(controlsEnabled);
ui->actionReload->setEnabled(controlsEnabled);
ui->actionInstall_mods->setEnabled(controlsEnabled);
ui->actionReplace_Minecraft_jar->setEnabled(controlsEnabled);
@@ -375,6 +376,16 @@ void VersionPage::on_actionReplace_Minecraft_jar_triggered()
updateButtons();
}
+void VersionPage::on_actionImport_Components_triggered()
+{
+ QStringList list = GuiUtil::BrowseForFiles("component", tr("Select components"), tr("Components (*.json)"),
+ APPLICATION->settings()->get("CentralModsDir").toString(), this->parentWidget());
+
+ if (!list.isEmpty())
+ m_profile->installComponents(list);
+
+ updateButtons();
+}
void VersionPage::on_actionAdd_Agents_triggered()
{
diff --git a/launcher/ui/pages/instance/VersionPage.h b/launcher/ui/pages/instance/VersionPage.h
index 166f36bb..a56f016d 100644
--- a/launcher/ui/pages/instance/VersionPage.h
+++ b/launcher/ui/pages/instance/VersionPage.h
@@ -86,6 +86,7 @@ private slots:
void on_actionMove_down_triggered();
void on_actionAdd_to_Minecraft_jar_triggered();
void on_actionReplace_Minecraft_jar_triggered();
+ void on_actionImport_Components_triggered();
void on_actionAdd_Agents_triggered();
void on_actionRevert_triggered();
void on_actionEdit_triggered();
diff --git a/launcher/ui/pages/instance/VersionPage.ui b/launcher/ui/pages/instance/VersionPage.ui
index 4cd50885..4777eafe 100644
--- a/launcher/ui/pages/instance/VersionPage.ui
+++ b/launcher/ui/pages/instance/VersionPage.ui
@@ -108,6 +108,7 @@
+
@@ -226,10 +227,10 @@
- Add Agents
+ Add Agents
- Add Java agents.
+ Add Java agents.
@@ -272,6 +273,14 @@
Open the instance's local libraries folder.
+
+
+ Import Components
+
+
+ Import existing component JSON files.
+
+