mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-18 07:33:12 +09:00
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:
1 parent
7c6aaeb05d
commit
13e12f7335
16 files changed
+146
-34
No files matched your search
@@ -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));
|
||||
|
||||
Reference in new issue
Block a user