fix: 编辑器打不开

This commit is contained in:
unanmed 2025-06-12 15:23:00 +08:00
parent da05785694
commit f796e93240
14 changed files with 97 additions and 66 deletions

View File

@ -1,6 +1,6 @@
import { backDir, has } from '@user/data-utils';
import { loading } from '@user/data-base';
import { LayerDoorAnimate } from '@user/client-modules';
import type { LayerDoorAnimate } from '@user/client-modules';
/**
*

View File

@ -1,5 +1,7 @@
import { createData } from '@user/entry-data';
import { create } from './create';
export function createGame() {
createData();
create();
}

View File

@ -4,12 +4,14 @@ import { patchAll } from '@user/data-fallback';
import { loading } from '@user/data-base';
import { Patch } from '@motajs/legacy-common';
createMota();
patchAll();
create();
export function createData() {
createMota();
patchAll();
create();
loading.once('coreInit', () => {
loading.once('coreInit', () => {
Patch.patchAll();
});
});
}
export * from './mota';

View File

@ -1,3 +1,7 @@
if (import.meta.env.DEV) {
import('./dev/hotReload');
}
export * from './boss';
export * from './chase';
export * from './fx';

View File

@ -5,10 +5,6 @@ import { createHook } from './hook';
import { initReplay } from './replay';
import { initUI } from './ui';
if (import.meta.env.DEV) {
import('./dev/hotReload');
}
export function create() {
initFallback();
loading.once('coreInit', () => {

View File

@ -127,7 +127,7 @@ export class Logger {
const n = Math.floor(code / 50) + 1;
const n2 = code % 50;
const url = `${location.origin}/_docs/logger/error/error${n}.html#error-code-${n2}`;
console.error(`[ERROR Code ${code}] ${text}. See ${url}`);
console.error(`[ERROR Code ${code}] ${text} See ${url}`);
}
}

View File

@ -1,11 +1,12 @@
import { createDanmaku } from './danmaku';
import { createFixed } from './fixed';
import { createUI } from './ui';
import { createSetting, createUI } from './ui';
export function createPreset() {
createDanmaku();
createFixed();
createUI();
createSetting();
}
export * from './ui';

View File

@ -224,46 +224,6 @@ mainSetting
.register('tips', '小贴士', true, COM.Boolean)
);
const { loading } = Mota.require('@user/data-base');
loading.once('coreInit', () => {
mainSetting.reset({
'screen.fullscreen': !!document.fullscreenElement,
'screen.halo': !!storage.getValue('screen.showHalo', true),
'screen.itemDetail': !!storage.getValue('screen.itemDetail', true),
'screen.heroDetail': !!storage.getValue('screen.heroDetail', false),
'screen.transition': !!storage.getValue('screen.transition', false),
'screen.fontSize': storage.getValue(
'screen.fontSize',
isMobile ? 9 : 16
),
'screen.smoothView': !!storage.getValue('screen.smoothView', true),
'screen.criticalGem': !!storage.getValue('screen.criticalGem', false),
'screen.fontSizeStatus': storage.getValue('screen.fontSizeStatus', 100),
'action.fixed': !!storage.getValue('action.fixed', true),
'audio.bgmEnabled': !!storage.getValue('audio.bgmEnabled', true),
'audio.bgmVolume': storage.getValue('audio.bgmVolume', 80),
'audio.soundEnabled': !!storage.getValue('audio.soundEnabled', true),
'audio.soundVolume': storage.getValue('audio.soundVolume', 80),
'utils.betterLoad': !!storage.getValue('utils.betterLoad', true),
'utils.autoScale': !!storage.getValue('utils.autoScale', true),
'fx.paraLight': !!storage.getValue('fx.paraLight', true),
'fx.frag': !!storage.getValue('fx.frag', true),
'fx.portalParticle': !!storage.getValue('fx.portalParticle', true),
'ui.mapScale': storage.getValue(
'ui.mapScale',
isMobile ? 300 : Math.floor(window.innerWidth / 600) * 50
),
'ui.mapLazy': storage.getValue('ui.mapLazy', false),
'ui.bookScale': storage.getValue('ui.bookScale', isMobile ? 100 : 80),
'ui.danmaku': storage.getValue('ui.danmaku', true),
'ui.danmakuSpeed': storage.getValue(
'ui.danmakuSpeed',
Math.floor(window.innerWidth / 30) * 5
),
'ui.tips': storage.getValue('ui.tips', true)
});
});
interface SettingTextData {
[x: string]: string[] | SettingTextData;
}
@ -320,3 +280,57 @@ getSettingText(settingsText);
window.addEventListener('resize', () => {
setFontSize();
});
export function createSetting() {
const { loading } = Mota.require('@user/data-base');
loading.once('coreInit', () => {
mainSetting.reset({
'screen.fullscreen': !!document.fullscreenElement,
'screen.halo': !!storage.getValue('screen.showHalo', true),
'screen.itemDetail': !!storage.getValue('screen.itemDetail', true),
'screen.heroDetail': !!storage.getValue('screen.heroDetail', false),
'screen.transition': !!storage.getValue('screen.transition', false),
'screen.fontSize': storage.getValue(
'screen.fontSize',
isMobile ? 9 : 16
),
'screen.smoothView': !!storage.getValue('screen.smoothView', true),
'screen.criticalGem': !!storage.getValue(
'screen.criticalGem',
false
),
'screen.fontSizeStatus': storage.getValue(
'screen.fontSizeStatus',
100
),
'action.fixed': !!storage.getValue('action.fixed', true),
'audio.bgmEnabled': !!storage.getValue('audio.bgmEnabled', true),
'audio.bgmVolume': storage.getValue('audio.bgmVolume', 80),
'audio.soundEnabled': !!storage.getValue(
'audio.soundEnabled',
true
),
'audio.soundVolume': storage.getValue('audio.soundVolume', 80),
'utils.betterLoad': !!storage.getValue('utils.betterLoad', true),
'utils.autoScale': !!storage.getValue('utils.autoScale', true),
'fx.paraLight': !!storage.getValue('fx.paraLight', true),
'fx.frag': !!storage.getValue('fx.frag', true),
'fx.portalParticle': !!storage.getValue('fx.portalParticle', true),
'ui.mapScale': storage.getValue(
'ui.mapScale',
isMobile ? 300 : Math.floor(window.innerWidth / 600) * 50
),
'ui.mapLazy': storage.getValue('ui.mapLazy', false),
'ui.bookScale': storage.getValue(
'ui.bookScale',
isMobile ? 100 : 80
),
'ui.danmaku': storage.getValue('ui.danmaku', true),
'ui.danmakuSpeed': storage.getValue(
'ui.danmakuSpeed',
Math.floor(window.innerWidth / 30) * 5
),
'ui.tips': storage.getValue('ui.tips', true)
});
});
}

View File

@ -3250,7 +3250,7 @@ colour : this.dataColor
try {
var tempobj = JSON.parse(JsonEvalString_0);
} catch (e) {throw new Error("不合法的JSON格式");}
if (!tempobj.type) throw new Error("自定义事件需要一个type:xxx");
// if (!tempobj.type) throw new Error("自定义事件需要一个type:xxx");
var code = JSON.stringify(tempobj) +',\n';
return code;
*/;
@ -3517,7 +3517,7 @@ isShopVisited_e
/* isShopVisited_e
default : ['shop1']
allShops : ['IdString_0']
var code = 'Mota.require('@user/legacy-plugin-data').isShopVisited(\'' + IdString_0 + '\')';
var code = 'Mota.require("@user/legacy-plugin-data").isShopVisited(\'' + IdString_0 + '\')';
return [code, Blockly.JavaScript.ORDER_ATOMIC];
*/;

