From 81c900a61d7a453c9e07db2a5aedde09f374c474 Mon Sep 17 00:00:00 2001 From: N0VAN0M4LY <224130499+N0VAN0M4LY@users.noreply.github.com> Date: Sun, 29 Nov 2026 07:39:12 +0800 Subject: [PATCH] feat(launcher): redesign the main launcher window The window is now a fixed 1120x720 frameless window with its own title bar: page navigation, language, minimize and close. The layout follows the game's launcher: a side panel, the main area over the background, and a bottom bar with the state of the current task and the primary action. The colours and type follow the game's website: dark blue-grey, red actions, Roboto Condensed (bundled, OFL), cyan progress. - Pages: home (requirements before installation, the current copy after), copies (copy details with folders to open, feature status grouped by inventory section), settings (language), about. - The install wizard is a hook shared by the side panel (step list), the main area (current step) and the bottom bar (back, next, install, cancel, copy progress). - The adaptation shown for a game version is the version itself when the patches were verified on it, otherwise the nearest verified one. - Both language packs are rewritten in consistent product wording. - New IPC: app:openFolder, install:listFeatures (patcher's new patchFeatures), window:minimize, window:close; app:getInfo reports the supported game versions. Launching is not built yet; its button stays disabled. Checked: launcher typecheck (main and renderer), electron-vite build, root typecheck. Ran the window from a scratch user data folder over the remote debugging port: every page and section in Chinese and English, empty and installed state, the wizard's first step, both new IPC calls, no console errors and no overflow. --- apps/launcher/package.json | 1 + apps/launcher/src/main/ipc/handlers.ts | 36 +- .../launcher/src/main/services/main-window.ts | 24 +- apps/launcher/src/renderer/src/App.tsx | 128 +++- .../renderer/src/components/LanguageMenu.tsx | 29 - .../src/renderer/src/components/Notice.tsx | 15 +- .../renderer/src/components/ProgressBar.tsx | 19 +- .../src/renderer/src/components/Row.tsx | 20 + .../src/renderer/src/components/Sheet.tsx | 24 + .../src/renderer/src/i18n/locales/en.json | 298 +++++++--- .../src/renderer/src/i18n/locales/zh-CN.json | 276 ++++++--- apps/launcher/src/renderer/src/main.tsx | 10 +- .../src/renderer/src/pages/InstallSummary.tsx | 31 - .../src/renderer/src/pages/WelcomePage.tsx | 31 - .../renderer/src/pages/about/AboutPage.tsx | 21 + .../renderer/src/pages/copies/CopySummary.tsx | 55 ++ .../src/pages/copies/FeatureStatus.tsx | 76 +++ .../src/pages/copies/missing-features.ts | 6 + .../src/renderer/src/pages/home/HomeMain.tsx | 27 + .../src/renderer/src/pages/home/HomeSide.tsx | 73 +++ .../src/renderer/src/pages/home/home-bar.ts | 26 + .../renderer/src/pages/install/CheckStep.tsx | 50 +- .../renderer/src/pages/install/DataStep.tsx | 9 +- .../renderer/src/pages/install/MethodStep.tsx | 72 ++- .../src/pages/install/ProgressStep.tsx | 46 +- .../renderer/src/pages/install/SourceStep.tsx | 47 +- .../renderer/src/pages/install/WizardMain.tsx | 28 + .../renderer/src/pages/install/WizardSide.tsx | 21 + ...{InstallWizard.tsx => useInstallWizard.ts} | 123 ++-- .../renderer/src/pages/install/wizard-bar.ts | 49 ++ .../src/pages/settings/GeneralSettings.tsx | 17 + .../src/renderer/src/shell/Background.tsx | 14 + .../src/renderer/src/shell/BottomBar.tsx | 37 ++ .../src/renderer/src/shell/Footer.tsx | 21 + .../src/renderer/src/shell/LanguageMenu.tsx | 39 ++ .../src/renderer/src/shell/SubNav.tsx | 21 + .../src/renderer/src/shell/TitleBar.tsx | 49 ++ .../src/renderer/src/shell/bar-model.ts | 31 + .../src/renderer/src/shell/navigation.ts | 38 ++ apps/launcher/src/renderer/src/styles/app.css | 307 ---------- .../src/renderer/src/styles/controls.css | 432 ++++++++++++++ .../src/renderer/src/styles/pages.css | 151 +++++ .../src/renderer/src/styles/shell.css | 552 ++++++++++++++++++ .../src/renderer/src/styles/tokens.css | 96 +++ apps/launcher/src/renderer/src/versions.ts | 31 + apps/launcher/src/shared/ipc/channels.ts | 2 + apps/launcher/src/shared/ipc/contract.ts | 21 + apps/launcher/src/shared/schemas/install.ts | 10 + package-lock.json | 10 + packages/patcher/src/index.ts | 1 + packages/patcher/src/patch-features.ts | 30 + 51 files changed, 2810 insertions(+), 771 deletions(-) delete mode 100644 apps/launcher/src/renderer/src/components/LanguageMenu.tsx create mode 100644 apps/launcher/src/renderer/src/components/Row.tsx create mode 100644 apps/launcher/src/renderer/src/components/Sheet.tsx delete mode 100644 apps/launcher/src/renderer/src/pages/InstallSummary.tsx delete mode 100644 apps/launcher/src/renderer/src/pages/WelcomePage.tsx create mode 100644 apps/launcher/src/renderer/src/pages/about/AboutPage.tsx create mode 100644 apps/launcher/src/renderer/src/pages/copies/CopySummary.tsx create mode 100644 apps/launcher/src/renderer/src/pages/copies/FeatureStatus.tsx create mode 100644 apps/launcher/src/renderer/src/pages/copies/missing-features.ts create mode 100644 apps/launcher/src/renderer/src/pages/home/HomeMain.tsx create mode 100644 apps/launcher/src/renderer/src/pages/home/HomeSide.tsx create mode 100644 apps/launcher/src/renderer/src/pages/home/home-bar.ts create mode 100644 apps/launcher/src/renderer/src/pages/install/WizardMain.tsx create mode 100644 apps/launcher/src/renderer/src/pages/install/WizardSide.tsx rename apps/launcher/src/renderer/src/pages/install/{InstallWizard.tsx => useInstallWizard.ts} (52%) create mode 100644 apps/launcher/src/renderer/src/pages/install/wizard-bar.ts create mode 100644 apps/launcher/src/renderer/src/pages/settings/GeneralSettings.tsx create mode 100644 apps/launcher/src/renderer/src/shell/Background.tsx create mode 100644 apps/launcher/src/renderer/src/shell/BottomBar.tsx create mode 100644 apps/launcher/src/renderer/src/shell/Footer.tsx create mode 100644 apps/launcher/src/renderer/src/shell/LanguageMenu.tsx create mode 100644 apps/launcher/src/renderer/src/shell/SubNav.tsx create mode 100644 apps/launcher/src/renderer/src/shell/TitleBar.tsx create mode 100644 apps/launcher/src/renderer/src/shell/bar-model.ts create mode 100644 apps/launcher/src/renderer/src/shell/navigation.ts delete mode 100644 apps/launcher/src/renderer/src/styles/app.css create mode 100644 apps/launcher/src/renderer/src/styles/controls.css create mode 100644 apps/launcher/src/renderer/src/styles/pages.css create mode 100644 apps/launcher/src/renderer/src/styles/shell.css create mode 100644 apps/launcher/src/renderer/src/styles/tokens.css create mode 100644 apps/launcher/src/renderer/src/versions.ts create mode 100644 packages/patcher/src/patch-features.ts diff --git a/apps/launcher/package.json b/apps/launcher/package.json index 6c72090..c2d03db 100644 --- a/apps/launcher/package.json +++ b/apps/launcher/package.json @@ -12,6 +12,7 @@ "typecheck": "tsc --noEmit -p tsconfig.node.json && tsc --noEmit -p tsconfig.web.json" }, "dependencies": { + "@fontsource/roboto-condensed": "^5.3.0", "@wto/patcher": "*", "@wto/server": "*", "i18next": "^26.3.6", diff --git a/apps/launcher/src/main/ipc/handlers.ts b/apps/launcher/src/main/ipc/handlers.ts index 39c9bbd..0c642b1 100644 --- a/apps/launcher/src/main/ipc/handlers.ts +++ b/apps/launcher/src/main/ipc/handlers.ts @@ -1,4 +1,5 @@ -import { app, BrowserWindow, dialog } from 'electron'; +import { app, BrowserWindow, dialog, shell } from 'electron'; +import { patchFeatures, verifiedGameVersions } from '@wto/patcher'; import { AppError } from '@shared/errors.ts'; import { getSettings, updateSettings } from '../services/config/settings-store.ts'; import { measureFolder } from '../services/game-folder/folder-size.ts'; @@ -6,16 +7,33 @@ import { inspectGameFolder, requireFolder } from '../services/game-folder/inspec 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 { resourcePaths } from '../services/resources/resource-paths.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('app:getInfo', () => { + const resources = resourcePaths(); + return { + version: app.getVersion(), + electron: process.versions.electron, + systemLocale: app.getLocale(), + userDataPath: app.getPath('userData'), + supportedGameVersions: verifiedGameVersions(resources.exePatches, resources.guiPatches), + }; + }); + handle('app:openFolder', async ({ path }) => { + await requireFolder(path); + const failure = await shell.openPath(path); + if (failure) console.warn('[app] opening the folder failed:', path, failure); + }); + + handle('window:minimize', (_input, sender) => { + BrowserWindow.fromWebContents(sender)?.minimize(); + }); + handle('window:close', (_input, sender) => { + BrowserWindow.fromWebContents(sender)?.close(); + }); handle('dialog:pickFolder', async ({ title }, sender) => { const window = BrowserWindow.fromWebContents(sender); @@ -40,6 +58,10 @@ export function registerIpcHandlers(): void { handle('install:start', (request) => installGame(request, (progress) => broadcast('event:install-progress', progress))); handle('install:cancel', () => ({ cancelled: cancelInstall() })); handle('install:getRecord', async () => ({ record: await readInstallRecord(), defaultDataPath: defaultDataPath() })); + handle('install:listFeatures', () => { + const resources = resourcePaths(); + return patchFeatures(resources.exePatches, resources.guiPatches).map((feature) => ({ ...feature, patchIds: [...feature.patchIds] })); + }); handle('settings:get', () => getSettings()); handle('settings:update', async (patch) => { diff --git a/apps/launcher/src/main/services/main-window.ts b/apps/launcher/src/main/services/main-window.ts index 99fbae8..efa3588 100644 --- a/apps/launcher/src/main/services/main-window.ts +++ b/apps/launcher/src/main/services/main-window.ts @@ -1,18 +1,30 @@ import { join } from 'node:path'; import { BrowserWindow, shell } from 'electron'; -/** The launcher's single window. */ +/** + * The launcher's single window: a fixed size without the system frame, like the game's own + * launcher. The window draws its title bar and asks for minimize and close over IPC. + */ + +/** The layout is drawn for exactly this content size. */ +const CONTENT_WIDTH = 1120; +const CONTENT_HEIGHT = 720; +/** The window background before the page paints (--bg in the window's styles). */ +const BACKGROUND = '#13191b'; let mainWindow: BrowserWindow | null = null; export function createMainWindow(): BrowserWindow { const window = new BrowserWindow({ - width: 960, - height: 640, - minWidth: 720, - minHeight: 480, + width: CONTENT_WIDTH, + height: CONTENT_HEIGHT, + useContentSize: true, + resizable: false, + maximizable: false, + fullscreenable: false, + frame: false, + backgroundColor: BACKGROUND, show: false, - autoHideMenuBar: true, webPreferences: { preload: join(import.meta.dirname, '../preload/index.cjs'), sandbox: true, diff --git a/apps/launcher/src/renderer/src/App.tsx b/apps/launcher/src/renderer/src/App.tsx index 3cec809..ca9178b 100644 --- a/apps/launcher/src/renderer/src/App.tsx +++ b/apps/launcher/src/renderer/src/App.tsx @@ -1,46 +1,128 @@ -import { useEffect, useState } from 'react'; +import { useEffect, useState, type ReactNode } from 'react'; import { useTranslation } from 'react-i18next'; +import type { IpcOutput } from '@shared/ipc/contract.ts'; import type { InstallRecord } from '@shared/schemas/install.ts'; import type { Settings } from '@shared/schemas/settings.ts'; -import { LanguageMenu } from './components/LanguageMenu.tsx'; +import { Sheet } from './components/Sheet.tsx'; import { applyLanguage, resolveLanguage } from './i18n/index.ts'; import { ipcOn } from './ipc.ts'; -import { InstallWizard } from './pages/install/InstallWizard.tsx'; -import { WelcomePage } from './pages/WelcomePage.tsx'; +import { AboutPage } from './pages/about/AboutPage.tsx'; +import { CopySummary } from './pages/copies/CopySummary.tsx'; +import { FeatureStatus } from './pages/copies/FeatureStatus.tsx'; +import { HomeMain } from './pages/home/HomeMain.tsx'; +import { HomeSide } from './pages/home/HomeSide.tsx'; +import { homeBar } from './pages/home/home-bar.ts'; +import { useInstallWizard } from './pages/install/useInstallWizard.ts'; +import { WizardMain } from './pages/install/WizardMain.tsx'; +import { WizardSide } from './pages/install/WizardSide.tsx'; +import { wizardBar } from './pages/install/wizard-bar.ts'; +import { GeneralSettings } from './pages/settings/GeneralSettings.tsx'; +import { Background } from './shell/Background.tsx'; +import { BottomBar } from './shell/BottomBar.tsx'; +import type { BarModel } from './shell/bar-model.ts'; +import { Footer } from './shell/Footer.tsx'; +import { COPY_SECTIONS, navigate, SETTINGS_SECTIONS, START_ROUTE, type Destination, type Route } from './shell/navigation.ts'; +import { SubNav } from './shell/SubNav.tsx'; +import { TitleBar } from './shell/TitleBar.tsx'; +import { useErrorMessage } from './useErrorMessage.ts'; interface AppProps { + readonly info: IpcOutput<'app:getInfo'>; readonly initialSettings: Settings; - readonly systemLocale: string; readonly initialRecord: InstallRecord | null; readonly defaultDataPath: string; } -export function App({ initialSettings, systemLocale, initialRecord, defaultDataPath }: AppProps) { +interface View { + readonly side: ReactNode; + readonly main: ReactNode; + readonly bar: BarModel; +} + +/** + * The window: title bar, side panel, main area, bottom bar, footer. Each page fills the side + * panel and the main area; the bottom bar belongs to the current task (the install wizard while + * it runs, otherwise install / launch). + */ +export function App({ info, initialSettings, initialRecord, defaultDataPath }: AppProps) { const { t } = useTranslation(); + const { message, report } = useErrorMessage(); const [settings, setSettings] = useState(initialSettings); const [record, setRecord] = useState(initialRecord); - const [installing, setInstalling] = useState(false); + const [route, setRoute] = useState(START_ROUTE); + const supported = info.supportedGameVersions; + + const wizard = useInstallWizard({ + defaultDataPath: record?.dataPath ?? defaultDataPath, + onInstalled: (installed) => { + setRecord(installed); + setRoute(START_ROUTE); + }, + }); useEffect(() => ipcOn('event:settings-changed', setSettings), []); - useEffect(() => applyLanguage(resolveLanguage(settings.language, systemLocale)), [settings.language, systemLocale]); + useEffect(() => applyLanguage(resolveLanguage(settings.language, info.systemLocale)), [settings.language, info.systemLocale]); + const go = (to: Destination): void => setRoute((current) => navigate(current, to)); + const home = homeBar(record, t, wizard.start); + + const view = ((): View => { + if (wizard.active) { + return { side: , main: , bar: wizardBar(wizard, t) }; + } + const homeSide = ; + switch (route.page) { + case 'home': + return { side: homeSide, main: , bar: home }; + case 'about': + return { side: homeSide, main: , bar: home }; + case 'settings': + return { + side: t(`settings.sections.${section}`)} onSelect={(section) => go({ page: 'settings', section })} />, + main: , + bar: home, + }; + case 'copies': { + const side = ( + <> + t(`copies.sections.${section}`)} onSelect={(section) => go({ page: 'copies', section })} /> +
+ +
+ + ); + if (!record) { + return { + side, + main: ( + +

{t('copies.none')}

+ +
+ ), + bar: home, + }; + } + const main = route.copies === 'features' + ? + : go({ page: 'copies', section: 'features' })} onReinstall={wizard.start} onError={report} />; + return { side, main, bar: home }; + } + } + })(); + + const paged = wizard.active || route.page !== 'home'; return ( -
-
-

{t('app.title')}

- -
-
- {installing ? ( - { setRecord(installed); setInstalling(false); }} - onClose={() => setInstalling(false)} - /> - ) : ( - setInstalling(true)} /> - )} +
+ + go({ page })} onError={report} /> + +
+ {view.main} + {message &&

{message}

}
+ +
); } diff --git a/apps/launcher/src/renderer/src/components/LanguageMenu.tsx b/apps/launcher/src/renderer/src/components/LanguageMenu.tsx deleted file mode 100644 index 32aeabd..0000000 --- a/apps/launcher/src/renderer/src/components/LanguageMenu.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import { useTranslation } from 'react-i18next'; -import { LANGUAGE_CHOICES, type LanguageChoice } from '@shared/languages.ts'; -import { ipcInvoke } from '../ipc.ts'; -import { useErrorMessage } from '../useErrorMessage.ts'; - -export function LanguageMenu({ value }: { readonly value: LanguageChoice }) { - const { t } = useTranslation(); - const { message, report } = useErrorMessage(); - - return ( - - ); -} diff --git a/apps/launcher/src/renderer/src/components/Notice.tsx b/apps/launcher/src/renderer/src/components/Notice.tsx index f2049e2..ce26f43 100644 --- a/apps/launcher/src/renderer/src/components/Notice.tsx +++ b/apps/launcher/src/renderer/src/components/Notice.tsx @@ -1,6 +1,15 @@ import type { ReactNode } from 'react'; -/** A boxed message: information, a warning the player can go past, or a problem that stops them. */ -export function Notice({ tone, children }: { readonly tone: 'info' | 'warning' | 'error'; readonly children: ReactNode }) { - return
{children}
; +type Tone = 'info' | 'warning' | 'error'; + +const ICONS: Record = { info: '✓', warning: '⚠', error: '✕' }; + +/** A boxed message: a result, a warning the player can go past, or a problem that stops them. */ +export function Notice({ tone, children }: { readonly tone: Tone; readonly children: ReactNode }) { + return ( +
+ +
{children}
+
+ ); } diff --git a/apps/launcher/src/renderer/src/components/ProgressBar.tsx b/apps/launcher/src/renderer/src/components/ProgressBar.tsx index 43a5bda..1fe5497 100644 --- a/apps/launcher/src/renderer/src/components/ProgressBar.tsx +++ b/apps/launcher/src/renderer/src/components/ProgressBar.tsx @@ -1,8 +1,21 @@ -/** A bar filled to `value` of `max`; without a max it shows that work is going on. */ -export function ProgressBar({ value, max }: { readonly value: number; readonly max: number | null }) { +interface ProgressBarProps { + readonly value: number; + /** Without a max the bar shows that work is going on. */ + readonly max: number | null; + readonly large?: boolean; +} + +/** A thin bar filled to `value` of `max`. */ +export function ProgressBar({ value, max, large = false }: ProgressBarProps) { const fraction = max ? Math.min(1, value / max) : null; return ( -
+
); diff --git a/apps/launcher/src/renderer/src/components/Row.tsx b/apps/launcher/src/renderer/src/components/Row.tsx new file mode 100644 index 0000000..8276aa2 --- /dev/null +++ b/apps/launcher/src/renderer/src/components/Row.tsx @@ -0,0 +1,20 @@ +import type { ReactNode } from 'react'; + +interface RowProps { + readonly label: ReactNode; + readonly hint?: ReactNode; + readonly children: ReactNode; +} + +/** A label with an optional hint on the left, its value or controls on the right. */ +export function Row({ label, hint, children }: RowProps) { + return ( +
+
+ {label} + {hint !== undefined && {hint}} +
+
{children}
+
+ ); +} diff --git a/apps/launcher/src/renderer/src/components/Sheet.tsx b/apps/launcher/src/renderer/src/components/Sheet.tsx new file mode 100644 index 0000000..405f512 --- /dev/null +++ b/apps/launcher/src/renderer/src/components/Sheet.tsx @@ -0,0 +1,24 @@ +import type { ReactNode } from 'react'; + +interface SheetProps { + readonly title: string; + /** Short context at the right of the heading. */ + readonly aside?: ReactNode; + /** Actions and notes under the content. */ + readonly foot?: ReactNode; + readonly children: ReactNode; +} + +/** A page's content panel over the dimmed background art. */ +export function Sheet({ title, aside, foot, children }: SheetProps) { + return ( +
+
+

{title}

+ {aside !== undefined && {aside}} +
+
{children}
+ {foot !== undefined &&
{foot}
} +
+ ); +} diff --git a/apps/launcher/src/renderer/src/i18n/locales/en.json b/apps/launcher/src/renderer/src/i18n/locales/en.json index f93893f..075b206 100644 --- a/apps/launcher/src/renderer/src/i18n/locales/en.json +++ b/apps/launcher/src/renderer/src/i18n/locales/en.json @@ -1,158 +1,272 @@ { "app": { - "title": "War Thunder Offline" + "title": "War Thunder Offline", + "subtitle": "War Thunder offline edition" + }, + "nav": { + "home": "Home", + "copies": "Copies", + "settings": "Settings", + "about": "About" + }, + "window": { + "minimize": "Minimize", + "close": "Close" }, "language": { "label": "Language", - "system": "System", + "system": "System default", "zh-CN": "简体中文", "en": "English" }, - "welcome": { - "title": "Not installed yet", - "body": "Install the offline version from your own War Thunder. By default it works on a copy; your original game is only read, never changed.", - "install": "Install" + "footer": { + "launcher": "Launcher {{version}}", + "game": "Game {{version}}", + "notInstalled": "Not installed", + "disclaimer": "Unofficial fan project, not affiliated with Gaijin Entertainment" }, - "installed": { - "title": "The offline version is installed", - "launchLater": "Starting the game comes in the next version.", - "reinstall": "Install again" + "home": { + "kicker": "Offline edition · Local server", + "installedKicker": "Game {{version}}", + "body": "Play complete battles against AI without a network connection or an account. Hangar, research, store and battle results are provided by the local server.", + "steps": { + "choose": "1 · Select game", + "chooseBody": "Locate your War Thunder installation", + "copy": "2 · Create copy", + "copyBody": "Copy the game files; the original stays unchanged", + "launch": "3 · Launch", + "launchBody": "Start the game from the launcher from then on" + } }, - "summary": { - "copy": "Game copy", - "data": "Data folder", - "version": "Game version", - "method": "Installed", - "methods": { - "copy": "as a copy in a new folder", - "in-place": "in the original folder" - }, - "missing": "These features do not work with your game version:" + "side": { + "requirements": "Requirements", + "game": "Game", + "gameValue": "War Thunder (official client)", + "versions": "Versions", + "space": "Disk space", + "spaceValue": "About 97 GB (copy installation)", + "about": "About the offline edition", + "aboutBody": "The local server provides profiles, hangar, store, battles and results on this computer. No network connection and no account are used. Installation only reads the original game files and changes nothing.", + "statement": "Statement and terms", + "currentCopy": "Current copy", + "copyName": "Game copy", + "adaptation": "Adaptation", + "features": "Features", + "allAvailable": "✓ All available", + "someMissing": "⚠ {{count}} unavailable", + "details": "Details", + "disclaimer": "Unofficial fan project, not affiliated with Gaijin Entertainment." + }, + "adaptation": { + "verified": "✓ Verified", + "nearest": "⚠ Nearest version" + }, + "bar": { + "notInstalled": "Not installed", + "notInstalledDetail": "Requires an installed copy of War Thunder", + "install": "Install", + "ready": "Ready", + "readyMissing": "Ready · {{count}} features unavailable", + "readyDetail": "Game {{version}} · Launching will be available in a later version", + "launch": "Launch" }, "folder": { - "none": "Not chosen", - "choose": "Choose folder", - "change": "Change" + "none": "Not selected", + "choose": "Browse…", + "change": "Change…" }, "wizard": { + "title": "Install the offline edition", + "note": "Installation does not modify the original game. Patched files are not written during installation; they are generated each time the game is launched.", "steps": { - "source": "Game", - "method": "Method", - "data": "Data", - "check": "Check", + "source": "Game location", + "method": "Installation type", + "data": "Data folder", + "check": "Patch check", "installing": "Install" }, + "barTitle": "Install · {{step}}", + "stepOf": "Step {{index}} of {{total}}", "back": "Back", "next": "Next", "cancel": "Cancel", - "install": "Install" + "install": "Install", + "installing": "Installing", + "checking": "Checking patches", + "checkingDetail": "Checking which patches apply to the selected game" }, "source": { - "title": "Choose your War Thunder folder", - "body": "The one holding aces.vromfs.bin and the win64 folder, such as the War Thunder folder in Steam.", - "notAGame": "This is not a War Thunder folder. Missing: {{files}}", - "versionVerified": "Game version {{version}}. The offline version is made for it.", - "versionUnverified": "Game version {{version}}. The offline version is made for {{verified}}, so some features may not work. The next steps check which.", - "versionUnknown": "unknown" + "body": "Select the War Thunder installation folder (the one containing aces.vromfs.bin and the win64 folder).", + "dialogTitle": "Select the War Thunder installation folder", + "notAGame": "The selected folder is not a War Thunder installation. Missing: {{files}}", + "versionVerified": "Game version {{version}} · Adaptation {{version}} (verified)", + "versionUnverified": "No adaptation exists for game version {{version}}; the nearest version, {{nearest}}, will be used. Some features may be unavailable; step 4 lists the results.", + "versionUnknown": "unknown", + "size": "Size {{size}} · {{files}} files", + "measuring": "Calculating size…", + "readOnly": "Installation only reads this folder and changes nothing in it." }, "method": { - "title": "How to install", - "copy": "Copy into a new folder (recommended)", - "copyBody": "The whole game is copied and the offline version goes into the copy. Your original stays as it is. Needs about {{size}}.", - "measuring": "(measuring)", - "targetTitle": "Choose a folder for the game copy", - "inPlace": "Install into this folder", - "inPlaceBody": "For a copy of the game you prepared yourself. Four files in {{path}} are replaced; the originals are kept in its wtoffline\\stock folder.", - "room": "{{free}} free on this drive.", - "noRoom": "Not enough room: {{needed}} needed, {{free}} free on this drive.", + "copy": "Copy installation (recommended)", + "copyBody": "Copies the complete game to a new folder and installs into the copy. The original is not affected. Requires about {{size}} of free space.", + "measuring": "(calculating size)", + "targetTitle": "Select a folder for the copy", + "inPlace": "In-place installation", + "inPlaceBody": "Installs directly into the selected folder, for a game copy you prepared yourself. Replaces 4 files in it; the originals are backed up to wtoffline\\stock.", + "room": "Free space on target drive: {{free}}", + "noRoom": "Not enough free space: {{needed}} required, {{free}} available on the target drive.", "problem": { - "not_empty": "This folder already holds files. Choose an empty or a new folder.", - "overlaps_stock": "Choose a folder other than the original game folder, outside it and not containing it.", - "not_a_folder": "This is not a folder." + "not_empty": "The selected folder is not empty. Select an empty or new folder.", + "overlaps_stock": "The folder cannot be the original installation folder, or a folder inside or above it.", + "not_a_folder": "The selected path is not a folder." } }, "steam": { - "title": "This folder is in a Steam library. Installing here:", - "risk1": "changes your online game client directly;", - "risk2": "can be undone when Steam verifies or updates the game;", - "risk3": "risks a ban if the online game is started with the changed files.", - "advice": "Copying into a new folder is the safer choice.", - "confirm": "I understand these risks and want to install here" + "title": "The selected folder is in a Steam library. Installing here will:", + "risk1": "modify the files of the official client;", + "risk2": "possibly be overwritten by Steam file verification or updates;", + "risk3": "risk an account ban if the official game is launched online with the modified files.", + "advice": "A copy installation is recommended instead.", + "confirm": "I understand these risks and want to install in this folder" }, "data": { - "title": "Choose the data folder", - "body": "Saves, caches and logs of the offline version go here. Take this folder along to take your saves." + "body": "Saves, caches and logs are stored in this folder. Moving the folder moves the saves.", + "dialogTitle": "Select the data folder" }, "check": { - "title": "Checking your game", - "running": "Checking that the offline version's changes fit your game. This takes a few seconds…", - "allFit": "All {{count}} changes fit your game.", - "essentialMissing": "Your game version lacks changes the offline version cannot run without, so it cannot be installed. Affected:", - "someMissing": "Some changes do not fit your game version. These features will not work:", - "details": "Which changes", - "accept": "Install without these features" + "running": "Checking which patches apply to the selected game. This takes a few seconds.", + "allFit": "All {{count}} patches apply to this game version.", + "essentialMissing": "Patches required by the offline edition do not apply to this game version. Installation is not possible. Affected features:", + "someMissing": "{{count}} patches do not apply to this game version. The following features will be unavailable:", + "details": "Patch details", + "accept": "Continue without these features" }, "progress": { - "title": "Installing", "phase": { - "checking": "Checking the game files…", - "measuring": "Counting the files to copy…", - "copying": "Copying the game…", - "backing-up": "Keeping the original files…", - "recording": "Finishing…" + "checking": "Checking game files", + "measuring": "Counting files", + "copying": "Copying game files", + "backing-up": "Backing up original files", + "recording": "Finishing installation" }, - "copied": "{{done}} of {{total}} copied ({{doneFiles}} of {{totalFiles}} files)", + "copied": "Copied {{done}} / {{total}} · {{doneFiles}} / {{totalFiles}} files", + "cancelHint": "Can be cancelled at any time; copied files will be deleted", "cancel": "Cancel installation", "cancelling": "Cancelling…" }, + "copies": { + "sections": { + "summary": "Copy details", + "features": "Feature status" + }, + "reinstall": "Reinstall…", + "none": "The offline edition is not installed yet.", + "summary": { + "version": "Game version", + "adaptation": "Adaptation", + "adaptationHint": "Selected automatically by game version", + "location": "Location", + "method": "Installation type", + "methods": { + "copy": "Copy installation", + "in-place": "In-place installation" + }, + "stock": "Original file backup", + "stockHint": "Patched files are generated from it at each launch", + "data": "Data folder", + "dataHint": "Saves, caches and logs", + "installedAt": "Installed", + "features": "Features", + "open": "Open" + }, + "features": { + "lead": "Each feature depends on one or more patches. When a patch does not apply, its features are unavailable; installation is not possible while a feature marked \"Required\" is unavailable.", + "essential": "Required", + "verifiedOn": "Verified: {{version}}", + "unavailable": "Patch does not apply: {{patches}}", + "allAvailable": "All available", + "someMissing": "{{count}} unavailable", + "checkedAt": "Checked {{time}} (at installation)" + } + }, + "featureSections": { + "A": "Startup and account", + "B": "Hangar and vehicles", + "C": "Tech tree and research", + "D": "Modifications, weapons and ammunition", + "E": "Crew", + "F": "Customization", + "G": "Economy and store", + "H": "Items and inventory", + "I": "Squadrons", + "J": "Game modes", + "K": "In battle", + "L": "After battle and statistics", + "M": "Replays", + "N": "Settings, controls and mods", + "O": "Multiplayer social features" + }, + "settings": { + "sections": { + "general": "General" + }, + "language": "Language", + "languageHint": "Display language of the launcher" + }, + "about": { + "launcher": "Launcher {{version}}", + "supported": "Supported game versions: {{versions}}", + "statement": "Statement", + "statementBody": "This is an unofficial fan project, not affiliated with Gaijin Entertainment. WTOffline contains no game files; an official War Thunder client is required. No network connection and no account are used." + }, "features": { - "A-离线启动": "Starting offline", - "A-与正版隔离": "Kept apart from the online game", - "A-不连 Gaijin": "No connection to Gaijin", - "A-新手流程": "Tutorials", + "A-离线启动": "Offline startup", + "A-与正版隔离": "Isolation from the official game", + "A-不连 Gaijin": "Gaijin connections blocked", + "A-新手流程": "Tutorial", "B-机库与载具": "Hangar and vehicles", "G-礼包商店": "Pack store", "G-兑换码": "Redeem codes", "G-市场": "Marketplace", "G-Marketplace": "Marketplace", - "G-货币": "Currency purchases", + "G-货币": "Currency purchase", "G-高级账户": "Premium account", "G-Premium Account": "Premium account", "G-Store": "Store", "G-加成道具": "Boosters", "H-合同 / 赌注": "Battle contracts", "H-补给箱": "Supply chests", - "H-物品回收与合成": "Recycling and crafting", + "H-物品回收与合成": "Item recycling and crafting", "H-兑换券": "Coupons", "H-External inventory": "External inventory items", - "J-对局模式": "Battle modes", + "J-对局模式": "Game modes", "J-陆战 街机 / 历史": "Ground battles (arcade, realistic)", "J-空战 街机 / 历史": "Air battles (arcade, realistic)", "J-海战 街机 / 历史": "Naval battles (arcade, realistic)", - "J-附加子模式": "Extra modes (such as night battles)", - "K-AI 对手与队友": "AI opponents and teammates", + "J-附加子模式": "Additional modes (such as night battles)", + "K-AI 对手与队友": "AI opponents and allies", "K-出生点数 / 重生": "Spawn points and respawning", "K-侦察": "Scouting and drones", "K-击杀、助攻、占点计分": "Kill, assist and capture scoring", - "K-补充载具": "Extra vehicles", + "K-补充载具": "Additional vehicles", "K-计分板": "Scoreboard", "L-结算页": "Battle results", "L-战斗奖章": "Battle awards" }, "errors": { - "internal_error": "Something went wrong inside the launcher.", - "settings_write_failed": "Could not save the settings.", - "folder_unreadable": "Cannot read the folder: {{path}}", - "not_a_game_folder": "This is not a War Thunder game folder: {{path}}", - "target_not_usable": "This folder cannot be used for the installation.", - "steam_library_not_confirmed": "The folder is in a Steam library. Confirm the warning first.", - "not_enough_space": "Not enough disk space: {{neededGb}} GB needed, {{freeGb}} GB free.", - "essential_patches_unavailable": "Your game version lacks changes the offline version cannot run without: {{patches}}", - "missing_features_not_accepted": "Some changes do not fit. Confirm whether to go on without those features first.", - "patch_check_failed": "Checking the game files failed.", - "copy_failed": "Copying the game failed. What was copied has been removed.", - "install_cancelled": "Installation cancelled. What was copied has been removed.", - "install_busy": "An installation is already running.", - "unknown": "Something went wrong." + "internal_error": "An internal launcher error occurred.", + "settings_write_failed": "The settings could not be saved.", + "folder_unreadable": "The folder cannot be read: {{path}}", + "not_a_game_folder": "The selected folder is not a War Thunder installation: {{path}}", + "target_not_usable": "The selected folder cannot be used for installation.", + "steam_library_not_confirmed": "The installation folder is in a Steam library. Confirm the risk notice first.", + "not_enough_space": "Not enough disk space: {{neededGb}} GB required, {{freeGb}} GB available.", + "essential_patches_unavailable": "Patches required by the offline edition do not apply to this game version. Installation is not possible: {{patches}}", + "missing_features_not_accepted": "Some patches do not apply. Confirm whether to continue without the affected features.", + "patch_check_failed": "An error occurred while checking patches.", + "copy_failed": "Copying the game files failed. The copied files have been deleted.", + "install_cancelled": "Installation cancelled. The copied files have been deleted.", + "install_busy": "An installation is already in progress.", + "unknown": "An unknown error occurred." } } diff --git a/apps/launcher/src/renderer/src/i18n/locales/zh-CN.json b/apps/launcher/src/renderer/src/i18n/locales/zh-CN.json index 1377293..758fe7b 100644 --- a/apps/launcher/src/renderer/src/i18n/locales/zh-CN.json +++ b/apps/launcher/src/renderer/src/i18n/locales/zh-CN.json @@ -1,6 +1,17 @@ { "app": { - "title": "战争雷霆离线版" + "title": "战争雷霆离线版", + "subtitle": "战争雷霆离线版" + }, + "nav": { + "home": "首页", + "copies": "副本", + "settings": "设置", + "about": "关于" + }, + "window": { + "minimize": "最小化", + "close": "关闭" }, "language": { "label": "语言", @@ -8,107 +19,210 @@ "zh-CN": "简体中文", "en": "English" }, - "welcome": { - "title": "尚未安装", - "body": "用你自己的战争雷霆安装离线版。默认会复制一份游戏,原版只读取、不修改。", - "install": "开始安装" + "footer": { + "launcher": "启动器 {{version}}", + "game": "游戏 {{version}}", + "notInstalled": "未安装", + "disclaimer": "非官方爱好者项目,与 Gaijin Entertainment 无关" }, - "installed": { - "title": "离线版已安装", - "launchLater": "启动游戏的功能将在下一版加入。", - "reinstall": "重新安装" + "home": { + "kicker": "单机离线版 · 本地服务器", + "installedKicker": "游戏 {{version}}", + "body": "无需联网与账号,即可与 AI 进行完整对局。机库、研发、商店与结算均由本地服务器提供。", + "steps": { + "choose": "1 · 选择游戏", + "chooseBody": "指定正版战争雷霆的安装位置", + "copy": "2 · 创建副本", + "copyBody": "复制游戏文件,正版保持不变", + "launch": "3 · 启动", + "launchBody": "此后从启动器直接进入游戏" + } }, - "summary": { - "copy": "游戏副本", - "data": "数据目录", - "version": "游戏版本", - "method": "安装方式", - "methods": { - "copy": "复制到新文件夹", - "in-place": "直接在原文件夹里安装" - }, - "missing": "你的游戏版本用不上以下功能:" + "side": { + "requirements": "系统要求", + "game": "游戏", + "gameValue": "战争雷霆正版客户端", + "versions": "支持版本", + "space": "磁盘空间", + "spaceValue": "约 97 GB(复制安装)", + "about": "关于离线版", + "aboutBody": "本地服务器在本机提供档案、机库、商店、对局与结算等服务。运行期间不联网,不使用任何账号。安装过程仅读取正版文件,不作任何修改。", + "statement": "声明与协议", + "currentCopy": "当前副本", + "copyName": "游戏副本", + "adaptation": "适配版本", + "features": "功能", + "allAvailable": "✓ 全部可用", + "someMissing": "⚠ {{count}} 项不可用", + "details": "详情", + "disclaimer": "非官方爱好者项目,与 Gaijin Entertainment 无关。" + }, + "adaptation": { + "verified": "✓ 已核对", + "nearest": "⚠ 就近适配" + }, + "bar": { + "notInstalled": "未安装", + "notInstalledDetail": "需要已安装的战争雷霆正版客户端", + "install": "安装", + "ready": "就绪", + "readyMissing": "就绪 · {{count}} 项功能不可用", + "readyDetail": "游戏 {{version}} · 启动功能将在后续版本提供", + "launch": "启动" }, "folder": { - "none": "尚未选择", - "choose": "选择文件夹", - "change": "更改" + "none": "未选择", + "choose": "浏览…", + "change": "更改…" }, "wizard": { + "title": "安装离线版", + "note": "安装过程不会修改正版游戏。补丁文件不在安装时写入,而是在每次启动时生成。", "steps": { "source": "游戏位置", "method": "安装方式", "data": "数据目录", - "check": "检查", + "check": "补丁检查", "installing": "安装" }, + "barTitle": "安装 · {{step}}", + "stepOf": "第 {{index}} 步,共 {{total}} 步", "back": "上一步", "next": "下一步", "cancel": "取消", - "install": "开始安装" + "install": "开始安装", + "installing": "安装中", + "checking": "正在检查补丁", + "checkingDetail": "正在核对补丁对所选游戏的适用情况" }, "source": { - "title": "选择你的战争雷霆游戏文件夹", - "body": "就是装有 aces.vromfs.bin 和 win64 文件夹的那个,例如 Steam 里的 War Thunder 文件夹。", - "notAGame": "这不是战争雷霆的游戏文件夹,缺少:{{files}}", - "versionVerified": "游戏版本 {{version}},离线版已适配这个版本。", - "versionUnverified": "游戏版本 {{version}}。离线版适配的是 {{verified}},其他版本可能有部分功能用不了。下一步会检查具体哪些。", - "versionUnknown": "未知" + "body": "选择战争雷霆的安装文件夹(包含 aces.vromfs.bin 与 win64 文件夹)。", + "dialogTitle": "选择战争雷霆的安装文件夹", + "notAGame": "所选文件夹不是战争雷霆的安装文件夹,缺少:{{files}}", + "versionVerified": "游戏版本 {{version}} · 适配版本 {{version}}(已核对)", + "versionUnverified": "游戏版本 {{version}} 暂无对应适配,将使用最接近的 {{nearest}}。部分功能可能不可用,检查结果将在第 4 步列出。", + "versionUnknown": "未知", + "size": "大小 {{size}} · {{files}} 个文件", + "measuring": "正在统计大小…", + "readOnly": "安装过程仅读取此文件夹,不作任何修改。" }, "method": { - "title": "怎么安装", - "copy": "复制到新文件夹(推荐)", - "copyBody": "把游戏完整复制一份,离线版装在副本里,原版不受影响。需要约 {{size}} 空间。", - "measuring": "(正在计算大小)", - "targetTitle": "选择存放游戏副本的文件夹", - "inPlace": "直接在这个文件夹里安装", - "inPlaceBody": "适合你已经自己准备好一份游戏副本的情况。会替换 {{path}} 里的 4 个文件,原文件备份在其中的 wtoffline\\stock 文件夹。", - "room": "这个盘还有 {{free}} 空间。", - "noRoom": "空间不够:需要 {{needed}},这个盘只剩 {{free}}。", + "copy": "复制安装(推荐)", + "copyBody": "将游戏完整复制到新文件夹,并在副本中安装。正版不受影响。需要约 {{size}} 可用空间。", + "measuring": "(正在统计大小)", + "targetTitle": "选择存放副本的文件夹", + "inPlace": "原位安装", + "inPlaceBody": "在所选文件夹中直接安装,适用于自行准备的游戏副本。将替换其中 4 个文件,原文件备份至 wtoffline\\stock。", + "room": "目标磁盘可用空间:{{free}}", + "noRoom": "可用空间不足:需要 {{needed}},目标磁盘仅剩 {{free}}。", "problem": { - "not_empty": "这个文件夹里已经有文件了,请选一个空文件夹或新文件夹。", - "overlaps_stock": "不能选原版游戏文件夹本身,也不能选它里面或包含它的文件夹。", - "not_a_folder": "这不是一个文件夹。" + "not_empty": "所选文件夹不为空。请选择空文件夹或新建文件夹。", + "overlaps_stock": "不能选择正版安装文件夹本身,或其上级、下级文件夹。", + "not_a_folder": "所选路径不是文件夹。" } }, "steam": { - "title": "这个文件夹在 Steam 游戏库里。在这里安装:", - "risk1": "等于直接改动你的正版客户端;", - "risk2": "Steam 校验文件或更新时,改动可能被覆盖;", - "risk3": "带着改过的文件联网启动正版,有被封号的风险。", - "advice": "建议改用“复制到新文件夹”。", - "confirm": "我了解这些风险,仍要在这里安装" + "title": "所选文件夹位于 Steam 游戏库中。在此安装将:", + "risk1": "修改正版客户端的文件;", + "risk2": "可能被 Steam 文件校验或更新覆盖;", + "risk3": "若以修改后的文件联网启动正版,存在账号封禁风险。", + "advice": "建议改用复制安装。", + "confirm": "我已了解上述风险,仍在此文件夹中安装" }, "data": { - "title": "选择数据目录", - "body": "离线版的存档、缓存和日志都放在这里。拷走这个文件夹就能带走存档。" + "body": "存档、缓存与日志保存在此文件夹。迁移该文件夹即可迁移存档。", + "dialogTitle": "选择数据目录" }, "check": { - "title": "检查你的游戏", - "running": "正在核对离线版的改动是否都适用于你的游戏,需要几秒钟……", - "allFit": "全部 {{count}} 项改动都适用于你的游戏。", - "essentialMissing": "你的游戏版本缺少离线版运行所必需的改动,无法安装。受影响的是:", - "someMissing": "有些改动不适用于你的游戏版本,下面这些功能会用不了:", - "details": "具体是哪些改动", - "accept": "缺少这些功能也继续安装" + "running": "正在核对补丁对所选游戏的适用情况,约需数秒。", + "allFit": "全部 {{count}} 个补丁均适用于此游戏版本。", + "essentialMissing": "此游戏版本缺少离线版运行所必需的补丁,无法安装。受影响的功能:", + "someMissing": "{{count}} 个补丁不适用于此游戏版本,以下功能将不可用:", + "details": "查看补丁详情", + "accept": "在缺少上述功能的情况下继续安装" }, "progress": { - "title": "正在安装", "phase": { - "checking": "正在检查游戏文件……", - "measuring": "正在统计要复制的文件……", - "copying": "正在复制游戏……", - "backing-up": "正在备份原版文件……", - "recording": "正在完成安装……" + "checking": "检查游戏文件", + "measuring": "统计文件", + "copying": "复制游戏文件", + "backing-up": "备份原版文件", + "recording": "完成安装" }, - "copied": "已复制 {{done}} / {{total}}({{doneFiles}} / {{totalFiles}} 个文件)", + "copied": "已复制 {{done}} / {{total}} · {{doneFiles}} / {{totalFiles}} 个文件", + "cancelHint": "可随时取消,已复制的文件将被删除", "cancel": "取消安装", - "cancelling": "正在取消……" + "cancelling": "正在取消…" + }, + "copies": { + "sections": { + "summary": "副本详情", + "features": "功能状态" + }, + "reinstall": "重新安装…", + "none": "尚未安装离线版。", + "summary": { + "version": "游戏版本", + "adaptation": "适配版本", + "adaptationHint": "按游戏版本自动选择", + "location": "位置", + "method": "安装方式", + "methods": { + "copy": "复制安装", + "in-place": "原位安装" + }, + "stock": "原版文件备份", + "stockHint": "每次启动时据此生成补丁文件", + "data": "数据目录", + "dataHint": "存档、缓存与日志", + "installedAt": "安装时间", + "features": "功能", + "open": "打开" + }, + "features": { + "lead": "每项功能依赖一个或多个补丁。补丁不适用时,对应功能不可用;标记为“必需”的功能不可用时无法安装。", + "essential": "必需", + "verifiedOn": "已核对:{{version}}", + "unavailable": "补丁不适用:{{patches}}", + "allAvailable": "全部可用", + "someMissing": "{{count}} 项不可用", + "checkedAt": "检查时间:{{time}}(安装时)" + } + }, + "featureSections": { + "A": "启动与账号", + "B": "机库与载具", + "C": "科技树与研发", + "D": "改装、武器与弹药", + "E": "乘员", + "F": "外观定制", + "G": "经济与商店", + "H": "道具与库存", + "I": "联队", + "J": "对局模式", + "K": "对局内", + "L": "战后与统计", + "M": "回放", + "N": "设置、操控与模组", + "O": "多人社交" + }, + "settings": { + "sections": { + "general": "常规" + }, + "language": "语言", + "languageHint": "启动器界面的显示语言" + }, + "about": { + "launcher": "启动器 {{version}}", + "supported": "支持的游戏版本:{{versions}}", + "statement": "声明", + "statementBody": "本项目为非官方爱好者项目,与 Gaijin Entertainment 无关。WTOffline 不包含任何游戏文件,使用前需拥有战争雷霆正版客户端。运行期间不联网,不使用任何账号。" }, "features": { "A-离线启动": "离线启动", - "A-与正版隔离": "与正版游戏隔离", - "A-不连 Gaijin": "不连接 Gaijin", + "A-与正版隔离": "与正版隔离", + "A-不连 Gaijin": "阻断 Gaijin 连接", "A-新手流程": "新手教程", "B-机库与载具": "机库与载具", "G-礼包商店": "礼包商店", @@ -133,26 +247,26 @@ "K-AI 对手与队友": "AI 对手与队友", "K-出生点数 / 重生": "出生点数与重生", "K-侦察": "侦察与无人机", - "K-击杀、助攻、占点计分": "击杀、助攻和占点计分", + "K-击杀、助攻、占点计分": "击杀、助攻与占点计分", "K-补充载具": "补充载具", "K-计分板": "计分板", "L-结算页": "战后结算", "L-战斗奖章": "战斗嘉奖" }, "errors": { - "internal_error": "启动器内部出错了。", - "settings_write_failed": "设置保存失败。", + "internal_error": "启动器内部错误。", + "settings_write_failed": "无法保存设置。", "folder_unreadable": "无法读取文件夹:{{path}}", - "not_a_game_folder": "这不是战争雷霆的游戏文件夹:{{path}}", - "target_not_usable": "这个文件夹不能用来安装。", - "steam_library_not_confirmed": "安装位置在 Steam 游戏库里,需要先确认风险提示。", - "not_enough_space": "磁盘空间不够:需要 {{neededGb}} GB,只剩 {{freeGb}} GB。", - "essential_patches_unavailable": "你的游戏版本缺少离线版必需的改动,无法安装:{{patches}}", - "missing_features_not_accepted": "有些改动用不上,需要先确认是否在缺少这些功能的情况下继续。", - "patch_check_failed": "检查游戏文件时出错了。", - "copy_failed": "复制游戏失败,已复制的部分已删除。", - "install_cancelled": "安装已取消,已复制的部分已删除。", - "install_busy": "已经有一个安装在进行。", - "unknown": "出错了。" + "not_a_game_folder": "所选文件夹不是战争雷霆的安装文件夹:{{path}}", + "target_not_usable": "所选文件夹不能用于安装。", + "steam_library_not_confirmed": "安装位置位于 Steam 游戏库中,请先确认风险提示。", + "not_enough_space": "磁盘空间不足:需要 {{neededGb}} GB,仅剩 {{freeGb}} GB。", + "essential_patches_unavailable": "此游戏版本缺少离线版运行所必需的补丁,无法安装:{{patches}}", + "missing_features_not_accepted": "部分补丁不适用,请先确认是否在缺少相应功能的情况下继续。", + "patch_check_failed": "检查补丁时出错。", + "copy_failed": "复制游戏文件失败,已复制的文件已删除。", + "install_cancelled": "安装已取消,已复制的文件已删除。", + "install_busy": "已有安装正在进行。", + "unknown": "发生未知错误。" } } diff --git a/apps/launcher/src/renderer/src/main.tsx b/apps/launcher/src/renderer/src/main.tsx index a118ca4..c50fd98 100644 --- a/apps/launcher/src/renderer/src/main.tsx +++ b/apps/launcher/src/renderer/src/main.tsx @@ -1,9 +1,15 @@ import { StrictMode } from 'react'; import { createRoot } from 'react-dom/client'; +import '@fontsource/roboto-condensed/400.css'; +import '@fontsource/roboto-condensed/500.css'; +import '@fontsource/roboto-condensed/700.css'; import { App } from './App.tsx'; import { initI18n, resolveLanguage } from './i18n/index.ts'; import { ipcInvoke } from './ipc.ts'; -import './styles/app.css'; +import './styles/tokens.css'; +import './styles/shell.css'; +import './styles/controls.css'; +import './styles/pages.css'; async function start(): Promise { const [settings, info, install] = await Promise.all([ipcInvoke('settings:get'), ipcInvoke('app:getInfo'), ipcInvoke('install:getRecord')]); @@ -14,7 +20,7 @@ async function start(): Promise { if (!root) throw new Error('#root is missing from index.html'); createRoot(root).render( - + , ); } diff --git a/apps/launcher/src/renderer/src/pages/InstallSummary.tsx b/apps/launcher/src/renderer/src/pages/InstallSummary.tsx deleted file mode 100644 index 260eed8..0000000 --- a/apps/launcher/src/renderer/src/pages/InstallSummary.tsx +++ /dev/null @@ -1,31 +0,0 @@ -import { useTranslation } from 'react-i18next'; -import type { InstallRecord } from '@shared/schemas/install.ts'; -import { featureName } from '../features.ts'; - -/** What is installed where, and which features are missing. */ -export function InstallSummary({ record }: { readonly record: InstallRecord }) { - const { t } = useTranslation(); - const missing = [...new Set(record.unavailablePatches.flatMap((patch) => patch.features))]; - return ( - <> -
-
{t('summary.copy')}
-
{record.copyPath}
-
{t('summary.data')}
-
{record.dataPath}
-
{t('summary.version')}
-
{record.gameVersion ?? t('source.versionUnknown')}
-
{t('summary.method')}
-
{t(`summary.methods.${record.method}`)}
-
- {missing.length > 0 && ( -
-

{t('summary.missing')}

-
    - {missing.map((feature) =>
  • {featureName(t, feature)}
  • )} -
-
- )} - - ); -} diff --git a/apps/launcher/src/renderer/src/pages/WelcomePage.tsx b/apps/launcher/src/renderer/src/pages/WelcomePage.tsx deleted file mode 100644 index 14e9855..0000000 --- a/apps/launcher/src/renderer/src/pages/WelcomePage.tsx +++ /dev/null @@ -1,31 +0,0 @@ -import { useTranslation } from 'react-i18next'; -import type { InstallRecord } from '@shared/schemas/install.ts'; -import { InstallSummary } from './InstallSummary.tsx'; - -interface WelcomePageProps { - /** The installed copy, or null before the first installation. */ - readonly record: InstallRecord | null; - readonly onInstall: () => void; -} - -/** The first screen: an invitation to install, or what is installed. */ -export function WelcomePage({ record, onInstall }: WelcomePageProps) { - const { t } = useTranslation(); - if (!record) { - return ( -
-

{t('welcome.title')}

-

{t('welcome.body')}

- -
- ); - } - return ( -
-

{t('installed.title')}

- -

{t('installed.launchLater')}

- -
- ); -} diff --git a/apps/launcher/src/renderer/src/pages/about/AboutPage.tsx b/apps/launcher/src/renderer/src/pages/about/AboutPage.tsx new file mode 100644 index 0000000..45a0696 --- /dev/null +++ b/apps/launcher/src/renderer/src/pages/about/AboutPage.tsx @@ -0,0 +1,21 @@ +import { useTranslation } from 'react-i18next'; +import { Sheet } from '../../components/Sheet.tsx'; + +/** The launcher's version, the game versions it supports, and the project statement. */ +export function AboutPage({ launcherVersion, supportedVersions }: { readonly launcherVersion: string; readonly supportedVersions: readonly string[] }) { + const { t } = useTranslation(); + return ( + +
+
WTOFFLINE
+
+ {t('about.launcher', { version: launcherVersion })} +
+ {t('about.supported', { versions: supportedVersions.join(', ') })} +
+
+

{t('about.statement')}

+

{t('about.statementBody')}

+
+ ); +} diff --git a/apps/launcher/src/renderer/src/pages/copies/CopySummary.tsx b/apps/launcher/src/renderer/src/pages/copies/CopySummary.tsx new file mode 100644 index 0000000..c4ebd1f --- /dev/null +++ b/apps/launcher/src/renderer/src/pages/copies/CopySummary.tsx @@ -0,0 +1,55 @@ +import { useTranslation } from 'react-i18next'; +import type { InstallRecord } from '@shared/schemas/install.ts'; +import { Row } from '../../components/Row.tsx'; +import { Sheet } from '../../components/Sheet.tsx'; +import { ipcInvoke } from '../../ipc.ts'; +import { adaptationFor, isVerified } from '../../versions.ts'; +import { missingFeatures } from './missing-features.ts'; + +interface CopySummaryProps { + readonly record: InstallRecord; + readonly supportedVersions: readonly string[]; + readonly onShowFeatures: () => void; + readonly onReinstall: () => void; + readonly onError: (error: unknown) => void; +} + +/** What is installed where: version, adaptation, folders, installation type. */ +export function CopySummary({ record, supportedVersions, onShowFeatures, onReinstall, onError }: CopySummaryProps) { + const { t, i18n } = useTranslation(); + const missing = missingFeatures(record).length; + const verified = isVerified(record.gameVersion, supportedVersions); + const folder = (path: string) => ( + <> + {path} + + + ); + return ( + {t('copies.reinstall')}} + > + {record.gameVersion ?? t('source.versionUnknown')} + + {adaptationFor(record.gameVersion, supportedVersions) ?? t('source.versionUnknown')} + {verified ? t('adaptation.verified') : t('adaptation.nearest')} + + {folder(record.copyPath)} + {t(`copies.summary.methods.${record.method}`)} + {folder(record.stockBackupPath)} + {folder(record.dataPath)} + {new Date(record.installedAt).toLocaleString(i18n.language)} + + {missing === 0 ? ( + {t('side.allAvailable')} + ) : ( + <> + {t('side.someMissing', { count: missing })} + + + )} + + + ); +} diff --git a/apps/launcher/src/renderer/src/pages/copies/FeatureStatus.tsx b/apps/launcher/src/renderer/src/pages/copies/FeatureStatus.tsx new file mode 100644 index 0000000..4a26ffe --- /dev/null +++ b/apps/launcher/src/renderer/src/pages/copies/FeatureStatus.tsx @@ -0,0 +1,76 @@ +import { useEffect, useState } from 'react'; +import { useTranslation } from 'react-i18next'; +import type { InstallRecord, PatchFeature } from '@shared/schemas/install.ts'; +import { Sheet } from '../../components/Sheet.tsx'; +import { featureName } from '../../features.ts'; +import { ipcInvoke } from '../../ipc.ts'; +import { adaptationFor } from '../../versions.ts'; + +interface FeatureStatusProps { + readonly record: InstallRecord; + readonly supportedVersions: readonly string[]; + readonly onError: (error: unknown) => void; +} + +/** Every feature the patches cover, grouped by inventory section, with what the copy lacks and why. */ +export function FeatureStatus({ record, supportedVersions, onError }: FeatureStatusProps) { + const { t, i18n } = useTranslation(); + const [features, setFeatures] = useState(null); + + useEffect(() => { + let current = true; + ipcInvoke('install:listFeatures') + .then((list) => current && setFeatures(list)) + .catch((error: unknown) => current && onError(error)); + return () => { + current = false; + }; + }, [onError]); + + const unavailable = new Map(); + for (const patch of record.unavailablePatches) { + for (const tag of patch.features) unavailable.set(tag, [...(unavailable.get(tag) ?? []), patch.patchId]); + } + const adaptation = adaptationFor(record.gameVersion, supportedVersions) ?? t('source.versionUnknown'); + const sections = groupBySection(features ?? []); + + return ( + {t('copies.features.checkedAt', { time: new Date(record.installedAt).toLocaleString(i18n.language) })}} + > +

{t('copies.features.lead')}

+ {sections.map(([section, list]) => ( +
+

{section} · {t(`featureSections.${section}`, { defaultValue: section })}

+ {list.map((feature) => { + const failed = unavailable.get(feature.tag); + return ( +
+ + + {featureName(t, feature.tag)} + {feature.essential && <> {t('copies.features.essential')}} + + + {failed ? t('copies.features.unavailable', { patches: failed.join(', ') }) : t('copies.features.verifiedOn', { version: adaptation })} + +
+ ); + })} +
+ ))} +
+ ); +} + +/** Features by the inventory section letter before the dash in their tag, sections in order. */ +function groupBySection(features: readonly PatchFeature[]): Array<[string, PatchFeature[]]> { + const groups = new Map(); + for (const feature of features) { + const section = feature.tag.split('-')[0] ?? ''; + groups.set(section, [...(groups.get(section) ?? []), feature]); + } + return [...groups.entries()].sort(([a], [b]) => a.localeCompare(b)); +} diff --git a/apps/launcher/src/renderer/src/pages/copies/missing-features.ts b/apps/launcher/src/renderer/src/pages/copies/missing-features.ts new file mode 100644 index 0000000..92a888a --- /dev/null +++ b/apps/launcher/src/renderer/src/pages/copies/missing-features.ts @@ -0,0 +1,6 @@ +import type { InstallRecord } from '@shared/schemas/install.ts'; + +/** The feature tags a copy lacks because their patches did not apply when it was installed, each once. */ +export function missingFeatures(record: InstallRecord): string[] { + return [...new Set(record.unavailablePatches.flatMap((patch) => patch.features))]; +} diff --git a/apps/launcher/src/renderer/src/pages/home/HomeMain.tsx b/apps/launcher/src/renderer/src/pages/home/HomeMain.tsx new file mode 100644 index 0000000..2873fae --- /dev/null +++ b/apps/launcher/src/renderer/src/pages/home/HomeMain.tsx @@ -0,0 +1,27 @@ +import { useTranslation } from 'react-i18next'; +import type { InstallRecord } from '@shared/schemas/install.ts'; + +/** The home page's main area: the background art with the title, and before installation the three steps. */ +export function HomeMain({ record }: { readonly record: InstallRecord | null }) { + const { t } = useTranslation(); + if (record) { + return ( +
+
{t('home.installedKicker', { version: record.gameVersion ?? t('source.versionUnknown') })}
+

{t('app.title')}

+
+ ); + } + return ( +
+
{t('home.kicker')}
+

{t('app.title')}

+

{t('home.body')}

+
    +
  1. {t('home.steps.choose')}{t('home.steps.chooseBody')}
  2. +
  3. {t('home.steps.copy')}{t('home.steps.copyBody')}
  4. +
  5. {t('home.steps.launch')}{t('home.steps.launchBody')}
  6. +
+
+ ); +} diff --git a/apps/launcher/src/renderer/src/pages/home/HomeSide.tsx b/apps/launcher/src/renderer/src/pages/home/HomeSide.tsx new file mode 100644 index 0000000..66b900b --- /dev/null +++ b/apps/launcher/src/renderer/src/pages/home/HomeSide.tsx @@ -0,0 +1,73 @@ +import { useTranslation } from 'react-i18next'; +import type { InstallRecord } from '@shared/schemas/install.ts'; +import type { Destination } from '../../shell/navigation.ts'; +import { adaptationFor, isVerified } from '../../versions.ts'; +import { missingFeatures } from '../copies/missing-features.ts'; + +interface HomeSideProps { + readonly record: InstallRecord | null; + readonly supportedVersions: readonly string[]; + readonly onNavigate: (to: Destination) => void; +} + +/** The side panel of the home and about pages: requirements before installation, the current copy after. */ +export function HomeSide({ record, supportedVersions, onNavigate }: HomeSideProps) { + const { t } = useTranslation(); + if (!record) { + return ( + <> +

{t('side.requirements')}

+
+
+
{t('side.game')}
+
{t('side.gameValue')}
+
{t('side.versions')}
+
{supportedVersions.join(', ')}
+
{t('side.space')}
+
{t('side.spaceValue')}
+
+
+

{t('side.about')}

+
+ {t('side.aboutBody')} +
+
+
{t('side.disclaimer')}
+ + ); + } + const missing = missingFeatures(record).length; + const adaptation = adaptationFor(record.gameVersion, supportedVersions); + return ( + <> +

{t('side.currentCopy')}

+
+
{t('side.copyName')}
+
{record.gameVersion ?? t('source.versionUnknown')} · {record.copyPath}
+
+
+
+
{t('side.adaptation')}
+
+ {adaptation ?? t('source.versionUnknown')}{' '} + {isVerified(record.gameVersion, supportedVersions) + ? {t('adaptation.verified')} + : {t('adaptation.nearest')}} +
+
{t('side.features')}
+
+ {missing === 0 ? ( + {t('side.allAvailable')} + ) : ( + <> + {t('side.someMissing', { count: missing })}{' '} + + + )} +
+
+
+
{t('side.disclaimer')}
+ + ); +} diff --git a/apps/launcher/src/renderer/src/pages/home/home-bar.ts b/apps/launcher/src/renderer/src/pages/home/home-bar.ts new file mode 100644 index 0000000..5f1ea20 --- /dev/null +++ b/apps/launcher/src/renderer/src/pages/home/home-bar.ts @@ -0,0 +1,26 @@ +import type { TFunction } from 'i18next'; +import type { InstallRecord } from '@shared/schemas/install.ts'; +import type { BarModel } from '../../shell/bar-model.ts'; +import { missingFeatures } from '../copies/missing-features.ts'; + +/** + * The bottom bar outside the wizard: install before the first installation, launch after it. + * Launching (local verification) is not built yet, so the button stays disabled and the detail says so. + */ +export function homeBar(record: InstallRecord | null, t: TFunction, onInstall: () => void): BarModel { + if (!record) { + return { + tone: 'idle', + title: t('bar.notInstalled'), + detail: t('bar.notInstalledDetail'), + primary: { label: t('bar.install'), onClick: onInstall }, + }; + } + const missing = missingFeatures(record).length; + return { + tone: missing ? 'warn' : 'ok', + title: missing ? t('bar.readyMissing', { count: missing }) : t('bar.ready'), + detail: t('bar.readyDetail', { version: record.gameVersion ?? t('source.versionUnknown') }), + primary: { label: t('bar.launch'), disabled: true }, + }; +} diff --git a/apps/launcher/src/renderer/src/pages/install/CheckStep.tsx b/apps/launcher/src/renderer/src/pages/install/CheckStep.tsx index a18f529..5a8520d 100644 --- a/apps/launcher/src/renderer/src/pages/install/CheckStep.tsx +++ b/apps/launcher/src/renderer/src/pages/install/CheckStep.tsx @@ -11,40 +11,38 @@ interface CheckStepProps { readonly onMissingAccepted: (accepted: boolean) => void; } -/** Step 4: which of the offline version's changes fit the player's game build. */ +/** Step 4: which of the offline version's patches apply to the player's game build. */ export function CheckStep({ check, missingAccepted, onMissingAccepted }: CheckStepProps) { const { t } = useTranslation(); if (!check) { return ( -
-

{t('check.title')}

-

{t('check.running')}

- -
+ <> +

{t('check.running')}

+ + ); } const essential = check.unavailable.filter((patch) => patch.essential); + if (check.unavailable.length === 0) { + return {t('check.allFit', { count: check.exePatchesReady + check.guiPatchesReady })}; + } + if (essential.length > 0) { + return ( + +

{t('check.essentialMissing')}

+ +
+ ); + } return ( -
-

{t('check.title')}

- {check.unavailable.length === 0 && {t('check.allFit', { count: check.exePatchesReady + check.guiPatchesReady })}} - {essential.length > 0 && ( - -

{t('check.essentialMissing')}

- -
- )} - {essential.length === 0 && check.unavailable.length > 0 && ( - -

{t('check.someMissing')}

- - -
- )} -
+ +

{t('check.someMissing', { count: check.unavailable.length })}

+ + +
); } diff --git a/apps/launcher/src/renderer/src/pages/install/DataStep.tsx b/apps/launcher/src/renderer/src/pages/install/DataStep.tsx index 4f26a05..3166b2a 100644 --- a/apps/launcher/src/renderer/src/pages/install/DataStep.tsx +++ b/apps/launcher/src/renderer/src/pages/install/DataStep.tsx @@ -11,10 +11,9 @@ interface DataStepProps { export function DataStep({ dataPath, onDataPath, onError }: DataStepProps) { const { t } = useTranslation(); return ( -
-

{t('data.title')}

-

{t('data.body')}

- -
+ <> +

{t('data.body')}

+ + ); } diff --git a/apps/launcher/src/renderer/src/pages/install/MethodStep.tsx b/apps/launcher/src/renderer/src/pages/install/MethodStep.tsx index c20dce5..d2e9dbc 100644 --- a/apps/launcher/src/renderer/src/pages/install/MethodStep.tsx +++ b/apps/launcher/src/renderer/src/pages/install/MethodStep.tsx @@ -1,3 +1,4 @@ +import type { ReactNode } from 'react'; import { useTranslation } from 'react-i18next'; import type { FolderSize, GameFolderInspection, InstallMethod, TargetFolderInspection } from '@shared/schemas/install.ts'; import { FolderField } from '../../components/FolderField.tsx'; @@ -33,35 +34,50 @@ export function MethodStep({ source, sourceSize, choice, onChoice, onError }: Me .then((target) => onChoice({ method: 'copy', target, steamConfirmed: false })) .catch(onError); }; + const steamWarning = steamLibraryInvolved(source, choice) + ? onChoice({ ...choice, steamConfirmed })} /> + : null; return ( -
-

{t('method.title')}

- - {choice.method === 'copy' && ( -
- - {choice.target && } -
- )} - - {steamLibraryInvolved(source, choice) && ( - onChoice({ ...choice, steamConfirmed })} /> - )} -
+ <> + choose('copy')} + > + + {choice.target && } + {steamWarning} + + choose('in-place')} + > + {steamWarning} + + + ); +} + +interface ChoiceProps { + readonly selected: boolean; + readonly title: string; + readonly body: string; + readonly onSelect: () => void; + /** Shown under the description while the choice is selected. */ + readonly children: ReactNode; +} + +function Choice({ selected, title, body, onSelect, children }: ChoiceProps) { + return ( +
+ + {title} +
{body}
+ {selected &&
{children}
} +
); } diff --git a/apps/launcher/src/renderer/src/pages/install/ProgressStep.tsx b/apps/launcher/src/renderer/src/pages/install/ProgressStep.tsx index e0976ff..d27ed83 100644 --- a/apps/launcher/src/renderer/src/pages/install/ProgressStep.tsx +++ b/apps/launcher/src/renderer/src/pages/install/ProgressStep.tsx @@ -1,39 +1,39 @@ import { useTranslation } from 'react-i18next'; -import type { InstallProgress } from '@shared/schemas/install.ts'; +import { INSTALL_PHASES, type InstallProgress } from '@shared/schemas/install.ts'; import { ProgressBar } from '../../components/ProgressBar.tsx'; import { formatBytes } from '../../format.ts'; -interface ProgressStepProps { - readonly progress: InstallProgress | null; - readonly cancelling: boolean; - readonly onCancel: () => void; -} - -/** Step 5: the installation running. Only the copy can be stopped; the other phases take seconds. */ -export function ProgressStep({ progress, cancelling, onCancel }: ProgressStepProps) { +/** + * Step 5: the installation running, phase by phase. Cancelling is in the bottom bar; only the + * copy can be stopped, the other phases take seconds. + */ +export function ProgressStep({ progress }: { readonly progress: InstallProgress | null }) { const { t } = useTranslation(); const phase = progress?.phase ?? 'checking'; + const current = INSTALL_PHASES.indexOf(phase); const copying = phase === 'copying' && progress !== null; return ( -
-

{t('progress.title')}

-

{t(`progress.phase.${phase}`)}

- + <> + {INSTALL_PHASES.map((name, position) => { + const state = position < current ? 'done' : position === current ? 'current' : 'pending'; + return ( +
+ + {t(`progress.phase.${name}`)} +
+ ); + })} + {copying && ( -

+

{t('progress.copied', { done: formatBytes(progress.doneBytes), total: formatBytes(progress.totalBytes), - doneFiles: progress.doneFiles, - totalFiles: progress.totalFiles, + doneFiles: progress.doneFiles.toLocaleString(), + totalFiles: progress.totalFiles.toLocaleString(), })} -

+
)} - {copying && ( - - )} -
+ ); } diff --git a/apps/launcher/src/renderer/src/pages/install/SourceStep.tsx b/apps/launcher/src/renderer/src/pages/install/SourceStep.tsx index 9a341f3..fd7c557 100644 --- a/apps/launcher/src/renderer/src/pages/install/SourceStep.tsx +++ b/apps/launcher/src/renderer/src/pages/install/SourceStep.tsx @@ -1,43 +1,60 @@ import { useTranslation } from 'react-i18next'; -import type { GameFolderInspection } from '@shared/schemas/install.ts'; +import type { FolderSize, GameFolderInspection } from '@shared/schemas/install.ts'; import { FolderField } from '../../components/FolderField.tsx'; import { Notice } from '../../components/Notice.tsx'; +import { formatBytes } from '../../format.ts'; import { ipcInvoke } from '../../ipc.ts'; +import { adaptationFor, isVerified } from '../../versions.ts'; interface SourceStepProps { readonly source: GameFolderInspection | null; + /** Null while the folder is measured. */ + readonly sourceSize: FolderSize | null; + readonly supportedVersions: readonly string[]; readonly onSource: (source: GameFolderInspection | null) => void; readonly onError: (error: unknown) => void; } -/** Step 1: the player's War Thunder installation. */ -export function SourceStep({ source, onSource, onError }: SourceStepProps) { +/** Step 1: the player's War Thunder installation, its version and the adaptation used for it. */ +export function SourceStep({ source, sourceSize, supportedVersions, onSource, onError }: SourceStepProps) { const { t } = useTranslation(); const inspect = (path: string): void => { onSource(null); ipcInvoke('install:inspectGameFolder', { path }).then(onSource).catch(onError); }; return ( -
-

{t('source.title')}

-

{t('source.body')}

- - {source && } -
+ <> +

{t('source.body')}

+ + {source && } +

{t('source.readOnly')}

+ ); } -function SourceVerdict({ source }: { readonly source: GameFolderInspection }) { +function SourceVerdict({ source, sourceSize, supportedVersions }: { readonly source: GameFolderInspection; readonly sourceSize: FolderSize | null; readonly supportedVersions: readonly string[] }) { const { t } = useTranslation(); if (source.missingFiles.length) { return {t('source.notAGame', { files: source.missingFiles.join(', ') })}; } - const verified = source.version !== null && source.verifiedVersions.includes(source.version); - return verified ? ( - {t('source.versionVerified', { version: source.version })} - ) : ( + const size = sourceSize ? t('source.size', { size: formatBytes(sourceSize.bytes), files: sourceSize.files.toLocaleString() }) : t('source.measuring'); + if (isVerified(source.version, supportedVersions)) { + return ( + +

{t('source.versionVerified', { version: source.version })}

+

{size}

+
+ ); + } + return ( - {t('source.versionUnverified', { version: source.version ?? t('source.versionUnknown'), verified: source.verifiedVersions.join(', ') })} +

+ {t('source.versionUnverified', { + version: source.version ?? t('source.versionUnknown'), + nearest: adaptationFor(source.version, supportedVersions) ?? t('source.versionUnknown'), + })} +

+

{size}

); } diff --git a/apps/launcher/src/renderer/src/pages/install/WizardMain.tsx b/apps/launcher/src/renderer/src/pages/install/WizardMain.tsx new file mode 100644 index 0000000..fae418f --- /dev/null +++ b/apps/launcher/src/renderer/src/pages/install/WizardMain.tsx @@ -0,0 +1,28 @@ +import { useTranslation } from 'react-i18next'; +import { Sheet } from '../../components/Sheet.tsx'; +import { CheckStep } from './CheckStep.tsx'; +import { DataStep } from './DataStep.tsx'; +import { MethodStep } from './MethodStep.tsx'; +import { ProgressStep } from './ProgressStep.tsx'; +import { SourceStep, sourceUsable } from './SourceStep.tsx'; +import { WIZARD_STEPS, type InstallWizard } from './useInstallWizard.ts'; + +/** The current wizard step in the main area. */ +export function WizardMain({ wizard, supportedVersions }: { readonly wizard: InstallWizard; readonly supportedVersions: readonly string[] }) { + const { t } = useTranslation(); + const { step, source } = wizard; + return ( + + {step === 'source' && ( + + )} + {step === 'method' && sourceUsable(source) && ( + + )} + {step === 'data' && } + {step === 'check' && } + {step === 'installing' && } + {wizard.message &&

{wizard.message}

} +
+ ); +} diff --git a/apps/launcher/src/renderer/src/pages/install/WizardSide.tsx b/apps/launcher/src/renderer/src/pages/install/WizardSide.tsx new file mode 100644 index 0000000..97e9c27 --- /dev/null +++ b/apps/launcher/src/renderer/src/pages/install/WizardSide.tsx @@ -0,0 +1,21 @@ +import { useTranslation } from 'react-i18next'; +import { WIZARD_STEPS, type WizardStep } from './useInstallWizard.ts'; + +/** The wizard's step list in the side panel. */ +export function WizardSide({ step }: { readonly step: WizardStep }) { + const { t } = useTranslation(); + const index = WIZARD_STEPS.indexOf(step); + return ( + <> +

{t('wizard.title')}

+
    + {WIZARD_STEPS.map((name, position) => ( +
  1. + {t(`wizard.steps.${name}`)} +
  2. + ))} +
+
{t('wizard.note')}
+ + ); +} diff --git a/apps/launcher/src/renderer/src/pages/install/InstallWizard.tsx b/apps/launcher/src/renderer/src/pages/install/useInstallWizard.ts similarity index 52% rename from apps/launcher/src/renderer/src/pages/install/InstallWizard.tsx rename to apps/launcher/src/renderer/src/pages/install/useInstallWizard.ts index 5040a5c..ae7e38a 100644 --- a/apps/launcher/src/renderer/src/pages/install/InstallWizard.tsx +++ b/apps/launcher/src/renderer/src/pages/install/useInstallWizard.ts @@ -1,31 +1,33 @@ import { useEffect, useState } from 'react'; -import { useTranslation } from 'react-i18next'; import type { FolderSize, GameFolderInspection, InstallProgress, InstallRecord, InstallRequest, PatchCheck } from '@shared/schemas/install.ts'; import { ipcInvoke, ipcOn } from '../../ipc.ts'; import { useErrorMessage } from '../../useErrorMessage.ts'; -import { CheckStep, checkUsable } from './CheckStep.tsx'; -import { DataStep } from './DataStep.tsx'; -import { MethodStep, methodUsable, type MethodChoice } from './MethodStep.tsx'; -import { ProgressStep } from './ProgressStep.tsx'; -import { SourceStep, sourceUsable } from './SourceStep.tsx'; +import { checkUsable } from './CheckStep.tsx'; +import { methodUsable, type MethodChoice } from './MethodStep.tsx'; +import { sourceUsable } from './SourceStep.tsx'; -const STEPS = ['source', 'method', 'data', 'check', 'installing'] as const; -type Step = (typeof STEPS)[number]; +export const WIZARD_STEPS = ['source', 'method', 'data', 'check', 'installing'] as const; +export type WizardStep = (typeof WIZARD_STEPS)[number]; -interface InstallWizardProps { +const NO_CHOICE: MethodChoice = { method: 'copy', target: null, steamConfirmed: false }; + +interface WizardOptions { readonly defaultDataPath: string; readonly onInstalled: (record: InstallRecord) => void; - readonly onClose: () => void; } -/** The install wizard: one screen per step, the work done by the main process over IPC. */ -export function InstallWizard({ defaultDataPath, onInstalled, onClose }: InstallWizardProps) { - const { t } = useTranslation(); +/** + * The install wizard's state and actions. The window shows it in three places: the step list in + * the side panel, the current step in the main area, and back / next in the bottom bar. The work + * is done by the main process over IPC. + */ +export function useInstallWizard({ defaultDataPath, onInstalled }: WizardOptions) { const { message, report, clear } = useErrorMessage(); - const [step, setStep] = useState('source'); + const [active, setActive] = useState(false); + const [step, setStep] = useState('source'); const [source, setSource] = useState(null); const [sourceSize, setSourceSize] = useState(null); - const [choice, setChoice] = useState({ method: 'copy', target: null, steamConfirmed: false }); + const [choice, setChoice] = useState(NO_CHOICE); const [dataPath, setDataPath] = useState(defaultDataPath); const [check, setCheck] = useState(null); const [missingAccepted, setMissingAccepted] = useState(false); @@ -40,12 +42,14 @@ export function InstallWizard({ defaultDataPath, onInstalled, onClose }: Install ipcInvoke('install:measureFolder', { path: source.path }) .then((size) => current && setSourceSize(size)) .catch((error: unknown) => current && report(error)); - return () => { current = false; }; + return () => { + current = false; + }; }, [source, report]); // The check runs every time the step is entered: the choices before it may have changed. useEffect(() => { - if (step !== 'check' || !sourceUsable(source)) return; + if (!active || step !== 'check' || !sourceUsable(source)) return; let current = true; setCheck(null); setMissingAccepted(false); @@ -56,11 +60,24 @@ export function InstallWizard({ defaultDataPath, onInstalled, onClose }: Install report(error); setStep('data'); }); - return () => { current = false; }; - }, [step, source, dataPath, report]); + return () => { + current = false; + }; + }, [active, step, source, dataPath, report]); useEffect(() => ipcOn('event:install-progress', setProgress), []); + const start = (): void => { + clear(); + setStep('source'); + setActive(true); + }; + + const chooseSource = (found: GameFolderInspection | null): void => { + setSource(found); + setChoice(NO_CHOICE); + }; + const install = (): void => { if (!sourceUsable(source)) return; const choices = { dataPath, steamLibraryConfirmed: choice.steamConfirmed, missingFeaturesAccepted: missingAccepted }; @@ -72,19 +89,17 @@ export function InstallWizard({ defaultDataPath, onInstalled, onClose }: Install setCancelling(false); setStep('installing'); ipcInvoke('install:start', request) - .then(onInstalled) + .then((record) => { + setActive(false); + onInstalled(record); + }) .catch((error: unknown) => { report(error); setStep('check'); }); }; - const cancel = (): void => { - setCancelling(true); - ipcInvoke('install:cancel').catch(report); - }; - - const canGoOn = (() => { + const canGoOn = ((): boolean => { switch (step) { case 'source': return sourceUsable(source); case 'method': return sourceUsable(source) && methodUsable(source, sourceSize, choice); @@ -93,41 +108,31 @@ export function InstallWizard({ defaultDataPath, onInstalled, onClose }: Install case 'installing': return false; } })(); - const index = STEPS.indexOf(step); + + const index = WIZARD_STEPS.indexOf(step); + const back = (): void => { clear(); - if (index === 0) onClose(); - else setStep(STEPS[index - 1]!); - }; - const next = (): void => { - clear(); - if (step === 'check') install(); - else setStep(STEPS[index + 1]!); + if (index === 0) setActive(false); + else setStep(WIZARD_STEPS[index - 1]!); }; - return ( -
-
    - {STEPS.map((name, position) => ( -
  1. {t(`wizard.steps.${name}`)}
  2. - ))} -
-
- {step === 'source' && { setSource(found); setChoice({ method: 'copy', target: null, steamConfirmed: false }); }} onError={report} />} - {step === 'method' && sourceUsable(source) && } - {step === 'data' && } - {step === 'check' && } - {step === 'installing' && } - {message &&

{message}

} -
- {step !== 'installing' && ( -
- - -
- )} -
- ); + const next = (): void => { + if (!canGoOn) return; + clear(); + if (step === 'check') install(); + else setStep(WIZARD_STEPS[index + 1]!); + }; + + const cancel = (): void => { + setCancelling(true); + ipcInvoke('install:cancel').catch(report); + }; + + return { + active, step, index, source, sourceSize, choice, dataPath, check, missingAccepted, progress, cancelling, message, canGoOn, + start, back, next, cancel, report, chooseSource, setChoice, setDataPath, setMissingAccepted, + }; } + +export type InstallWizard = ReturnType; diff --git a/apps/launcher/src/renderer/src/pages/install/wizard-bar.ts b/apps/launcher/src/renderer/src/pages/install/wizard-bar.ts new file mode 100644 index 0000000..fcbbb47 --- /dev/null +++ b/apps/launcher/src/renderer/src/pages/install/wizard-bar.ts @@ -0,0 +1,49 @@ +import type { TFunction } from 'i18next'; +import type { BarModel } from '../../shell/bar-model.ts'; +import { formatBytes } from '../../format.ts'; +import { WIZARD_STEPS, type InstallWizard } from './useInstallWizard.ts'; + +/** The bottom bar while the wizard runs: back on the left, next / install as the primary action. */ +export function wizardBar(wizard: InstallWizard, t: TFunction): BarModel { + const { step, index, check, progress, cancelling } = wizard; + const stepOf = t('wizard.stepOf', { index: index + 1, total: WIZARD_STEPS.length }); + + if (step === 'installing') { + const phase = progress?.phase ?? 'checking'; + const copying = phase === 'copying' && progress !== null; + return { + tone: 'busy', + title: t(`progress.phase.${phase}`), + detail: copying ? t('progress.cancelHint') : stepOf, + progress: copying + ? { + value: progress.doneBytes, + max: progress.totalBytes, + start: `${Math.floor((progress.doneBytes / Math.max(1, progress.totalBytes)) * 100)}%`, + end: `${formatBytes(progress.doneBytes)} / ${formatBytes(progress.totalBytes)}`, + } + : { value: 0, max: null }, + primary: { label: t('wizard.installing'), disabled: true }, + ...(copying ? { secondary: { label: cancelling ? t('progress.cancelling') : t('progress.cancel'), disabled: cancelling, onClick: wizard.cancel } } : {}), + }; + } + + const back = { label: index === 0 ? t('wizard.cancel') : t('wizard.back'), onClick: wizard.back }; + if (step === 'check' && check === null) { + return { + tone: 'busy', + title: t('wizard.checking'), + detail: t('wizard.checkingDetail'), + progress: { value: 0, max: null }, + primary: { label: t('wizard.install'), disabled: true }, + secondary: back, + }; + } + return { + tone: 'idle', + title: t('wizard.barTitle', { step: t(`wizard.steps.${step}`) }), + detail: stepOf, + primary: { label: step === 'check' ? t('wizard.install') : t('wizard.next'), disabled: !wizard.canGoOn, onClick: wizard.next }, + secondary: back, + }; +} diff --git a/apps/launcher/src/renderer/src/pages/settings/GeneralSettings.tsx b/apps/launcher/src/renderer/src/pages/settings/GeneralSettings.tsx new file mode 100644 index 0000000..cd0c266 --- /dev/null +++ b/apps/launcher/src/renderer/src/pages/settings/GeneralSettings.tsx @@ -0,0 +1,17 @@ +import { useTranslation } from 'react-i18next'; +import type { Settings } from '@shared/schemas/settings.ts'; +import { Row } from '../../components/Row.tsx'; +import { Sheet } from '../../components/Sheet.tsx'; +import { LanguageMenu } from '../../shell/LanguageMenu.tsx'; + +/** General launcher settings. */ +export function GeneralSettings({ settings, onError }: { readonly settings: Settings; readonly onError: (error: unknown) => void }) { + const { t } = useTranslation(); + return ( + + + + + + ); +} diff --git a/apps/launcher/src/renderer/src/shell/Background.tsx b/apps/launcher/src/renderer/src/shell/Background.tsx new file mode 100644 index 0000000..69c156c --- /dev/null +++ b/apps/launcher/src/renderer/src/shell/Background.tsx @@ -0,0 +1,14 @@ +/** The window background: the art read from the game copy, or the launcher's own drawing. */ +export function Background({ artUrl }: { readonly artUrl: string | null }) { + return ( + <> +