Show adaptation pack updates in the launcher
- IPC patches:active / check / apply / useBundled and the event patch-set-changed; installing or reverting is refused while a copy is being maintained, since a build reads the patch set as it runs. - Setting checkPatchPacksOnStart (on by default): the window checks once when it opens and stays quiet when the check fails. - The footer shows an available pack at the right end and leads to the About page, which shows the patch set in use, checks on request, and downloads and activates a pack only when the player clicks for it; a pack that needs a newer offline version, or a failed check, is explained there. Supported game versions follow the active set. - Chinese and English text.
This commit is contained in:
1 parent
6068d5bc65
commit
f4d2916f0d
13 files changed
+372
-44
No files matched your search
@@ -22,6 +22,8 @@ export const IPC_CHANNEL_PREFIXES = [
|
||||
'launch:',
|
||||
/** The launcher's own settings. */
|
||||
'settings:',
|
||||
/** Adaptation packs: the active patch set, update checks, installing a newer pack. */
|
||||
'patches:',
|
||||
/** The launcher window itself (it draws its own title bar). */
|
||||
'window:',
|
||||
] as const;
|
||||
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
} from '../schemas/install.ts';
|
||||
import { LabInfoSchema, LaunchStateSchema } from '../schemas/launch.ts';
|
||||
import { MaintenanceInfoSchema, MaintenanceProgressSchema, MaintenanceRequestSchema } from '../schemas/maintenance.ts';
|
||||
import { ActivePatchSetSchema, PackApplyResultSchema, PackCheckSchema } from '../schemas/patch-pack.ts';
|
||||
import { ResearchBranchSchema, ResearchOperationSchema, SaveResearchSchema, OfficialImportOptionsSchema, OfficialPreviewSchema, SaveOfficialRequestSchema, CurrencyEditsSchema, SaveBackupNameSchema, SaveBackupSchema, SaveDetailsSchema, SaveKeysSchema, SaveListSchema, SaveRegistrationSchema, SaveTransferSchema } from '../schemas/saves.ts';
|
||||
import { TuningPatchSchema, TuningViewSchema } from '../schemas/tuning.ts';
|
||||
import { SettingsPatchSchema, SettingsSchema } from '../schemas/settings.ts';
|
||||
@@ -233,6 +234,26 @@ export const ipcContract = {
|
||||
input: SettingsPatchSchema,
|
||||
output: SettingsSchema,
|
||||
},
|
||||
'patches:active': {
|
||||
/** The patch set builds use: the bundled one or a downloaded adaptation pack. */
|
||||
input: z.void(),
|
||||
output: ActivePatchSetSchema,
|
||||
},
|
||||
'patches:check': {
|
||||
/** Asks GitHub for the newest adaptation pack. */
|
||||
input: z.void(),
|
||||
output: PackCheckSchema,
|
||||
},
|
||||
'patches:apply': {
|
||||
/** Downloads, verifies and activates the newest pack; the window asks the player first. */
|
||||
input: z.void(),
|
||||
output: PackApplyResultSchema,
|
||||
},
|
||||
'patches:useBundled': {
|
||||
/** Stops using downloaded packs. */
|
||||
input: z.void(),
|
||||
output: ActivePatchSetSchema,
|
||||
},
|
||||
'window:minimize': {
|
||||
input: z.void(),
|
||||
output: z.void(),
|
||||
@@ -249,6 +270,8 @@ export const ipcEvents = {
|
||||
'event:launch-state': LaunchStateSchema,
|
||||
'event:copies-changed': CopiesSchema,
|
||||
'event:copy-maintenance': MaintenanceProgressSchema,
|
||||
/** Another patch set became active (a pack was installed, or the bundled set restored). */
|
||||
'event:patch-set-changed': ActivePatchSetSchema,
|
||||
} as const;
|
||||
|
||||
export type IpcChannel = keyof typeof ipcContract;
|
||||
|
||||
@@ -1,56 +1,69 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
/**
|
||||
* What the launcher reports about adaptation packs (main/services/patch-pack/): which patch set
|
||||
* the builds use, and whether a newer pack is released.
|
||||
*/
|
||||
|
||||
/** The patch set that ships with the launcher, or a downloaded adaptation pack. */
|
||||
export type PatchSetSource = 'bundled' | 'downloaded';
|
||||
export const PatchSetSourceSchema = z.enum(['bundled', 'downloaded']);
|
||||
|
||||
export interface ActivePatchSet {
|
||||
readonly source: PatchSetSource;
|
||||
export const ActivePatchSetSchema = z.object({
|
||||
source: PatchSetSourceSchema,
|
||||
/** Pack version; null for a bundled set without one (a repository checkout). */
|
||||
readonly version: string | null;
|
||||
version: z.string().nullable(),
|
||||
/** Game versions with a version record in the set. */
|
||||
readonly gameVersions: readonly string[];
|
||||
}
|
||||
gameVersions: z.array(z.string()),
|
||||
});
|
||||
|
||||
export interface PackRelease {
|
||||
readonly version: string;
|
||||
readonly gameVersions: readonly string[];
|
||||
readonly minAppVersion: string;
|
||||
readonly publishedAt: string | null;
|
||||
}
|
||||
export const PackReleaseSchema = z.object({
|
||||
version: z.string(),
|
||||
gameVersions: z.array(z.string()),
|
||||
minAppVersion: z.string(),
|
||||
publishedAt: z.string().nullable(),
|
||||
});
|
||||
|
||||
export type PackCheckStatus =
|
||||
export const PackCheckStatusSchema = z.enum([
|
||||
/** No release is newer than the active set. */
|
||||
| 'up_to_date'
|
||||
'up_to_date',
|
||||
/** A newer pack this launcher can use. */
|
||||
| 'available'
|
||||
'available',
|
||||
/** A newer pack needs a newer offline version (launcher) first. */
|
||||
| 'needs_app_update'
|
||||
'needs_app_update',
|
||||
/** The check could not be made; see `problem`. */
|
||||
| 'failed';
|
||||
'failed',
|
||||
]);
|
||||
|
||||
export type PackProblem =
|
||||
export const PackProblemSchema = z.enum([
|
||||
/** This build of the launcher carries no signing key, so it accepts no pack. */
|
||||
| 'no_signing_key'
|
||||
'no_signing_key',
|
||||
/** GitHub could not be reached or answered with an error. */
|
||||
| 'network'
|
||||
'network',
|
||||
/** The release or the pack is malformed. */
|
||||
| 'contents'
|
||||
'contents',
|
||||
/** The signature does not match. */
|
||||
| 'signature'
|
||||
'signature',
|
||||
/** The pack is larger than allowed. */
|
||||
| 'size';
|
||||
'size',
|
||||
]);
|
||||
|
||||
export interface PackCheck {
|
||||
readonly status: PackCheckStatus;
|
||||
readonly active: ActivePatchSet;
|
||||
export const PackCheckSchema = z.object({
|
||||
status: PackCheckStatusSchema,
|
||||
active: ActivePatchSetSchema,
|
||||
/** The newest released pack; null when none is released or the check failed. */
|
||||
readonly latest: PackRelease | null;
|
||||
readonly problem: PackProblem | null;
|
||||
}
|
||||
latest: PackReleaseSchema.nullable(),
|
||||
problem: PackProblemSchema.nullable(),
|
||||
});
|
||||
|
||||
export type PackApplyResult =
|
||||
| { readonly ok: true; readonly active: ActivePatchSet }
|
||||
| { readonly ok: false; readonly problem: PackProblem | 'needs_app_update' | 'up_to_date' };
|
||||
export const PackApplyResultSchema = z.discriminatedUnion('ok', [
|
||||
z.object({ ok: z.literal(true), active: ActivePatchSetSchema }),
|
||||
z.object({ ok: z.literal(false), problem: z.union([PackProblemSchema, z.enum(['needs_app_update', 'up_to_date'])]) }),
|
||||
]);
|
||||
|
||||
export type PatchSetSource = z.output<typeof PatchSetSourceSchema>;
|
||||
export type ActivePatchSet = z.output<typeof ActivePatchSetSchema>;
|
||||
export type PackRelease = z.output<typeof PackReleaseSchema>;
|
||||
export type PackCheckStatus = z.output<typeof PackCheckStatusSchema>;
|
||||
export type PackProblem = z.output<typeof PackProblemSchema>;
|
||||
export type PackCheck = z.output<typeof PackCheckSchema>;
|
||||
export type PackApplyResult = z.output<typeof PackApplyResultSchema>;
|
||||
@@ -14,6 +14,8 @@ export const SettingsSchema = z.object({
|
||||
background: BackgroundChoiceSchema.default(BACKGROUND_RANDOM),
|
||||
/** Fetch wallpapers from the game website's public gallery. */
|
||||
officialWallpapers: z.boolean().default(true),
|
||||
/** Ask GitHub for a newer adaptation pack when the launcher starts. */
|
||||
checkPatchPacksOnStart: z.boolean().default(true),
|
||||
windowClose: WindowCloseSchema.default('quit'),
|
||||
afterGameStarts: AfterGameStartsSchema.default('minimize'),
|
||||
autoSaveBackups: z.boolean().default(true),
|
||||
@@ -29,6 +31,7 @@ export const SettingsPatchSchema = z.object({
|
||||
language: LanguageChoiceSchema.optional(),
|
||||
background: BackgroundChoiceSchema.optional(),
|
||||
officialWallpapers: z.boolean().optional(),
|
||||
checkPatchPacksOnStart: z.boolean().optional(),
|
||||
windowClose: WindowCloseSchema.optional(),
|
||||
afterGameStarts: AfterGameStartsSchema.optional(),
|
||||
autoSaveBackups: z.boolean().optional(),
|
||||
|
||||
Reference in new issue
Block a user