mota-js/_server
2019-03-20 13:47:48 +08:00
..
blockly type:insert 2019-03-19 23:57:43 +08:00
CodeMirror editor format js 2019-02-18 23:51:38 +08:00
colorPicker blockly-version 2019-02-18 10:20:34 -05:00
css Fix diff' 2019-03-17 02:07:06 +08:00
vendor fix bug: polyfill old version of IE 2018-01-20 13:30:36 +08:00
comment.js npc48 animate & loadBgm 2019-03-10 13:50:55 +08:00
data.comment.js remove flyRange 2019-03-16 03:03:02 +08:00
editor_blockly.js updateDamage, addValue 2019-03-18 19:21:23 +08:00
editor_file.js ui 2019-03-19 14:23:43 -04:00
editor_mode.js Merge pull request #326 from zhaouv/plugins 2019-03-20 13:28:09 +08:00
editor_multi.js autoFormat & clearPoint 2019-02-27 00:37:46 +08:00
editor.js resetGame & core.init 2019-03-17 18:00:00 +08:00
events.comment.js commonEvents 2019-02-02 14:08:55 +08:00
fs.js main.log && 2019-01-16 19:09:42 +08:00
fsTest_cs.html fsTest 2019-01-01 11:06:03 -05:00
functions.comment.js plugins 2019-03-20 13:47:48 +08:00
maps.comment.js common event-create 2019-01-31 16:56:08 -05:00
plugins.comment.js plugins 2019-03-20 13:47:48 +08:00
README.md delete legacy comment 2019-01-31 17:15:53 -05:00
vm.js editor-airwall 2018-09-27 18:01:38 +08:00

editor

! 以下均是v2.0时的说明, 未及时改动

本目录下所有文件,以及../editor.html../启动服务.exe(源码)是地图编辑器的所有组件.

editor.js,editor_file.jseditor_mode.js耦合较强,editor_blockly.jseditor_multi.jsfs.js基本可以独立使用.

各组件功能

总体上

display:none的形式引入了index.htmldom,修改了原来的.gameCanvas #ui #data等的名字以避免冲突

通过main.init('editor')加载数据

editor模式关闭了部分动画

core.drawMapeditor模式下不再画图,而是生成画图的函数提供给editor

editor模式下GlobalAnimate可以独立的选择是否播放

core.playBgmcore.playSound中非play模式不再播放声音

core.showcore.hide中非play模式不再进行动画而是立刻完成并执行回调

editor模式不执行core.resize

editor.js

editor.mapInit();//清空地图
editor.changeFloor('MT2')//切换地图
editor.guid()//产生一个可以作为id的长随机字符串

editor.updateMap中画未定义快的报错

editor_file.js

提供了以下函数进行楼层map数组相关的操作

editor.file.getFloorFileList
editor.file.loadFloorFile
editor.file.saveFloorFile
editor.file.saveFloorFileAs

编辑模式有关的查询

editor.file.editItem('redJewel',[],function(a){console.log(a)});
editor.file.editEnemy('redBat',[],function(a){console.log(a)});
editor.file.editLoc(2,0,[],function(a){console.log(a)});
editor.file.editFloor([],function(a){console.log(a)});
editor.file.editTower([],function(a){console.log(a)});
editor.file.editFunctions([],function(a){console.log(a)});

编辑模式有关的编辑

editor.info={images: "terrains", y: 9};
editor.file.changeIdAndIdnum('yellowWall2',16,editor.info,function(a){console.log(a)});
editor.file.editItem('book',[["change","['items']['name']","怪物手册的新名字"]],function(a){console.log(a)});
editor.file.editEnemy('redBat',[['change',"['atk']",20]],function(a){console.log(a)});
editor.file.editLoc(2,6,[["change","['afterBattle']",null]],function(a){console.log(a)});
editor.file.editFloor([["change","['title']",'样板 33 层']],function(a){console.log(a)});
editor.file.editTower([["change","['values']['lavaDamage']",200]],function(a){console.log(a)});
editor.file.editFunctions(["change","['events']['afterChangeLight']","function(x,y){console.log(x,y)}"],function(a){console.log(a)});

editor_mode.js

生成表格并绑定事件的函数

editor.mode.loc();
editor.mode.enemyitem();
editor.mode.floor();
editor.mode.tower();
editor.mode.functions();

切换模式

editor.mode.onmode('');//清空
editor.mode.onmode('save');//保存
editor.mode.onmode('nextChange');//下次onmode时前端进行切换

editor.mode.onmode('loc');
editor.mode.onmode('enemyitem');
editor.mode.onmode('floor');
editor.mode.onmode('tower');
editor.mode.onmode('functions');
editor.mode.onmode('map');
editor.mode.onmode('appendpic');

onmode('save')时,改动才会保存到文件,涉及到图片的改动需要刷新页面使得editor能看到

表格的onchange的实现中,获得当前模式的方式.不注意的话,修改index.html中页面的结构,会被坑

var node = thisTr.parentNode;
while (!editor_mode._ids.hasOwnProperty(node.getAttribute('id'))) {
  node = node.parentNode;
}
editor_mode.onmode(editor_mode._ids[node.getAttribute('id')]);

editor.mode.listen中提供了追加素材的支持.

editor_blockly.js

把选定id_的事件用blockly编辑

editor_blockly.import(id_,{type:'event'});

把文本区域的代码转换成图块

editor_blockly.parse();

editor_multi.js

CodeMirror 实现有高亮的多行文本编辑

编辑选定id_的文本域

editor_multi.import(id_,{lint:true})

编辑blockly方块的特定域

editor_multi.multiLineEdit(value,b,f,{lint:true},callback)

fs.js

模仿node的fs模块提供如下api,与启动服务.exe配合为js提供文件读写功能

fs.readFile('file.in','utf-8',callback) 
//读文本文件
//callback:function(err, data)
//data:字符串
fs.readFile('file.in','base64',callback) 
//读二进制文件
//callback:function(err, data)  
//data:base64字符串

fs.writeFile('file.out', data ,'utf-8', callback)
//写文本文件
//callback:function(err)
//data:字符串
fs.writeFile('file.out', data ,'base64', callback)
//写二进制文件
//callback:function(err)
//data:base64字符串

fs.readdir(path, callback)
//callback:function(err, data) 
//path:支持"/"做分隔符
//data:[filename1,filename2,..] filename是字符串,只包含文件不包含目录

//所有参数不允许缺省