From ed9550a773a8ec0200462271a095a95d66433b21 Mon Sep 17 00:00:00 2001 From: YouWei Zhao Date: Thu, 31 Jan 2019 16:56:08 -0500 Subject: [PATCH 1/8] common event-create create js file&obj, load them in main and editor_file --- _server/editor_file.js | 1 + _server/events.comment.js | 30 ++++++++++++++++++++++++++++++ _server/maps.comment.js | 2 +- main.js | 2 +- project/events.js | 5 +++++ 5 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 _server/events.comment.js create mode 100644 project/events.js diff --git a/_server/editor_file.js b/_server/editor_file.js index 2fe185c5..202b17b9 100644 --- a/_server/editor_file.js +++ b/_server/editor_file.js @@ -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) { diff --git a/_server/events.comment.js b/_server/events.comment.js new file mode 100644 index 00000000..4a4f1094 --- /dev/null +++ b/_server/events.comment.js @@ -0,0 +1,30 @@ +var events_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = +{ + + "_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": "自定义公共事件,可以双击进入事件编辑器" + } + } +} \ No newline at end of file diff --git a/_server/maps.comment.js b/_server/maps.comment.js index be2e8db8..187119a9 100644 --- a/_server/maps.comment.js +++ b/_server/maps.comment.js @@ -1,4 +1,4 @@ -var maps_comment_90f36752_8815_4be8_b32b_d7fad1d0542e = +var maps_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = { ////////////////////////// 地形部分 ////////////////////////// diff --git a/main.js b/main.js index 0f6da394..4dd18be2 100644 --- a/main.js +++ b/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' diff --git a/project/events.js b/project/events.js new file mode 100644 index 00000000..b9f7661e --- /dev/null +++ b/project/events.js @@ -0,0 +1,5 @@ +var events_c12a15a8_c380_4b28_8144_256cba95f760 = +{ + "test": ["应该无法删除"], + "test2": ["应该可以删除"] +} \ No newline at end of file From 08315af63d6f281c96b2ebadd999342fee372ce4 Mon Sep 17 00:00:00 2001 From: YouWei Zhao Date: Thu, 31 Jan 2019 17:11:05 -0500 Subject: [PATCH 2/8] common event blockly delete legacy point_m add commentEvent_m --- _server/blockly/MotaAction.g4 | 32 ++++++++++++-------------------- _server/editor_blockly.js | 12 +----------- editor-mobile.html | 2 +- editor.html | 2 +- 4 files changed, 15 insertions(+), 33 deletions(-) diff --git a/_server/blockly/MotaAction.g4 b/_server/blockly/MotaAction.g4 index 5650453f..e870f95b 100644 --- a/_server/blockly/MotaAction.g4 +++ b/_server/blockly/MotaAction.g4 @@ -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; diff --git a/_server/editor_blockly.js b/_server/editor_blockly.js index 202f142f..910e6188 100644 --- a/_server/editor_blockly.js +++ b/_server/editor_blockly.js @@ -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(), diff --git a/editor-mobile.html b/editor-mobile.html index e4116e16..33e2c3f9 100644 --- a/editor-mobile.html +++ b/editor-mobile.html @@ -185,7 +185,6 @@ diff --git a/editor.html b/editor.html index e67d5fe3..ff424f31 100644 --- a/editor.html +++ b/editor.html @@ -181,7 +181,6 @@ From 4ae8c2e8630ab03254dd0f681b10d1435906aa30 Mon Sep 17 00:00:00 2001 From: YouWei Zhao Date: Thu, 31 Jan 2019 17:15:53 -0500 Subject: [PATCH 3/8] delete legacy comment --- _server/README.md | 25 ++-------------------- _server/editor_file.js | 48 +----------------------------------------- 2 files changed, 3 insertions(+), 70 deletions(-) diff --git a/_server/README.md b/_server/README.md index 374db923..521ce1cc 100644 --- a/_server/README.md +++ b/_server/README.md @@ -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 - 渲染成 -$textarea(evalstr)$end - 渲染成