Support collapsed blocks
This commit is contained in:
parent
e0c4544b8c
commit
3cca8e2cb1
@ -762,8 +762,9 @@ tooltip : text:显示一段文字(剧情)
|
||||
helpUrl : /_docs/#/instruction
|
||||
doubleclicktext : EvalString_Multi_0
|
||||
default : ["欢迎使用事件编辑器(回车直接多行编辑)"]
|
||||
var code = '"'+EvalString_Multi_0+'",\n';
|
||||
return code;
|
||||
var code = '"'+EvalString_Multi_0+'"';
|
||||
if (block.isCollapsed()) code = '{"type": "text", "text": '+code+', "_collapsed": true}';
|
||||
return code+',\n';
|
||||
*/;
|
||||
|
||||
text_1_s
|
||||
@ -788,8 +789,9 @@ if(EvalString_2 && !(/^(up|center|down|hero|this)(,(hero|null|\d+,\d+|\d+))?$/.t
|
||||
throw new Error('对话框效果的用法请右键点击帮助');
|
||||
}
|
||||
EvalString_2 = EvalString_2 && ('\\b['+EvalString_2+']');
|
||||
var code = '"'+title+EvalString_2+EvalString_Multi_0+'",\n';
|
||||
return code;
|
||||
var code = '"'+title+EvalString_2+EvalString_Multi_0+'"';
|
||||
if (block.isCollapsed()) code = '{"type": "text", "text": '+code+', "_collapsed": true}';
|
||||
return code+',\n';
|
||||
*/;
|
||||
|
||||
text_2_s
|
||||
@ -814,8 +816,9 @@ if(EvalString_2 && !(/^(up|center|down|hero|this)(,(hero|null|\d+,\d+|\d+))?$/.t
|
||||
throw new Error('对话框效果的用法请右键点击帮助');
|
||||
}
|
||||
EvalString_2 = EvalString_2 && ('\\b['+EvalString_2+']');
|
||||
var code = '"'+title+EvalString_2+textDrawingList_0.replace(/\s/g, '')+EvalString_Multi_0+'",\n';
|
||||
return code;
|
||||
var code = '"'+title+EvalString_2+textDrawingList_0.replace(/\s/g, '')+EvalString_Multi_0+'"';
|
||||
if (block.isCollapsed()) code = '{"type": "text", "text": '+code+', "_collapsed": true}';
|
||||
return code+',\n';
|
||||
*/;
|
||||
|
||||
textDrawingList
|
||||
@ -2351,9 +2354,9 @@ if_s
|
||||
tooltip : if: 条件判断
|
||||
helpUrl : /_docs/#/instruction
|
||||
colour : this.eventColor
|
||||
var code = ['{"type": "if", "condition": "',expression_0,'",\n',
|
||||
var code = ['{"type": "if", "condition": "',expression_0,'",',block.isCollapsed()?'"_collapsed": true,\n':'\n',
|
||||
'"true": [\n',action_0,'],\n',
|
||||
'"false": [\n',action_1,']\n',
|
||||
'"false": [\n',action_1,']',
|
||||
'},\n'].join('');
|
||||
return code;
|
||||
*/;
|
||||
@ -2366,8 +2369,8 @@ if_1_s
|
||||
tooltip : if: 条件判断
|
||||
helpUrl : /_docs/#/instruction
|
||||
colour : this.eventColor
|
||||
var code = ['{"type": "if", "condition": "',expression_0,'",\n',
|
||||
'"true": [\n',action_0,'],\n',
|
||||
var code = ['{"type": "if", "condition": "',expression_0,'",',block.isCollapsed()?'"_collapsed": true,\n':'\n',
|
||||
'"true": [\n',action_0,']',
|
||||
'},\n'].join('');
|
||||
return code;
|
||||
*/;
|
||||
@ -2381,7 +2384,7 @@ tooltip : switch: 多重条件分歧
|
||||
helpUrl : /_docs/#/instruction
|
||||
default : ["判别值"]
|
||||
colour : this.eventColor
|
||||
var code = ['{"type": "switch", "condition": "',expression_0,'", "caseList": [\n',
|
||||
var code = ['{"type": "switch", "condition": "',expression_0,'", ',block.isCollapsed()?'"_collapsed": true, ':'','"caseList": [\n',
|
||||
switchCase_0,
|
||||
'], },\n'].join('');
|
||||
return code;
|
||||
@ -2397,7 +2400,8 @@ helpUrl : /_docs/#/instruction
|
||||
default : ["", false]
|
||||
colour : this.subColor
|
||||
Bool_0 = Bool_0?', "nobreak": true':'';
|
||||
var code = '{"case": "'+expression_0+'"'+Bool_0+', "action": [\n'+action_0+']},\n';
|
||||
var collapsed=block.isCollapsed()?', "_collapsed": true':'';
|
||||
var code = '{"case": "'+expression_0+'"'+Bool_0+collapsed+', "action": [\n'+action_0+']},\n';
|
||||
return code;
|
||||
*/;
|
||||
|
||||
@ -2422,7 +2426,7 @@ if (EvalString_0==''){
|
||||
EvalString_Multi_0 = title+EvalString_Multi_0;
|
||||
EvalString_Multi_0 = EvalString_Multi_0 ?(', "text": "'+EvalString_Multi_0+'"'):'';
|
||||
Int_0 = Int_0 ? (', "timeout": '+Int_0) : '';
|
||||
var code = ['{"type": "choices"',EvalString_Multi_0,Int_0,', "choices": [\n',
|
||||
var code = ['{"type": "choices"',EvalString_Multi_0,Int_0,block.isCollapsed()?', "_collapsed": true':'',', "choices": [\n',
|
||||
choicesContext_0,
|
||||
']},\n'].join('');
|
||||
return code;
|
||||
@ -2441,7 +2445,8 @@ colour : this.subColor
|
||||
ColorString_0 = ColorString_0 ? (', "color": ['+ColorString_0+']') : '';
|
||||
EvalString_1 = EvalString_1 && (', "condition": "'+EvalString_1+'"')
|
||||
IdString_0 = IdString_0?(', "icon": "'+IdString_0+'"'):'';
|
||||
var code = '{"text": "'+EvalString_0+'"'+IdString_0+ColorString_0+EvalString_1+', "action": [\n'+action_0+']},\n';
|
||||
var collapsed=block.isCollapsed()?', "_collapsed": true':'';
|
||||
var code = '{"text": "'+EvalString_0+'"'+IdString_0+ColorString_0+EvalString_1+collapsed+', "action": [\n'+action_0+']},\n';
|
||||
return code;
|
||||
*/;
|
||||
|
||||
@ -2455,7 +2460,7 @@ default : ["确认要xxx吗?",0,false]
|
||||
doubleclicktext : EvalString_Multi_0
|
||||
Bool_0 = Bool_0?', "default": true':''
|
||||
Int_0 = Int_0 ? (', "timeout": '+Int_0) : '';
|
||||
var code = ['{"type": "confirm"'+Int_0+Bool_0+', "text": "',EvalString_Multi_0,'",\n',
|
||||
var code = ['{"type": "confirm"'+Int_0+Bool_0+', "text": "',EvalString_Multi_0,'",',block.isCollapsed()?'"_collapsed": true,\n':'\n',
|
||||
'"yes": [\n',action_0,'],\n',
|
||||
'"no": [\n',action_1,']\n',
|
||||
'},\n'].join('');
|
||||
@ -2472,7 +2477,8 @@ colour : this.eventColor
|
||||
if (!/^temp:[A-Z]$/.test(expression_0)) {
|
||||
throw new Error('循环遍历仅允许使用临时变量!');
|
||||
}
|
||||
return '{"type": "for", "name": "'+expression_0+'", "from": "'+EvalString_0+'", "to": "'+EvalString_1+'", "step": "'+EvalString_2+'",\n"data": [\n'+action_0+']},\n';
|
||||
var collapsed=block.isCollapsed()?', "_collapsed": true':'';
|
||||
return '{"type": "for", "name": "'+expression_0+'", "from": "'+EvalString_0+'", "to": "'+EvalString_1+'", "step": "'+EvalString_2+'"'+collapsed+',\n"data": [\n'+action_0+']},\n';
|
||||
*/;
|
||||
|
||||
forEach_s
|
||||
@ -2488,7 +2494,8 @@ if (!/^temp:[A-Z]$/.test(expression_0)) {
|
||||
if (JsonEvalString_0 == '' || !(JSON.parse(JsonEvalString_0) instanceof Array)) {
|
||||
throw new Error('参数列表必须是个有效的数组!');
|
||||
}
|
||||
return '{"type": "forEach", "name": "'+expression_0+'", "list": '+JsonEvalString_0 + ',\n"data": [\n'+action_0+']},\n';
|
||||
var collapsed=block.isCollapsed()?', "_collapsed": true':'';
|
||||
return '{"type": "forEach", "name": "'+expression_0+'", "list": '+JsonEvalString_0 + collapsed+',\n"data": [\n'+action_0+']},\n';
|
||||
*/;
|
||||
|
||||
while_s
|
||||
@ -2498,7 +2505,7 @@ while_s
|
||||
tooltip : while:前置条件循环
|
||||
helpUrl : /_docs/#/instruction
|
||||
colour : this.eventColor
|
||||
var code = ['{"type": "while", "condition": "',expression_0,'",\n',
|
||||
var code = ['{"type": "while", "condition": "',expression_0,'",',block.isCollapsed()?'"_collapsed": true,\n':'\n',
|
||||
'"data": [\n',action_0,'],\n',
|
||||
'},\n'].join('');
|
||||
return code;
|
||||
@ -2511,7 +2518,7 @@ dowhile_s
|
||||
tooltip : dowhile:后置条件循环
|
||||
helpUrl : /_docs/#/instruction
|
||||
colour : this.eventColor
|
||||
var code = ['{"type": "dowhile", "condition": "',expression_0,'",\n',
|
||||
var code = ['{"type": "dowhile", "condition": "',expression_0,'",',block.isCollapsed()?'"_collapsed": true,\n':'\n',
|
||||
'"data": [\n',action_0,'],\n',
|
||||
'},\n'].join('');
|
||||
return code;
|
||||
@ -2551,7 +2558,8 @@ default : [0]
|
||||
colour : this.soundColor
|
||||
Int_0 = Int_0?(', "timeout": ' + Int_0):'';
|
||||
waitContext_0 = waitContext_0 ? (', "data": [\n' + waitContext_0 + ']') : '';
|
||||
var code = '{"type": "wait"' + Int_0 + waitContext_0 + '},\n';
|
||||
var collapsed=block.isCollapsed()?', "_collapsed": true':'';
|
||||
var code = '{"type": "wait"' + Int_0 + collapsed + waitContext_0 + '},\n';
|
||||
return code;
|
||||
*/;
|
||||
|
||||
@ -2572,7 +2580,8 @@ colour : this.subColor
|
||||
if (!/^\d+(,\d+)*$/.test(EvalString_0)) {
|
||||
throw new Error('键值必须是正整数,可以以逗号分隔');
|
||||
}
|
||||
var code = '{"case": "keyboard", "keycode": "' + EvalString_0 + '", "action": [\n' + action_0 + ']},\n';
|
||||
var collapsed=block.isCollapsed()?', "_collapsed": true':'';
|
||||
var code = '{"case": "keyboard", "keycode": "' + EvalString_0 + '"'+collapsed+', "action": [\n' + action_0 + ']},\n';
|
||||
return code;
|
||||
*/;
|
||||
|
||||
@ -2586,7 +2595,8 @@ helpUrl : /_docs/#/instruction
|
||||
default : [0,32,0,32]
|
||||
previewBlock : true
|
||||
colour : this.subColor
|
||||
var code = '{"case": "mouse", "px": [' + PosString_0 + ',' + PosString_1 + '], "py": [' + PosString_2 + ',' + PosString_3 + '], "action": [\n' + action_0 + ']},\n';
|
||||
var collapsed=block.isCollapsed()?', "_collapsed": true':'';
|
||||
var code = '{"case": "mouse", "px": [' + PosString_0 + ',' + PosString_1 + '], "py": [' + PosString_2 + ',' + PosString_3 + ']'+collapsed+', "action": [\n' + action_0 + ']},\n';
|
||||
return code;
|
||||
*/;
|
||||
|
||||
@ -2672,7 +2682,8 @@ previewUI_s
|
||||
tooltip : previewUI: ui绘制并预览
|
||||
helpUrl : /_docs/#/instruction
|
||||
previewBlock : true
|
||||
var code = ['{"type": "previewUI", "action": [\n', action_0,']},\n'].join('');
|
||||
var collapsed=block.isCollapsed()?', "_collapsed": true':'';
|
||||
var code = ['{"type": "previewUI"'+collapsed+', "action": [\n', action_0,']},\n'].join('');
|
||||
return code;
|
||||
*/;
|
||||
|
||||
|
||||
@ -247,15 +247,16 @@ ActionParser.prototype.parseAction = function() {
|
||||
}
|
||||
return text_choices;
|
||||
}
|
||||
this.next = MotaActionBlocks['text_2_s'].xmlText([
|
||||
this.next = MotaActionFunctions.xmlText('text_2_s', [
|
||||
info[0], info[1], info[2], info[3], buildTextDrawing(textDrawing), this.next
|
||||
]);
|
||||
], /* isShadow */false, /*comment*/ null, /*collapsed*/ data._collapsed);
|
||||
} else if (info[0] || info[1] || info[2]) {
|
||||
this.next = MotaActionBlocks['text_1_s'].xmlText([
|
||||
info[0], info[1], info[2], info[3], this.next]);
|
||||
this.next = MotaActionFunctions.xmlText('text_1_s',[
|
||||
info[0], info[1], info[2], info[3], this.next], /* isShadow */false, /*comment*/ null, /*collapsed*/ data._collapsed);
|
||||
}
|
||||
else {
|
||||
this.next = MotaActionBlocks['text_0_s'].xmlText([info[3],this.next]);
|
||||
this.next = MotaActionFunctions.xmlText('text_0_s', [info[3],this.next],
|
||||
/* isShadow */false, /*comment*/ null, /*collapsed*/ data._collapsed);
|
||||
}
|
||||
break;
|
||||
case "autoText": // 自动剧情文本
|
||||
@ -652,73 +653,75 @@ ActionParser.prototype.parseAction = function() {
|
||||
break;
|
||||
case "if": // 条件判断
|
||||
if (data["false"]) {
|
||||
this.next = MotaActionBlocks['if_s'].xmlText([
|
||||
this.next = MotaActionFunctions.xmlText('if_s', [
|
||||
this.expandEvalBlock([data.condition]),
|
||||
this.insertActionList(data["true"]),
|
||||
this.insertActionList(data["false"]),
|
||||
this.next]);
|
||||
this.next], /* isShadow */false, /*comment*/ null, /*collapsed*/ data._collapsed);
|
||||
}
|
||||
else {
|
||||
this.next = MotaActionBlocks['if_1_s'].xmlText([
|
||||
this.next = MotaActionFunctions.xmlText('if_1_s', [
|
||||
this.expandEvalBlock([data.condition]),
|
||||
this.insertActionList(data["true"]),
|
||||
this.next]);
|
||||
this.next], /* isShadow */false, /*comment*/ null, /*collapsed*/ data._collapsed);
|
||||
}
|
||||
break;
|
||||
case "confirm": // 显示确认框
|
||||
this.next = MotaActionBlocks['confirm_s'].xmlText([
|
||||
this.next = MotaActionFunctions.xmlText('confirm_s', [
|
||||
this.EvalString_Multi(data.text), data.timeout||0, data["default"],
|
||||
this.insertActionList(data["yes"]),
|
||||
this.insertActionList(data["no"]),
|
||||
this.next]);
|
||||
this.next], /* isShadow */false, /*comment*/ null, /*collapsed*/ data._collapsed);
|
||||
break;
|
||||
case "switch": // 多重条件分歧
|
||||
var case_caseList = null;
|
||||
for(var ii=data.caseList.length-1,caseNow;caseNow=data.caseList[ii];ii--) {
|
||||
case_caseList=MotaActionBlocks['switchCase'].xmlText([
|
||||
this.isset(caseNow.case)?this.expandEvalBlock([caseNow.case]):"值",caseNow.nobreak,this.insertActionList(caseNow.action),case_caseList]);
|
||||
case_caseList=MotaActionFunctions.xmlText('switchCase', [
|
||||
this.isset(caseNow.case)?this.expandEvalBlock([caseNow.case]):"值",caseNow.nobreak,this.insertActionList(caseNow.action),case_caseList],
|
||||
/* isShadow */false, /*comment*/ null, /*collapsed*/ caseNow._collapsed);
|
||||
}
|
||||
this.next = MotaActionBlocks['switch_s'].xmlText([
|
||||
this.next = MotaActionFunctions.xmlText('switch_s', [
|
||||
this.expandEvalBlock([data.condition]),
|
||||
case_caseList,this.next]);
|
||||
case_caseList,this.next], /* isShadow */false, /*comment*/ null, /*collapsed*/ data._collapsed);
|
||||
break;
|
||||
case "choices": // 提供选项
|
||||
var text_choices = null;
|
||||
for(var ii=data.choices.length-1,choice;choice=data.choices[ii];ii--) {
|
||||
choice.color = this.Colour(choice.color);
|
||||
text_choices=MotaActionBlocks['choicesContext'].xmlText([
|
||||
choice.text,choice.icon,choice.color,'rgba('+choice.color+')',choice.condition||'',this.insertActionList(choice.action),text_choices]);
|
||||
text_choices=MotaActionFunctions.xmlText('choicesContext', [
|
||||
choice.text,choice.icon,choice.color,'rgba('+choice.color+')',choice.condition||'',this.insertActionList(choice.action),text_choices],
|
||||
/* isShadow */false, /*comment*/ null, /*collapsed*/ choice._collapsed);
|
||||
}
|
||||
if (!this.isset(data.text)) data.text = '';
|
||||
var info = this.getTitleAndPosition(data.text);
|
||||
this.next = MotaActionBlocks['choices_s'].xmlText([
|
||||
info[3],info[0],info[1],data.timeout||0,text_choices,this.next]);
|
||||
this.next = MotaActionFunctions.xmlText('choices_s', [
|
||||
info[3],info[0],info[1],data.timeout||0,text_choices,this.next], /* isShadow */false, /*comment*/ null, /*collapsed*/ data._collapsed);
|
||||
break;
|
||||
case "for": // 循环遍历
|
||||
this.next = MotaActionBlocks['for_s'].xmlText([
|
||||
this.next = MotaActionFunctions.xmlText('for_s',[
|
||||
this.expandEvalBlock([data.name]),
|
||||
data.from || 0, data.to || 0, data.step || 0,
|
||||
this.insertActionList(data.data),
|
||||
this.next]);
|
||||
this.next], /* isShadow */false, /*comment*/ null, /*collapsed*/ data._collapsed);
|
||||
break;
|
||||
case "forEach": // 循环遍历列表
|
||||
this.next = MotaActionBlocks['forEach_s'].xmlText([
|
||||
this.next = MotaActionFunctions.xmlText('forEach_s',[
|
||||
this.expandEvalBlock([data.name]),
|
||||
JSON.stringify(data.list),
|
||||
this.insertActionList(data.data),
|
||||
this.next]);
|
||||
this.next], /* isShadow */false, /*comment*/ null, /*collapsed*/ data._collapsed);
|
||||
break;
|
||||
case "while": // 前置条件循环处理
|
||||
this.next = MotaActionBlocks['while_s'].xmlText([
|
||||
this.next = MotaActionFunctions.xmlText('while_s',[
|
||||
this.expandEvalBlock([data.condition]),
|
||||
this.insertActionList(data.data),
|
||||
this.next]);
|
||||
this.next], /* isShadow */false, /*comment*/ null, /*collapsed*/ data._collapsed);
|
||||
break;
|
||||
case "dowhile": // 后置条件循环处理
|
||||
this.next = MotaActionBlocks['dowhile_s'].xmlText([
|
||||
this.next = MotaActionFunctions.xmlText('dowhile_s',[
|
||||
this.insertActionList(data.data),
|
||||
this.expandEvalBlock([data.condition]),
|
||||
this.next]);
|
||||
this.next], /* isShadow */false, /*comment*/ null, /*collapsed*/ data._collapsed);
|
||||
break;
|
||||
case "break": // 跳出循环
|
||||
this.next = MotaActionBlocks['break_s'].xmlText([
|
||||
@ -775,18 +778,18 @@ ActionParser.prototype.parseAction = function() {
|
||||
if (data.data) {
|
||||
for(var ii=data.data.length-1,caseNow;caseNow=data.data[ii];ii--) {
|
||||
if (caseNow["case"] == "keyboard") {
|
||||
case_waitList = MotaActionBlocks['waitContext_1'].xmlText([
|
||||
case_waitList = MotaActionFunctions.xmlText('waitContext_1',[
|
||||
caseNow.keycode || "0", this.insertActionList(caseNow.action), case_waitList
|
||||
]);
|
||||
], /* isShadow */false, /*comment*/ null, /*collapsed*/ caseNow._collapsed);
|
||||
} else if (caseNow["case"] == "mouse") {
|
||||
case_waitList = MotaActionBlocks['waitContext_2'].xmlText([
|
||||
case_waitList = MotaActionFunctions.xmlText('waitContext_2',[
|
||||
caseNow.px[0], caseNow.px[1], caseNow.py[0], caseNow.py[1], this.insertActionList(caseNow.action), case_waitList
|
||||
]);
|
||||
], /* isShadow */false, /*comment*/ null, /*collapsed*/ caseNow._collapsed);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.next = MotaActionBlocks['wait_s'].xmlText([
|
||||
data.timeout||0,case_waitList, this.next]);
|
||||
this.next = MotaActionFunctions.xmlText('wait_s',[
|
||||
data.timeout||0,case_waitList, this.next], /* isShadow */false, /*comment*/ null, /*collapsed*/ data._collapsed);
|
||||
break;
|
||||
case "waitAsync": // 等待所有异步事件执行完毕
|
||||
this.next = MotaActionBlocks['waitAsync_s'].xmlText([
|
||||
@ -813,9 +816,9 @@ ActionParser.prototype.parseAction = function() {
|
||||
this.next]);
|
||||
break;
|
||||
case "previewUI": // UI绘制预览
|
||||
this.next = MotaActionBlocks['previewUI_s'].xmlText([
|
||||
this.next = MotaActionFunctions.xmlText('previewUI_s',[
|
||||
this.insertActionList(data.action), this.next
|
||||
]);
|
||||
], /* isShadow */false, /*comment*/ null, /*collapsed*/ data._collapsed);
|
||||
break;
|
||||
case "clearMap": // 清除画布
|
||||
this.next = MotaActionBlocks['clearMap_s'].xmlText([
|
||||
|
||||
@ -476,11 +476,11 @@ function omitedcheckUpdateFunction(event) {
|
||||
}
|
||||
|
||||
// 因为在editor_blockly.parse里已经HTML转义过一次了,所以这里要覆盖掉以避免在注释中出现<等
|
||||
MotaActionFunctions.xmlText = function (ruleName,inputs,isShadow,comment) {
|
||||
MotaActionFunctions.xmlText = function (ruleName,inputs,isShadow,comment,collapsed) {
|
||||
var rule = MotaActionBlocks[ruleName];
|
||||
var blocktext = isShadow?'shadow':'block';
|
||||
var xmlText = [];
|
||||
xmlText.push('<'+blocktext+' type="'+ruleName+'">');
|
||||
xmlText.push('<'+blocktext+' type="'+ruleName+'"'+(collapsed ? ' collapsed="true"' : '')+'>');
|
||||
if(!inputs)inputs=[];
|
||||
for (var ii=0,inputType;inputType=rule.argsType[ii];ii++) {
|
||||
var input = inputs[ii];
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 68 KiB After Width: | Height: | Size: 67 KiB |
Loading…
Reference in New Issue
Block a user