summaryrefslogtreecommitdiffstats
path: root/logic
diff options
context:
space:
mode:
authorJan Dalheimer <jan@dalheimer.de>2014-01-28 07:39:43 +0100
committerJan Dalheimer <jan@dalheimer.de>2014-01-28 07:39:43 +0100
commit556d8f0ec16e5030cfbfac9dc0fc2c796e829dcb (patch)
tree85ff7f3dc490a752a299a6d2983392018036857f /logic
parent986141b5035c99747c7e06cd447b8b4e27eb2b27 (diff)
downloadMultiMC-556d8f0ec16e5030cfbfac9dc0fc2c796e829dcb.tar
MultiMC-556d8f0ec16e5030cfbfac9dc0fc2c796e829dcb.tar.gz
MultiMC-556d8f0ec16e5030cfbfac9dc0fc2c796e829dcb.tar.lz
MultiMC-556d8f0ec16e5030cfbfac9dc0fc2c796e829dcb.tar.xz
MultiMC-556d8f0ec16e5030cfbfac9dc0fc2c796e829dcb.zip
custom.json overrides all. For user patching there now is instance.json
Diffstat (limited to 'logic')
-rw-r--r--logic/OneSixVersionBuilder.cpp107
1 files changed, 65 insertions, 42 deletions
diff --git a/logic/OneSixVersionBuilder.cpp b/logic/OneSixVersionBuilder.cpp
index 3b119b45..a8e7253b 100644
--- a/logic/OneSixVersionBuilder.cpp
+++ b/logic/OneSixVersionBuilder.cpp
@@ -695,13 +695,11 @@ bool OneSixVersionBuilder::build(const bool excludeCustom)
QDir root(m_instance->instanceRoot());
QDir patches(root.absoluteFilePath("patches/"));
- // version.json -> patches/*.json -> custom.json
-
- // version.json
+ if (QFile::exists(root.absoluteFilePath("custom.json")))
{
- QLOG_INFO() << "Reading version.json";
+ QLOG_INFO() << "Reading custom.json";
VersionFile file;
- if (!read(QFileInfo(root.absoluteFilePath("version.json")), false, &file))
+ if (!read(QFileInfo(root.absoluteFilePath("custom.json")), false, &file))
{
return false;
}
@@ -713,65 +711,90 @@ bool OneSixVersionBuilder::build(const bool excludeCustom)
m_widgetParent, QObject::tr("Error"),
QObject::tr(
"Error while applying %1. Please check MultiMC-0.log for more info.")
- .arg(root.absoluteFilePath("version.json")));
+ .arg(root.absoluteFilePath("custom.json")));
return false;
}
}
-
- // patches/
+ else
{
- // load all, put into map for ordering, apply in the right order
+ // version.json -> patches/*.json -> instance.json
- QMap<int, QPair<QString, VersionFile>> files;
- for (auto info : patches.entryInfoList(QStringList() << "*.json", QDir::Files))
+ // version.json
{
- QLOG_INFO() << "Reading" << info.fileName();
+ QLOG_INFO() << "Reading version.json";
VersionFile file;
- if (!read(info, true, &file))
+ if (!read(QFileInfo(root.absoluteFilePath("version.json")), false, &file))
{
return false;
}
- files.insert(file.order, qMakePair(info.fileName(), file));
- }
- for (auto order : files.keys())
- {
- QLOG_DEBUG() << "Applying file with order" << order;
- auto filePair = files[order];
bool isError = false;
- filePair.second.applyTo(m_version, isError);
+ file.applyTo(m_version, isError);
if (isError)
{
QMessageBox::critical(
- m_widgetParent, QObject::tr("Error"),
- QObject::tr(
- "Error while applying %1. Please check MultiMC-0.log for more info.")
- .arg(filePair.first));
+ m_widgetParent, QObject::tr("Error"),
+ QObject::tr(
+ "Error while applying %1. Please check MultiMC-0.log for more info.")
+ .arg(root.absoluteFilePath("version.json")));
return false;
}
}
- }
- // custom.json
- if (!excludeCustom)
- {
- if (QFile::exists(root.absoluteFilePath("custom.json")))
+ // patches/
{
- QLOG_INFO() << "Reading custom.json";
- VersionFile file;
- if (!read(QFileInfo(root.absoluteFilePath("custom.json")), false, &file))
+ // load all, put into map for ordering, apply in the right order
+
+ QMap<int, QPair<QString, VersionFile>> files;
+ for (auto info : patches.entryInfoList(QStringList() << "*.json", QDir::Files))
{
- return false;
+ QLOG_INFO() << "Reading" << info.fileName();
+ VersionFile file;
+ if (!read(info, true, &file))
+ {
+ return false;
+ }
+ files.insert(file.order, qMakePair(info.fileName(), file));
}
- bool isError = false;
- file.applyTo(m_version, isError);
- if (isError)
+ for (auto order : files.keys())
{
- QMessageBox::critical(
- m_widgetParent, QObject::tr("Error"),
- QObject::tr(
- "Error while applying %1. Please check MultiMC-0.log for more info.")
- .arg(root.absoluteFilePath("custom.json")));
- return false;
+ QLOG_DEBUG() << "Applying file with order" << order;
+ auto filePair = files[order];
+ bool isError = false;
+ filePair.second.applyTo(m_version, isError);
+ if (isError)
+ {
+ QMessageBox::critical(
+ m_widgetParent, QObject::tr("Error"),
+ QObject::tr(
+ "Error while applying %1. Please check MultiMC-0.log for more info.")
+ .arg(filePair.first));
+ return false;
+ }
+ }
+ }
+
+ // instance.json
+ if (!excludeCustom)
+ {
+ if (QFile::exists(root.absoluteFilePath("instance.json")))
+ {
+ QLOG_INFO() << "Reading instance.json";
+ VersionFile file;
+ if (!read(QFileInfo(root.absoluteFilePath("instance.json")), false, &file))
+ {
+ return false;
+ }
+ bool isError = false;
+ file.applyTo(m_version, isError);
+ if (isError)
+ {
+ QMessageBox::critical(
+ m_widgetParent, QObject::tr("Error"),
+ QObject::tr(
+ "Error while applying %1. Please check MultiMC-0.log for more info.")
+ .arg(root.absoluteFilePath("instance.json")));
+ return false;
+ }
}
}
}