fix(saves): keep imported presets intact, cap crews to preset units and drop used-unit scan
This commit is contained in:
1 parent
388dc9d9d7
commit
e6e75d92c6
10 files changed
+109
-114
No files matched your search
@@ -356,7 +356,6 @@
|
||||
"full": "All equipment",
|
||||
"basic": "Essential equipment",
|
||||
"stock": "Stock configuration",
|
||||
"includeUsed": "Include additional vehicles from per-unit settings (without prerequisite lines)",
|
||||
"preview": "Preview",
|
||||
"import": "Import",
|
||||
"summary": "{{files}} file(s) · {{presets}} preset(s) · {{vehicles}} available vehicle(s)",
|
||||
|
||||
@@ -356,7 +356,6 @@
|
||||
"full": "完全体",
|
||||
"basic": "基础生存配件",
|
||||
"stock": "白板状态",
|
||||
"includeUsed": "额外包含其他单车配置中的载具(不连带解锁前置科技树)",
|
||||
"preview": "预览",
|
||||
"import": "导入",
|
||||
"summary": "{{files}} 个文件 · {{presets}} 套预设 · {{vehicles}} 辆可用载具",
|
||||
|
||||
@@ -5,7 +5,7 @@ import { Row } from '../../components/Row.tsx';
|
||||
import { ipcInvoke } from '../../ipc.ts';
|
||||
|
||||
const DEFAULTS: OfficialImportOptions = {
|
||||
importSettings: true, unlockVehicles: true, includeUsedVehicles: false, equipment: 'full',
|
||||
importSettings: true, unlockVehicles: true, equipment: 'full',
|
||||
};
|
||||
|
||||
interface Props {
|
||||
@@ -26,12 +26,12 @@ export function OfficialSaveImport({ copyId, userId, readOnly, onError, onImport
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [imported, setImported] = useState(false);
|
||||
|
||||
const stageAndPreview = async (accountId: string, includeUsed: boolean): Promise<string[]> => {
|
||||
const stageAndPreview = async (accountId: string): Promise<string[]> => {
|
||||
const copied = await ipcInvoke('saves:copyOnlineData', { copyId, userId, accountId });
|
||||
setSelectedAccount(accountId);
|
||||
setPaths(copied);
|
||||
setImported(false);
|
||||
const nextPreview = await ipcInvoke('saves:previewOfficial', { copyId, userId, paths: copied, includeUsedVehicles: includeUsed });
|
||||
const nextPreview = await ipcInvoke('saves:previewOfficial', { copyId, userId, paths: copied });
|
||||
setPreview(nextPreview);
|
||||
return copied;
|
||||
};
|
||||
@@ -49,7 +49,7 @@ export function OfficialSaveImport({ copyId, userId, readOnly, onError, onImport
|
||||
return;
|
||||
}
|
||||
const first = found[0]!;
|
||||
const copied = await stageAndPreview(first.accountId, options.includeUsedVehicles);
|
||||
const copied = await stageAndPreview(first.accountId);
|
||||
if (importImmediately && found.length === 1 && !readOnly && (options.importSettings || options.unlockVehicles)) {
|
||||
const result = await ipcInvoke('saves:importOfficial', { copyId, userId, paths: copied, options });
|
||||
setPreview(result);
|
||||
@@ -65,7 +65,7 @@ export function OfficialSaveImport({ copyId, userId, readOnly, onError, onImport
|
||||
if (!accountId) return;
|
||||
setBusy(true);
|
||||
setImported(false);
|
||||
stageAndPreview(accountId, options.includeUsedVehicles)
|
||||
stageAndPreview(accountId)
|
||||
.catch(onError)
|
||||
.finally(() => setBusy(false));
|
||||
};
|
||||
@@ -80,11 +80,11 @@ export function OfficialSaveImport({ copyId, userId, readOnly, onError, onImport
|
||||
}).catch(onError);
|
||||
};
|
||||
|
||||
const load = (targetPaths = paths, includeUsed = options.includeUsedVehicles): void => {
|
||||
const load = (targetPaths = paths): void => {
|
||||
if (targetPaths.length === 0) return;
|
||||
setBusy(true);
|
||||
setImported(false);
|
||||
ipcInvoke('saves:previewOfficial', { copyId, userId, paths: targetPaths, includeUsedVehicles: includeUsed })
|
||||
ipcInvoke('saves:previewOfficial', { copyId, userId, paths: targetPaths })
|
||||
.then(setPreview)
|
||||
.catch(onError)
|
||||
.finally(() => setBusy(false));
|
||||
@@ -178,19 +178,6 @@ export function OfficialSaveImport({ copyId, userId, readOnly, onError, onImport
|
||||
<option value="basic">{t('saves.official.basic')}</option>
|
||||
<option value="stock">{t('saves.official.stock')}</option>
|
||||
</select>
|
||||
<label className="check check-inline">
|
||||
<input type="checkbox" checked={options.includeUsedVehicles} disabled={busy || !options.unlockVehicles} onChange={(event) => {
|
||||
const nextInclude = event.target.checked;
|
||||
setOptions({ ...options, includeUsedVehicles: nextInclude });
|
||||
setImported(false);
|
||||
if (paths.length > 0 && preview) {
|
||||
load(paths, nextInclude);
|
||||
} else {
|
||||
setPreview(null);
|
||||
}
|
||||
}} />
|
||||
{t('saves.official.includeUsed')}
|
||||
</label>
|
||||
</Row>
|
||||
<div className="copy-list-actions">
|
||||
<button type="button" className="button" disabled={busy || paths.length === 0} onClick={() => load()}>{t('saves.official.preview')}</button>
|
||||
|
||||
Reference in new issue
Block a user