View File

@ -360,7 +360,7 @@ core.prototype._loadGameProcess = async function () {
if (main.pluginUseCompress) {
await main.loadScript(`project/processG.min.js`);
} else {
await main.loadScript(`src/game/index.esm.ts`, true);
await main.loadScript(`src/editor.esm.ts`, true);
}
}
}

View File

@ -47,7 +47,6 @@ main.floors.MT0=
"他从石头的缝隙中看去,看到满山的枫叶在秋风中摇曳,仿佛在提醒他时间的流逝。",
"这些自然的变迁,虽然无情,却也教会了他如何适应和生存。",
"\t[原始人]今天的天气似乎不错,那就上山看看吧。",
"\r[red]注意!!!\r[]该塔新增了很多新的功能同时对样板的ui进行了大幅度的改动操作也有改变由于内容过多这里不再一一描述具体请在道具栏查看百科全书百科全书是在你面前的几个道具中的其中一个",
{
"type": "function",
"function": "function(){\nif (!core.isReplaying()) Mota.require('@motajs/legacy-ui').fixedUi.open('chapter', { chapter: '序章 起源' });\n}"
@ -122,11 +121,7 @@ main.floors.MT0=
"autoEvent": {},
"bgm": "cave.opus",
"beforeBattle": {},
"bg2map": [
],
"fg2map": [
],
"bg2map": [],
"fg2map": [],
"cannotMoveIn": {}
}

View File

@ -17,6 +17,7 @@ import { WebSocket, WebSocketServer } from 'ws';
import chokidar from 'chokidar';
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import replace from '@rollup/plugin-replace';
const base = './public';
@ -150,10 +151,23 @@ async function getEsmFile(
exclude: '**/node_modules/**'
},
plugins: [
typescript({ sourceMap: true }),
nodeResolve(),
typescript({
sourceMap: true,
noCheck: true,
paths: {
'@motajs/*': ['packages/*/src'],
'@user/*': ['packages-user/*/src']
}
}),
nodeResolve({
browser: true,
preferBuiltins: false
}),
commonjs(),
json()
json(),
replace({
'import.meta.env.DEV': 'false'
})
],
onwarn() {}
});

3
src/editor.ts Normal file
View File

@ -0,0 +1,3 @@
import { createData } from '@user/entry-data';
createData();