feat: 录像回放设置 & fix: 快捷商店报错

This commit is contained in:
AncTe committed 2025-06-25 16:22:51 +08:00
1 parent 45ba43ac8e
commit 010383a914
7 files changed
+88 -29

No files matched your search

@@ -489,9 +489,6 @@ gameKey
.realize('fly', () => {
core.useFly(true);
})
.realize('replay', () => {
core.ui._drawReplay();
})
.realize('shop', () => {
core.openQuickShop(true);
})
@@ -5,7 +5,8 @@ import {
mainUIController,
openStatistics,
saveLoad,
openSettings
openSettings,
ReplaySettingsUI
} from './ui';
export function createAction() {
@@ -21,5 +22,10 @@ export function createAction() {
})
.realize('menu', () => {
openSettings(mainUIController, [420, 240, 240, 400, 0.5, 0.5]);
})
.realize('replay', () => {
mainUIController.open(ReplaySettingsUI, {
loc: [420, 240, void 0, void 0, 0.5, 0.5]
});
});
}
@@ -566,3 +566,21 @@ export async function saveLoad(
}
return true;
}
export async function saveWithExist(
controller: IUIMountable,
loc: ElementLocator,
props?: SaveProps
) {
const validate = (_: number, exist: boolean): SaveValidation => {
return { message: '无效的存档!', valid: exist };
};
const index = await selectSave(
controller,
loc,
SaveMode.Load,
validate,
props
);
return index;
}
@@ -21,6 +21,8 @@ import { getVitualKeyOnce } from '@motajs/legacy-ui';
import { getAllSavesData, getSaveData, syncFromServer } from '../utils';
import { getInput } from '../components/input';
import { openStatistics } from './statistics';
import { saveWithExist } from './save';
import { compressToBase64 } from 'lz-string';
export interface MainSettingsProps
extends Partial<ChoicesProps>,
@@ -144,7 +146,7 @@ export const ReplaySettings = defineComponent<MainSettingsProps>(props => {
[ReplayChoice.Back, '返回游戏']
];
const choose = (key: ChoiceKey) => {
const choose = async (key: ChoiceKey) => {
switch (key) {
case ReplayChoice.Start: {
props.controller.closeAll();
@@ -155,15 +157,59 @@ export const ReplaySettings = defineComponent<MainSettingsProps>(props => {
break;
}
case ReplayChoice.StartFromSave: {
// todo
const index = await saveWithExist(
props.controller,
[0, 0, 840, 480]
);
if (index === -2) break;
if (index === -1) {
core.doSL('autoSave', 'replayLoad');
} else {
core.doSL(index + 1, 'replayLoad');
}
props.controller.closeAll();
break;
}
case ReplayChoice.ResumeReplay: {
// todo
const index = await saveWithExist(
props.controller,
[0, 0, 840, 480]
);
if (index === -2) break;
const name = index === -1 ? 'autoSave' : index + 1;
const success = core.doSL(name, 'replayRemain');
if (!success) {
props.controller.closeAll();
break;
}
await getConfirm(
props.controller,
'[步骤2]请选择第二个存档。\n\r[yellow]该存档必须是前一个存档的后续。\r\n将尝试播放到此存档。',
[420, 240, void 0, void 0, 0.5, 0.5],
240
);
const index2 = await saveWithExist(
props.controller,
[0, 0, 840, 480]
);
if (index2 === -2) break;
const name2 = index2 === -1 ? 'autoSave' : index2 + 1;
core.doSL(name2, 'replayRemain');
props.controller.closeAll();
break;
}
case ReplayChoice.ReplayRest: {
// todo
const index = await saveWithExist(
props.controller,
[0, 0, 840, 480]
);
if (index === -2) break;
if (index === -1) {
core.doSL('autoSave', 'replaySince');
} else {
core.doSL(index + 1, 'replaySince');
}
props.controller.closeAll();
break;
}
case ReplayChoice.ChooseReplay: {
@@ -174,8 +220,7 @@ export const ReplaySettings = defineComponent<MainSettingsProps>(props => {
case ReplayChoice.Download: {
core.download(
core.firstData.name + '_' + core.formatDate2() + '.h5route',
// @ts-expect-error 暂时无法推导
LZString.compressToBase64(
compressToBase64(
JSON.stringify({
name: core.firstData.name,
hard: core.status.hard,