fix: 编辑器

This commit is contained in:
unanmed 2024-02-04 19:52:49 +08:00
parent 63179995cd
commit 5d54b205f0
4 changed files with 30 additions and 20 deletions

View File

@ -18,13 +18,6 @@ var data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
"_docs": "楼层列表", "_docs": "楼层列表",
"_data": "在这里按顺序放所有的楼层;其顺序直接影响到楼层传送器、浏览地图和上/下楼器的顺序" "_data": "在这里按顺序放所有的楼层;其顺序直接影响到楼层传送器、浏览地图和上/下楼器的顺序"
}, },
"plugin": {
"_leaf": true,
"_type": "textarea",
"_range": "thiseval instanceof Array",
"_docs": "插件列表",
"_data": "在这里按顺序放所有的插件,顺序会影响到插件的加载,越靠前越早加载"
},
"floorPartitions": { "floorPartitions": {
"_leaf": true, "_leaf": true,
"_type": "event", "_type": "event",

View File

@ -276,10 +276,10 @@ function core() {
core.prototype.init = async function (coreData, callback) { core.prototype.init = async function (coreData, callback) {
this._forwardFuncs(); this._forwardFuncs();
for (var key in coreData) core[key] = coreData[key]; for (var key in coreData) core[key] = coreData[key];
await this._loadGameProcess();
this._init_flags(); this._init_flags();
this._init_platform(); this._init_platform();
this._init_others(); this._init_others();
await this._loadGameProcess();
var b = main.mode == 'editor'; var b = main.mode == 'editor';
// 初始化画布 // 初始化画布
@ -302,12 +302,12 @@ core.prototype.init = async function (coreData, callback) {
}; };
core.prototype.initSync = function (coreData, callback) { core.prototype.initSync = function (coreData, callback) {
this._loadGameProcessSync();
this._forwardFuncs(); this._forwardFuncs();
for (var key in coreData) core[key] = coreData[key]; for (var key in coreData) core[key] = coreData[key];
this._init_flags(); this._init_flags();
this._init_platform(); this._init_platform();
this._init_others(); this._init_others();
this._loadGameProcessSync();
core.loader._load(function () { core.loader._load(function () {
core._afterLoadResources(callback); core._afterLoadResources(callback);
@ -319,11 +319,9 @@ core.prototype._loadGameProcess = async function () {
if (main.pluginUseCompress) { if (main.pluginUseCompress) {
await main.loadScript(`project/processG.min.js?v=${main.version}`); await main.loadScript(`project/processG.min.js?v=${main.version}`);
} else { } else {
// if (main.mode === 'play') { if (main.mode === 'editor') {
// await main.loadScript(`src/game/index.ts`, true); await main.loadScript(`src/game/index.esm.ts`, true);
// } else { }
// await main.loadScript(`src/game/index.esm.ts`, true);
// }
} }
}; };

View File

@ -521,17 +521,26 @@ loader.prototype.loadOneMusic = function (name) {
if (main.bgmRemote) if (main.bgmRemote)
music.src = main.bgmRemoteRoot + core.firstData.name + '/' + name; music.src = main.bgmRemoteRoot + core.firstData.name + '/' + name;
else music.src = 'project/bgms/' + name; else music.src = 'project/bgms/' + name;
if (main.mode === 'editor') {
music.loop = 'loop';
core.material.bgms[name] = music;
} else {
Mota.require('var', 'bgm').add(`bgms.${name}`, music); Mota.require('var', 'bgm').add(`bgms.${name}`, music);
}
}; };
loader.prototype.loadOneSound = function (name) { loader.prototype.loadOneSound = function (name) {
const sound = Mota.require('var', 'sound');
core.http( core.http(
'GET', 'GET',
'project/sounds/' + name + '?v=' + main.version, 'project/sounds/' + name + '?v=' + main.version,
null, null,
function (data) { function (data) {
if (main.mode === 'editor') {
core.loader._loadOneSound_decodeData(name, data);
} else {
const sound = Mota.require('var', 'sound');
sound.add(`sounds.${name}`, data); sound.add(`sounds.${name}`, data);
}
}, },
function (e) { function (e) {
core.material.sounds[name] = null; core.material.sounds[name] = null;

View File

@ -402,14 +402,24 @@ main.prototype.loadAsync = async function (mode, callback) {
].forEach(function (t) { ].forEach(function (t) {
coreData[t] = main[t]; coreData[t] = main[t];
}); });
if (main.mode === 'play') {
await core.init(coreData, callback); await core.init(coreData, callback);
if (main.mode === 'play') main.loading.emit('coreInit'); main.loading.emit('coreInit');
core.initStatus.maps = core.maps._initMaps(); core.initStatus.maps = core.maps._initMaps();
} else {
await core.init(coreData, () => {
callback();
core.initStatus.maps = core.maps._initMaps();
});
main.loading.emit('coreInit');
}
core.resize(); core.resize();
main.core = core; main.core = core;
if (main.mode === 'editor') return;
// 自动放缩最大化 // 自动放缩最大化
let auto = Mota.require('var', 'mainSetting').getValue('autoScale', true); let auto = Mota.require('var', 'mainSetting').getValue('autoScale', true);