feat(launcher): show official gallery and local game wallpapers

The window background now comes from two sources, served to the window
over a wto-art:// scheme from the launcher's cache:

- Website wallpapers: the newest entries of the public wallpaper gallery
  on warthunder.com (two pages), list refreshed at most daily, each
  1920x1080 picture downloaded when first shown and kept in the cache.
  No cookies, no sign-in; a setting turns it off. Without a connection
  the pictures downloaded before stay available.
- Game pictures: the nation pictures the game's own launcher keeps in
  launcherr.dat next to the game, extracted from the installed copy
  (fflate) once per archive version.

Without either, the window keeps its drawn background. The settings
choose a random picture per start or a fixed one (thumbnail grid); the
home page shows the picture's name with previous / next.

Checked: launcher typecheck, electron-vite build. Ran the window from a
scratch user data folder with a fake copy holding a copy of the real
launcherr.dat: 18 website wallpapers and 9 game pictures listed, both
sizes and the game pictures load through wto-art://, an unknown picture
is refused, stepping saves the choice, turning wallpapers off leaves
the game pictures, no console errors.
This commit is contained in:
N0VAN0M4LY committed 2026-11-29 07:45:26 +08:00
1 parent 81c900a61d
commit d82f9856f6
21 files changed
+693 -8

No files matched your search

+6
View File
@@ -1,4 +1,5 @@
import { z } from 'zod';
import { BackgroundPictureSchema } from '../schemas/background.ts';
import {
FolderSizeSchema,
GameFolderInspectionSchema,
@@ -31,6 +32,11 @@ export const ipcContract = {
supportedGameVersions: z.array(z.string()),
}),
},
'app:listBackgrounds': {
/** The website's wallpapers (when allowed in the settings) and the installed copy's pictures. */
input: z.void(),
output: z.array(BackgroundPictureSchema),
},
'app:openFolder': {
/** Opens a folder in the file manager; refused unless it exists. */
input: z.object({ path: z.string().min(1) }),
@@ -0,0 +1,18 @@
import { z } from 'zod';
/**
* A background picture the window may show. `key` is what the settings store for a fixed choice:
* `official:<gallery id>` for a website wallpaper, `game:<name>` for a picture of the game copy.
*/
export const BackgroundPictureSchema = z.object({
key: z.string(),
source: z.enum(['official', 'game']),
/** The nation for game pictures (translated by the window), the picture name for wallpapers. */
label: z.string(),
url: z.string(),
thumbnailUrl: z.string(),
});
export type BackgroundPicture = z.output<typeof BackgroundPictureSchema>;
export const BACKGROUND_RANDOM = 'random';
export const BackgroundChoiceSchema = z.string().regex(/^(random|game:[a-z]+|official:[0-9a-f]{24})$/);
@@ -1,11 +1,16 @@
import { z } from 'zod';
import { LANGUAGE_CHOICES } from '../languages.ts';
import { BACKGROUND_RANDOM, BackgroundChoiceSchema } from './background.ts';
const LanguageChoiceSchema = z.enum(LANGUAGE_CHOICES);
/** The launcher's own settings (not the game's, not the local service's tuning). */
export const SettingsSchema = z.object({
language: LanguageChoiceSchema.default('system'),
/** A new picture on every start, or one picture by its key (schemas/background.ts). */
background: BackgroundChoiceSchema.default(BACKGROUND_RANDOM),
/** Fetch wallpapers from the game website's public gallery. */
officialWallpapers: z.boolean().default(true),
});
export type Settings = z.output<typeof SettingsSchema>;
@@ -13,6 +18,8 @@ export type Settings = z.output<typeof SettingsSchema>;
/** A change to some settings; the merged result is validated again before it is saved. */
export const SettingsPatchSchema = z.object({
language: LanguageChoiceSchema.optional(),
background: BackgroundChoiceSchema.optional(),
officialWallpapers: z.boolean().optional(),
});
export type SettingsPatch = z.output<typeof SettingsPatchSchema>;