mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2026-06-29 01:54:20 +03:00
feat: add button to import component JSONs
Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
This commit is contained in:
parent
219c5b323d
commit
fff52cb247
5 changed files with 59 additions and 2 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue