diff --git a/apps/launcher/src/renderer/src/App.tsx b/apps/launcher/src/renderer/src/App.tsx index 63316c7..ac52eb0 100644 --- a/apps/launcher/src/renderer/src/App.tsx +++ b/apps/launcher/src/renderer/src/App.tsx @@ -124,7 +124,7 @@ export function App({ info, initialSettings, initialCopies }: AppProps) { }; const perCopyStatus = ['version-changed', 'failed', 'port-busy', 'server-exited', 'game-exited'].includes(launch.phase); const launchStatus: LaunchState = perCopyStatus && launch.copyId && launch.copyId !== record?.id ? { phase: 'ready' } : launch; - const home = homeBar(record, launchStatus, t, () => wizard.start('new'), { + const home = homeBar(record, launchStatus, t, wizard.start, { start: () => { ipcInvoke('launch:start').catch(report); }, stop: () => { ipcInvoke('launch:stop').catch(report); }, checkVersion: () => go({ page: 'copies', section: 'features' }), @@ -191,8 +191,7 @@ export function App({ info, initialSettings, initialCopies }: AppProps) { supportedVersions={supported} onSelect={selectCopy} onRelocate={relocateCopy} - onAdd={() => wizard.start('new')} - onAddExisting={() => wizard.start('existing')} + onAdd={wizard.start} /> ), bar: home, @@ -204,10 +203,7 @@ export function App({ info, initialSettings, initialCopies }: AppProps) { main: (

{t('copies.none')}

-
- - -
+
), bar: home, diff --git a/apps/launcher/src/renderer/src/i18n/locales/en.json b/apps/launcher/src/renderer/src/i18n/locales/en.json index 662af78..777ab11 100644 --- a/apps/launcher/src/renderer/src/i18n/locales/en.json +++ b/apps/launcher/src/renderer/src/i18n/locales/en.json @@ -111,6 +111,7 @@ "wizard": { "title": "Add a client", "steps": { + "mode": "Setup mode", "source": "Game location", "method": "Installation type", "data": "Data folder", @@ -127,6 +128,13 @@ "checking": "Checking patches", "checkingDetail": "Checking which patches apply to the selected game" }, + "mode": { + "body": "Choose how to add an offline client.", + "newTitle": "Fresh installation from online client", + "newBody": "Create a new offline client from an installed online War Thunder folder via full copy, space-saving copy, or in-place setup.", + "existingTitle": "Add existing offline client", + "existingBody": "Register an already prepared offline client folder directly without copying game files." + }, "source": { "body": "Select the folder where War Thunder is installed.", "dialogTitle": "Select the War Thunder installation folder", @@ -215,7 +223,6 @@ "maintain": "Maintenance" }, "add": "Add a client", - "addExisting": "Add existing client", "missingFolder": "Folder missing", "relocate": "Relocate…", "relocateDialogTitle": "Select the moved client folder", 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 8dd35ad..5177b20 100644 --- a/apps/launcher/src/renderer/src/i18n/locales/zh-CN.json +++ b/apps/launcher/src/renderer/src/i18n/locales/zh-CN.json @@ -111,6 +111,7 @@ "wizard": { "title": "添加客户端", "steps": { + "mode": "添加方式", "source": "游戏位置", "method": "安装方式", "data": "数据目录", @@ -127,6 +128,13 @@ "checking": "正在检查补丁", "checkingDetail": "正在核对补丁对所选游戏的适用情况" }, + "mode": { + "body": "选择添加离线客户端的方式。", + "newTitle": "从在线版全新安装", + "newBody": "从已安装的战争雷霆在线版创建新的离线客户端,支持完整复制、省空间复制或原位安装。", + "existingTitle": "添加已有离线客户端", + "existingBody": "直接登记已准备好的离线客户端文件夹,不重新复制游戏文件。" + }, "source": { "body": "选择已安装的战争雷霆文件夹。", "dialogTitle": "选择战争雷霆安装文件夹", @@ -215,7 +223,6 @@ "maintain": "维护" }, "add": "添加客户端", - "addExisting": "添加已有客户端", "missingFolder": "目录不存在", "relocate": "重新定位…", "relocateDialogTitle": "选择挪动后的客户端文件夹", diff --git a/apps/launcher/src/renderer/src/pages/copies/CopyList.tsx b/apps/launcher/src/renderer/src/pages/copies/CopyList.tsx index 24411f3..a79ee76 100644 --- a/apps/launcher/src/renderer/src/pages/copies/CopyList.tsx +++ b/apps/launcher/src/renderer/src/pages/copies/CopyList.tsx @@ -9,10 +9,9 @@ interface CopyListProps { readonly onSelect: (id: string, detail?: boolean) => void; readonly onRelocate: (id: string) => void; readonly onAdd: () => void; - readonly onAddExisting: () => void; } -export function CopyList({ registry, supportedVersions, onSelect, onRelocate, onAdd, onAddExisting }: CopyListProps) { +export function CopyList({ registry, supportedVersions, onSelect, onRelocate, onAdd }: CopyListProps) { const { t } = useTranslation(); return ( @@ -55,7 +54,6 @@ export function CopyList({ registry, supportedVersions, onSelect, onRelocate, on ); })} - ); diff --git a/apps/launcher/src/renderer/src/pages/install/ModeStep.tsx b/apps/launcher/src/renderer/src/pages/install/ModeStep.tsx new file mode 100644 index 0000000..0662761 --- /dev/null +++ b/apps/launcher/src/renderer/src/pages/install/ModeStep.tsx @@ -0,0 +1,41 @@ +import { useTranslation } from 'react-i18next'; +import type { WizardMode } from './useInstallWizard.ts'; + +interface ModeStepProps { + readonly mode: WizardMode; + readonly onMode: (mode: WizardMode) => void; +} + +/** Step 1: choose whether to install a new offline client or register an existing one. */ +export function ModeStep({ mode, onMode }: ModeStepProps) { + const { t } = useTranslation(); + const options: ReadonlyArray<{ readonly value: WizardMode; readonly title: string; readonly body: string }> = [ + { value: 'new', title: t('mode.newTitle'), body: t('mode.newBody') }, + { value: 'existing', title: t('mode.existingTitle'), body: t('mode.existingBody') }, + ]; + return ( + <> +

{t('mode.body')}

+ {options.map((option) => { + const selected = mode === option.value; + return ( +
onMode(option.value)} + > + onMode(option.value)} + aria-label={option.title} + /> + {option.title} +
{option.body}
+
+ ); + })} + + ); +} diff --git a/apps/launcher/src/renderer/src/pages/install/WizardMain.tsx b/apps/launcher/src/renderer/src/pages/install/WizardMain.tsx index bf81aaa..d699cd2 100644 --- a/apps/launcher/src/renderer/src/pages/install/WizardMain.tsx +++ b/apps/launcher/src/renderer/src/pages/install/WizardMain.tsx @@ -4,6 +4,7 @@ import { Sheet } from '../../components/Sheet.tsx'; import { CheckStep } from './CheckStep.tsx'; import { DataStep } from './DataStep.tsx'; import { MethodStep } from './MethodStep.tsx'; +import { ModeStep } from './ModeStep.tsx'; import { ProgressStep } from './ProgressStep.tsx'; import { SourceStep, sourceUsable } from './SourceStep.tsx'; import { WIZARD_STEPS, type InstallWizard } from './useInstallWizard.ts'; @@ -14,6 +15,7 @@ export function WizardMain({ wizard, supportedVersions }: { readonly wizard: Ins const { step, source } = wizard; return ( + {step === 'mode' && } {step === 'source' && ( ('new'); - const [step, setStep] = useState('source'); + const [step, setStep] = useState('mode'); const [source, setSource] = useState(null); const [stockSource, setStockSource] = useState(null); const [sourceSize, setSourceSize] = useState(null); @@ -97,13 +97,13 @@ export function useInstallWizard({ onInstalled }: WizardOptions) { useEffect(() => ipcOn('event:install-progress', setProgress), []); - const start = (nextMode: WizardMode = 'new'): void => { + const start = (): void => { clear(); - setMode(nextMode); - setStep('source'); + setMode('new'); + setStep('mode'); setSource(null); setStockSource(null); - setChoice(nextMode === 'existing' ? { method: 'existing', target: null, steamConfirmed: false } : NO_CHOICE); + setChoice(NO_CHOICE); setName(''); setDraftId(null); setDataPath(''); @@ -116,6 +116,15 @@ export function useInstallWizard({ onInstalled }: WizardOptions) { }).catch(report); }; + const chooseMode = (nextMode: WizardMode): void => { + if (nextMode === mode) return; + setMode(nextMode); + setSource(null); + setStockSource(null); + setChoice(nextMode === 'existing' ? { method: 'existing', target: null, steamConfirmed: false } : NO_CHOICE); + setName(''); + }; + const chooseSource = (found: GameFolderInspection | null): void => { setSource(found); setStockSource(null); @@ -169,6 +178,7 @@ export function useInstallWizard({ onInstalled }: WizardOptions) { const canGoOn = ((): boolean => { switch (step) { + case 'mode': return draftId !== null; case 'source': return draftId !== null && sourceUsable(source, stockSource); case 'method': return name.trim().length > 0 && sourceUsable(source, stockSource) && methodUsable(source, sourceSize, choice); case 'data': return dataReady; @@ -200,7 +210,7 @@ export function useInstallWizard({ onInstalled }: WizardOptions) { return { active, mode, step, index, source, stockSource, sourceSize, choice, name, dataPath, decalSource, check, missingAccepted, progress, cancelling, message, canGoOn, steamDataPath: dataChecked?.inSteam ? dataChecked.path : null, steamDataConfirmed: dataChecked?.confirmed ?? false, - start, back, next, cancel, report, chooseSource, setStockSource, setChoice, setName, setDataPath, setSteamDataConfirmed, setDecalSource, setMissingAccepted, + start, back, next, cancel, report, chooseMode, chooseSource, setStockSource, setChoice, setName, setDataPath, setSteamDataConfirmed, setDecalSource, setMissingAccepted, }; }