Compare commits

..

1 Commits

Author SHA1 Message Date
AncTe
df6798787d
Merge e3edac3d55 into 820dc5bf4c 2025-06-24 15:28:56 +00:00
10 changed files with 58 additions and 150 deletions

View File

@ -489,6 +489,9 @@ gameKey
.realize('fly', () => {
core.useFly(true);
})
.realize('replay', () => {
core.ui._drawReplay();
})
.realize('shop', () => {
core.openQuickShop(true);
})

View File

@ -5,8 +5,7 @@ import {
mainUIController,
openStatistics,
saveLoad,
openSettings,
ReplaySettingsUI
openSettings
} from './ui';
export function createAction() {
@ -22,10 +21,5 @@ 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]
});
});
}

View File

@ -8,7 +8,7 @@ import {
VNode,
watch
} from 'vue';
import { clamp, isNil } from 'lodash-es';
import { clamp } from 'lodash-es';
import { DefaultProps, ElementLocator, Font } from '@motajs/render';
import { SetupComponentOptions } from '@motajs/system-ui';
@ -177,18 +177,6 @@ export const Page = defineComponent<
updateRectAndText();
}
);
watch(
() => props.page,
page => {
if (!isNil(page)) {
const target = clamp(page, 0, props.pages - 1);
if (nowPage.value !== target) {
nowPage.value = target;
emit('pageChange', target);
}
}
}
);
/**
*

View File

@ -1,7 +1,7 @@
import { createApp, Font } from '@motajs/render';
import { defineComponent } from 'vue';
import { MAIN_HEIGHT, MAIN_WIDTH } from './shared';
import { hook, loading } from '@user/data-base';
import { loading } from '@user/data-base';
import { createLoopMap } from './loopMap';
import { createElements } from './elements';
import { mainRenderer } from './renderer';
@ -38,11 +38,6 @@ export function createRender() {
mainRenderer.show();
});
hook.on('restart', () => {
sceneController.closeAll();
sceneController.open(GameTitleUI, {});
});
Font.setDefaults(new Font('normal', 18));
}

View File

@ -76,10 +76,7 @@ export const SaveItem = defineComponent<SaveItemProps>(props => {
if (!props.data) return '';
else {
const hero = props.data.data.hero;
const hp = core.formatBigNumber(hero.hp);
const atk = core.formatBigNumber(hero.atk);
const def = core.formatBigNumber(hero.def);
return `${hp}/${atk}/${def}`;
return `${hero.hp}/${hero.atk}/${hero.def}`;
}
});
@ -186,8 +183,6 @@ export const Save = defineComponent<SaveProps, SaveEmits, keyof SaveEmits>(
return [right, height.value - 13, void 0, void 0, 1, 1];
});
//#region 数据信息
/**
* 0 pageCap-1
*/
@ -209,9 +204,10 @@ export const Save = defineComponent<SaveProps, SaveEmits, keyof SaveEmits>(
const index = getIndex(i, page);
promises.push(getSave(index + 1));
}
const before = page;
const before = now.value;
const data = await Promise.all(promises);
if (now.value !== before) return;
if (before !== now.value) return;
data.forEach((v, i) => {
if (v) {
saveData[i] = v;
@ -221,17 +217,6 @@ export const Save = defineComponent<SaveProps, SaveEmits, keyof SaveEmits>(
});
};
onMounted(() => {
const startIndex = getPosIndex(core.saves.saveIndex);
selected.value = startIndex - 1;
pageRef.value?.changePage(
Math.floor(core.saves.saveIndex / (grid.value.count - 1))
);
updateDataList(now.value);
});
//#region 逻辑操作
const exist = (index: number) => {
return saveData[index] !== null;
};
@ -240,6 +225,15 @@ export const Save = defineComponent<SaveProps, SaveEmits, keyof SaveEmits>(
saveData[index] = null;
};
onMounted(() => {
const startIndex = getPosIndex(core.saves.saveIndex);
selected.value = startIndex;
pageRef.value?.changePage(
Math.floor(core.saves.saveIndex / (grid.value.count - 1))
);
updateDataList(now.value);
});
const emitSave = async (index: number) => {
const posIndex = getPosIndex(index);
if (inDelete.value) {
@ -264,6 +258,15 @@ export const Save = defineComponent<SaveProps, SaveEmits, keyof SaveEmits>(
}
};
const wheel = (ev: IWheelEvent) => {
const delta = Math.sign(ev.wheelY);
if (ev.ctrlKey) {
pageRef.value?.movePage(delta * 10);
} else {
pageRef.value?.movePage(delta);
}
};
const toggleDelete = () => {
inDelete.value = !inDelete.value;
};
@ -371,16 +374,6 @@ export const Save = defineComponent<SaveProps, SaveEmits, keyof SaveEmits>(
{ type: 'down-repeat' }
);
//#region 事件监听
const wheel = (ev: IWheelEvent) => {
const delta = Math.sign(ev.wheelY);
if (ev.ctrlKey) {
pageRef.value?.movePage(delta * 10);
} else {
pageRef.value?.movePage(delta);
}
};
return () => (
<container loc={props.loc}>
<Page
@ -400,7 +393,6 @@ export const Save = defineComponent<SaveProps, SaveEmits, keyof SaveEmits>(
const index = i === 0 ? 0 : rawIndex;
return (
<SaveItem
key={index}
loc={v}
index={index}
selected={selected.value === i}
@ -539,6 +531,7 @@ export async function saveSave(
props
);
if (index === -2) return false;
core.saves.saveIndex = index;
core.doSL(index + 1, 'save');
return true;
}
@ -566,21 +559,3 @@ 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;
}

View File

@ -21,8 +21,6 @@ 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>,
@ -60,7 +58,7 @@ export const MainSettings = defineComponent<MainSettingsProps>(props => {
[MainChoice.Back, '返回游戏']
];
const choose = async (key: ChoiceKey) => {
const choose = (key: ChoiceKey) => {
switch (key) {
case MainChoice.SystemSetting: {
mainUi.open('settings');
@ -94,16 +92,8 @@ export const MainSettings = defineComponent<MainSettingsProps>(props => {
break;
}
case MainChoice.Restart: {
const confirm = await getConfirm(
props.controller,
'确认要返回标题吗?',
[420, 240, void 0, void 0, 0.5, 0.5],
240
);
if (confirm) {
props.controller.closeAll();
core.restart();
}
props.controller.closeAll();
core.restart();
break;
}
case MainChoice.Back: {
@ -146,7 +136,7 @@ export const ReplaySettings = defineComponent<MainSettingsProps>(props => {
[ReplayChoice.Back, '返回游戏']
];
const choose = async (key: ChoiceKey) => {
const choose = (key: ChoiceKey) => {
switch (key) {
case ReplayChoice.Start: {
props.controller.closeAll();
@ -157,59 +147,15 @@ export const ReplaySettings = defineComponent<MainSettingsProps>(props => {
break;
}
case ReplayChoice.StartFromSave: {
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();
// todo
break;
}
case ReplayChoice.ResumeReplay: {
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();
// todo
break;
}
case ReplayChoice.ReplayRest: {
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();
// todo
break;
}
case ReplayChoice.ChooseReplay: {
@ -220,7 +166,8 @@ export const ReplaySettings = defineComponent<MainSettingsProps>(props => {
case ReplayChoice.Download: {
core.download(
core.firstData.name + '_' + core.formatDate2() + '.h5route',
compressToBase64(
// @ts-expect-error 暂时无法推导
LZString.compressToBase64(
JSON.stringify({
name: core.firstData.name,
hard: core.status.hard,

View File

@ -237,8 +237,7 @@ export class UIController
closeAll(ui?: IGameUI): void {
if (!ui) {
const list = this.stack.slice();
list.forEach(v => this.close(v));
this.stack.splice(0);
} else {
const list = this.stack.filter(v => v.ui === ui);
list.forEach(v => this.close(v));

View File

@ -2019,7 +2019,7 @@ control.prototype.doSL = function (id, type) {
this._doSL_load(id, this._doSL_replayLoad_afterGet);
break;
case 'replayRemain':
return this._doSL_load(id, this._doSL_replayRemain_afterGet);
this._doSL_load(id, this._doSL_replayRemain_afterGet);
break;
case 'replaySince':
this._doSL_load(id, this._doSL_replaySince_afterGet);
@ -2186,8 +2186,7 @@ control.prototype._doSL_replayLoad_afterGet = function (id, data) {
control.prototype._doSL_replayRemain_afterGet = function (id, data) {
if (!data) {
core.playSound('操作失败');
core.drawTip('无效的存档');
return false;
return core.drawTip('无效的存档');
}
var route = core.decodeRoute(data.route);
if (core.status.tempRoute) {
@ -2200,18 +2199,27 @@ control.prototype._doSL_replayRemain_afterGet = function (id, data) {
core.ui.closePanel();
core.startReplay(remainRoute);
core.drawTip('接续播放录像');
return true;
return;
} else if (
data.floorId != core.status.floorId ||
data.hero.loc.x != core.getHeroLoc('x') ||
data.hero.loc.y != core.getHeroLoc('y')
) {
alert('楼层或坐标不一致!');
return false;
}
)
return alert('楼层或坐标不一致!');
core.status.tempRoute = route;
return true;
core.ui.closePanel();
core.drawText(
'\t[步骤2]请选择第二个存档。\n\r[yellow]该存档必须是前一个存档的后续。\r\n将尝试播放到此存档。',
function () {
core.status.event.id = 'replayRemain';
core.lockControl();
var saveIndex = core.saves.saveIndex;
var page = Math.floor((saveIndex - 1) / 5),
offset = saveIndex - 5 * page;
core.ui._drawSLPanel(10 * page + offset);
}
);
};
control.prototype._doSL_replaySince_afterGet = function (id, data) {

View File

@ -3408,7 +3408,7 @@ events.prototype.openToolbox = function (fromUserAction) {
////// 点击快捷商店按钮时的打开操作 //////
events.prototype.openQuickShop = function (fromUserAction) {
if (core.isReplaying()) return;
const shop = Mota.require('@user/legacy-plugin-data');
const shop = Mota.require('@user/data-state');
if (Object.keys(core.status.shops).length == 0) {
core.playSound('操作失败');

View File

@ -610,8 +610,7 @@ interface Control {
/**
*
*/
doSL(id: string | number, type: Exclude<SLType, 'replayRemain'>): void;
doSL(id: string | number, type: 'replayRemain'): boolean;
doSL(id: string | number, type: SLType): void;
/**
*