expand
This commit is contained in:
parent
ea85ac5d75
commit
cc46a86915
@ -2564,9 +2564,7 @@ expression
|
||||
//todo 修改recieveOrder,根据Arithmetic_List_0不同的值设定不同的recieveOrder
|
||||
var code = expression_0 + Arithmetic_List_0 + expression_1;
|
||||
var ops = {
|
||||
'^': 'Math.pow('+expression_0+','+expression_1+')',
|
||||
'和': expression_0+' && '+expression_1,
|
||||
'或': expression_0+' || '+expression_1,
|
||||
'^': 'Math.pow('+expression_0+','+expression_1+')'
|
||||
}
|
||||
if (ops[Arithmetic_List_0])code = ops[Arithmetic_List_0];
|
||||
var orders = {
|
||||
@ -2581,8 +2579,8 @@ var orders = {
|
||||
'<': Blockly.JavaScript.ORDER_RELATIONAL,
|
||||
'>=': Blockly.JavaScript.ORDER_RELATIONAL,
|
||||
'<=': Blockly.JavaScript.ORDER_RELATIONAL,
|
||||
'和': Blockly.JavaScript.ORDER_LOGICAL_AND,
|
||||
'或': Blockly.JavaScript.ORDER_LOGICAL_OR
|
||||
'&&': Blockly.JavaScript.ORDER_LOGICAL_AND,
|
||||
'||': Blockly.JavaScript.ORDER_LOGICAL_OR
|
||||
}
|
||||
return [code, orders[Arithmetic_List_0]];
|
||||
*/;
|
||||
@ -2774,8 +2772,8 @@ ShopUse_List
|
||||
/*ShopUse_List ['money','exp']*/;
|
||||
|
||||
Arithmetic_List
|
||||
: '+'|'-'|'*'|'/'|'^'|'=='|'!='|'>'|'<'|'>='|'<='|'和'|'或'
|
||||
;
|
||||
: '+'|'-'|'*'|'/'|'^'|'=='|'!='|'>'|'<'|'>='|'<='|'且'|'或'
|
||||
/*Arithmetic_List ['+','-','*','/','^','==','!=','>','<','>=','<=','&&','||']*/;
|
||||
|
||||
AssignOperator_List
|
||||
: '='|'+='|'-='|'*='|'/='|'**='|'//='|'%='
|
||||
|
||||
@ -997,12 +997,13 @@ ActionParser.prototype.matchEvalAtom = function(args) {
|
||||
}
|
||||
|
||||
ActionParser.prototype.matchEvalCompare=function(args, isShadow){
|
||||
var raw=args[0].replace(/>/g,'>').replace(/</g,'<')
|
||||
if (MotaActionFunctions.disableExpandCompare) return {ret:false};
|
||||
var raw=args[0].replace(/>/g,'>').replace(/</g,'<').replace(/"/g,'"').replace(/ /g,' ').replace(/&/g,'&')
|
||||
if (raw[0]+raw.slice(-1)=='()') raw=raw.slice(1,-1);
|
||||
var str=raw
|
||||
var xml=MotaActionBlocks['expression_arithmetic_0'].xmlText
|
||||
if (!/<=|<|>=|>|==|!=/.exec(str)) return {ret:false};
|
||||
str=str.replace(/[^<>=!()]/g,' ')
|
||||
if (!/<=|<|>=|>|==|!=|&&|\|\|/.exec(str)) return {ret:false};
|
||||
str=str.replace(/[^<>=!()&|]/g,' ')
|
||||
// 处理括号匹配
|
||||
var old;
|
||||
do {
|
||||
@ -1010,11 +1011,11 @@ ActionParser.prototype.matchEvalCompare=function(args, isShadow){
|
||||
str=str.replace(/\([^()]*\)/g,function(v){return Array.from({length:v.length+1}).join(' ')})
|
||||
} while (old!=str);
|
||||
// 按优先级依次寻找以下符号
|
||||
var oplist=['<','<=','>','>=','==','!=']
|
||||
var oplist=['<','<=','>','>=','==','!=','&&','||'].reverse()
|
||||
for (var index = 0,op; op=oplist[index]; index++) {
|
||||
var match=new RegExp('(?<= )'+op+'(?= )').exec(str)
|
||||
var match=new RegExp('(?<= )'+(op=='||'?'\\|\\|':op)+'(?= )').exec(str)
|
||||
if (!match) continue;
|
||||
args=[this.expandEvalBlock([raw.slice(0,match.index)],isShadow),op,this.expandEvalBlock([raw.slice(match.index+op.length)],isShadow)]
|
||||
args=[this.expandEvalBlock([raw.slice(0,match.index)],isShadow),(op=='&&'?'&&':op),this.expandEvalBlock([raw.slice(match.index+op.length)],isShadow)]
|
||||
return {ret:true,xml:xml,args:args}
|
||||
}
|
||||
return {ret:false}
|
||||
@ -1248,6 +1249,7 @@ MotaActionFunctions.pattern.replaceEnemyList = [
|
||||
];
|
||||
|
||||
MotaActionFunctions.disableReplace = false;
|
||||
MotaActionFunctions.disableExpandCompare = false;
|
||||
|
||||
MotaActionFunctions.replaceToName_token = function (str) {
|
||||
if (!str || MotaActionFunctions.disableReplace) return str;
|
||||
|
||||
@ -1 +1 @@
|
||||
{"lastUsed":[],"foldPerCol":50,"folded":false,"editorLastFloorId":"sample0","disableBlocklyReplace":false,"shortcut":{"48":0,"49":0,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0,"57":0}}
|
||||
{"lastUsed":[],"foldPerCol":50,"folded":false,"editorLastFloorId":"sample0","disableBlocklyReplace":false,"disableBlocklyExpandCompare":false,"shortcut":{"48":0,"49":0,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0,"57":0}}
|
||||
@ -87,6 +87,8 @@ function editor() {
|
||||
ratio : 1,
|
||||
// blockly转义
|
||||
disableBlocklyReplace: false,
|
||||
// blockly展开比较
|
||||
disableBlocklyExpandCompare: false,
|
||||
|
||||
// 绑定机关门事件相关
|
||||
bindSpecialDoor: {
|
||||
|
||||
@ -497,6 +497,16 @@ function omitedcheckUpdateFunction(event) {
|
||||
alert("已" + (replaceCheckbox.checked ? "开启" : "关闭") + "中文变量名替换!\n关闭并重开事件编辑器以生效。");
|
||||
}
|
||||
|
||||
editor.uivalues.disableBlocklyExpandCompare = editor.config.get("disableBlocklyExpandCompare", false);
|
||||
var expandCompareCheckbox = document.getElementById('blocklyExpandCompare');
|
||||
expandCompareCheckbox.checked = !editor.uivalues.disableBlocklyExpandCompare;
|
||||
|
||||
editor_blockly.triggerExpandCompare = function () {
|
||||
editor.uivalues.disableBlocklyExpandCompare = !expandCompareCheckbox.checked;
|
||||
editor.config.set("disableBlocklyExpandCompare", !expandCompareCheckbox.checked);
|
||||
if (MotaActionFunctions) MotaActionFunctions.disableExpandCompare = !expandCompareCheckbox.checked;
|
||||
}
|
||||
|
||||
var input_ = '';
|
||||
editor_blockly.runOne = function () {
|
||||
//var printf = console.log;
|
||||
@ -527,6 +537,7 @@ function omitedcheckUpdateFunction(event) {
|
||||
input_ = xhr.responseText;
|
||||
editor_blockly.runOne();
|
||||
MotaActionFunctions.disableReplace = editor.uivalues.disableBlocklyReplace;
|
||||
MotaActionFunctions.disableExpandCompare = editor.uivalues.disableBlocklyExpandCompare;
|
||||
}
|
||||
xhr.open('GET', '_server/MotaAction.g4', true);
|
||||
xhr.send(null);
|
||||
|
||||
@ -234,6 +234,8 @@
|
||||
<button class="cpPanel" onclick="editor.uievent.searchUsedFlags()" style="margin-left:5px">变量出现位置搜索</button>
|
||||
<input type="checkbox" class="cpPanel" id="blocklyReplace" onchange="editor_blockly.triggerReplace()" style="margin-left: 10px" />
|
||||
<span class="cpPanel" style="margin-left: -4px; font-size: 13px">开启中文名替换</span>
|
||||
<input type="checkbox" class="cpPanel" id="blocklyExpandCompare" onchange="editor_blockly.triggerExpandCompare()" style="margin-left: 10px" />
|
||||
<span class="cpPanel" style="margin-left: -4px; font-size: 13px">展开值块逻辑运算</span>
|
||||
<xml id="toolbox" style="display:none">
|
||||
</xml>
|
||||
</h3>
|
||||
|
||||
@ -229,6 +229,8 @@
|
||||
<button class="cpPanel" onclick="editor.uievent.searchUsedFlags()" style="margin-left:5px">变量出现位置搜索</button>
|
||||
<input type="checkbox" class="cpPanel" id="blocklyReplace" onchange="editor_blockly.triggerReplace()" style="margin-left: 10px" />
|
||||
<span class="cpPanel" style="margin-left: -4px; font-size: 13px">开启中文名替换</span>
|
||||
<input type="checkbox" class="cpPanel" id="blocklyExpandCompare" onchange="editor_blockly.triggerExpandCompare()" style="margin-left: 10px" />
|
||||
<span class="cpPanel" style="margin-left: -4px; font-size: 13px">展开值块逻辑运算</span>
|
||||
<xml id="toolbox" style="display:none">
|
||||
</xml>
|
||||
</h3>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user