Merge pull request #630 from jamierocks/h-atl-depends
This commit is contained in:
commit
7f73e57c67
@ -414,7 +414,31 @@ 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.arguments.isEmpty()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mainClass = m_version.mainClass.mainClass;
|
||||||
|
auto extraArguments = m_version.extraArguments.arguments;
|
||||||
|
|
||||||
|
auto hasMainClassDepends = !m_version.mainClass.depends.isEmpty();
|
||||||
|
auto hasExtraArgumentsDepends = !m_version.extraArguments.depends.isEmpty();
|
||||||
|
if (hasMainClassDepends || hasExtraArgumentsDepends) {
|
||||||
|
QSet<QString> mods;
|
||||||
|
for (const auto& item : m_version.mods) {
|
||||||
|
mods.insert(item.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -442,12 +466,12 @@ 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
|
||||||
auto args = m_version.extraArguments.split(" ");
|
auto args = extraArguments.split(" ");
|
||||||
QString previous;
|
QString previous;
|
||||||
for(auto arg : args) {
|
for(auto arg : args) {
|
||||||
if(arg.startsWith("--tweakClass=") || previous == "--tweakClass") {
|
if(arg.startsWith("--tweakClass=") || previous == "--tweakClass") {
|
||||||
@ -757,6 +781,17 @@ bool PackInstallTask::extractMods(
|
|||||||
for (auto iter = toCopy.begin(); iter != toCopy.end(); iter++) {
|
for (auto iter = toCopy.begin(); iter != toCopy.end(); iter++) {
|
||||||
auto &from = iter.key();
|
auto &from = iter.key();
|
||||||
auto &to = iter.value();
|
auto &to = iter.value();
|
||||||
|
|
||||||
|
// If the file already exists, assume the mod is the correct copy - and remove
|
||||||
|
// the copy from the Configs.zip
|
||||||
|
QFileInfo fileInfo(to);
|
||||||
|
if (fileInfo.exists()) {
|
||||||
|
if (!QFile::remove(to)) {
|
||||||
|
qWarning() << "Failed to delete" << to;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
FS::copy fileCopyOperation(from, to);
|
FS::copy fileCopyOperation(from, to);
|
||||||
if(!fileCopyOperation()) {
|
if(!fileCopyOperation()) {
|
||||||
qWarning() << "Failed to copy" << from << "to" << to;
|
qWarning() << "Failed to copy" << from << "to" << to;
|
||||||
|
@ -212,6 +212,18 @@ static void loadVersionMessages(ATLauncher::VersionMessages& m, QJsonObject& obj
|
|||||||
m.update = Json::ensureString(obj, "update", "");
|
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", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
void ATLauncher::loadVersion(PackVersion & v, QJsonObject & obj)
|
||||||
{
|
{
|
||||||
v.version = Json::requireString(obj, "version");
|
v.version = Json::requireString(obj, "version");
|
||||||
@ -220,12 +232,12 @@ 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")) {
|
||||||
auto arguments = Json::requireObject(obj, "extraArguments");
|
auto arguments = Json::requireObject(obj, "extraArguments");
|
||||||
v.extraArguments = Json::ensureString(arguments, "arguments", "");
|
loadVersionExtraArguments(v.extraArguments, arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(obj.contains("loader")) {
|
if(obj.contains("loader")) {
|
||||||
|
@ -150,13 +150,25 @@ struct VersionMessages
|
|||||||
QString update;
|
QString update;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct PackVersionMainClass
|
||||||
|
{
|
||||||
|
QString mainClass;
|
||||||
|
QString depends;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct PackVersionExtraArguments
|
||||||
|
{
|
||||||
|
QString arguments;
|
||||||
|
QString depends;
|
||||||
|
};
|
||||||
|
|
||||||
struct PackVersion
|
struct PackVersion
|
||||||
{
|
{
|
||||||
QString version;
|
QString version;
|
||||||
QString minecraft;
|
QString minecraft;
|
||||||
bool noConfigs;
|
bool noConfigs;
|
||||||
QString mainClass;
|
PackVersionMainClass mainClass;
|
||||||
QString extraArguments;
|
PackVersionExtraArguments extraArguments;
|
||||||
|
|
||||||
VersionLoader loader;
|
VersionLoader loader;
|
||||||
QVector<VersionLibrary> libraries;
|
QVector<VersionLibrary> libraries;
|
||||||
|
Loading…
Reference in New Issue
Block a user