mirror of
https://github.com/unanmed/HumanBreak.git
synced 2025-07-18 19:11:48 +08:00
Compare commits
5 Commits
e3edac3d55
...
010383a914
Author | SHA1 | Date | |
---|---|---|---|
010383a914 | |||
45ba43ac8e | |||
783b7beacd | |||
ef0c6a1647 | |||
e0b3b2a68b |
@ -489,9 +489,6 @@ gameKey
|
|||||||
.realize('fly', () => {
|
.realize('fly', () => {
|
||||||
core.useFly(true);
|
core.useFly(true);
|
||||||
})
|
})
|
||||||
.realize('replay', () => {
|
|
||||||
core.ui._drawReplay();
|
|
||||||
})
|
|
||||||
.realize('shop', () => {
|
.realize('shop', () => {
|
||||||
core.openQuickShop(true);
|
core.openQuickShop(true);
|
||||||
})
|
})
|
||||||
|
@ -5,7 +5,8 @@ import {
|
|||||||
mainUIController,
|
mainUIController,
|
||||||
openStatistics,
|
openStatistics,
|
||||||
saveLoad,
|
saveLoad,
|
||||||
openSettings
|
openSettings,
|
||||||
|
ReplaySettingsUI
|
||||||
} from './ui';
|
} from './ui';
|
||||||
|
|
||||||
export function createAction() {
|
export function createAction() {
|
||||||
@ -21,5 +22,10 @@ export function createAction() {
|
|||||||
})
|
})
|
||||||
.realize('menu', () => {
|
.realize('menu', () => {
|
||||||
openSettings(mainUIController, [420, 240, 240, 400, 0.5, 0.5]);
|
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]
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ import {
|
|||||||
VNode,
|
VNode,
|
||||||
watch
|
watch
|
||||||
} from 'vue';
|
} from 'vue';
|
||||||
import { clamp } from 'lodash-es';
|
import { clamp, isNil } from 'lodash-es';
|
||||||
import { DefaultProps, ElementLocator, Font } from '@motajs/render';
|
import { DefaultProps, ElementLocator, Font } from '@motajs/render';
|
||||||
import { SetupComponentOptions } from '@motajs/system-ui';
|
import { SetupComponentOptions } from '@motajs/system-ui';
|
||||||
|
|
||||||
@ -177,6 +177,18 @@ export const Page = defineComponent<
|
|||||||
updateRectAndText();
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 切换页码
|
* 切换页码
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { createApp, Font } from '@motajs/render';
|
import { createApp, Font } from '@motajs/render';
|
||||||
import { defineComponent } from 'vue';
|
import { defineComponent } from 'vue';
|
||||||
import { MAIN_HEIGHT, MAIN_WIDTH } from './shared';
|
import { MAIN_HEIGHT, MAIN_WIDTH } from './shared';
|
||||||
import { loading } from '@user/data-base';
|
import { hook, loading } from '@user/data-base';
|
||||||
import { createLoopMap } from './loopMap';
|
import { createLoopMap } from './loopMap';
|
||||||
import { createElements } from './elements';
|
import { createElements } from './elements';
|
||||||
import { mainRenderer } from './renderer';
|
import { mainRenderer } from './renderer';
|
||||||
@ -38,6 +38,11 @@ export function createRender() {
|
|||||||
mainRenderer.show();
|
mainRenderer.show();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
hook.on('restart', () => {
|
||||||
|
sceneController.closeAll();
|
||||||
|
sceneController.open(GameTitleUI, {});
|
||||||
|
});
|
||||||
|
|
||||||
Font.setDefaults(new Font('normal', 18));
|
Font.setDefaults(new Font('normal', 18));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +76,10 @@ export const SaveItem = defineComponent<SaveItemProps>(props => {
|
|||||||
if (!props.data) return '';
|
if (!props.data) return '';
|
||||||
else {
|
else {
|
||||||
const hero = props.data.data.hero;
|
const hero = props.data.data.hero;
|
||||||
return `${hero.hp}/${hero.atk}/${hero.def}`;
|
const hp = core.formatBigNumber(hero.hp);
|
||||||
|
const atk = core.formatBigNumber(hero.atk);
|
||||||
|
const def = core.formatBigNumber(hero.def);
|
||||||
|
return `${hp}/${atk}/${def}`;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -183,6 +186,8 @@ export const Save = defineComponent<SaveProps, SaveEmits, keyof SaveEmits>(
|
|||||||
return [right, height.value - 13, void 0, void 0, 1, 1];
|
return [right, height.value - 13, void 0, void 0, 1, 1];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//#region 数据信息
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取存档在当前页的序号,范围为 0 到 pageCap-1。
|
* 获取存档在当前页的序号,范围为 0 到 pageCap-1。
|
||||||
*/
|
*/
|
||||||
@ -204,10 +209,9 @@ export const Save = defineComponent<SaveProps, SaveEmits, keyof SaveEmits>(
|
|||||||
const index = getIndex(i, page);
|
const index = getIndex(i, page);
|
||||||
promises.push(getSave(index + 1));
|
promises.push(getSave(index + 1));
|
||||||
}
|
}
|
||||||
const before = now.value;
|
const before = page;
|
||||||
const data = await Promise.all(promises);
|
const data = await Promise.all(promises);
|
||||||
if (before !== now.value) return;
|
if (now.value !== before) return;
|
||||||
|
|
||||||
data.forEach((v, i) => {
|
data.forEach((v, i) => {
|
||||||
if (v) {
|
if (v) {
|
||||||
saveData[i] = v;
|
saveData[i] = v;
|
||||||
@ -217,6 +221,17 @@ 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) => {
|
const exist = (index: number) => {
|
||||||
return saveData[index] !== null;
|
return saveData[index] !== null;
|
||||||
};
|
};
|
||||||
@ -225,15 +240,6 @@ export const Save = defineComponent<SaveProps, SaveEmits, keyof SaveEmits>(
|
|||||||
saveData[index] = null;
|
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 emitSave = async (index: number) => {
|
||||||
const posIndex = getPosIndex(index);
|
const posIndex = getPosIndex(index);
|
||||||
if (inDelete.value) {
|
if (inDelete.value) {
|
||||||
@ -258,15 +264,6 @@ 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 = () => {
|
const toggleDelete = () => {
|
||||||
inDelete.value = !inDelete.value;
|
inDelete.value = !inDelete.value;
|
||||||
};
|
};
|
||||||
@ -374,6 +371,16 @@ export const Save = defineComponent<SaveProps, SaveEmits, keyof SaveEmits>(
|
|||||||
{ type: 'down-repeat' }
|
{ 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 () => (
|
return () => (
|
||||||
<container loc={props.loc}>
|
<container loc={props.loc}>
|
||||||
<Page
|
<Page
|
||||||
@ -393,6 +400,7 @@ export const Save = defineComponent<SaveProps, SaveEmits, keyof SaveEmits>(
|
|||||||
const index = i === 0 ? 0 : rawIndex;
|
const index = i === 0 ? 0 : rawIndex;
|
||||||
return (
|
return (
|
||||||
<SaveItem
|
<SaveItem
|
||||||
|
key={index}
|
||||||
loc={v}
|
loc={v}
|
||||||
index={index}
|
index={index}
|
||||||
selected={selected.value === i}
|
selected={selected.value === i}
|
||||||
@ -531,7 +539,6 @@ export async function saveSave(
|
|||||||
props
|
props
|
||||||
);
|
);
|
||||||
if (index === -2) return false;
|
if (index === -2) return false;
|
||||||
core.saves.saveIndex = index;
|
|
||||||
core.doSL(index + 1, 'save');
|
core.doSL(index + 1, 'save');
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -559,3 +566,21 @@ export async function saveLoad(
|
|||||||
}
|
}
|
||||||
return true;
|
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 { getAllSavesData, getSaveData, syncFromServer } from '../utils';
|
||||||
import { getInput } from '../components/input';
|
import { getInput } from '../components/input';
|
||||||
import { openStatistics } from './statistics';
|
import { openStatistics } from './statistics';
|
||||||
|
import { saveWithExist } from './save';
|
||||||
|
import { compressToBase64 } from 'lz-string';
|
||||||
|
|
||||||
export interface MainSettingsProps
|
export interface MainSettingsProps
|
||||||
extends Partial<ChoicesProps>,
|
extends Partial<ChoicesProps>,
|
||||||
@ -58,7 +60,7 @@ export const MainSettings = defineComponent<MainSettingsProps>(props => {
|
|||||||
[MainChoice.Back, '返回游戏']
|
[MainChoice.Back, '返回游戏']
|
||||||
];
|
];
|
||||||
|
|
||||||
const choose = (key: ChoiceKey) => {
|
const choose = async (key: ChoiceKey) => {
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case MainChoice.SystemSetting: {
|
case MainChoice.SystemSetting: {
|
||||||
mainUi.open('settings');
|
mainUi.open('settings');
|
||||||
@ -92,8 +94,16 @@ export const MainSettings = defineComponent<MainSettingsProps>(props => {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MainChoice.Restart: {
|
case MainChoice.Restart: {
|
||||||
props.controller.closeAll();
|
const confirm = await getConfirm(
|
||||||
core.restart();
|
props.controller,
|
||||||
|
'确认要返回标题吗?',
|
||||||
|
[420, 240, void 0, void 0, 0.5, 0.5],
|
||||||
|
240
|
||||||
|
);
|
||||||
|
if (confirm) {
|
||||||
|
props.controller.closeAll();
|
||||||
|
core.restart();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MainChoice.Back: {
|
case MainChoice.Back: {
|
||||||
@ -136,7 +146,7 @@ export const ReplaySettings = defineComponent<MainSettingsProps>(props => {
|
|||||||
[ReplayChoice.Back, '返回游戏']
|
[ReplayChoice.Back, '返回游戏']
|
||||||
];
|
];
|
||||||
|
|
||||||
const choose = (key: ChoiceKey) => {
|
const choose = async (key: ChoiceKey) => {
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case ReplayChoice.Start: {
|
case ReplayChoice.Start: {
|
||||||
props.controller.closeAll();
|
props.controller.closeAll();
|
||||||
@ -147,15 +157,59 @@ export const ReplaySettings = defineComponent<MainSettingsProps>(props => {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ReplayChoice.StartFromSave: {
|
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;
|
break;
|
||||||
}
|
}
|
||||||
case ReplayChoice.ResumeReplay: {
|
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;
|
break;
|
||||||
}
|
}
|
||||||
case ReplayChoice.ReplayRest: {
|
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;
|
break;
|
||||||
}
|
}
|
||||||
case ReplayChoice.ChooseReplay: {
|
case ReplayChoice.ChooseReplay: {
|
||||||
@ -166,8 +220,7 @@ export const ReplaySettings = defineComponent<MainSettingsProps>(props => {
|
|||||||
case ReplayChoice.Download: {
|
case ReplayChoice.Download: {
|
||||||
core.download(
|
core.download(
|
||||||
core.firstData.name + '_' + core.formatDate2() + '.h5route',
|
core.firstData.name + '_' + core.formatDate2() + '.h5route',
|
||||||
// @ts-expect-error 暂时无法推导
|
compressToBase64(
|
||||||
LZString.compressToBase64(
|
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
name: core.firstData.name,
|
name: core.firstData.name,
|
||||||
hard: core.status.hard,
|
hard: core.status.hard,
|
||||||
|
@ -237,7 +237,8 @@ export class UIController
|
|||||||
|
|
||||||
closeAll(ui?: IGameUI): void {
|
closeAll(ui?: IGameUI): void {
|
||||||
if (!ui) {
|
if (!ui) {
|
||||||
this.stack.splice(0);
|
const list = this.stack.slice();
|
||||||
|
list.forEach(v => this.close(v));
|
||||||
} else {
|
} else {
|
||||||
const list = this.stack.filter(v => v.ui === ui);
|
const list = this.stack.filter(v => v.ui === ui);
|
||||||
list.forEach(v => this.close(v));
|
list.forEach(v => this.close(v));
|
||||||
|
@ -2019,7 +2019,7 @@ control.prototype.doSL = function (id, type) {
|
|||||||
this._doSL_load(id, this._doSL_replayLoad_afterGet);
|
this._doSL_load(id, this._doSL_replayLoad_afterGet);
|
||||||
break;
|
break;
|
||||||
case 'replayRemain':
|
case 'replayRemain':
|
||||||
this._doSL_load(id, this._doSL_replayRemain_afterGet);
|
return this._doSL_load(id, this._doSL_replayRemain_afterGet);
|
||||||
break;
|
break;
|
||||||
case 'replaySince':
|
case 'replaySince':
|
||||||
this._doSL_load(id, this._doSL_replaySince_afterGet);
|
this._doSL_load(id, this._doSL_replaySince_afterGet);
|
||||||
@ -2186,7 +2186,8 @@ control.prototype._doSL_replayLoad_afterGet = function (id, data) {
|
|||||||
control.prototype._doSL_replayRemain_afterGet = function (id, data) {
|
control.prototype._doSL_replayRemain_afterGet = function (id, data) {
|
||||||
if (!data) {
|
if (!data) {
|
||||||
core.playSound('操作失败');
|
core.playSound('操作失败');
|
||||||
return core.drawTip('无效的存档');
|
core.drawTip('无效的存档');
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
var route = core.decodeRoute(data.route);
|
var route = core.decodeRoute(data.route);
|
||||||
if (core.status.tempRoute) {
|
if (core.status.tempRoute) {
|
||||||
@ -2199,27 +2200,18 @@ control.prototype._doSL_replayRemain_afterGet = function (id, data) {
|
|||||||
core.ui.closePanel();
|
core.ui.closePanel();
|
||||||
core.startReplay(remainRoute);
|
core.startReplay(remainRoute);
|
||||||
core.drawTip('接续播放录像');
|
core.drawTip('接续播放录像');
|
||||||
return;
|
return true;
|
||||||
} else if (
|
} else if (
|
||||||
data.floorId != core.status.floorId ||
|
data.floorId != core.status.floorId ||
|
||||||
data.hero.loc.x != core.getHeroLoc('x') ||
|
data.hero.loc.x != core.getHeroLoc('x') ||
|
||||||
data.hero.loc.y != core.getHeroLoc('y')
|
data.hero.loc.y != core.getHeroLoc('y')
|
||||||
)
|
) {
|
||||||
return alert('楼层或坐标不一致!');
|
alert('楼层或坐标不一致!');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
core.status.tempRoute = route;
|
core.status.tempRoute = route;
|
||||||
core.ui.closePanel();
|
return true;
|
||||||
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) {
|
control.prototype._doSL_replaySince_afterGet = function (id, data) {
|
||||||
|
@ -3408,7 +3408,7 @@ events.prototype.openToolbox = function (fromUserAction) {
|
|||||||
////// 点击快捷商店按钮时的打开操作 //////
|
////// 点击快捷商店按钮时的打开操作 //////
|
||||||
events.prototype.openQuickShop = function (fromUserAction) {
|
events.prototype.openQuickShop = function (fromUserAction) {
|
||||||
if (core.isReplaying()) return;
|
if (core.isReplaying()) return;
|
||||||
const shop = Mota.require('@user/data-state');
|
const shop = Mota.require('@user/legacy-plugin-data');
|
||||||
|
|
||||||
if (Object.keys(core.status.shops).length == 0) {
|
if (Object.keys(core.status.shops).length == 0) {
|
||||||
core.playSound('操作失败');
|
core.playSound('操作失败');
|
||||||
|
3
src/types/declaration/control.d.ts
vendored
3
src/types/declaration/control.d.ts
vendored
@ -610,7 +610,8 @@ interface Control {
|
|||||||
/**
|
/**
|
||||||
* 实际进行存读档事件
|
* 实际进行存读档事件
|
||||||
*/
|
*/
|
||||||
doSL(id: string | number, type: SLType): void;
|
doSL(id: string | number, type: Exclude<SLType, 'replayRemain'>): void;
|
||||||
|
doSL(id: string | number, type: 'replayRemain'): boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 同步存档到服务器
|
* 同步存档到服务器
|
||||||
|
Loading…
Reference in New Issue
Block a user