diff --git a/packages-user/data-state/src/mechanism/misc.ts b/packages-user/data-state/src/mechanism/misc.ts index 9fb68a2..9655ab0 100644 --- a/packages-user/data-state/src/mechanism/misc.ts +++ b/packages-user/data-state/src/mechanism/misc.ts @@ -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'; /** * 一些零散机制的数据 diff --git a/packages-user/entry-client/src/index.ts b/packages-user/entry-client/src/index.ts index 3f58b4d..2a166b0 100644 --- a/packages-user/entry-client/src/index.ts +++ b/packages-user/entry-client/src/index.ts @@ -1,5 +1,7 @@ +import { createData } from '@user/entry-data'; import { create } from './create'; export function createGame() { + createData(); create(); } diff --git a/packages-user/entry-data/src/index.ts b/packages-user/entry-data/src/index.ts index 1c6fadc..010949b 100644 --- a/packages-user/entry-data/src/index.ts +++ b/packages-user/entry-data/src/index.ts @@ -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', () => { - Patch.patchAll(); -}); + loading.once('coreInit', () => { + Patch.patchAll(); + }); +} export * from './mota'; diff --git a/packages-user/legacy-plugin-data/src/dev/hotReload.ts b/packages-user/legacy-plugin-client/src/dev/hotReload.ts similarity index 100% rename from packages-user/legacy-plugin-data/src/dev/hotReload.ts rename to packages-user/legacy-plugin-client/src/dev/hotReload.ts diff --git a/packages-user/legacy-plugin-client/src/index.ts b/packages-user/legacy-plugin-client/src/index.ts index d55557b..d77935a 100644 --- a/packages-user/legacy-plugin-client/src/index.ts +++ b/packages-user/legacy-plugin-client/src/index.ts @@ -1,3 +1,7 @@ +if (import.meta.env.DEV) { + import('./dev/hotReload'); +} + export * from './boss'; export * from './chase'; export * from './fx'; diff --git a/packages-user/legacy-plugin-data/src/index.ts b/packages-user/legacy-plugin-data/src/index.ts index d2c7078..dab702a 100644 --- a/packages-user/legacy-plugin-data/src/index.ts +++ b/packages-user/legacy-plugin-data/src/index.ts @@ -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', () => { diff --git a/packages/common/src/logger.ts b/packages/common/src/logger.ts index 3146b0f..d57a211 100644 --- a/packages/common/src/logger.ts +++ b/packages/common/src/logger.ts @@ -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}`); } } diff --git a/packages/legacy-ui/src/preset/index.ts b/packages/legacy-ui/src/preset/index.ts index 40400c9..8b00c2e 100644 --- a/packages/legacy-ui/src/preset/index.ts +++ b/packages/legacy-ui/src/preset/index.ts @@ -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'; diff --git a/packages/legacy-ui/src/preset/ui.ts b/packages/legacy-ui/src/preset/ui.ts index 8239362..10a4a32 100644 --- a/packages/legacy-ui/src/preset/ui.ts +++ b/packages/legacy-ui/src/preset/ui.ts @@ -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) + }); + }); +} diff --git a/public/_server/MotaAction.g4 b/public/_server/MotaAction.g4 index d24bb7a..8e668e0 100644 --- a/public/_server/MotaAction.g4 +++ b/public/_server/MotaAction.g4 @@ -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]; */; diff --git a/public/libs/core.js b/public/libs/core.js index 369e4d0..6ccf6e3 100644 --- a/public/libs/core.js +++ b/public/libs/core.js @@ -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); } } } diff --git a/public/project/floors/MT0.js b/public/project/floors/MT0.js index 33231b2..33e86fa 100644 --- a/public/project/floors/MT0.js +++ b/public/project/floors/MT0.js @@ -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": {} } \ No newline at end of file diff --git a/script/dev.ts b/script/dev.ts index 52379d0..f16be2f 100644 --- a/script/dev.ts +++ b/script/dev.ts @@ -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() {} }); diff --git a/src/editor.ts b/src/editor.ts new file mode 100644 index 0000000..db2c753 --- /dev/null +++ b/src/editor.ts @@ -0,0 +1,3 @@ +import { createData } from '@user/entry-data'; + +createData();