feat(launcher): inspect game installation and destination folders
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).
This commit is contained in:
1 parent
38e9549e15
commit
ab0d3b1f30
13 files changed
+310
-1
No files matched your search
@@ -14,6 +14,8 @@ export const APP_ERROR_CODES = [
|
||||
'internal_error',
|
||||
/** The launcher's own settings file could not be written. */
|
||||
'settings_write_failed',
|
||||
/** A folder the player chose does not exist or cannot be read (params: path). */
|
||||
'folder_unreadable',
|
||||
] as const;
|
||||
|
||||
export type AppErrorCode = (typeof APP_ERROR_CODES)[number];
|
||||
|
||||
@@ -8,6 +8,10 @@
|
||||
export const IPC_CHANNEL_PREFIXES = [
|
||||
/** The launcher itself: version, folders. */
|
||||
'app:',
|
||||
/** System dialogs (folder pickers). */
|
||||
'dialog:',
|
||||
/** Installing the offline version: looking at the chosen folders, copying, patching. */
|
||||
'install:',
|
||||
/** The launcher's own settings. */
|
||||
'settings:',
|
||||
] as const;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { z } from 'zod';
|
||||
import { FolderSizeSchema, GameFolderInspectionSchema, TargetFolderInspectionSchema } from '../schemas/install.ts';
|
||||
import { SettingsPatchSchema, SettingsSchema } from '../schemas/settings.ts';
|
||||
|
||||
/**
|
||||
@@ -19,6 +20,24 @@ export const ipcContract = {
|
||||
userDataPath: z.string(),
|
||||
}),
|
||||
},
|
||||
'dialog:pickFolder': {
|
||||
/** The dialog title, already translated by the window. */
|
||||
input: z.object({ title: z.string().optional() }),
|
||||
/** The chosen folder, or null when the player cancelled. */
|
||||
output: z.object({ path: z.string().nullable() }),
|
||||
},
|
||||
'install:inspectGameFolder': {
|
||||
input: z.object({ path: z.string().min(1) }),
|
||||
output: GameFolderInspectionSchema,
|
||||
},
|
||||
'install:inspectTargetFolder': {
|
||||
input: z.object({ path: z.string().min(1), stockPath: z.string().min(1) }),
|
||||
output: TargetFolderInspectionSchema,
|
||||
},
|
||||
'install:measureFolder': {
|
||||
input: z.object({ path: z.string().min(1) }),
|
||||
output: FolderSizeSchema,
|
||||
},
|
||||
'settings:get': {
|
||||
input: z.void(),
|
||||
output: SettingsSchema,
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
/** What the launcher found in a folder the player chose as their War Thunder installation. */
|
||||
export const GameFolderInspectionSchema = z.object({
|
||||
path: z.string(),
|
||||
/** Files a game folder must have that this one lacks; empty for a game folder. */
|
||||
missingFiles: z.array(z.string()),
|
||||
/** The file version of win64/aces.exe, or null when it has none or is missing. */
|
||||
version: z.string().nullable(),
|
||||
/** The versions every patch was verified on; a different version is pointed out, not refused. */
|
||||
verifiedVersions: z.array(z.string()),
|
||||
/** The folder lies in a Steam library: installing into it needs the player's confirmation. */
|
||||
inSteamLibrary: z.boolean(),
|
||||
});
|
||||
export type GameFolderInspection = z.output<typeof GameFolderInspectionSchema>;
|
||||
|
||||
/** Why a folder cannot hold the game copy. */
|
||||
export const TARGET_PROBLEMS = [
|
||||
/** The folder holds files already (a copy needs an empty or a new folder). */
|
||||
'not_empty',
|
||||
/** The folder is the stock installation, lies inside it, or contains it. */
|
||||
'overlaps_stock',
|
||||
/** The path names a file, not a folder. */
|
||||
'not_a_folder',
|
||||
] as const;
|
||||
|
||||
export const TargetFolderInspectionSchema = z.object({
|
||||
path: z.string(),
|
||||
problem: z.enum(TARGET_PROBLEMS).nullable(),
|
||||
inSteamLibrary: z.boolean(),
|
||||
/** Bytes free on the drive the folder is on; null when the drive cannot be read. */
|
||||
freeBytes: z.number().nullable(),
|
||||
/** Whether the folder is on the same drive as the stock installation. */
|
||||
sameDriveAsStock: z.boolean(),
|
||||
});
|
||||
export type TargetFolderInspection = z.output<typeof TargetFolderInspectionSchema>;
|
||||
|
||||
export const FolderSizeSchema = z.object({
|
||||
bytes: z.number(),
|
||||
files: z.number(),
|
||||
});
|
||||
export type FolderSize = z.output<typeof FolderSizeSchema>;
|
||||
Reference in new issue
Block a user