diff options
author | Petr Mrázek <peterix@gmail.com> | 2017-04-21 22:23:00 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2017-04-21 22:23:00 +0200 |
commit | f3c46dbf11ada91b0da8de506cb5308a7242bb33 (patch) | |
tree | 3bf443394e449a6eedb8d002a335f84cc7a6a37c /api/logic/minecraft/onesix | |
parent | 581460dcf95c76d228785dbd0e894fbeb2c1a22d (diff) | |
download | MultiMC-f3c46dbf11ada91b0da8de506cb5308a7242bb33.tar MultiMC-f3c46dbf11ada91b0da8de506cb5308a7242bb33.tar.gz MultiMC-f3c46dbf11ada91b0da8de506cb5308a7242bb33.tar.lz MultiMC-f3c46dbf11ada91b0da8de506cb5308a7242bb33.tar.xz MultiMC-f3c46dbf11ada91b0da8de506cb5308a7242bb33.zip |
NOISSUE silly/simple implementation of mod metadata in OneSix version format
Diffstat (limited to 'api/logic/minecraft/onesix')
-rw-r--r-- | api/logic/minecraft/onesix/OneSixVersionFormat.cpp | 31 | ||||
-rw-r--r-- | api/logic/minecraft/onesix/OneSixVersionFormat.h | 4 |
2 files changed, 35 insertions, 0 deletions
diff --git a/api/logic/minecraft/onesix/OneSixVersionFormat.cpp b/api/logic/minecraft/onesix/OneSixVersionFormat.cpp index da55d91b..e27389b6 100644 --- a/api/logic/minecraft/onesix/OneSixVersionFormat.cpp +++ b/api/logic/minecraft/onesix/OneSixVersionFormat.cpp @@ -126,6 +126,18 @@ VersionFilePtr OneSixVersionFormat::versionFileFromJson(const QJsonDocument &doc } } + if (root.contains("mods")) + { + for (auto libVal : requireArray(root.value("mods"))) + { + QJsonObject libObj = requireObject(libVal); + // parse the jarmod + auto lib = OneSixVersionFormat::modFromJson(libObj, filename); + // and add to jar mods + out->mods.append(lib); + } + } + auto readLibs = [&](const char * which) { for (auto libVal : requireArray(root.value(which))) @@ -246,6 +258,15 @@ QJsonDocument OneSixVersionFormat::versionFileToJson(const VersionFilePtr &patch } root.insert("jarMods", array); } + if (!patch->mods.isEmpty()) + { + QJsonArray array; + for (auto value: patch->jarMods) + { + array.append(OneSixVersionFormat::modtoJson(value.get())); + } + root.insert("mods", array); + } // write the contents to a json document. { QJsonDocument out; @@ -306,3 +327,13 @@ QJsonObject OneSixVersionFormat::jarModtoJson(Library *jarmod) } return out; } + +LibraryPtr OneSixVersionFormat::modFromJson(const QJsonObject& libObj, const QString& filename) +{ + return libraryFromJson(libObj, filename); +} + +QJsonObject OneSixVersionFormat::modtoJson(Library *jarmod) +{ + return libraryToJson(jarmod); +} diff --git a/api/logic/minecraft/onesix/OneSixVersionFormat.h b/api/logic/minecraft/onesix/OneSixVersionFormat.h index 0a29a202..64f18da8 100644 --- a/api/logic/minecraft/onesix/OneSixVersionFormat.h +++ b/api/logic/minecraft/onesix/OneSixVersionFormat.h @@ -22,4 +22,8 @@ public: // new jar mods derived from libraries static LibraryPtr jarModFromJson(const QJsonObject &libObj, const QString &filename); static QJsonObject jarModtoJson(Library * jarmod); + + // mods, also derived from libraries + static LibraryPtr modFromJson(const QJsonObject &libObj, const QString &filename); + static QJsonObject modtoJson(Library * jarmod); }; |