fix: 加载 & 热重载

This commit is contained in:
unanmed 2024-04-20 19:49:21 +08:00
parent 938bd18808
commit 61b47929f6
3 changed files with 31 additions and 6 deletions

View File

@ -305,10 +305,15 @@ main.prototype.loadSync = function (mode, callback) {
});
core.initSync(coreData, callback);
main.loading.emit('coreLoaded');
main.loading.emit('coreInit');
core.initStatus.maps = core.maps._initMaps();
core.resize();
main.core = core;
core.completeAchievement = () => 0;
core.plugin = { drawLight: 0 };
};
main.prototype.loadAsync = async function (mode, callback) {
@ -402,20 +407,30 @@ main.prototype.loadAsync = async function (mode, callback) {
].forEach(function (t) {
coreData[t] = main[t];
});
if (main.mode === 'play') {
await core.init(coreData, callback);
if (main.mode === 'play') main.loading.emit('coreInit');
main.loading.emit('coreInit');
core.initStatus.maps = core.maps._initMaps();
} else {
await core.init(coreData, () => {
callback();
core.initStatus.maps = core.maps._initMaps();
});
main.loading.emit('coreInit');
}
core.resize();
main.core = core;
if (main.mode === 'editor') return;
// 自动放缩最大化
let auto = Mota.require('var', 'mainSetting').getValue('autoSclae');
let auto = Mota.require('var', 'mainSetting').getValue('autoScale', true);
if (auto && !core.domStyle.isVertical) {
try {
Mota.Plugin.require('utils_g').maxGameScale();
Mota.Plugin.require('utils_g').maxGameScale(1);
requestAnimationFrame(() => {
var style = getComputedStyle(main.dom.gameGroup);
var height = parseFloat(style.height);

View File

@ -131,7 +131,16 @@ main.floors.MT48=
"value": "1"
}
],
"false": []
"false": [
{
"type": "changeFloor",
"floorId": "MT49",
"loc": [
7,
14
]
}
]
}
]
},

View File

@ -527,6 +527,7 @@ function watchProject() {
/_.*/
]
});
watcher.removeAllListeners();
watcher.on('change', async path => {
// 楼层热重载
if (/project(\/|\\)floors(\/|\\).*\.js$/.test(path)) {