mirror of
https://github.com/UltimMC/Launcher.git
synced 2025-10-04 17:09:25 +00:00
NOISSUE Handle main class depends for ATLauncher
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2020-2021 Jamie Mansfield <jmansfield@cadixdev.org>
|
* Copyright 2020-2022 Jamie Mansfield <jmansfield@cadixdev.org>
|
||||||
* Copyright 2021 Petr Mrazek <peterix@gmail.com>
|
* Copyright 2021 Petr Mrazek <peterix@gmail.com>
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@@ -357,10 +357,24 @@ bool PackInstallTask::createLibrariesComponent(QString instanceRoot, std::shared
|
|||||||
|
|
||||||
bool PackInstallTask::createPackComponent(QString instanceRoot, std::shared_ptr<PackProfile> profile)
|
bool PackInstallTask::createPackComponent(QString instanceRoot, std::shared_ptr<PackProfile> profile)
|
||||||
{
|
{
|
||||||
if(m_version.mainClass == QString() && m_version.extraArguments == QString()) {
|
if(m_version.mainClass.mainClass.isEmpty() && m_version.extraArguments.isEmpty()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto mainClass = m_version.mainClass.mainClass;
|
||||||
|
|
||||||
|
auto hasMainClassDepends = !m_version.mainClass.depends.isEmpty();
|
||||||
|
if (hasMainClassDepends) {
|
||||||
|
QSet<QString> mods;
|
||||||
|
for (const auto& item : m_version.mods) {
|
||||||
|
mods.insert(item.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasMainClassDepends && !mods.contains(m_version.mainClass.depends)) {
|
||||||
|
mainClass = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto uuid = QUuid::createUuid();
|
auto uuid = QUuid::createUuid();
|
||||||
auto id = uuid.toString().remove('{').remove('}');
|
auto id = uuid.toString().remove('{').remove('}');
|
||||||
auto target_id = "org.multimc.atlauncher." + id;
|
auto target_id = "org.multimc.atlauncher." + id;
|
||||||
@@ -385,8 +399,8 @@ bool PackInstallTask::createPackComponent(QString instanceRoot, std::shared_ptr<
|
|||||||
|
|
||||||
auto f = std::make_shared<VersionFile>();
|
auto f = std::make_shared<VersionFile>();
|
||||||
f->name = m_pack + " " + m_version_name;
|
f->name = m_pack + " " + m_version_name;
|
||||||
if(m_version.mainClass != QString() && !mainClasses.contains(m_version.mainClass)) {
|
if(!mainClass.isEmpty() && !mainClasses.contains(mainClass)) {
|
||||||
f->mainClass = m_version.mainClass;
|
f->mainClass = mainClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse out tweakers
|
// Parse out tweakers
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2020-2021 Jamie Mansfield <jmansfield@cadixdev.org>
|
* Copyright 2020-2022 Jamie Mansfield <jmansfield@cadixdev.org>
|
||||||
* Copyright 2021 Petr Mrazek <peterix@gmail.com>
|
* Copyright 2021 Petr Mrazek <peterix@gmail.com>
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@@ -185,6 +185,12 @@ static void loadVersionMod(ATLauncher::VersionMod & p, QJsonObject & obj) {
|
|||||||
p.effectively_hidden = p.hidden || p.library;
|
p.effectively_hidden = p.hidden || p.library;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void loadVersionMainClass(ATLauncher::PackVersionMainClass & m, QJsonObject & obj)
|
||||||
|
{
|
||||||
|
m.mainClass = Json::ensureString(obj, "mainClass", "");
|
||||||
|
m.depends = Json::ensureString(obj, "depends", "");
|
||||||
|
}
|
||||||
|
|
||||||
void ATLauncher::loadVersion(PackVersion & v, QJsonObject & obj)
|
void ATLauncher::loadVersion(PackVersion & v, QJsonObject & obj)
|
||||||
{
|
{
|
||||||
v.version = Json::requireString(obj, "version");
|
v.version = Json::requireString(obj, "version");
|
||||||
@@ -193,7 +199,7 @@ void ATLauncher::loadVersion(PackVersion & v, QJsonObject & obj)
|
|||||||
|
|
||||||
if(obj.contains("mainClass")) {
|
if(obj.contains("mainClass")) {
|
||||||
auto main = Json::requireObject(obj, "mainClass");
|
auto main = Json::requireObject(obj, "mainClass");
|
||||||
v.mainClass = Json::ensureString(main, "mainClass", "");
|
loadVersionMainClass(v.mainClass, main);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(obj.contains("extraArguments")) {
|
if(obj.contains("extraArguments")) {
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2020 Jamie Mansfield <jmansfield@cadixdev.org>
|
* Copyright 2020-2022 Jamie Mansfield <jmansfield@cadixdev.org>
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -122,12 +122,18 @@ struct VersionConfigs
|
|||||||
QString sha1;
|
QString sha1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct PackVersionMainClass
|
||||||
|
{
|
||||||
|
QString mainClass;
|
||||||
|
QString depends;
|
||||||
|
};
|
||||||
|
|
||||||
struct PackVersion
|
struct PackVersion
|
||||||
{
|
{
|
||||||
QString version;
|
QString version;
|
||||||
QString minecraft;
|
QString minecraft;
|
||||||
bool noConfigs;
|
bool noConfigs;
|
||||||
QString mainClass;
|
PackVersionMainClass mainClass;
|
||||||
QString extraArguments;
|
QString extraArguments;
|
||||||
|
|
||||||
VersionLoader loader;
|
VersionLoader loader;
|
||||||
|
Reference in New Issue
Block a user