fix(copies): honor confirmed Steam locations
Bind confirmation to the selected copy and data paths throughout installation, launch, and maintenance. Validate redirected runtime data paths and recheck original files before refreshing an in-place backup. Verified by type checking and build. The acceptance checklist covers directory links and Steam confirmation.
This commit is contained in:
1 parent
84158f719d
commit
5a78b1fdf8
28 files changed
+813
-459
No files matched your search
@@ -159,7 +159,10 @@
|
||||
"steam": {
|
||||
"inPlaceWarning": "Launching offline will modify the game files in this Steam installation. Steam updates or file verification may overwrite the changes. Launching the official game online with modified files may result in an account ban.",
|
||||
"copyWarning": "The destination is in a Steam library. Choose a folder outside the library to keep the offline copy separate.",
|
||||
"confirm": "Confirm this folder"
|
||||
"confirm": "Confirm this folder",
|
||||
"dataWarning": "Steam may remove saves, caches, and logs stored under the game folder when uninstalling the game.",
|
||||
"maintenanceWarning": "This copy or its data folder is in a Steam library. Offline play can change game files in the library. Steam can replace them during an update or file verification. Using modified files online may result in an account ban. Uninstalling the game through Steam may also remove any saves stored under its folder.",
|
||||
"confirmLocations": "Confirm these locations"
|
||||
},
|
||||
"data": {
|
||||
"body": "Select a folder for saves, caches, and logs.",
|
||||
@@ -220,6 +223,10 @@
|
||||
"delete": "Delete copy",
|
||||
"deleteAction": "Delete…",
|
||||
"deleteHint": "The data folder is kept by default.",
|
||||
"unlink": "Remove registration",
|
||||
"unlinkAction": "Remove…",
|
||||
"unlinkHint": "The launcher keeps the Steam game files and data folder in place.",
|
||||
"unlinkLocation": "Remove the launcher's registration for {{path}}? Steam game files and data will stay in place.",
|
||||
"deleteLocation": "Delete the game copy at {{path}}?",
|
||||
"deleteData": "Also delete the data folder at {{path}}",
|
||||
"confirm": "Confirm deletion",
|
||||
@@ -229,6 +236,7 @@
|
||||
"applying": "Applying changes"
|
||||
},
|
||||
"result": {
|
||||
"confirm-steam": "Steam locations confirmed.",
|
||||
"check": "Patch check complete.",
|
||||
"repair": "Original files restored.",
|
||||
"update": "Copy updated.",
|
||||
@@ -654,7 +662,8 @@
|
||||
"launch_lab_version": "The lab copy and the stock backup must use the same game version.",
|
||||
"launch_lab_failed": "The isolated launch failed. See the launcher log.",
|
||||
"launch_game_running": "Another game process is running.",
|
||||
"launch_copy_in_steam": "The launch requires a separate copy and data folder outside Steam.",
|
||||
"launch_copy_in_steam": "The development lab requires a copy and data folder outside Steam.",
|
||||
"launch_steam_confirmation_required": "Confirm the Steam locations in Copy Maintenance before launching.",
|
||||
"launch_location": "The game copy, stock backup, or data folder location is invalid.",
|
||||
"launch_stock_version": "The stock backup and game copy versions do not match.",
|
||||
"launch_build_failed": "The game files could not be generated.",
|
||||
@@ -667,7 +676,7 @@
|
||||
"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.",
|
||||
"steam_library_not_confirmed": "The copy or data 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.",
|
||||
|
||||
@@ -159,7 +159,10 @@
|
||||
"steam": {
|
||||
"inPlaceWarning": "离线启动会修改此 Steam 安装中的游戏文件。Steam 更新或文件校验可能覆盖改动。使用修改后的文件联网启动正版可能导致账号封禁。",
|
||||
"copyWarning": "目标文件夹位于 Steam 游戏库。建议将副本放在游戏库之外。",
|
||||
"confirm": "确认使用此文件夹"
|
||||
"confirm": "确认使用此文件夹",
|
||||
"dataWarning": "数据目录放在 Steam 游戏文件夹内时,在 Steam 中卸载游戏可能一并删除存档、缓存和日志。",
|
||||
"maintenanceWarning": "副本或数据目录位于 Steam 游戏库中。离线启动可能修改库内的游戏文件。Steam 更新或校验可能覆盖改动,使用修改后的文件联网启动可能导致账号封禁。在 Steam 中卸载游戏还可能删除保存在该游戏文件夹内的存档。",
|
||||
"confirmLocations": "确认使用这些位置"
|
||||
},
|
||||
"data": {
|
||||
"body": "选择用于保存存档、缓存和日志的文件夹。",
|
||||
@@ -220,6 +223,10 @@
|
||||
"delete": "删除副本",
|
||||
"deleteAction": "删除…",
|
||||
"deleteHint": "默认保留数据目录。",
|
||||
"unlink": "解除登记",
|
||||
"unlinkAction": "解除登记…",
|
||||
"unlinkHint": "Steam 游戏文件和数据目录将留在原处。",
|
||||
"unlinkLocation": "从启动器中解除 {{path}} 的登记?Steam 游戏文件和数据将留在原处。",
|
||||
"deleteLocation": "确认删除 {{path}} 中的游戏副本?",
|
||||
"deleteData": "同时删除 {{path}} 中的数据",
|
||||
"confirm": "确认删除",
|
||||
@@ -229,6 +236,7 @@
|
||||
"applying": "正在应用更改"
|
||||
},
|
||||
"result": {
|
||||
"confirm-steam": "已确认 Steam 目录。",
|
||||
"check": "补丁检查已完成。",
|
||||
"repair": "原版文件已还原。",
|
||||
"update": "副本已更新。",
|
||||
@@ -654,7 +662,8 @@
|
||||
"launch_lab_version": "实验副本和原版文件备份必须使用同一游戏版本。",
|
||||
"launch_lab_failed": "隔离启动失败。请查看启动器日志。",
|
||||
"launch_game_running": "已有游戏进程在运行。",
|
||||
"launch_copy_in_steam": "启动需使用 Steam 目录外的副本和数据目录。",
|
||||
"launch_copy_in_steam": "隔离实验需使用 Steam 目录外的副本和数据目录。",
|
||||
"launch_steam_confirmation_required": "请在副本维护中确认 Steam 目录后再启动。",
|
||||
"launch_location": "副本、原版文件备份或数据目录的位置无效。",
|
||||
"launch_stock_version": "原版文件备份的版本与副本不一致。",
|
||||
"launch_build_failed": "无法生成游戏文件。",
|
||||
@@ -667,7 +676,7 @@
|
||||
"folder_unreadable": "无法读取文件夹:{{path}}",
|
||||
"not_a_game_folder": "所选文件夹不是战争雷霆的安装文件夹:{{path}}",
|
||||
"target_not_usable": "所选文件夹不能用于安装。",
|
||||
"steam_library_not_confirmed": "安装位置位于 Steam 游戏库中,请先确认风险提示。",
|
||||
"steam_library_not_confirmed": "副本或数据目录位于 Steam 游戏库中,请先确认风险提示。",
|
||||
"not_enough_space": "磁盘空间不足:需要 {{neededGb}} GB,仅剩 {{freeGb}} GB。",
|
||||
"essential_patches_unavailable": "此游戏版本缺少离线版运行所必需的补丁,无法安装:{{patches}}",
|
||||
"missing_features_not_accepted": "部分补丁不适用,请先确认是否在缺少相应功能的情况下继续。",
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import type { IpcInput } from '@shared/ipc/contract.ts';
|
||||
import type { InstallRecord } from '@shared/schemas/install.ts';
|
||||
import type { MaintenanceInfo, MaintenanceProgress, MaintenanceRequest } from '@shared/schemas/maintenance.ts';
|
||||
import { ProgressBar } from '../../components/ProgressBar.tsx';
|
||||
import { Row } from '../../components/Row.tsx';
|
||||
import { Sheet } from '../../components/Sheet.tsx';
|
||||
import { formatBytes } from '../../format.ts';
|
||||
import { AppIpcError, ipcInvoke, ipcOn } from '../../ipc.ts';
|
||||
import { CopyMaintenanceActions, CopyRemoval, type CopyRemovalOptions } from './CopyMaintenanceControls.tsx';
|
||||
|
||||
interface CopyMaintenanceProps {
|
||||
readonly record: InstallRecord;
|
||||
@@ -14,14 +15,14 @@ interface CopyMaintenanceProps {
|
||||
}
|
||||
|
||||
type Operation = MaintenanceRequest['operation'];
|
||||
type OperationOptions = Pick<IpcInput<'copies:maintain'>, 'deleteData' | 'steamLocations'>;
|
||||
|
||||
export function CopyMaintenance({ record, onError }: CopyMaintenanceProps) {
|
||||
const { t, i18n } = useTranslation();
|
||||
const { t } = useTranslation();
|
||||
const [info, setInfo] = useState<MaintenanceInfo | null>(null);
|
||||
const [working, setWorking] = useState<Operation | null>(null);
|
||||
const [progress, setProgress] = useState<MaintenanceProgress | null>(null);
|
||||
const [confirming, setConfirming] = useState(false);
|
||||
const [deleteData, setDeleteData] = useState(false);
|
||||
const [removal, setRemoval] = useState<CopyRemovalOptions | null>(null);
|
||||
const [result, setResult] = useState<Operation | 'cancelled' | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -30,20 +31,20 @@ export function CopyMaintenance({ record, onError }: CopyMaintenanceProps) {
|
||||
if (mounted) setInfo(value);
|
||||
}).catch(onError);
|
||||
return () => { mounted = false; };
|
||||
}, [record.id, record.gameVersion, onError]);
|
||||
}, [record.id, record.gameVersion, record.steamLibraryConfirmation, onError]);
|
||||
|
||||
useEffect(() => ipcOn('event:copy-maintenance', (event) => {
|
||||
if (event.id === record.id) setProgress(event);
|
||||
}), [record.id]);
|
||||
|
||||
const run = (operation: Operation): void => {
|
||||
const run = (operation: Operation, options: OperationOptions = {}): void => {
|
||||
setResult(null);
|
||||
setWorking(operation);
|
||||
setProgress(null);
|
||||
ipcInvoke('copies:maintain', { id: record.id, operation, deleteData: operation === 'delete' && deleteData })
|
||||
ipcInvoke('copies:maintain', { id: record.id, operation, ...options })
|
||||
.then(() => {
|
||||
setResult(operation);
|
||||
setConfirming(false);
|
||||
setRemoval(null);
|
||||
})
|
||||
.catch((error: unknown) => {
|
||||
if (error instanceof AppIpcError && error.code === 'maintenance_cancelled') setResult('cancelled');
|
||||
@@ -52,69 +53,54 @@ export function CopyMaintenance({ record, onError }: CopyMaintenanceProps) {
|
||||
.finally(() => setWorking(null));
|
||||
};
|
||||
|
||||
const busy = working !== null;
|
||||
return (
|
||||
<Sheet title={t('copies.sections.maintain')} aside={record.name}>
|
||||
<Row label={t('copies.maintenance.update')} hint={info?.sourceVersion
|
||||
? t(info.updateAvailable
|
||||
? (record.hardlinkedFiles?.length ? 'copies.maintenance.updateDetaches' : 'copies.maintenance.newVersion')
|
||||
: 'copies.maintenance.currentVersion', { version: info.sourceVersion })
|
||||
: t('copies.maintenance.noSource')}>
|
||||
<button type="button" className={info?.updateAvailable ? 'button button-primary' : 'button'}
|
||||
disabled={working !== null || !info?.updateAvailable} onClick={() => run('update')}>
|
||||
{t('copies.maintenance.updateAction')}
|
||||
</button>
|
||||
</Row>
|
||||
<Row label={t('copies.maintenance.spaceSaving')} hint={info?.spaceSavingAvailable
|
||||
? t('copies.maintenance.spaceSavingHint') : t('copies.maintenance.spaceSavingUnavailable')}>
|
||||
<button type="button" className="button" disabled={working !== null || !info?.spaceSavingAvailable}
|
||||
onClick={() => run('compact')}>{t('copies.maintenance.compactAction')}</button>
|
||||
</Row>
|
||||
<Row label={t('copies.maintenance.check')} hint={record.lastCheckedAt
|
||||
? t('copies.maintenance.lastCheck', { date: new Date(record.lastCheckedAt).toLocaleString(i18n.language) })
|
||||
: t('copies.maintenance.checkHint')}>
|
||||
<button type="button" className="button" disabled={working !== null} onClick={() => run('check')}>
|
||||
{t('copies.maintenance.check')}
|
||||
</button>
|
||||
</Row>
|
||||
<Row label={t('copies.maintenance.repair')} hint={t('copies.maintenance.repairHint')}>
|
||||
<button type="button" className="button" disabled={working !== null} onClick={() => run('repair')}>
|
||||
{t('copies.maintenance.repairAction')}
|
||||
</button>
|
||||
</Row>
|
||||
<Row label={t('copies.maintenance.delete')} hint={t('copies.maintenance.deleteHint')}>
|
||||
<button type="button" className="button" disabled={working !== null} onClick={() => {
|
||||
setConfirming(true);
|
||||
setDeleteData(false);
|
||||
}}>{t('copies.maintenance.deleteAction')}</button>
|
||||
</Row>
|
||||
{confirming && (
|
||||
<section className="maintenance-confirm" role="group" aria-label={t('copies.maintenance.confirm')}>
|
||||
<p>{t('copies.maintenance.deleteLocation', { path: record.copyPath })}</p>
|
||||
<label className="check">
|
||||
<input type="checkbox" checked={deleteData} disabled={working !== null} onChange={(event) => setDeleteData(event.target.checked)} />
|
||||
{t('copies.maintenance.deleteData', { path: record.dataPath })}
|
||||
</label>
|
||||
<div className="copy-list-actions">
|
||||
<button type="button" className="button" disabled={working !== null} onClick={() => setConfirming(false)}>{t('wizard.cancel')}</button>
|
||||
<button type="button" className="button button-primary" disabled={working !== null} onClick={() => run('delete')}>
|
||||
{t('copies.maintenance.confirm')}
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
)}
|
||||
<CopyMaintenanceActions
|
||||
record={record}
|
||||
info={info}
|
||||
busy={busy}
|
||||
onRun={run}
|
||||
onConfirmSteam={(steamLocations) => run('confirm-steam', { steamLocations })}
|
||||
/>
|
||||
<CopyRemoval
|
||||
record={record}
|
||||
info={info}
|
||||
busy={busy}
|
||||
options={removal}
|
||||
onOptionsChange={setRemoval}
|
||||
onRemove={(deleteData) => run('delete', { deleteData })}
|
||||
/>
|
||||
{working && (
|
||||
<div className="maintenance-progress" role="status">
|
||||
<p>{t(`copies.maintenance.phase.${progress?.phase ?? 'checking'}`)}</p>
|
||||
<ProgressBar value={progress?.doneBytes ?? 0} max={progress?.totalBytes || null} />
|
||||
{progress?.totalBytes ? <p className="small">{formatBytes(progress.doneBytes)} / {formatBytes(progress.totalBytes)}</p> : null}
|
||||
{(working === 'update' || working === 'compact') && progress?.phase !== 'applying' && (
|
||||
<button type="button" className="button" onClick={() => ipcInvoke('copies:cancelMaintenance').catch(onError)}>
|
||||
{t('wizard.cancel')}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
<MaintenanceStatus
|
||||
operation={working}
|
||||
progress={progress}
|
||||
onCancel={() => ipcInvoke('copies:cancelMaintenance').catch(onError)}
|
||||
/>
|
||||
)}
|
||||
{result && <p className="small" role="status">{t(`copies.maintenance.result.${result}`)}</p>}
|
||||
</Sheet>
|
||||
);
|
||||
}
|
||||
|
||||
interface MaintenanceStatusProps {
|
||||
readonly operation: Operation;
|
||||
readonly progress: MaintenanceProgress | null;
|
||||
readonly onCancel: () => void;
|
||||
}
|
||||
|
||||
function MaintenanceStatus({ operation, progress, onCancel }: MaintenanceStatusProps) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<div className="maintenance-progress" role="status">
|
||||
<p>{t(`copies.maintenance.phase.${progress?.phase ?? 'checking'}`)}</p>
|
||||
<ProgressBar value={progress?.doneBytes ?? 0} max={progress?.totalBytes || null} />
|
||||
{progress?.totalBytes ? <p className="small">{formatBytes(progress.doneBytes)} / {formatBytes(progress.totalBytes)}</p> : null}
|
||||
{(operation === 'update' || operation === 'compact') && progress?.phase !== 'applying' && (
|
||||
<button type="button" className="button" onClick={onCancel}>
|
||||
{t('wizard.cancel')}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import type { InstallRecord } from '@shared/schemas/install.ts';
|
||||
import type { MaintenanceInfo, MaintenanceRequest } from '@shared/schemas/maintenance.ts';
|
||||
import { Notice } from '../../components/Notice.tsx';
|
||||
import { Row } from '../../components/Row.tsx';
|
||||
|
||||
interface CopyMaintenanceControlsProps {
|
||||
readonly record: InstallRecord;
|
||||
readonly info: MaintenanceInfo | null;
|
||||
readonly busy: boolean;
|
||||
}
|
||||
|
||||
interface CopyMaintenanceActionsProps extends CopyMaintenanceControlsProps {
|
||||
readonly onRun: (operation: 'update' | 'compact' | 'check' | 'repair') => void;
|
||||
readonly onConfirmSteam: (locations: NonNullable<MaintenanceRequest['steamLocations']>) => void;
|
||||
}
|
||||
|
||||
export function CopyMaintenanceActions({ record, info, busy, onRun, onConfirmSteam }: CopyMaintenanceActionsProps) {
|
||||
const { t, i18n } = useTranslation();
|
||||
const steam = info?.steamLocations;
|
||||
return (
|
||||
<>
|
||||
{info?.steamConfirmationRequired && steam && (
|
||||
<Notice tone="warning">
|
||||
<p>{t('steam.maintenanceWarning')}</p>
|
||||
<p className="small">{steam.copyPath}<br />{steam.dataPath}</p>
|
||||
<button type="button" className="button" disabled={busy}
|
||||
onClick={() => onConfirmSteam({ copyPath: steam.copyPath, dataPath: steam.dataPath })}>
|
||||
{t('steam.confirmLocations')}
|
||||
</button>
|
||||
</Notice>
|
||||
)}
|
||||
<Row label={t('copies.maintenance.update')} hint={info?.sourceVersion
|
||||
? t(info.updateAvailable
|
||||
? (record.hardlinkedFiles?.length ? 'copies.maintenance.updateDetaches' : 'copies.maintenance.newVersion')
|
||||
: 'copies.maintenance.currentVersion', { version: info.sourceVersion })
|
||||
: t('copies.maintenance.noSource')}>
|
||||
<button type="button" className={info?.updateAvailable ? 'button button-primary' : 'button'}
|
||||
disabled={busy || !info?.updateAvailable} onClick={() => onRun('update')}>
|
||||
{t('copies.maintenance.updateAction')}
|
||||
</button>
|
||||
</Row>
|
||||
<Row label={t('copies.maintenance.spaceSaving')} hint={info?.spaceSavingAvailable
|
||||
? t('copies.maintenance.spaceSavingHint') : t('copies.maintenance.spaceSavingUnavailable')}>
|
||||
<button type="button" className="button" disabled={busy || !info?.spaceSavingAvailable}
|
||||
onClick={() => onRun('compact')}>{t('copies.maintenance.compactAction')}</button>
|
||||
</Row>
|
||||
<Row label={t('copies.maintenance.check')} hint={record.lastCheckedAt
|
||||
? t('copies.maintenance.lastCheck', { date: new Date(record.lastCheckedAt).toLocaleString(i18n.language) })
|
||||
: t('copies.maintenance.checkHint')}>
|
||||
<button type="button" className="button" disabled={busy} onClick={() => onRun('check')}>
|
||||
{t('copies.maintenance.check')}
|
||||
</button>
|
||||
</Row>
|
||||
<Row label={t('copies.maintenance.repair')} hint={t('copies.maintenance.repairHint')}>
|
||||
<button type="button" className="button" disabled={busy} onClick={() => onRun('repair')}>
|
||||
{t('copies.maintenance.repairAction')}
|
||||
</button>
|
||||
</Row>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export interface CopyRemovalOptions {
|
||||
readonly deleteData: boolean;
|
||||
}
|
||||
|
||||
interface CopyRemovalProps extends CopyMaintenanceControlsProps {
|
||||
readonly options: CopyRemovalOptions | null;
|
||||
readonly onOptionsChange: (options: CopyRemovalOptions | null) => void;
|
||||
readonly onRemove: (deleteData: boolean) => void;
|
||||
}
|
||||
|
||||
export function CopyRemoval({ record, info, busy, options, onOptionsChange, onRemove }: CopyRemovalProps) {
|
||||
const { t } = useTranslation();
|
||||
const steam = info?.steamLocations;
|
||||
const unlinkOnly = steam?.copyInSteam === true;
|
||||
const canDeleteData = !unlinkOnly && !steam?.dataInSteam;
|
||||
const action = t(unlinkOnly ? 'copies.maintenance.unlink' : 'copies.maintenance.confirm');
|
||||
|
||||
return (
|
||||
<>
|
||||
<Row label={t(unlinkOnly ? 'copies.maintenance.unlink' : 'copies.maintenance.delete')}
|
||||
hint={t(unlinkOnly ? 'copies.maintenance.unlinkHint' : 'copies.maintenance.deleteHint')}>
|
||||
<button type="button" className="button" disabled={busy || !info}
|
||||
onClick={() => onOptionsChange({ deleteData: false })}>
|
||||
{t(unlinkOnly ? 'copies.maintenance.unlinkAction' : 'copies.maintenance.deleteAction')}
|
||||
</button>
|
||||
</Row>
|
||||
{options && (
|
||||
<section className="maintenance-confirm" role="group" aria-label={action}>
|
||||
<p>{t(unlinkOnly ? 'copies.maintenance.unlinkLocation' : 'copies.maintenance.deleteLocation', { path: steam?.copyPath ?? record.copyPath })}</p>
|
||||
{canDeleteData && (
|
||||
<label className="check">
|
||||
<input type="checkbox" checked={options.deleteData} disabled={busy}
|
||||
onChange={(event) => onOptionsChange({ deleteData: event.target.checked })} />
|
||||
{t('copies.maintenance.deleteData', { path: record.dataPath })}
|
||||
</label>
|
||||
)}
|
||||
<div className="copy-list-actions">
|
||||
<button type="button" className="button" disabled={busy} onClick={() => onOptionsChange(null)}>{t('wizard.cancel')}</button>
|
||||
<button type="button" className="button button-primary" disabled={busy} onClick={() => onRemove(canDeleteData && options.deleteData)}>
|
||||
{action}
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,22 +1,36 @@
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { FolderField } from '../../components/FolderField.tsx';
|
||||
import { Notice } from '../../components/Notice.tsx';
|
||||
import { Row } from '../../components/Row.tsx';
|
||||
|
||||
interface DataStepProps {
|
||||
readonly dataPath: string;
|
||||
readonly decalSource: string | null;
|
||||
readonly steamDataPath: string | null;
|
||||
readonly steamDataConfirmed: boolean;
|
||||
readonly onSteamDataConfirmed: (confirmed: boolean) => void;
|
||||
readonly onDecalSource: (path: string | null) => void;
|
||||
readonly onDataPath: (path: string) => void;
|
||||
readonly onError: (error: unknown) => void;
|
||||
}
|
||||
|
||||
/** Step 3: where saves, caches and logs of the offline version are kept. */
|
||||
export function DataStep({ dataPath, decalSource, onDataPath, onDecalSource, onError }: DataStepProps) {
|
||||
export function DataStep({ dataPath, decalSource, steamDataPath, steamDataConfirmed, onSteamDataConfirmed, onDataPath, onDecalSource, onError }: DataStepProps) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<>
|
||||
<p className="lead">{t('data.body')}</p>
|
||||
<FolderField path={dataPath} dialogTitle={t('data.dialogTitle')} onChosen={onDataPath} onError={onError} />
|
||||
{steamDataPath && (
|
||||
<Notice tone="warning">
|
||||
<p>{t('steam.dataWarning')}</p>
|
||||
<p className="small">{steamDataPath}</p>
|
||||
<label className="check">
|
||||
<input type="checkbox" checked={steamDataConfirmed} onChange={(event) => onSteamDataConfirmed(event.target.checked)} />
|
||||
{t('steam.confirm')}
|
||||
</label>
|
||||
</Notice>
|
||||
)}
|
||||
<Row label={t('decals.source')} hint={t('decals.hint')}>
|
||||
<FolderField path={decalSource} dialogTitle={t('decals.choose')} onChosen={onDecalSource} onError={onError} />
|
||||
{decalSource && <button type="button" className="button" onClick={() => onDecalSource(null)}>{t('decals.useDefault')}</button>}
|
||||
|
||||
@@ -34,8 +34,10 @@ export function MethodStep({ source, sourceSize, choice, onChoice, onError }: Me
|
||||
.then((target) => onChoice((current) => ({ ...current, target, steamConfirmed: false })))
|
||||
.catch(onError);
|
||||
};
|
||||
const steamWarning = steamLibraryInvolved(source, choice)
|
||||
? <SteamWarning method={choice.method} confirmed={choice.steamConfirmed} onConfirmed={(steamConfirmed) => onChoice({ ...choice, steamConfirmed })} />
|
||||
const folder = choice.method === 'in-place' ? source : choice.target;
|
||||
const steamWarning = folder?.inSteamLibrary
|
||||
? <SteamWarning method={choice.method} path={folder.resolvedPath} confirmed={choice.steamConfirmed}
|
||||
onConfirmed={(steamConfirmed) => onChoice({ ...choice, steamConfirmed })} />
|
||||
: null;
|
||||
const targetPicker = (
|
||||
<>
|
||||
@@ -120,11 +122,12 @@ function TargetVerdict({ target, sourceSize, method }: {
|
||||
: <Notice tone="info">{t('method.room', { free: formatBytes(target.freeBytes) })}</Notice>;
|
||||
}
|
||||
|
||||
function SteamWarning({ method, confirmed, onConfirmed }: { readonly method: Method; readonly confirmed: boolean; readonly onConfirmed: (confirmed: boolean) => void }) {
|
||||
function SteamWarning({ method, path, confirmed, onConfirmed }: { readonly method: Method; readonly path: string; readonly confirmed: boolean; readonly onConfirmed: (confirmed: boolean) => void }) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<Notice tone="warning">
|
||||
<p>{t(method === 'in-place' ? 'steam.inPlaceWarning' : 'steam.copyWarning')}</p>
|
||||
<p className="small">{path}</p>
|
||||
<label className="check">
|
||||
<input type="checkbox" checked={confirmed} onChange={(event) => onConfirmed(event.target.checked)} />
|
||||
{t('steam.confirm')}
|
||||
|
||||
@@ -28,6 +28,9 @@ export function WizardMain({ wizard, supportedVersions }: { readonly wizard: Ins
|
||||
{step === 'data' && (
|
||||
<DataStep
|
||||
dataPath={wizard.dataPath}
|
||||
steamDataPath={wizard.steamDataPath}
|
||||
steamDataConfirmed={wizard.steamDataConfirmed}
|
||||
onSteamDataConfirmed={wizard.setSteamDataConfirmed}
|
||||
decalSource={wizard.decalSource}
|
||||
onDataPath={wizard.setDataPath}
|
||||
onDecalSource={wizard.setDecalSource}
|
||||
|
||||
@@ -30,6 +30,7 @@ export function useInstallWizard({ onInstalled }: WizardOptions) {
|
||||
const [draftId, setDraftId] = useState<string | null>(null);
|
||||
const [name, setName] = useState('');
|
||||
const [dataPath, setDataPath] = useState('');
|
||||
const [dataInspection, setDataInspection] = useState<{ picked: string; path: string; inSteam: boolean; confirmed: boolean } | null>(null);
|
||||
const [decalSource, setDecalSource] = useState<string | null>(null);
|
||||
const [check, setCheck] = useState<PatchCheck | null>(null);
|
||||
const [missingAccepted, setMissingAccepted] = useState(false);
|
||||
@@ -49,6 +50,26 @@ export function useInstallWizard({ onInstalled }: WizardOptions) {
|
||||
};
|
||||
}, [source, report]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!active || !dataPath) return;
|
||||
let current = true;
|
||||
ipcInvoke('install:inspectDataFolder', { path: dataPath })
|
||||
.then(({ path, inSteam }) => {
|
||||
if (!current) return;
|
||||
setDataInspection((previous) => previous?.picked === dataPath && previous.path === path && previous.inSteam === inSteam
|
||||
? previous
|
||||
: { picked: dataPath, path, inSteam, confirmed: false });
|
||||
})
|
||||
.catch((error: unknown) => current && report(error));
|
||||
return () => { current = false; };
|
||||
}, [active, dataPath, report]);
|
||||
|
||||
const dataChecked = dataInspection?.picked === dataPath ? dataInspection : null;
|
||||
const dataReady = dataChecked !== null && (!dataChecked.inSteam || dataChecked.confirmed);
|
||||
const setSteamDataConfirmed = (confirmed: boolean): void => {
|
||||
setDataInspection((inspection) => inspection ? { ...inspection, confirmed } : null);
|
||||
};
|
||||
|
||||
// The check runs every time the step is entered: the choices before it may have changed.
|
||||
useEffect(() => {
|
||||
if (!active || step !== 'check' || !sourceUsable(source)) return;
|
||||
@@ -77,6 +98,7 @@ export function useInstallWizard({ onInstalled }: WizardOptions) {
|
||||
setName('');
|
||||
setDraftId(null);
|
||||
setDataPath('');
|
||||
setDataInspection(null);
|
||||
setDecalSource(null);
|
||||
setActive(true);
|
||||
ipcInvoke('install:prepareCopy').then(({ id, dataPath: folder }) => {
|
||||
@@ -92,10 +114,13 @@ export function useInstallWizard({ onInstalled }: WizardOptions) {
|
||||
};
|
||||
|
||||
const install = (): void => {
|
||||
if (!sourceUsable(source) || !draftId) return;
|
||||
if (!sourceUsable(source) || !draftId || !dataReady) return;
|
||||
const copyFolder = choice.method === 'in-place' ? source : choice.target;
|
||||
const choices = {
|
||||
id: draftId, name, dataPath,
|
||||
steamLibraryConfirmed: choice.steamConfirmed, missingFeaturesAccepted: missingAccepted,
|
||||
...(choice.steamConfirmed && copyFolder ? { confirmedSteamCopyPath: copyFolder.resolvedPath } : {}),
|
||||
...(dataChecked.confirmed ? { confirmedSteamDataPath: dataChecked.path } : {}),
|
||||
missingFeaturesAccepted: missingAccepted,
|
||||
...(decalSource ? { decalSourcePath: decalSource } : {}),
|
||||
};
|
||||
const request: InstallRequest = choice.method === 'in-place'
|
||||
@@ -120,8 +145,8 @@ export function useInstallWizard({ onInstalled }: WizardOptions) {
|
||||
switch (step) {
|
||||
case 'source': return draftId !== null && sourceUsable(source);
|
||||
case 'method': return name.trim().length > 0 && sourceUsable(source) && methodUsable(source, sourceSize, choice);
|
||||
case 'data': return dataPath.length > 0;
|
||||
case 'check': return checkUsable(check, missingAccepted);
|
||||
case 'data': return dataReady;
|
||||
case 'check': return dataReady && checkUsable(check, missingAccepted);
|
||||
case 'installing': return false;
|
||||
}
|
||||
})();
|
||||
@@ -148,7 +173,8 @@ export function useInstallWizard({ onInstalled }: WizardOptions) {
|
||||
|
||||
return {
|
||||
active, step, index, source, sourceSize, choice, name, dataPath, decalSource, check, missingAccepted, progress, cancelling, message, canGoOn,
|
||||
start, back, next, cancel, report, chooseSource, setChoice, setName, setDataPath, setDecalSource, setMissingAccepted,
|
||||
steamDataPath: dataChecked?.inSteam ? dataChecked.path : null, steamDataConfirmed: dataChecked?.confirmed ?? false,
|
||||
start, back, next, cancel, report, chooseSource, setChoice, setName, setDataPath, setSteamDataConfirmed, setDecalSource, setMissingAccepted,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user