mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2025-06-13 05:37:42 +02:00
Implement recommendedRam in CurseForge import
Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
@ -54,6 +54,7 @@
|
|||||||
|
|
||||||
#include "settings/INISettingsObject.h"
|
#include "settings/INISettingsObject.h"
|
||||||
|
|
||||||
|
#include "sys.h"
|
||||||
#include "tasks/ConcurrentTask.h"
|
#include "tasks/ConcurrentTask.h"
|
||||||
#include "ui/dialogs/BlockedModsDialog.h"
|
#include "ui/dialogs/BlockedModsDialog.h"
|
||||||
#include "ui/dialogs/CustomMessageBox.h"
|
#include "ui/dialogs/CustomMessageBox.h"
|
||||||
@ -418,6 +419,24 @@ bool FlameCreationTask::createInstance()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int recommendedRAM = m_pack.minecraft.recommendedRAM;
|
||||||
|
|
||||||
|
// only set memory if this is a fresh instance
|
||||||
|
if (m_instance == nullptr && recommendedRAM > 0) {
|
||||||
|
const uint64_t sysMiB = Sys::getSystemRam() / Sys::mebibyte;
|
||||||
|
const uint64_t max = sysMiB * 0.9;
|
||||||
|
|
||||||
|
if (recommendedRAM > max) {
|
||||||
|
logWarning(tr("The recommended memory of the modpack exceeds 90% of your system RAM—reducing it from %1 MiB to %2 MiB!")
|
||||||
|
.arg(recommendedRAM)
|
||||||
|
.arg(max));
|
||||||
|
recommendedRAM = max;
|
||||||
|
}
|
||||||
|
|
||||||
|
instance.settings()->set("OverrideMemory", true);
|
||||||
|
instance.settings()->set("MaxMemAlloc", recommendedRAM);
|
||||||
|
}
|
||||||
|
|
||||||
QString jarmodsPath = FS::PathCombine(m_stagingPath, "minecraft", "jarmods");
|
QString jarmodsPath = FS::PathCombine(m_stagingPath, "minecraft", "jarmods");
|
||||||
QFileInfo jarmodsInfo(jarmodsPath);
|
QFileInfo jarmodsInfo(jarmodsPath);
|
||||||
if (jarmodsInfo.isDir()) {
|
if (jarmodsInfo.isDir()) {
|
||||||
|
@ -27,6 +27,7 @@ static void loadMinecraftV1(Flame::Minecraft& m, QJsonObject& minecraft)
|
|||||||
loadModloaderV1(loader, obj);
|
loadModloaderV1(loader, obj);
|
||||||
m.modLoaders.append(loader);
|
m.modLoaders.append(loader);
|
||||||
}
|
}
|
||||||
|
m.recommendedRAM = Json::ensureInteger(minecraft, "recommendedRam", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void loadManifestV1(Flame::Manifest& pack, QJsonObject& manifest)
|
static void loadManifestV1(Flame::Manifest& pack, QJsonObject& manifest)
|
||||||
|
@ -67,6 +67,7 @@ struct Minecraft {
|
|||||||
QString version;
|
QString version;
|
||||||
QString libraries;
|
QString libraries;
|
||||||
QList<Flame::Modloader> modLoaders;
|
QList<Flame::Modloader> modLoaders;
|
||||||
|
int recommendedRAM;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Manifest {
|
struct Manifest {
|
||||||
|
Reference in New Issue
Block a user