fix: 回到标题界面

This commit is contained in:
unanmed 2025-06-25 12:29:19 +08:00
parent ef0c6a1647
commit 783b7beacd
3 changed files with 19 additions and 5 deletions

View File

@ -1,7 +1,7 @@
import { createApp, Font } from '@motajs/render';
import { defineComponent } from 'vue';
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 { createElements } from './elements';
import { mainRenderer } from './renderer';
@ -38,6 +38,11 @@ export function createRender() {
mainRenderer.show();
});
hook.on('restart', () => {
sceneController.closeAll();
sceneController.open(GameTitleUI, {});
});
Font.setDefaults(new Font('normal', 18));
}

View File

@ -58,7 +58,7 @@ export const MainSettings = defineComponent<MainSettingsProps>(props => {
[MainChoice.Back, '返回游戏']
];
const choose = (key: ChoiceKey) => {
const choose = async (key: ChoiceKey) => {
switch (key) {
case MainChoice.SystemSetting: {
mainUi.open('settings');
@ -92,8 +92,16 @@ export const MainSettings = defineComponent<MainSettingsProps>(props => {
break;
}
case MainChoice.Restart: {
props.controller.closeAll();
core.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();
}
break;
}
case MainChoice.Back: {

View File

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