Tie data exports to mod packs

Store the export manifest in ModPack to allow mulitple mod packs to have
different data exported. This is necessary as the export contains the
settings prototypes needed to create a proper UI for mod settings.

For now the useLocale and useItemMetadata interfaces uses the manifest
for a default mod pack set in the master config.
This commit is contained in:
Hornwitser committed 2023-02-02 00:28:58 +01:00
1 parent 7c6aaeb05d
commit 13e12f7335
16 files changed
+146 -34

No files matched your search

+11
View File
@@ -3,6 +3,7 @@ const zlib = require("zlib");
const libSchema = require("../schema");
const ExportManifest = require("./ExportManifest");
const { integerFactorioVersion } = require("./version");
@@ -99,6 +100,12 @@ class ModPack {
"runtime-per-user": new Map(),
};
/**
* Mapping to files containing exported data for this modpack
* @type {module:lib/data.ExportManifest|undefined}
*/
exportManifest;
/**
* True if this mod pack has been deleted from the list of mod packs.
* @type {boolean}
@@ -128,6 +135,7 @@ class ModPack {
"runtime-per-user": ModSettingsJsonSchema,
},
},
"export_manifest": ExportManifest.jsonSchema,
"is_deleted": { type: "boolean" },
},
};
@@ -151,6 +159,7 @@ class ModPack {
"runtime-per-user": new Map(Object.entries(json.settings["runtime-per-user"])),
};
}
if (json.export_manifest) { this.exportManifest = new ExportManifest(json.export_manifest); }
if (json.is_deleted) { this.isDeleted = json.is_deleted; }
if (!this.mods.has("base")) {
@@ -171,6 +180,7 @@ class ModPack {
"runtime-per-user": Object.fromEntries(this.settings["runtime-per-user"]),
},
};
if (this.exportManifest) { json.export_manifest = this.exportManifest.toJSON(); }
if (this.isDeleted) { json.is_deleted = this.isDeleted; }
return json;
}
@@ -178,6 +188,7 @@ class ModPack {
toModPackString() {
const json = this.toJSON();
delete json.id;
delete json.export_manifest;
// eslint-disable-next-line node/no-sync
let buf = zlib.deflateSync(JSON.stringify(json));