From a9d92e799621a1d6b1291208f42d73fbd2eab971 Mon Sep 17 00:00:00 2001 From: YouWei Zhao Date: Fri, 29 Jun 2018 22:57:49 +0800 Subject: [PATCH] fix bug in editor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1.比如道具效果 useItemEffect 等,在新注册后默认是null;如果要编辑需要先改成空的双引号"",然后再双击编辑;否则直接双击的话系统会认为是一个JSON,写脚本就会出错 2.事件编辑器保存时检测用的框是否是正确 --- _server/comment.js | 4 ++++ _server/editor_blockly.js | 14 +++++++++++++- _server/editor_mode.js | 2 +- _server/editor_multi.js | 2 +- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/_server/comment.js b/_server/comment.js index 858dcb03..a2651a2b 100644 --- a/_server/comment.js +++ b/_server/comment.js @@ -39,24 +39,28 @@ comment_c456ea59_6018_45ef_8bcc_211a24c627dc = "itemEffect": { "_leaf": true, "_type": "textarea", + "_string": true, "_lint": true, "_data": "cls为items的即捡即用类物品的效果,如需设置可以先将其设置为空字符串\"\",然后双击进行编辑。" }, "itemEffectTip": { "_leaf": true, "_type": "textarea", + "_string": true, "_lint": true, "_data": "cls为items的即捡即用类物品,在获得时左上角额外显示的文字,如需设置可以先将其设置为空字符串\"\",然后双击进行编辑。" }, "useItemEffect": { "_leaf": true, "_type": "textarea", + "_string": true, "_lint": true, "_data": "cls为tools或contants时的使用物品效果,如需设置可以先将其设置为空字符串\"\",然后双击进行编辑。" }, "canUseItemEffect": { "_leaf": true, "_type": "textarea", + "_string": true, "_lint": true, "_data": "cls为tools或contants时对当前能否使用该物品的判断,如需设置可以先将其设置为空字符串\"\",然后双击进行编辑。" } diff --git a/_server/editor_blockly.js b/_server/editor_blockly.js index c547ebef..e58ee4e0 100644 --- a/_server/editor_blockly.js +++ b/_server/editor_blockly.js @@ -413,6 +413,18 @@ document.getElementById('blocklyDiv').onmousewheel = function(e){ editor_blockly.id = ''; return; } + if(editor_blockly.workspace.topBlocks_.length>=2){ + codeAreaHL.setValue('入口方块只能有一个'); + return; + } + var eventType = document.getElementById('entryType').value; + if(editor_blockly.workspace.topBlocks_.length==1){ + var blockType = editor_blockly.workspace.topBlocks_[0].type; + if(blockType!==eventType+'_m'){ + codeAreaHL.setValue('入口方块类型错误'); + return; + } + } var setvalue = function (value) { var thisTr = document.getElementById(editor_blockly.id); editor_blockly.id = ''; @@ -422,7 +434,7 @@ document.getElementById('blocklyDiv').onmousewheel = function(e){ input.onchange(); } if (codeAreaHL.getValue() === '') { - setvalue('null'); + eventType==='shop'?setvalue('[]'):setvalue('null'); return; } var code = Blockly.JavaScript.workspaceToCode(editor_blockly.workspace); diff --git a/_server/editor_mode.js b/_server/editor_mode.js index bc8ff3e1..8b263262 100644 --- a/_server/editor_mode.js +++ b/_server/editor_mode.js @@ -120,7 +120,7 @@ editor_mode = function (editor) { } input.ondblclick = function () { if (cobj._type === 'event') editor_blockly.import(guid, {type: cobj._event}); - if (cobj._type === 'textarea') editor_multi.import(guid, {lint: cobj._lint}); + if (cobj._type === 'textarea') editor_multi.import(guid, {lint: cobj._lint, string: cobj._string}); } }); diff --git a/_server/editor_multi.js b/_server/editor_multi.js index 739ae55d..2c426991 100644 --- a/_server/editor_multi.js +++ b/_server/editor_multi.js @@ -72,7 +72,7 @@ editor_multi = function () { editor_multi.lintAutocomplete = false; if (args.lint === true) editor_multi.lintAutocomplete = true; if (field.indexOf('Effect') !== -1) editor_multi.lintAutocomplete = true; - if (input.value.slice(0, 1) === '"') { + if (input.value.slice(0, 1) === '"' || args.string) { editor_multi.isString = true; codeEditor.setValue(JSON.parse(input.value) || ''); } else {