feat(launcher): detect missing client folders and support relocating while keeping saves
This commit is contained in:
1 parent
2820d40d87
commit
a0515c4ed3
12 files changed
+199
-20
No files matched your search
@@ -72,10 +72,17 @@ export function App({ info, initialSettings, initialCopies }: AppProps) {
|
||||
|
||||
const wizard = useInstallWizard({ onInstalled: () => setRoute(START_ROUTE) });
|
||||
|
||||
const backgrounds = useBackgrounds(record?.copyPath ?? null, settings, report);
|
||||
const backgrounds = useBackgrounds(record && !record.folderMissing ? record.copyPath : null, settings, report);
|
||||
|
||||
useEffect(() => ipcOn('event:settings-changed', setSettings), []);
|
||||
useEffect(() => ipcOn('event:copies-changed', setRegistry), []);
|
||||
useEffect(() => {
|
||||
const refreshCopies = (): void => {
|
||||
ipcInvoke('copies:list').then(setRegistry).catch(() => undefined);
|
||||
};
|
||||
window.addEventListener('focus', refreshCopies);
|
||||
return () => window.removeEventListener('focus', refreshCopies);
|
||||
}, []);
|
||||
useEffect(() => applyLanguage(resolveLanguage(settings.language, info.systemLocale)), [settings.language, info.systemLocale]);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -106,12 +113,22 @@ export function App({ info, initialSettings, initialCopies }: AppProps) {
|
||||
if (details) go({ page: 'copies', section: 'summary' });
|
||||
}).catch(report);
|
||||
};
|
||||
const relocateCopy = (id: string): void => {
|
||||
clearError();
|
||||
ipcInvoke('dialog:pickFolder', { title: t('copies.relocateDialogTitle') })
|
||||
.then(({ path }) => {
|
||||
if (!path) return;
|
||||
return ipcInvoke('copies:relocate', { id, path }).then(setRegistry);
|
||||
})
|
||||
.catch(report);
|
||||
};
|
||||
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'), {
|
||||
start: () => { ipcInvoke('launch:start').catch(report); },
|
||||
stop: () => { ipcInvoke('launch:stop').catch(report); },
|
||||
checkVersion: () => go({ page: 'copies', section: 'features' }),
|
||||
relocate: () => { if (record) relocateCopy(record.id); },
|
||||
});
|
||||
|
||||
const view = ((): View => {
|
||||
@@ -168,7 +185,16 @@ export function App({ info, initialSettings, initialCopies }: AppProps) {
|
||||
if (route.copies === 'list') {
|
||||
return {
|
||||
side,
|
||||
main: <CopyList registry={registry} supportedVersions={supported} onSelect={selectCopy} onAdd={() => wizard.start('new')} onAddExisting={() => wizard.start('existing')} />,
|
||||
main: (
|
||||
<CopyList
|
||||
registry={registry}
|
||||
supportedVersions={supported}
|
||||
onSelect={selectCopy}
|
||||
onRelocate={relocateCopy}
|
||||
onAdd={() => wizard.start('new')}
|
||||
onAddExisting={() => wizard.start('existing')}
|
||||
/>
|
||||
),
|
||||
bar: home,
|
||||
};
|
||||
}
|
||||
@@ -192,7 +218,15 @@ export function App({ info, initialSettings, initialCopies }: AppProps) {
|
||||
}
|
||||
const main = route.copies === 'features'
|
||||
? <FeatureStatus record={record} supportedVersions={supported} onError={report} />
|
||||
: <CopySummary record={record} supportedVersions={supported} onShowFeatures={() => go({ page: 'copies', section: 'features' })} onError={report} />;
|
||||
: (
|
||||
<CopySummary
|
||||
record={record}
|
||||
supportedVersions={supported}
|
||||
onShowFeatures={() => go({ page: 'copies', section: 'features' })}
|
||||
onRelocate={() => relocateCopy(record.id)}
|
||||
onError={report}
|
||||
/>
|
||||
);
|
||||
return { side, main, bar: home };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,6 +67,7 @@
|
||||
"ready": "Ready",
|
||||
"readyMissing": "Ready · {{count}} features unavailable",
|
||||
"readyDetail": "Game {{version}}",
|
||||
"missingFolder": "Client folder not found",
|
||||
"launch": "Launch"
|
||||
},
|
||||
"launch": {
|
||||
@@ -215,6 +216,9 @@
|
||||
},
|
||||
"add": "Add a client",
|
||||
"addExisting": "Add existing client",
|
||||
"missingFolder": "Folder missing",
|
||||
"relocate": "Relocate…",
|
||||
"relocateDialogTitle": "Select the moved client folder",
|
||||
"list": { "current": "Current", "select": "Set as current" },
|
||||
"none": "The offline edition is not installed yet.",
|
||||
"maintenance": {
|
||||
@@ -267,6 +271,7 @@
|
||||
"adaptation": "Check status",
|
||||
"adaptationHint": "Whether every patch was checked on this game version and verified in game",
|
||||
"location": "Location",
|
||||
"missingHint": "Game files were not found at this path. Relocate to the moved folder to keep existing saves and tuning.",
|
||||
"method": "Installation type",
|
||||
"methods": {
|
||||
"copy": "Copy installation",
|
||||
|
||||
@@ -67,6 +67,7 @@
|
||||
"ready": "就绪",
|
||||
"readyMissing": "就绪 · {{count}} 项功能不可用",
|
||||
"readyDetail": "游戏 {{version}}",
|
||||
"missingFolder": "客户端目录不存在",
|
||||
"launch": "启动"
|
||||
},
|
||||
"launch": {
|
||||
@@ -215,6 +216,9 @@
|
||||
},
|
||||
"add": "添加客户端",
|
||||
"addExisting": "添加已有客户端",
|
||||
"missingFolder": "目录不存在",
|
||||
"relocate": "重新定位…",
|
||||
"relocateDialogTitle": "选择挪动后的客户端文件夹",
|
||||
"list": { "current": "当前", "select": "设为当前" },
|
||||
"none": "尚未安装离线版。",
|
||||
"maintenance": {
|
||||
@@ -267,6 +271,7 @@
|
||||
"adaptation": "核对状态",
|
||||
"adaptationHint": "这个游戏版本是否检查过全部补丁并在游戏里验证过",
|
||||
"location": "位置",
|
||||
"missingHint": "未在原位置找到游戏文件。可重新定位至挪动后的文件夹,保留现有存档和数值。",
|
||||
"method": "安装方式",
|
||||
"methods": {
|
||||
"copy": "复制安装",
|
||||
|
||||
@@ -7,11 +7,12 @@ interface CopyListProps {
|
||||
readonly registry: Copies;
|
||||
readonly supportedVersions: readonly string[];
|
||||
readonly onSelect: (id: string, detail?: boolean) => void;
|
||||
readonly onRelocate: (id: string) => void;
|
||||
readonly onAdd: () => void;
|
||||
readonly onAddExisting: () => void;
|
||||
}
|
||||
|
||||
export function CopyList({ registry, supportedVersions, onSelect, onAdd, onAddExisting }: CopyListProps) {
|
||||
export function CopyList({ registry, supportedVersions, onSelect, onRelocate, onAdd, onAddExisting }: CopyListProps) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<Sheet title={t('copies.sections.list')}>
|
||||
@@ -25,6 +26,7 @@ export function CopyList({ registry, supportedVersions, onSelect, onAdd, onAddEx
|
||||
<div className="copy-list-heading">
|
||||
<strong>{copy.name}</strong>
|
||||
{current && <span className="ok">{t('copies.list.current')}</span>}
|
||||
{copy.folderMissing && <span className="warn">{t('copies.missingFolder')}</span>}
|
||||
</div>
|
||||
<dl className="kv">
|
||||
<dt>{t('copies.summary.version')}</dt>
|
||||
@@ -39,7 +41,14 @@ export function CopyList({ registry, supportedVersions, onSelect, onAdd, onAddEx
|
||||
<dd className="folder-path" data-ellipsis-tip={copy.copyPath}>{copy.copyPath}</dd>
|
||||
</dl>
|
||||
<div className="copy-list-actions">
|
||||
{!current && <button type="button" className="button button-primary" onClick={() => onSelect(copy.id)}>{t('copies.list.select')}</button>}
|
||||
{copy.folderMissing && (
|
||||
<button type="button" className="button button-primary" onClick={() => onRelocate(copy.id)}>{t('copies.relocate')}</button>
|
||||
)}
|
||||
{!current && (
|
||||
<button type="button" className={copy.folderMissing ? 'button' : 'button button-primary'} onClick={() => onSelect(copy.id)}>
|
||||
{t('copies.list.select')}
|
||||
</button>
|
||||
)}
|
||||
<button type="button" className="button" onClick={() => onSelect(copy.id, true)}>{t('side.details')}</button>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
@@ -11,11 +11,12 @@ interface CopySummaryProps {
|
||||
readonly record: InstallRecord;
|
||||
readonly supportedVersions: readonly string[];
|
||||
readonly onShowFeatures: () => void;
|
||||
readonly onRelocate: () => void;
|
||||
readonly onError: (error: unknown) => void;
|
||||
}
|
||||
|
||||
/** What is installed where: version, adaptation, folders, installation type. */
|
||||
export function CopySummary({ record, supportedVersions, onShowFeatures, onError }: CopySummaryProps) {
|
||||
export function CopySummary({ record, supportedVersions, onShowFeatures, onRelocate, onError }: CopySummaryProps) {
|
||||
const { t, i18n } = useTranslation();
|
||||
const [name, setName] = useState(record.name);
|
||||
const [importing, setImporting] = useState(false);
|
||||
@@ -52,7 +53,18 @@ export function CopySummary({ record, supportedVersions, onShowFeatures, onError
|
||||
<Row label={t('copies.summary.adaptation')} hint={t('copies.summary.adaptationHint')}>
|
||||
<span className={verified ? 'ok' : 'warn'}>{verified ? t('adaptation.verified') : t('adaptation.unverified')}</span>
|
||||
</Row>
|
||||
<Row label={t('copies.summary.location')}>{folder(record.copyPath)}</Row>
|
||||
<Row label={t('copies.summary.location')} hint={record.folderMissing ? t('copies.summary.missingHint') : undefined}>
|
||||
<span className="folder-path" data-ellipsis-tip={record.copyPath}>{record.copyPath}</span>
|
||||
{record.folderMissing && <span className="warn">{t('copies.missingFolder')}</span>}
|
||||
<button type="button" className={record.folderMissing ? 'button button-primary' : 'button'} onClick={onRelocate}>
|
||||
{t('copies.relocate')}
|
||||
</button>
|
||||
{!record.folderMissing && (
|
||||
<button type="button" className="button" onClick={() => ipcInvoke('app:openFolder', { path: record.copyPath }).catch(onError)}>
|
||||
{t('copies.summary.open')}
|
||||
</button>
|
||||
)}
|
||||
</Row>
|
||||
<Row label={t('copies.summary.method')}>{t(`copies.summary.methods.${record.hardlinkedFiles?.length ? 'hardlink' : record.method}`)}</Row>
|
||||
{record.sourcePath && <Row label={t('copies.summary.source')}>{folder(record.sourcePath)}</Row>}
|
||||
<Row label={t('copies.summary.stock')} hint={t('copies.summary.stockHint')}>{folder(record.stockBackupPath)}</Row>
|
||||
|
||||
@@ -39,7 +39,10 @@ export function HomeSide({ record, copies, supportedVersions, onNavigate, onSele
|
||||
<>
|
||||
<h3 className="side-heading">{t('side.currentCopy')}</h3>
|
||||
<button type="button" className="copy-card copy-card-button" aria-expanded={choosingCopy} onClick={() => setChoosingCopy(!choosingCopy)}>
|
||||
<span className="copy-card-name">{record.name}</span>
|
||||
<span className="copy-card-name">
|
||||
{record.name}
|
||||
{record.folderMissing && <> · <span className="warn">{t('copies.missingFolder')}</span></>}
|
||||
</span>
|
||||
<span className="copy-card-meta" data-ellipsis-tip={`${record.gameVersion ?? t('source.versionUnknown')} · ${record.copyPath}`}>
|
||||
{record.gameVersion ?? t('source.versionUnknown')} · {record.copyPath}
|
||||
</span>
|
||||
@@ -51,7 +54,7 @@ export function HomeSide({ record, copies, supportedVersions, onNavigate, onSele
|
||||
setChoosingCopy(false);
|
||||
onSelectCopy(copy.id);
|
||||
}}>
|
||||
{copy.name} · {copy.gameVersion ?? t('source.versionUnknown')}
|
||||
{copy.name} · {copy.folderMissing ? t('copies.missingFolder') : (copy.gameVersion ?? t('source.versionUnknown'))}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@@ -8,6 +8,7 @@ interface LaunchActions {
|
||||
readonly start: () => void;
|
||||
readonly stop: () => void;
|
||||
readonly checkVersion: () => void;
|
||||
readonly relocate: () => void;
|
||||
}
|
||||
|
||||
/** The installation and launch actions shown outside the wizard. */
|
||||
@@ -90,6 +91,14 @@ export function homeBar(
|
||||
primary: { label: t('bar.install'), onClick: onInstall },
|
||||
};
|
||||
}
|
||||
if (record.folderMissing) {
|
||||
return {
|
||||
tone: 'bad',
|
||||
title: t('bar.missingFolder'),
|
||||
detail: record.copyPath,
|
||||
primary: { label: t('copies.relocate'), onClick: actions.relocate },
|
||||
};
|
||||
}
|
||||
const missing = missingFeatures(record).length;
|
||||
return {
|
||||
tone: missing ? 'warn' : 'ok',
|
||||
|
||||
Reference in new issue
Block a user