diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index 7771588d..bce0fd45 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -28,6 +28,18 @@ grammar MotaAction; //===============parser=============== //===blockly语句=== +common_m + : '编辑事件' BGNL? Newline action+ BEND + + +/* common_m +tooltip : 编辑事件 +helpUrl : /_docs/#/instruction +var code = '[\n'+action_0+']\n'; +return code; +*/; + + //事件 事件编辑器入口之一 event_m : '事件' BGNL? Newline '覆盖触发器' Bool '启用' Bool '通行状态' B_0_List '显伤' Bool BGNL? Newline action+ BEND diff --git a/_server/editor_blockly.js b/_server/editor_blockly.js index 39fedfe2..89605f5b 100644 --- a/_server/editor_blockly.js +++ b/_server/editor_blockly.js @@ -105,7 +105,7 @@ editor_blockly = function () { eval('obj=' + codeAreaHL.getValue().replace(/[<>&]/g, function (c) { return {'<': '<', '>': '>', '&': '&'}[c]; }).replace(/\\(r|f|i|c|d|e|g|z)/g,'\\\\$1')), - editor_blockly.entryType + editor_blockly.isCommonEntry() ? 'common' : editor_blockly.entryType ); } @@ -179,7 +179,7 @@ editor_blockly = function () { var eventType = editor_blockly.entryType; if(editor_blockly.workspace.topBlocks_.length==1){ var blockType = editor_blockly.workspace.topBlocks_[0].type; - if(blockType!==eventType+'_m'){ + if(blockType!==eventType+'_m' && !(editor_blockly.isCommonEntry() && blockType == 'common_m')){ editor_blockly.setValue('入口方块类型错误'); return; } diff --git a/_server/editor_blocklyconfig.js b/_server/editor_blocklyconfig.js index 780d5d75..171e9217 100644 --- a/_server/editor_blocklyconfig.js +++ b/_server/editor_blocklyconfig.js @@ -59,6 +59,7 @@ editor_blocklyconfig=(function(){ "commonEvent": "回收钥匙商店", "args": "" }],'shop'), + MotaActionBlocks['common_m'].xmlText(), MotaActionBlocks['afterBattle_m'].xmlText(), MotaActionBlocks['afterGetItem_m'].xmlText(), MotaActionBlocks['afterOpenDoor_m'].xmlText(), @@ -374,10 +375,15 @@ var workspace = Blockly.inject(blocklyDiv,{ trashcan: false, }); +editor_blockly.isCommonEntry = function () { + var commonEntries = ['afterBattle', 'afterOpenDoor', 'firstArrive', 'eachArrive', 'commonEvent', 'item']; + return commonEntries.indexOf(editor_blockly.entryType) >= 0; +} + editor_blockly.entranceCategoryCallback = function(workspace) { var list=toolboxObj['入口方块'] var xmlList = []; - var eventType = editor_blockly.entryType+'_m'; + var eventType = (editor_blockly.isCommonEntry() ? 'common' : editor_blockly.entryType)+'_m'; for(var ii=0,blockText;blockText=list[ii];ii++){ if(new RegExp('').exec(blockText)){ var block = Blockly.Xml.textToDom(''+blockText+'').firstChild; @@ -452,7 +458,7 @@ function omitedcheckUpdateFunction(event) { var eventType = editor_blockly.entryType; if(editor_blockly.workspace.topBlocks_.length==1){ var blockType = editor_blockly.workspace.topBlocks_[0].type; - if(blockType!==eventType+'_m'){ + if(blockType!==eventType+'_m' && !(editor_blockly.isCommonEntry() && blockType == 'common_m')){ editor_blockly.setValue('入口方块类型错误'); return; }