Files
WT-Offline/apps/launcher/src/main/ipc/handlers.ts
T
N0VAN0M4LY d06989622f Inspect the folders the player chooses for installation
The install wizard needs to tell whether the chosen folder is a War
Thunder installation, which version it is, whether it is a Steam
library, and whether the folder for the copy can take it.

The patcher reads the game version from win64/aces.exe (the
VS_FIXEDFILEINFO block of its version resource) and works out the
versions every exe and GUI patch was verified on, from their
verified_on lists, so the version check follows the patch definitions
instead of a constant.

The launcher gets four IPC calls, each validated against the contract:
- dialog:pickFolder, a folder picker titled by the window;
- install:inspectGameFolder: missing game files, version, verified
  versions, Steam library;
- install:inspectTargetFolder: new or empty, not overlapping the stock
  installation, Steam library, free space on its drive, and whether it
  is on the stock installation's drive (the space saving copy needs
  that);
- install:measureFolder: bytes and files of the stock installation,
  regular files only, links not followed.
A folder that does not exist or cannot be read is the folder_unreadable
error code, translated in both languages. In development the patch
folders and the hook library come from this repository; the packaged
layout comes with the installer build.

Checked with both typechecks, the launcher build, and the calls made
from a running launcher window: the stock folder (2.61.0.37, verified),
a non-game folder, a missing path, a Steam library path, four target
folders (new, inside the stock folder, not empty, other drive) and the
size of the offline copy (96.9 GB in 10,972 files).
2026-11-29 03:36:00 +08:00

44 lines
2.0 KiB
TypeScript

import { app, BrowserWindow, dialog } from 'electron';
import { AppError } from '@shared/errors.ts';
import { getSettings, updateSettings } from '../services/config/settings-store.ts';
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 { broadcast, handle } from './register.ts';
/** Registers the handler of every contract channel. One line per channel; the work is in services/. */
export function registerIpcHandlers(): void {
handle('app:getInfo', () => ({
version: app.getVersion(),
electron: process.versions.electron,
systemLocale: app.getLocale(),
userDataPath: app.getPath('userData'),
}));
handle('dialog:pickFolder', async ({ title }, sender) => {
const window = BrowserWindow.fromWebContents(sender);
const options = { properties: ['openDirectory', 'createDirectory'] as Array<'openDirectory' | 'createDirectory'>, ...(title ? { title } : {}) };
const result = window ? await dialog.showOpenDialog(window, options) : await dialog.showOpenDialog(options);
return { path: result.canceled ? null : (result.filePaths[0] ?? null) };
});
handle('install:inspectGameFolder', ({ path }) => inspectGameFolder(path));
handle('install:inspectTargetFolder', ({ path, stockPath }) => inspectTargetFolder(path, stockPath));
handle('install:measureFolder', async ({ path }) => {
await requireFolder(path);
try {
return await measureFolder(path);
} catch (error) {
console.warn('[install] measuring the folder failed:', error);
throw new AppError('folder_unreadable', { path });
}
});
handle('settings:get', () => getSettings());
handle('settings:update', async (patch) => {
const settings = await updateSettings(patch);
broadcast('event:settings-changed', settings);
return settings;
});
}