From 0c24e662c92dfa7d8b5cfc04faa62829d608396a Mon Sep 17 00:00:00 2001 From: YouWei Zhao Date: Tue, 9 Jan 2018 23:45:16 +0800 Subject: [PATCH] editor --- 2.0diff.md | 67 ++++++++++++++++++++++++++++++------------ _server/editor.js | 8 +++++ _server/editor_file.js | 3 +- _server/editor_mode.js | 52 ++++++++++++++++++++++++++++++-- editor.html | 10 +++++-- 5 files changed, 117 insertions(+), 23 deletions(-) diff --git a/2.0diff.md b/2.0diff.md index 0f9ad4eb..814b4b04 100644 --- a/2.0diff.md +++ b/2.0diff.md @@ -12,8 +12,10 @@ + 重命名为`editor.html` * 需要相应的修改本地服务的按钮打开的网址,为了兼容,临时加了个内容为``的`drawMapGUI.html` + 不再独立的导入数据和画图,尽可能的通过`main.init('editor')`复用代码 -+ 能够在本地服务器环境中直接修改`project`中的数据,目前只完成了文件操作的代码`_server/editor_file.js`,前端尚未完成 ++ 能够在本地服务器环境中直接修改`project`中的数据,即全GUI下做塔 + 把`editor`的代码拆到了`_server/editor.js`中 ++ 添加了`_server/css/editor_mode.css`存放编辑模式有关的样式 ++ 添加了`_server/editor_mode.js`存放编辑模式的实现 ## 具体: @@ -24,7 +26,7 @@ `main.listen`和`main.init`改为在`index.html`中执行 -添加了`main.prototype.loadPureData`,在`main.init`中先加载存数据再加载`libs` +添加了`main.prototype.loadPureData`,在`main.init`中先加载纯数据再加载`libs` ### core.js `core.drawMap`中`editor`模式下不再画图,而是生成画图的函数提供给`editor` @@ -74,7 +76,35 @@ editor.file.editFloor(editor,[["change","['title']",'样板 33 层']],function(a editor.file.editTower(editor,[["change","['values']['lavaDamage']",200]],function(a){console.log(a)}); ``` +### editor_mode.js +4个生成表格并绑定事件的函数 +```javascript +editor_mode.loc(); +editor_mode.emenyitem(); +editor_mode.floor(); +editor_mode.tower(); +``` +切换模式 +```javascript +editor_mode.onmode(''); +editor_mode.onmode('loc'); +editor_mode.onmode('emenyitem'); +editor_mode.onmode('floor'); +editor_mode.onmode('tower'); +``` +在切换模式时,改动才会保存到文件,并且需要刷新页面使得`editor`能看到改动 + +表格的`onchange`的实现中,获得当前模式的方式.不注意的话,修改`index.html`中页面的结构,会被坑 +```javascript +var node = thisTr.parentNode; +while (!editor_mode._ids.hasOwnProperty(node.getAttribute('id'))) { + node = node.parentNode; +} +editor_mode.onmode(editor_mode._ids[node.getAttribute('id')]); +``` ### drawMapGUI.html +重命名为`editor.html` + 把`editor`的代码拆到了`_server/editor.js`中 以`display:none`的形式引入了`index.html`的`dom`,修改了原来的`.gameCanvas #ui #data`等的名字以避免冲突 @@ -96,26 +126,27 @@ $range(evalstr:thiseval)$end $leaf(evalstr:thiseval)$end 强制指定为叶节点,如果eval(evalstr)为true -todo: //以下几个中选一个 [ $select(evalstr)$end 渲染成,此为默认选项 +$input(evalstr)$end + 渲染成 $textarea(evalstr)$end - 渲染成