fix: 读档报错

This commit is contained in:
unanmed 2025-06-23 17:11:21 +08:00
parent 1bfad1d5e7
commit 32184d23a2
4 changed files with 18 additions and 6 deletions

View File

@ -407,6 +407,10 @@ export class HeroRenderer
this.animateTick(time);
this.moveTick(time);
});
if (core.status.hero) {
const image = core.status.hero.image;
this.setImage(core.material.images.images[image]);
}
}
onDestroy(layer: Layer): void {

View File

@ -7,7 +7,7 @@ import {
SetupComponentOptions,
UIComponentProps
} from '@motajs/system-ui';
import { defineComponent, ref, computed, watch } from 'vue';
import { defineComponent, ref, computed, watch, nextTick } from 'vue';
import { Page, PageExpose } from '../components';
import { useKey } from '../use';
import { MAP_WIDTH, MAP_HEIGHT } from '../shared';
@ -423,8 +423,9 @@ export async function saveSave(
}
};
const index = await selectSave(controller, loc, validate, props);
if (index === -2) return;
if (index === -2) return false;
core.doSL(index + 1, 'save');
return true;
}
export async function saveLoad(
@ -436,10 +437,11 @@ export async function saveLoad(
return { message: '无效的存档!', valid: exist };
};
const index = await selectSave(controller, loc, validate, props);
if (index === -2) return;
if (index === -2) return false;
if (index === -1) {
core.doSL('autosave', 'load');
} else {
core.doSL(index + 1, 'load');
}
return true;
}

View File

@ -7,6 +7,7 @@ import {
import { defineComponent, nextTick, onMounted, ref } from 'vue';
import { MAIN_HEIGHT, MAIN_WIDTH } from '../shared';
import {
ElementLocator,
IActionEvent,
MotaOffscreenCanvas2D,
Shader,
@ -169,8 +170,13 @@ export const GameTitle = defineComponent<GameTitleProps>(props => {
buttonsAlpha.set(1);
};
const loadGame = () => {
saveLoad(props.controller, [0, 0, MAIN_WIDTH, MAIN_HEIGHT]);
const loadGame = async () => {
const loc: ElementLocator = [0, 0, MAIN_WIDTH, MAIN_HEIGHT];
const success = await saveLoad(props.controller, loc);
if (success) {
props.controller.close(props.instance);
props.controller.open(MainSceneUI, {});
}
};
const replay = () => {

View File

@ -2147,7 +2147,7 @@ control.prototype._doSL_load_afterGet = function (id, data) {
Mota.r(() => {
Mota.require('@user/legacy-plugin-client').end(false);
});
core.ui.closePanel();
// core.ui.closePanel();
core.loadData(data, function () {
core.removeFlag('__fromLoad__');
core.drawTip('读档成功');