From 556d8f0ec16e5030cfbfac9dc0fc2c796e829dcb Mon Sep 17 00:00:00 2001 From: Jan Dalheimer Date: Tue, 28 Jan 2014 07:39:43 +0100 Subject: custom.json overrides all. For user patching there now is instance.json --- logic/OneSixVersionBuilder.cpp | 107 +++++++++++++++++++++++++---------------- 1 file 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> 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> 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; + } } } } -- cgit v1.2.3