diff --git a/src/core/main/setting.ts b/src/core/main/setting.ts index c0edb54..56f4d79 100644 --- a/src/core/main/setting.ts +++ b/src/core/main/setting.ts @@ -1,4 +1,4 @@ -import { reactive } from 'vue'; +import { Component, reactive } from 'vue'; import { EmitableEvent, EventEmitter } from '../common/eventEmitter'; import { loading } from '../loader/load'; import { hook } from './game'; @@ -14,6 +14,7 @@ export interface MotaSettingItem { defaults?: boolean | number; step?: [number, number, number]; display?: (value: T) => string; + controller?: Component; special?: string; } @@ -147,6 +148,12 @@ export class MotaSetting extends EventEmitter { return this; } + setValueController(key: string, com: Component) { + const setting = this.getSettingBy(key.split('.')); + setting.controller = com; + return this; + } + private getSettingBy(list: string[]) { let now: MotaSetting = this; diff --git a/src/plugin/game/dev/hotReload.js b/src/plugin/game/dev/hotReload.js index 04c5a5e..867242a 100644 --- a/src/plugin/game/dev/hotReload.js +++ b/src/plugin/game/dev/hotReload.js @@ -56,50 +56,6 @@ export {}; console.log(`Floor hot reload: ${data}`); } - /** - * 热重载脚本编辑 - */ - async function reloadScript() { - // 脚本编辑略微麻烦点 - const before = functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a; - // 这里不能用动态导入,因为动态导入会变成模块,变量就不是全局的了 - const script = document.createElement('script'); - script.src = `/forceTem/project/functions.js?v=${Date.now()}`; - document.body.appendChild(script); - await new Promise(res => { - script.onload = () => res('success'); - }); - const after = functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a; - // 找到差异的函数 - for (const mod in before) { - const fns = before[mod]; - for (const id in fns) { - const fn = fns[id]; - if (typeof fn !== 'function') continue; - const now = after[mod][id]; - if (fn.toString() !== now.toString()) { - try { - if (mod === 'events') { - core.events.eventdata[id] = now; - } else if (mod === 'enemys') { - core.enemys.enemydata[id] = now; - } else if (mod === 'actions') { - core.actions.actionsdata[id] = now; - } else if (mod === 'control') { - core.control.controldata[id] = now; - } else if (mod === 'ui') { - core.ui.uidata[id] = now; - } - core.updateStatusBar(true, true); - console.log(`Function hot reload: ${mod}.${id}`); - } catch (e) { - console.error(e); - } - } - } - } - } - /** * 属性热重载,包括全塔属性等 * @param {string} data @@ -168,7 +124,6 @@ export {}; if (data.type === 'reload') location.reload(); if (data.type === 'floorHotReload') reloadFloor(data.floor); if (data.type === 'dataHotReload') reloadData(data.data); - if (data.type === 'functionsHotReload') reloadScript(); if (data.type === 'cssHotReload') reloadCss(data.path); }); })(); diff --git a/src/ui/settings.vue b/src/ui/settings.vue index 4c17d45..e341f1e 100644 --- a/src/ui/settings.vue +++ b/src/ui/settings.vue @@ -52,7 +52,10 @@ >
-
+
+ +
+