blockly common entry

This commit is contained in:
ckcz123 2021-07-21 18:10:02 +08:00
parent 634c9cdeba
commit 9aa44f51a4
3 changed files with 22 additions and 4 deletions

View File

@ -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

View File

@ -105,7 +105,7 @@ editor_blockly = function () {
eval('obj=' + codeAreaHL.getValue().replace(/[<>&]/g, function (c) {
return {'<': '&lt;', '>': '&gt;', '&': '&amp;'}[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;
}

View File

@ -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('<block type="'+eventType+'">').exec(blockText)){
var block = Blockly.Xml.textToDom('<xml>'+blockText+'</xml>').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;
}