ATLauncher: Handle extra arguments depends
This commit is contained in:
parent
f28a0aa666
commit
101ca60b2b
@ -414,14 +414,16 @@ bool PackInstallTask::createLibrariesComponent(QString instanceRoot, std::shared
|
||||
|
||||
bool PackInstallTask::createPackComponent(QString instanceRoot, std::shared_ptr<PackProfile> profile)
|
||||
{
|
||||
if (m_version.mainClass.mainClass.isEmpty() && m_version.extraArguments.isEmpty()) {
|
||||
if (m_version.mainClass.mainClass.isEmpty() && m_version.extraArguments.arguments.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
auto mainClass = m_version.mainClass.mainClass;
|
||||
auto extraArguments = m_version.extraArguments.arguments;
|
||||
|
||||
auto hasMainClassDepends = !m_version.mainClass.depends.isEmpty();
|
||||
if (hasMainClassDepends) {
|
||||
auto hasExtraArgumentsDepends = !m_version.extraArguments.depends.isEmpty();
|
||||
if (hasMainClassDepends || hasExtraArgumentsDepends) {
|
||||
QSet<QString> mods;
|
||||
for (const auto& item : m_version.mods) {
|
||||
mods.insert(item.name);
|
||||
@ -430,6 +432,14 @@ bool PackInstallTask::createPackComponent(QString instanceRoot, std::shared_ptr<
|
||||
if (hasMainClassDepends && !mods.contains(m_version.mainClass.depends)) {
|
||||
mainClass = "";
|
||||
}
|
||||
|
||||
if (hasExtraArgumentsDepends && !mods.contains(m_version.extraArguments.depends)) {
|
||||
extraArguments = "";
|
||||
}
|
||||
}
|
||||
|
||||
if (mainClass.isEmpty() && extraArguments.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
auto uuid = QUuid::createUuid();
|
||||
@ -461,7 +471,7 @@ bool PackInstallTask::createPackComponent(QString instanceRoot, std::shared_ptr<
|
||||
}
|
||||
|
||||
// Parse out tweakers
|
||||
auto args = m_version.extraArguments.split(" ");
|
||||
auto args = extraArguments.split(" ");
|
||||
QString previous;
|
||||
for(auto arg : args) {
|
||||
if(arg.startsWith("--tweakClass=") || previous == "--tweakClass") {
|
||||
|
@ -218,6 +218,12 @@ static void loadVersionMainClass(ATLauncher::PackVersionMainClass& m, QJsonObjec
|
||||
m.depends = Json::ensureString(obj, "depends", "");
|
||||
}
|
||||
|
||||
static void loadVersionExtraArguments(ATLauncher::PackVersionExtraArguments& a, QJsonObject& obj)
|
||||
{
|
||||
a.arguments = Json::ensureString(obj, "arguments", "");
|
||||
a.depends = Json::ensureString(obj, "depends", "");
|
||||
}
|
||||
|
||||
void ATLauncher::loadVersion(PackVersion & v, QJsonObject & obj)
|
||||
{
|
||||
v.version = Json::requireString(obj, "version");
|
||||
@ -231,7 +237,7 @@ void ATLauncher::loadVersion(PackVersion & v, QJsonObject & obj)
|
||||
|
||||
if(obj.contains("extraArguments")) {
|
||||
auto arguments = Json::requireObject(obj, "extraArguments");
|
||||
v.extraArguments = Json::ensureString(arguments, "arguments", "");
|
||||
loadVersionExtraArguments(v.extraArguments, arguments);
|
||||
}
|
||||
|
||||
if(obj.contains("loader")) {
|
||||
|
@ -156,13 +156,19 @@ struct PackVersionMainClass
|
||||
QString depends;
|
||||
};
|
||||
|
||||
struct PackVersionExtraArguments
|
||||
{
|
||||
QString arguments;
|
||||
QString depends;
|
||||
};
|
||||
|
||||
struct PackVersion
|
||||
{
|
||||
QString version;
|
||||
QString minecraft;
|
||||
bool noConfigs;
|
||||
PackVersionMainClass mainClass;
|
||||
QString extraArguments;
|
||||
PackVersionExtraArguments extraArguments;
|
||||
|
||||
VersionLoader loader;
|
||||
QVector<VersionLibrary> libraries;
|
||||
|
Loading…
Reference in New Issue
Block a user