ATLauncher: Handle main class depends
This commit is contained in:
parent
dca4ea5cea
commit
f28a0aa666
@ -414,10 +414,24 @@ bool PackInstallTask::createLibrariesComponent(QString instanceRoot, std::shared
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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 id = uuid.toString().remove('{').remove('}');
|
||||
auto target_id = "org.multimc.atlauncher." + id;
|
||||
@ -442,8 +456,8 @@ bool PackInstallTask::createPackComponent(QString instanceRoot, std::shared_ptr<
|
||||
|
||||
auto f = std::make_shared<VersionFile>();
|
||||
f->name = m_pack + " " + m_version_name;
|
||||
if(m_version.mainClass != QString() && !mainClasses.contains(m_version.mainClass)) {
|
||||
f->mainClass = m_version.mainClass;
|
||||
if (!mainClass.isEmpty() && !mainClasses.contains(mainClass)) {
|
||||
f->mainClass = mainClass;
|
||||
}
|
||||
|
||||
// Parse out tweakers
|
||||
|
@ -212,6 +212,12 @@ static void loadVersionMessages(ATLauncher::VersionMessages& m, QJsonObject& obj
|
||||
m.update = Json::ensureString(obj, "update", "");
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
v.version = Json::requireString(obj, "version");
|
||||
@ -220,7 +226,7 @@ void ATLauncher::loadVersion(PackVersion & v, QJsonObject & obj)
|
||||
|
||||
if(obj.contains("mainClass")) {
|
||||
auto main = Json::requireObject(obj, "mainClass");
|
||||
v.mainClass = Json::ensureString(main, "mainClass", "");
|
||||
loadVersionMainClass(v.mainClass, main);
|
||||
}
|
||||
|
||||
if(obj.contains("extraArguments")) {
|
||||
|
@ -150,12 +150,18 @@ struct VersionMessages
|
||||
QString update;
|
||||
};
|
||||
|
||||
struct PackVersionMainClass
|
||||
{
|
||||
QString mainClass;
|
||||
QString depends;
|
||||
};
|
||||
|
||||
struct PackVersion
|
||||
{
|
||||
QString version;
|
||||
QString minecraft;
|
||||
bool noConfigs;
|
||||
QString mainClass;
|
||||
PackVersionMainClass mainClass;
|
||||
QString extraArguments;
|
||||
|
||||
VersionLoader loader;
|
||||
|
Loading…
Reference in New Issue
Block a user