feat(decals): import a decal cache for each copy
Store the chosen cache in the copy data directory and use it for future builds. Restore the placeholder index when the copy has no available cache. Verified type checks, the launcher build, a temporary .43 build, and the import and replacement flow from the Windows package.
This commit is contained in:
1 parent
10839f050f
commit
1e3843b7e9
18 files changed
+304
-53
No files matched your search
@@ -88,6 +88,15 @@
|
||||
"port-busy": "Port {{port}} is already in use",
|
||||
"server-exited": "The local server exited unexpectedly"
|
||||
},
|
||||
"decals": {
|
||||
"source": "Decal source",
|
||||
"hint": "Import the game's cache/content folder. The copy uses placeholder decals when no cache is available.",
|
||||
"choose": "Choose decal cache…",
|
||||
"useDefault": "Use placeholder decals",
|
||||
"importing": "Importing decal cache",
|
||||
"imported": "Imported cache",
|
||||
"default": "Placeholder decals"
|
||||
},
|
||||
"folder": {
|
||||
"none": "Not selected",
|
||||
"choose": "Browse…",
|
||||
@@ -165,6 +174,7 @@
|
||||
"measuring": "Counting files",
|
||||
"verifying": "Verifying resources to share",
|
||||
"copying": "Copying game files",
|
||||
"importing-decals": "Importing decal cache",
|
||||
"backing-up": "Backing up original files",
|
||||
"recording": "Finishing installation"
|
||||
},
|
||||
@@ -597,6 +607,8 @@
|
||||
"copy_not_found": "The selected copy is no longer available.",
|
||||
"copies_write_failed": "The copy registry could not be saved.",
|
||||
"copy_location_in_use": "The copy or data location overlaps an existing copy.",
|
||||
"decal_source_invalid": "The selected folder does not contain a usable decal cache.",
|
||||
"decal_import_failed": "The decal cache could not be imported into the copy's data folder. See the launcher log.",
|
||||
"maintenance_busy": "Maintenance requires the game, local server and other copy operations to be stopped.",
|
||||
"maintenance_location": "The operation would affect files outside the registered copy or data folder.",
|
||||
"maintenance_no_update": "A newer version is unavailable at the installation source.",
|
||||
|
||||
@@ -88,6 +88,15 @@
|
||||
"port-busy": "端口 {{port}} 已被占用",
|
||||
"server-exited": "本地服务器意外退出"
|
||||
},
|
||||
"decals": {
|
||||
"source": "贴花来源",
|
||||
"hint": "可导入正版游戏的 cache/content。未导入时使用占位贴花。",
|
||||
"choose": "选择贴花缓存…",
|
||||
"useDefault": "使用占位贴花",
|
||||
"importing": "正在导入贴花缓存",
|
||||
"imported": "已导入缓存",
|
||||
"default": "占位贴花"
|
||||
},
|
||||
"folder": {
|
||||
"none": "未选择",
|
||||
"choose": "浏览…",
|
||||
@@ -165,6 +174,7 @@
|
||||
"measuring": "统计文件",
|
||||
"verifying": "核对可共用的资源",
|
||||
"copying": "复制游戏文件",
|
||||
"importing-decals": "正在导入贴花缓存",
|
||||
"backing-up": "备份原版文件",
|
||||
"recording": "完成安装"
|
||||
},
|
||||
@@ -597,6 +607,8 @@
|
||||
"copy_not_found": "所选副本已不可用。",
|
||||
"copies_write_failed": "无法保存副本记录。",
|
||||
"copy_location_in_use": "副本位置或数据目录与已有副本重叠。",
|
||||
"decal_source_invalid": "选定的目录缺少有效的贴花缓存。",
|
||||
"decal_import_failed": "无法把贴花缓存导入副本数据目录。请查看启动器日志。",
|
||||
"maintenance_busy": "维护前需结束游戏、本地服务器和其他副本操作。",
|
||||
"maintenance_location": "操作会影响登记的副本或数据目录之外的文件。",
|
||||
"maintenance_no_update": "安装来源没有可用的新版本。",
|
||||
|
||||
@@ -18,9 +18,22 @@ interface CopySummaryProps {
|
||||
export function CopySummary({ record, supportedVersions, onShowFeatures, onError }: CopySummaryProps) {
|
||||
const { t, i18n } = useTranslation();
|
||||
const [name, setName] = useState(record.name);
|
||||
const [importing, setImporting] = useState(false);
|
||||
useEffect(() => setName(record.name), [record.id, record.name]);
|
||||
const missing = missingFeatures(record).length;
|
||||
const verified = isVerified(record.gameVersion, supportedVersions);
|
||||
const applyDecals = async (chooseFolder: boolean): Promise<void> => {
|
||||
setImporting(true);
|
||||
try {
|
||||
const path = chooseFolder ? (await ipcInvoke('dialog:pickFolder', { title: t('decals.choose') })).path : null;
|
||||
if (chooseFolder && path === null) return;
|
||||
await ipcInvoke('copies:setDecalSource', { id: record.id, path });
|
||||
} catch (error) {
|
||||
onError(error);
|
||||
} finally {
|
||||
setImporting(false);
|
||||
}
|
||||
};
|
||||
const folder = (path: string) => (
|
||||
<>
|
||||
<span className="folder-path" title={path}>{path}</span>
|
||||
@@ -44,6 +57,17 @@ export function CopySummary({ record, supportedVersions, onShowFeatures, onError
|
||||
{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>
|
||||
<Row label={t('copies.summary.data')} hint={t('copies.summary.dataHint')}>{folder(record.dataPath)}</Row>
|
||||
<Row label={t('decals.source')} hint={t('decals.hint')}>
|
||||
<span>{t(importing ? 'decals.importing' : record.decalCacheId ? 'decals.imported' : 'decals.default')}</span>
|
||||
<button type="button" className="button" disabled={importing} onClick={() => { void applyDecals(true); }}>
|
||||
{t('decals.choose')}
|
||||
</button>
|
||||
{record.decalCacheId && (
|
||||
<button type="button" className="button" disabled={importing} onClick={() => { void applyDecals(false); }}>
|
||||
{t('decals.useDefault')}
|
||||
</button>
|
||||
)}
|
||||
</Row>
|
||||
<Row label={t('copies.summary.installedAt')}>{new Date(record.installedAt).toLocaleString(i18n.language)}</Row>
|
||||
<Row label={t('copies.summary.features')}>
|
||||
{missing === 0 ? (
|
||||
|
||||
@@ -1,19 +1,26 @@
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { FolderField } from '../../components/FolderField.tsx';
|
||||
import { Row } from '../../components/Row.tsx';
|
||||
|
||||
interface DataStepProps {
|
||||
readonly dataPath: string;
|
||||
readonly decalSource: string | null;
|
||||
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, onDataPath, onError }: DataStepProps) {
|
||||
export function DataStep({ dataPath, decalSource, 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} />
|
||||
<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>}
|
||||
</Row>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -7,13 +7,15 @@ import { formatBytes } from '../../format.ts';
|
||||
* Step 5: the installation running, phase by phase. Resource verification and copying can be
|
||||
* cancelled from the bottom bar.
|
||||
*/
|
||||
export function ProgressStep({ progress, useHardLinks }: {
|
||||
export function ProgressStep({ progress, useHardLinks, importDecals }: {
|
||||
readonly progress: InstallProgress | null;
|
||||
readonly useHardLinks: boolean;
|
||||
readonly importDecals: boolean;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const phase = progress?.phase ?? 'checking';
|
||||
const phases: readonly InstallProgress['phase'][] = useHardLinks ? INSTALL_PHASES : INSTALL_PHASES.filter((name) => name !== 'verifying');
|
||||
const phases = INSTALL_PHASES.filter((name) =>
|
||||
(useHardLinks || name !== 'verifying') && (importDecals || name !== 'importing-decals'));
|
||||
const current = phases.indexOf(phase);
|
||||
const tracking = (phase === 'copying' || phase === 'verifying') && progress !== null;
|
||||
const caption = phase === 'verifying' ? 'progress.verified' : useHardLinks ? 'progress.prepared' : 'progress.copied';
|
||||
|
||||
@@ -25,9 +25,17 @@ export function WizardMain({ wizard, supportedVersions }: { readonly wizard: Ins
|
||||
<MethodStep source={source} sourceSize={wizard.sourceSize} choice={wizard.choice} onChoice={wizard.setChoice} onError={wizard.report} />
|
||||
</>
|
||||
)}
|
||||
{step === 'data' && <DataStep dataPath={wizard.dataPath} onDataPath={wizard.setDataPath} onError={wizard.report} />}
|
||||
{step === 'data' && (
|
||||
<DataStep
|
||||
dataPath={wizard.dataPath}
|
||||
decalSource={wizard.decalSource}
|
||||
onDataPath={wizard.setDataPath}
|
||||
onDecalSource={wizard.setDecalSource}
|
||||
onError={wizard.report}
|
||||
/>
|
||||
)}
|
||||
{step === 'check' && <CheckStep check={wizard.check} missingAccepted={wizard.missingAccepted} onMissingAccepted={wizard.setMissingAccepted} />}
|
||||
{step === 'installing' && <ProgressStep progress={wizard.progress} useHardLinks={wizard.choice.method === 'hardlink'} />}
|
||||
{step === 'installing' && <ProgressStep progress={wizard.progress} useHardLinks={wizard.choice.method === 'hardlink'} importDecals={wizard.decalSource !== null} />}
|
||||
{wizard.message && <p className="error-text" role="alert">{wizard.message}</p>}
|
||||
</Sheet>
|
||||
);
|
||||
|
||||
@@ -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 [decalSource, setDecalSource] = useState<string | null>(null);
|
||||
const [check, setCheck] = useState<PatchCheck | null>(null);
|
||||
const [missingAccepted, setMissingAccepted] = useState(false);
|
||||
const [progress, setProgress] = useState<InstallProgress | null>(null);
|
||||
@@ -76,6 +77,7 @@ export function useInstallWizard({ onInstalled }: WizardOptions) {
|
||||
setName('');
|
||||
setDraftId(null);
|
||||
setDataPath('');
|
||||
setDecalSource(null);
|
||||
setActive(true);
|
||||
ipcInvoke('install:prepareCopy').then(({ id, dataPath: folder }) => {
|
||||
setDraftId(id);
|
||||
@@ -91,7 +93,11 @@ export function useInstallWizard({ onInstalled }: WizardOptions) {
|
||||
|
||||
const install = (): void => {
|
||||
if (!sourceUsable(source) || !draftId) return;
|
||||
const choices = { id: draftId, name, dataPath, steamLibraryConfirmed: choice.steamConfirmed, missingFeaturesAccepted: missingAccepted };
|
||||
const choices = {
|
||||
id: draftId, name, dataPath,
|
||||
steamLibraryConfirmed: choice.steamConfirmed, missingFeaturesAccepted: missingAccepted,
|
||||
...(decalSource ? { decalSourcePath: decalSource } : {}),
|
||||
};
|
||||
const request: InstallRequest = choice.method === 'in-place'
|
||||
? { method: 'in-place', gamePath: source.path, ...choices }
|
||||
: { method: 'copy', useHardLinks: choice.method === 'hardlink', sourcePath: source.path, copyPath: choice.target!.path, ...choices };
|
||||
@@ -141,8 +147,8 @@ export function useInstallWizard({ onInstalled }: WizardOptions) {
|
||||
};
|
||||
|
||||
return {
|
||||
active, step, index, source, sourceSize, choice, name, dataPath, check, missingAccepted, progress, cancelling, message, canGoOn,
|
||||
start, back, next, cancel, report, chooseSource, setChoice, setName, setDataPath, setMissingAccepted,
|
||||
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,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -11,10 +11,11 @@ export function wizardBar(wizard: InstallWizard, t: TFunction): BarModel {
|
||||
if (step === 'installing') {
|
||||
const phase = progress?.phase ?? 'checking';
|
||||
const tracking = (phase === 'copying' || phase === 'verifying') && progress !== null;
|
||||
const cancellable = tracking || phase === 'importing-decals';
|
||||
return {
|
||||
tone: 'busy',
|
||||
title: t(`progress.phase.${phase}`),
|
||||
detail: tracking ? t('progress.cancelHint') : stepOf,
|
||||
detail: cancellable ? t('progress.cancelHint') : stepOf,
|
||||
progress: tracking
|
||||
? {
|
||||
value: progress.doneBytes,
|
||||
@@ -24,7 +25,7 @@ export function wizardBar(wizard: InstallWizard, t: TFunction): BarModel {
|
||||
}
|
||||
: { value: 0, max: null },
|
||||
primary: { label: t('wizard.installing'), disabled: true },
|
||||
...(tracking ? { secondary: { label: cancelling ? t('progress.cancelling') : t('progress.cancel'), disabled: cancelling, onClick: wizard.cancel } } : {}),
|
||||
...(cancellable ? { secondary: { label: cancelling ? t('progress.cancelling') : t('progress.cancel'), disabled: cancelling, onClick: wizard.cancel } } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user