feat(launcher)!: manage multiple game copies

BREAKING CHANGE: The launcher stores copy registrations in copies.json. Installations recorded only in install.json must be registered again.
This commit is contained in:
N0VAN0M4LY committed 2026-11-29 15:14:41 +08:00
1 parent e41b73aaa3
commit 7d68dc0548
24 files changed
+408 -97

No files matched your search

@@ -77,7 +77,12 @@ export type PatchCheck = z.output<typeof PatchCheckSchema>;
export const INSTALL_METHODS = ['copy', 'in-place'] as const;
export type InstallMethod = (typeof INSTALL_METHODS)[number];
export const CopyIdSchema = z.uuid();
export const CopyNameSchema = z.string().trim().min(1);
const InstallChoicesSchema = z.object({
id: CopyIdSchema,
name: CopyNameSchema,
/** Where the local server keeps saves, caches and logs. */
dataPath: z.string().min(1),
/** The player confirmed installing into a Steam library after the warning. */
@@ -115,6 +120,10 @@ export type InstallProgress = z.output<typeof InstallProgressSchema>;
/** What the launcher knows about the installed game copy. */
export const InstallRecordSchema = z.object({
id: CopyIdSchema,
name: CopyNameSchema,
/** Recorded only for a separate source copied during installation. */
sourcePath: z.string().min(1).nullable(),
method: z.enum(INSTALL_METHODS),
copyPath: z.string(),
dataPath: z.string(),
@@ -126,3 +135,14 @@ export const InstallRecordSchema = z.object({
installedAt: z.string(),
});
export type InstallRecord = z.output<typeof InstallRecordSchema>;
export const CopiesSchema = z.object({
formatVersion: z.literal(1),
current: CopyIdSchema.nullable(),
copies: z.array(InstallRecordSchema),
}).refine(({ current, copies }) => {
const ids = new Set(copies.map((copy) => copy.id));
return ids.size === copies.length && (copies.length === 0 ? current === null : current !== null && ids.has(current));
});
export type Copies = z.output<typeof CopiesSchema>;