commit
4c785c668f
@ -1,5 +1,7 @@
|
||||
# editor
|
||||
|
||||
>! 以下均是v2.0时的说明, 未及时改动
|
||||
|
||||
本目录下所有文件,以及`../editor.html`和`../启动服务.exe`([源码](http://github.com/ckcz123/mota-js-server/))是地图编辑器的所有组件.
|
||||
|
||||
`editor.js`,`editor_file.js`和`editor_mode.js`耦合较强,`editor_blockly.js`和`editor_multi.js`和`fs.js`基本可以独立使用.
|
||||
@ -103,23 +105,6 @@ editor_mode.onmode(editor_mode._ids[node.getAttribute('id')]);
|
||||
|
||||
`editor.mode.listen`中提供了追加素材的支持.
|
||||
|
||||
处理注释的特殊指令
|
||||
```
|
||||
$range(evalstr:thiseval)$end
|
||||
限制取值范围,要求修改后的eval(evalstr)为true
|
||||
$leaf(evalstr:thiseval)$end
|
||||
强制指定为叶节点,如果eval(evalstr)为true
|
||||
|
||||
//以下几个中选一个 [
|
||||
$select(evalstr)$end
|
||||
渲染成<select>,选项为数组eval(evalstr)['values']
|
||||
$input(evalstr)$end
|
||||
渲染成<input>
|
||||
$textarea(evalstr)$end
|
||||
渲染成<textarea>
|
||||
默认选项为$textarea()$end
|
||||
// ]
|
||||
```
|
||||
|
||||
### editor_blockly.js
|
||||
|
||||
@ -177,9 +162,3 @@ fs.readdir(path, callback)
|
||||
//所有参数不允许缺省
|
||||
```
|
||||
|
||||
## z-index
|
||||
|
||||
目前主体部分使用了 0-15,75,100
|
||||
|
||||
blockly使用 200,201
|
||||
多行文本编辑器使用 300
|
||||
@ -26,17 +26,6 @@ code=JSON.stringify(code,null,2).split('"data_asdfefw"').join('[\n'+action_0+']\
|
||||
return code;
|
||||
*/;
|
||||
|
||||
//加点 事件编辑器入口之一
|
||||
point_m
|
||||
: '加点' BGNL? Newline choicesContext+ BEND
|
||||
|
||||
|
||||
/* point_m
|
||||
tooltip : 加点事件
|
||||
helpUrl : https://h5mota.com/games/template/docs/#/event?id=%e5%8a%a0%e7%82%b9%e4%ba%8b%e4%bb%b6
|
||||
var code = '{"type": "choices", "choices": [\n'+choicesContext_0+']}\n';
|
||||
return code;
|
||||
*/;
|
||||
|
||||
//升级 事件编辑器入口之一
|
||||
level_m
|
||||
@ -217,6 +206,18 @@ var code = '{"floorId": "'+toFloorId+'"'+loc+DirectionEx_List_0+Int_0+Bool_0+' }
|
||||
return code;
|
||||
*/;
|
||||
|
||||
//commonEvent 事件编辑器入口之一
|
||||
commonEvent_m
|
||||
: '公共事件' BGNL? Newline action+ BEND
|
||||
|
||||
|
||||
/* commonEvent_m
|
||||
tooltip : 公共事件
|
||||
helpUrl : https://h5mota.com/games/template/docs/#/event
|
||||
var code = '[\n'+action_0+']\n';
|
||||
return code;
|
||||
*/;
|
||||
|
||||
//为了避免关键字冲突,全部加了_s
|
||||
//动作
|
||||
action
|
||||
@ -1960,15 +1961,6 @@ ActionParser.prototype.parse = function (obj,type) {
|
||||
obj.time,!this.isset(obj.portalWithoutTrigger)
|
||||
]);
|
||||
|
||||
case 'point':
|
||||
if(!obj)obj={};
|
||||
var text_choices = null;
|
||||
for(var ii=obj.choices.length-1,choice;choice=obj.choices[ii];ii--) {
|
||||
text_choices=MotaActionBlocks['choicesContext'].xmlText([
|
||||
choice.text,this.parseList(choice.action),text_choices]);
|
||||
}
|
||||
return MotaActionBlocks['point_m'].xmlText([text_choices]);
|
||||
|
||||
case 'level':
|
||||
if(!obj)obj={};
|
||||
var text_choices = null;
|
||||
|
||||
@ -62,6 +62,7 @@ editor.prototype.init = function (callback) {
|
||||
editor.mode.floor();
|
||||
editor.mode.tower();
|
||||
editor.mode.functions();
|
||||
editor.mode.commonevent();
|
||||
editor.mode.showMode('tower');
|
||||
|
||||
editor_multi = editor_multi();
|
||||
|
||||
@ -23,17 +23,6 @@ editor_blockly = function () {
|
||||
{"type": "hide", "time": 500},
|
||||
],'event'),
|
||||
MotaActionBlocks['changeFloor_m'].xmlText(),
|
||||
//MotaActionFunctions.actionParser.parse({"type": "choices", "choices": [
|
||||
// {"text": "攻击+\${point}", "action": [
|
||||
// {"type": "setValue", "name": "status:atk", "value": "status:atk+\${point}"},
|
||||
// ]},
|
||||
// {"text": "防御+\${2*point}", "action": [
|
||||
// {"type": "setValue", "name": "status:def", "value": "status:def+\${2*point}"},
|
||||
// ]},
|
||||
// {"text": "生命+\${200*point}", "action": [
|
||||
// {"type": "setValue", "name": "status:hp", "value": "status:hp+\${200*point}"},
|
||||
// ]},
|
||||
//]},'point'),
|
||||
MotaActionFunctions.actionParser.parse([{
|
||||
"id": "moneyShop1",
|
||||
"name": "贪婪之神",
|
||||
@ -55,6 +44,7 @@ editor_blockly = function () {
|
||||
MotaActionBlocks['firstArrive_m'].xmlText(),
|
||||
MotaActionBlocks['eachArrive_m'].xmlText(),
|
||||
MotaActionBlocks['level_m'].xmlText(),
|
||||
MotaActionBlocks['commonEvent_m'].xmlText(),
|
||||
],
|
||||
'显示文字':[
|
||||
MotaActionBlocks['text_0_s'].xmlText(),
|
||||
|
||||
@ -7,6 +7,7 @@ editor_file = function (editor, callback) {
|
||||
'comment': 'comment',
|
||||
'data.comment': 'dataComment',
|
||||
'functions.comment': 'functionsComment',
|
||||
'events.comment': 'eventsComment',
|
||||
}
|
||||
for (var key in commentjs) {
|
||||
(function (key) {
|
||||
@ -49,25 +50,7 @@ editor_file = function (editor, callback) {
|
||||
throw('未设置callback')
|
||||
}
|
||||
;
|
||||
/* var fs = editor.fs;
|
||||
fs.readFile('project/floors/'+filename+'.js','utf-8',function(err, data){
|
||||
if (err!=null){callback(err);return;}
|
||||
data=data.split('=');
|
||||
data=[data[0],data.slice(1).join('=')];
|
||||
var varnameId = data[0].split('.').slice(-1)[0].trim();
|
||||
var filenameId = filename.split('/').slice(-1)[0].split('\\').slice(-1)[0];
|
||||
eval('b3917d1d_71c2_41f2_a8aa_481b215ffb99='+data[1]);
|
||||
var floorData = b3917d1d_71c2_41f2_a8aa_481b215ffb99;
|
||||
delete(b3917d1d_71c2_41f2_a8aa_481b215ffb99);
|
||||
var floorId = floorData.floorId;
|
||||
if (varnameId!=filenameId || filenameId!=floorId){
|
||||
callback('文件名,第一行的变量名以及floorId不一致');
|
||||
return;
|
||||
}
|
||||
editor.currentFloorId = floorId;
|
||||
editor.currentFloorData = floorData;
|
||||
callback(null)
|
||||
}); */
|
||||
|
||||
editor.currentFloorId = editor.core.status.floorId;
|
||||
editor.currentFloorData = editor.core.floors[editor.currentFloorId];
|
||||
}
|
||||
@ -833,6 +816,39 @@ editor_file = function (editor, callback) {
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
editor_file.editCommonEvent = function (actionList, callback) {
|
||||
/*actionList:[
|
||||
["change","['test']",['123']],
|
||||
]
|
||||
为[]时只查询不修改
|
||||
*/
|
||||
var data_obj = events_c12a15a8_c380_4b28_8144_256cba95f760.commonEvent;
|
||||
if (!isset(callback)) {
|
||||
printe('未设置callback');
|
||||
throw('未设置callback')
|
||||
}
|
||||
;
|
||||
if (isset(actionList) && actionList.length > 0) {
|
||||
actionList.forEach(function (value) {
|
||||
value[1] = "['commonEvent']" + value[1];
|
||||
});
|
||||
saveSetting('events', actionList, function (err) {
|
||||
callback([
|
||||
Object.assign({},data_obj),
|
||||
editor_file.eventsComment._data.commonEvent,
|
||||
err]);
|
||||
});
|
||||
} else {
|
||||
callback([
|
||||
Object.assign({},data_obj),
|
||||
editor_file.eventsComment._data.commonEvent,
|
||||
null]);
|
||||
}
|
||||
}
|
||||
//callback([obj,commentObj,err:String])
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
var isset = function (val) {
|
||||
if (val == undefined || val == null) {
|
||||
return false;
|
||||
@ -996,37 +1012,20 @@ editor_file = function (editor, callback) {
|
||||
editor_file.saveFloorFile(callback);
|
||||
return;
|
||||
}
|
||||
if (file == 'events') {
|
||||
actionList.forEach(function (value) {
|
||||
eval("events_c12a15a8_c380_4b28_8144_256cba95f760" + value[1] + '=' + JSON.stringify(value[2]));
|
||||
});
|
||||
var datastr = 'var events_c12a15a8_c380_4b28_8144_256cba95f760 = \n';
|
||||
datastr += JSON.stringify(events_c12a15a8_c380_4b28_8144_256cba95f760, null, '\t');
|
||||
fs.writeFile('project/events.js', encode(datastr), 'base64', function (err, data) {
|
||||
callback(err);
|
||||
});
|
||||
return;
|
||||
}
|
||||
callback('出错了,要设置的文件名不识别');
|
||||
}
|
||||
|
||||
/*
|
||||
$select({\"values\":[\"keys\",\"items\",\"constants\",\"tools\"]})$end
|
||||
$range(thiseval==~~thiseval &&thiseval>0)$end
|
||||
$leaf(true)$end
|
||||
$select({\"values\":[true]})$end
|
||||
$select({\"values\":[false]})$end
|
||||
$select({\"values\":[true,false]})$end
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
所有注释中的特殊指令
|
||||
$range(evalstr:thiseval)$end
|
||||
限制取值范围,要求修改后的eval(evalstr)为true
|
||||
$leaf(evalstr:thiseval)$end
|
||||
强制指定为叶节点,如果eval(evalstr)为true
|
||||
|
||||
//以下几个中选一个 [
|
||||
$select(evalstr)$end
|
||||
渲染成<select>,选项为数组eval(evalstr)['values']
|
||||
$input(evalstr)$end
|
||||
渲染成<input>
|
||||
$textarea(evalstr)$end
|
||||
渲染成<textarea>
|
||||
默认选项为$textarea()$end
|
||||
// ]
|
||||
|
||||
*/
|
||||
return editor_file;
|
||||
}
|
||||
//editor_file = editor_file(editor);
|
||||
@ -11,6 +11,8 @@ editor_mode = function (editor) {
|
||||
|
||||
'map': 'left',
|
||||
'appendpic': 'left1',
|
||||
|
||||
'commonevent': 'left9',
|
||||
}
|
||||
this._ids = {}
|
||||
this.dom = {}
|
||||
@ -341,75 +343,40 @@ editor_mode = function (editor) {
|
||||
editor_mode.prototype.doActionList = function (mode, actionList) {
|
||||
if (actionList.length == 0) return;
|
||||
printf('修改中...');
|
||||
switch (mode) {
|
||||
case 'loc':
|
||||
|
||||
editor.file.editLoc(editor_mode.pos.x, editor_mode.pos.y, actionList, function (objs_) {//console.log(objs_);
|
||||
var cb=function(objs_){
|
||||
if (objs_.slice(-1)[0] != null) {
|
||||
printe(objs_.slice(-1)[0]);
|
||||
throw(objs_.slice(-1)[0])
|
||||
}
|
||||
;printf('修改成功');
|
||||
}
|
||||
switch (mode) {
|
||||
case 'loc':
|
||||
editor.file.editLoc(editor_mode.pos.x, editor_mode.pos.y, actionList, function (objs_) {
|
||||
cb(objs_);
|
||||
editor.drawPosSelection();
|
||||
});
|
||||
break;
|
||||
case 'enemyitem':
|
||||
|
||||
if (editor_mode.info.images == 'enemys' || editor_mode.info.images == 'enemy48') {
|
||||
editor.file.editEnemy(editor_mode.info.id, actionList, function (objs_) {//console.log(objs_);
|
||||
if (objs_.slice(-1)[0] != null) {
|
||||
printe(objs_.slice(-1)[0]);
|
||||
throw(objs_.slice(-1)[0])
|
||||
}
|
||||
;printf('修改成功')
|
||||
});
|
||||
editor.file.editEnemy(editor_mode.info.id, actionList, cb);
|
||||
} else if (editor_mode.info.images == 'items') {
|
||||
editor.file.editItem(editor_mode.info.id, actionList, function (objs_) {//console.log(objs_);
|
||||
if (objs_.slice(-1)[0] != null) {
|
||||
printe(objs_.slice(-1)[0]);
|
||||
throw(objs_.slice(-1)[0])
|
||||
}
|
||||
;printf('修改成功')
|
||||
});
|
||||
editor.file.editItem(editor_mode.info.id, actionList, cb);
|
||||
} else {
|
||||
editor.file.editMapBlocksInfo(editor_mode.info.idnum, actionList, function (objs_) {//console.log(objs_);
|
||||
if (objs_.slice(-1)[0] != null) {
|
||||
printe(objs_.slice(-1)[0]);
|
||||
throw(objs_.slice(-1)[0])
|
||||
}
|
||||
;printf('修改成功');
|
||||
});
|
||||
editor.file.editMapBlocksInfo(editor_mode.info.idnum, actionList, cb);
|
||||
}
|
||||
break;
|
||||
case 'floor':
|
||||
|
||||
editor.file.editFloor(actionList, function (objs_) {//console.log(objs_);
|
||||
if (objs_.slice(-1)[0] != null) {
|
||||
printe(objs_.slice(-1)[0]);
|
||||
throw(objs_.slice(-1)[0])
|
||||
}
|
||||
;printf('修改成功');
|
||||
});
|
||||
editor.file.editFloor(actionList, cb);
|
||||
break;
|
||||
case 'tower':
|
||||
|
||||
editor.file.editTower(actionList, function (objs_) {//console.log(objs_);
|
||||
if (objs_.slice(-1)[0] != null) {
|
||||
printe(objs_.slice(-1)[0]);
|
||||
throw(objs_.slice(-1)[0])
|
||||
}
|
||||
;printf('修改成功')
|
||||
});
|
||||
editor.file.editTower(actionList, cb);
|
||||
break;
|
||||
case 'functions':
|
||||
|
||||
editor.file.editFunctions(actionList, function (objs_) {//console.log(objs_);
|
||||
if (objs_.slice(-1)[0] != null) {
|
||||
printe(objs_.slice(-1)[0]);
|
||||
throw(objs_.slice(-1)[0])
|
||||
}
|
||||
;printf('修改成功')
|
||||
});
|
||||
editor.file.editFunctions(actionList, cb);
|
||||
break;
|
||||
case 'commonevent':
|
||||
editor.file.editCommonEvent(actionList, cb);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -540,6 +507,19 @@ editor_mode = function (editor) {
|
||||
if (Boolean(callback)) callback();
|
||||
}
|
||||
|
||||
editor_mode.prototype.commonevent = function (callback) {
|
||||
var objs = [];
|
||||
editor.file.editCommonEvent([], function (objs_) {
|
||||
objs = objs_;
|
||||
//console.log(objs_)
|
||||
});
|
||||
//只查询不修改时,内部实现不是异步的,所以可以这么写
|
||||
var tableinfo = editor_mode.objToTable_(objs[0], objs[1]);
|
||||
document.getElementById('table_b7bf0124_99fd_4af8_ae2f_0017f04a7c7d').innerHTML = tableinfo.HTML;
|
||||
tableinfo.listen(tableinfo.guids);
|
||||
if (Boolean(callback)) callback();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
editor_mode.prototype.listen = function (callback) {
|
||||
|
||||
36
_server/events.comment.js
Normal file
36
_server/events.comment.js
Normal file
@ -0,0 +1,36 @@
|
||||
var events_comment_c456ea59_6018_45ef_8bcc_211a24c627dc =
|
||||
{
|
||||
|
||||
"_type": "object",
|
||||
"_data": {
|
||||
"commonEvent": {
|
||||
|
||||
"_type": "object",
|
||||
"_data": function (key) {
|
||||
var obj = {
|
||||
"addPoint": {
|
||||
"_leaf": true,
|
||||
"_type": "event",
|
||||
"_range": "thiseval instanceof Array",
|
||||
"_event": "commonEvent",
|
||||
"_data": "加点事件,可以双击进入事件编辑器"
|
||||
},
|
||||
"test": {
|
||||
"_leaf": true,
|
||||
"_type": "event",
|
||||
"_range": "thiseval instanceof Array",
|
||||
"_event": "commonEvent",
|
||||
"_data": "测试事件, events.comment.js中标记了_range不能为null, 所以应该无法删除"
|
||||
},
|
||||
}
|
||||
if (obj[key]) return obj[key];
|
||||
return {
|
||||
"_leaf": true,
|
||||
"_type": "event",
|
||||
"_event": "commonEvent",
|
||||
"_data": "自定义公共事件,可以双击进入事件编辑器"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
var maps_comment_90f36752_8815_4be8_b32b_d7fad1d0542e =
|
||||
var maps_comment_c456ea59_6018_45ef_8bcc_211a24c627dc =
|
||||
{
|
||||
////////////////////////// 地形部分 //////////////////////////
|
||||
|
||||
|
||||
@ -185,7 +185,6 @@
|
||||
<select id="entryType" disabled="disabled" style="display: none">
|
||||
<option value="event">event</option>
|
||||
<option value="changeFloor">changeFloor</option>
|
||||
<option value="point">point</option>
|
||||
<option value="level">level</option>
|
||||
<option value="shop">shop</option>
|
||||
<option value="afterBattle">afterBattle</option>
|
||||
@ -193,6 +192,7 @@
|
||||
<option value="afterOpenDoor">afterOpenDoor</option>
|
||||
<option value="firstArrive">firstArrive</option>
|
||||
<option value="eachArrive">eachArrive</option>
|
||||
<option value="commonEvent">commonEvent</option>
|
||||
</select>
|
||||
<button onclick="editor_blockly.confirm()">确认</button>
|
||||
<button onclick="editor_blockly.parse()">解析</button>
|
||||
@ -242,6 +242,23 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="left9" class='leftTab' style="z-index:-1;opacity: 0;"><!-- commonevent -->
|
||||
<h3 class="leftTabHeader">公共事件 <button onclick="editor.mode.onmode('save')">保存</button> <button onclick="editor.mode.changeDoubleClickModeByButton('add')">添加</button> <button onclick="editor.mode.changeDoubleClickModeByButton('delete')">删除</button>
|
||||
</h3>
|
||||
<div class="leftTabContent">
|
||||
<div class='etable'>
|
||||
<table>
|
||||
<tbody id='table_b7bf0124_99fd_4af8_ae2f_0017f04a7c7d'>
|
||||
<tr>
|
||||
<td>条目</td>
|
||||
<td>注释</td>
|
||||
<td>值</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="mid">
|
||||
<div class="col" id='mapColMark'></div>
|
||||
<div class="row" id='mapRowMark'></div>
|
||||
@ -309,6 +326,7 @@
|
||||
<option value="tower">全塔属性</option>
|
||||
<option value="functions">脚本编辑</option>
|
||||
<option value="appendpic">追加素材</option>
|
||||
<option value="commonevent">公共事件</option>
|
||||
</select>
|
||||
<select id="brushMod" style="clear:right">
|
||||
<option value="line">画线</option>
|
||||
|
||||
20
editor.html
20
editor.html
@ -181,7 +181,6 @@
|
||||
<select id="entryType" disabled="disabled" style="display: none">
|
||||
<option value="event">event</option>
|
||||
<option value="changeFloor">changeFloor</option>
|
||||
<option value="point">point</option>
|
||||
<option value="level">level</option>
|
||||
<option value="shop">shop</option>
|
||||
<option value="afterBattle">afterBattle</option>
|
||||
@ -189,6 +188,7 @@
|
||||
<option value="afterOpenDoor">afterOpenDoor</option>
|
||||
<option value="firstArrive">firstArrive</option>
|
||||
<option value="eachArrive">eachArrive</option>
|
||||
<option value="commonEvent">commonEvent</option>
|
||||
</select>
|
||||
<button onclick="editor_blockly.confirm()">确认</button>
|
||||
<button onclick="editor_blockly.parse()">解析</button>
|
||||
@ -238,6 +238,23 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="left9" class='leftTab' style="z-index:-1;opacity: 0;"><!-- commonevent -->
|
||||
<h3 class="leftTabHeader">公共事件 <button onclick="editor.mode.onmode('save')">保存</button> <button onclick="editor.mode.changeDoubleClickModeByButton('add')">添加</button> <button onclick="editor.mode.changeDoubleClickModeByButton('delete')">删除</button>
|
||||
</h3>
|
||||
<div class="leftTabContent">
|
||||
<div class='etable'>
|
||||
<table>
|
||||
<tbody id='table_b7bf0124_99fd_4af8_ae2f_0017f04a7c7d'>
|
||||
<tr>
|
||||
<td>条目</td>
|
||||
<td>注释</td>
|
||||
<td>值</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="mid">
|
||||
<table class="col" id='mapColMark'></table>
|
||||
<table class="row" id='mapRowMark'></table>
|
||||
@ -277,6 +294,7 @@
|
||||
<option value="tower">全塔属性</option>
|
||||
<option value="functions">脚本编辑</option>
|
||||
<option value="appendpic">追加素材</option>
|
||||
<option value="commonevent">公共事件</option>
|
||||
</select>
|
||||
<br/>
|
||||
<span style="font-size: 12px;">
|
||||
|
||||
2
main.js
2
main.js
@ -75,7 +75,7 @@ function main() {
|
||||
'loader', 'control', 'utils', 'items', 'icons', 'maps', 'enemys', 'events', 'actions', 'data', 'ui', 'core'
|
||||
];
|
||||
this.pureData = [
|
||||
'data', 'enemys', 'icons', 'maps', 'items', 'functions'
|
||||
'data', 'enemys', 'icons', 'maps', 'items', 'functions', 'events'
|
||||
];
|
||||
this.materials = [
|
||||
'animates', 'enemys', 'hero', 'items', 'npcs', 'terrains', 'enemy48', 'npc48'
|
||||
|
||||
14
project/events.js
Normal file
14
project/events.js
Normal file
@ -0,0 +1,14 @@
|
||||
var events_c12a15a8_c380_4b28_8144_256cba95f760 =
|
||||
{
|
||||
"commonEvent": {
|
||||
"addPoint": [
|
||||
""
|
||||
],
|
||||
"test": [
|
||||
"应该无法删除"
|
||||
],
|
||||
"test2": [
|
||||
"应该可以删除"
|
||||
]
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user