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

+20 -3
View File
@@ -8,7 +8,7 @@ import { measureFolder } from '../services/game-folder/folder-size.ts';
import { inspectGameFolder, requireFolder } from '../services/game-folder/inspect-game-folder.ts';
import { inspectTargetFolder } from '../services/game-folder/inspect-target-folder.ts';
import { cancelInstall, checkGameFolder, installGame } from '../services/install/install-game.ts';
import { defaultDataPath, readInstallRecord } from '../services/install/install-record.ts';
import { createCopyDraft, listCopies, readInstallRecord, renameCopy, setCurrentCopy } from '../services/install/install-record.ts';
import { readInstalledLab } from '../services/launch/lab-handoff.ts';
import { getLaunchState, openServerStatus, startLaunch, stopLaunch } from '../services/launch/launch-controller.ts';
import { resourcePaths } from '../services/resources/resource-paths.ts';
@@ -54,6 +54,7 @@ export function registerIpcHandlers(): void {
return { path: result.canceled ? null : (result.filePaths[0] ?? null) };
});
handle('install:prepareCopy', () => createCopyDraft());
handle('install:inspectGameFolder', ({ path }) => inspectGameFolder(path));
handle('install:inspectTargetFolder', ({ path, stockPath }) => inspectTargetFolder(path, stockPath));
handle('install:measureFolder', async ({ path }) => {
@@ -67,14 +68,30 @@ export function registerIpcHandlers(): void {
});
handle('install:checkPatches', ({ gamePath, dataPath }) => checkGameFolder(gamePath, dataPath));
handle('install:start', (request) => installGame(request, (progress) => broadcast('event:install-progress', progress)));
handle('install:start', async (request) => {
const record = await installGame(request, (progress) => broadcast('event:install-progress', progress));
broadcast('event:copies-changed', await listCopies());
return record;
});
handle('install:cancel', () => ({ cancelled: cancelInstall() }));
handle('install:getRecord', async () => ({ record: await readInstallRecord(), defaultDataPath: defaultDataPath() }));
handle('install:getRecord', async () => ({ record: await readInstallRecord() }));
handle('install:listFeatures', () => {
const resources = resourcePaths();
return patchFeatures(resources.patches).map((feature) => ({ ...feature, patchIds: [...feature.patchIds] }));
});
handle('copies:list', () => listCopies());
handle('copies:setCurrent', async ({ id }) => {
const registry = await setCurrentCopy(id);
broadcast('event:copies-changed', registry);
return registry;
});
handle('copies:rename', async ({ id, name }) => {
const registry = await renameCopy(id, name);
broadcast('event:copies-changed', registry);
return registry;
});
handle('launch:getState', () => getLaunchState());
handle('launch:getLabInfo', () => readInstalledLab().catch(() => null));
handle('launch:start', () => startLaunch((state) => broadcast('event:launch-state', state)));