Awesome menu and saves

This commit is contained in:
2026-11-14 14:48:07 -03:00
parent a69db0cd2a
commit 95e058d659
11 changed files with 861 additions and 128 deletions
+14
View File
@@ -116,6 +116,20 @@ export function write_mod(mod: Mod): Uint8Array<ArrayBuffer> {
return zipSync(sorted, { mtime: FIXED_TIME, level: 9 }) as Uint8Array<ArrayBuffer>;
}
// only a .cubi's manifest, checked, without unzipping the rest. for listing mods, read_mod checks the whole thing
export function read_manifest(bytes: Uint8Array, file: string): ManifestJson {
let manifest: ManifestJson;
try {
const files = unzipSync(bytes, { filter: (entry) => entry.name === "manifest.json" });
manifest = JSON.parse(new TextDecoder().decode(files["manifest.json"]));
} catch (e) {
throw new ModError(file, [`isn't a readable .cubi: ${(e as Error).message}`]);
}
const problems = validate_manifest(manifest, manifest?.id);
if (problems.length > 0) throw new ModError(file, problems.map((problem) => `manifest.json: ${problem}`));
return manifest;
}
// opens and checks a .cubi. file is only for error messages. throws ModError listing what's wrong
export function read_mod(bytes: Uint8Array, file: string): Mod {
let files: Record<string, Uint8Array>;