调整事件块双击&添加第一个menu例子
This commit is contained in:
parent
bf841505ab
commit
bede1ff661
@ -18,6 +18,8 @@ allBgms : ['EvalString_1']
|
|||||||
allSounds : ['EvalString_1']
|
allSounds : ['EvalString_1']
|
||||||
allShops : ['EvalString_1']
|
allShops : ['EvalString_1']
|
||||||
allFloorIds : ['EvalString_1']
|
allFloorIds : ['EvalString_1']
|
||||||
|
// 选择素材
|
||||||
|
material : ["./project/animates/", "IdString_0"]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@ -1759,6 +1761,7 @@ helpUrl : https://h5mota.com/games/template/_docs/#/event?id=animate%EF%BC%9A%E6
|
|||||||
default : ["zone","hero",false,false]
|
default : ["zone","hero",false,false]
|
||||||
allAnimates : ['IdString_0']
|
allAnimates : ['IdString_0']
|
||||||
material : ["./project/animates/", "IdString_0"]
|
material : ["./project/animates/", "IdString_0"]
|
||||||
|
menu : [['选择位置','editor_blockly.selectPoint(block,["EvalString_0","EvalString_0"])']]
|
||||||
colour : this.soundColor
|
colour : this.soundColor
|
||||||
if (EvalString_0) {
|
if (EvalString_0) {
|
||||||
if(MotaActionFunctions.pattern.id2.test(EvalString_0)) {
|
if(MotaActionFunctions.pattern.id2.test(EvalString_0)) {
|
||||||
|
|||||||
@ -230,9 +230,8 @@ editor_blockly = function () {
|
|||||||
return hasAsync;
|
return hasAsync;
|
||||||
}
|
}
|
||||||
|
|
||||||
var previewBlock = function (b) {
|
editor_blockly.previewBlock = function (b,args) {
|
||||||
|
|
||||||
if (b && MotaActionBlocks[b.type].previewBlock) {
|
|
||||||
try {
|
try {
|
||||||
// 特殊处理立绘
|
// 特殊处理立绘
|
||||||
if (b.type == 'textDrawing') {
|
if (b.type == 'textDrawing') {
|
||||||
@ -323,23 +322,10 @@ editor_blockly = function () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {main.log(e);}
|
} catch (e) {main.log(e);}
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
editor_blockly.doubleClickBlock = function (blockId) {
|
editor_blockly.selectMaterial = function(b,material){
|
||||||
var b = editor_blockly.workspace.getBlockById(blockId);
|
|
||||||
|
|
||||||
if (previewBlock(b)) return;
|
|
||||||
|
|
||||||
if (b && MotaActionBlocks[b.type].selectPoint) { // selectPoint
|
|
||||||
this.selectPoint();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (b && MotaActionBlocks[b.type].material) {
|
|
||||||
var material = JSON.parse(MotaActionBlocks[b.type].material);
|
|
||||||
editor.uievent.selectMaterial([b.getFieldValue(material[1])], '请选择素材', material[0], function (one) {
|
editor.uievent.selectMaterial([b.getFieldValue(material[1])], '请选择素材', material[0], function (one) {
|
||||||
if (b.type == 'animate_s') {
|
if (b.type == 'animate_s') {
|
||||||
return /^[-A-Za-z0-9_.]+\.animate$/.test(one) ? one.substring(0, one.length - 8) : null;
|
return /^[-A-Za-z0-9_.]+\.animate$/.test(one) ? one.substring(0, one.length - 8) : null;
|
||||||
@ -350,11 +336,9 @@ editor_blockly = function () {
|
|||||||
b.setFieldValue(value[0], material[1]);
|
b.setFieldValue(value[0], material[1]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var f = b ? MotaActionBlocks[b.type].doubleclicktext : null;
|
editor_blockly.doubleclicktext = function(b,f){
|
||||||
if (f) {
|
|
||||||
var value = b.getFieldValue(f);
|
var value = b.getFieldValue(f);
|
||||||
//多行编辑
|
//多行编辑
|
||||||
editor_multi.multiLineEdit(value, b, f, {'lint': f === 'RawEvalString_0'}, function (newvalue, b, f) {
|
editor_multi.multiLineEdit(value, b, f, {'lint': f === 'RawEvalString_0'}, function (newvalue, b, f) {
|
||||||
@ -363,6 +347,29 @@ editor_blockly = function () {
|
|||||||
b.setFieldValue(newvalue.split('\n').join('\\n'), f);
|
b.setFieldValue(newvalue.split('\n').join('\\n'), f);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
editor_blockly.doubleClickBlock = function (blockId) {
|
||||||
|
var b = editor_blockly.workspace.getBlockById(blockId);
|
||||||
|
|
||||||
|
if (b && MotaActionBlocks[b.type].previewBlock){
|
||||||
|
editor_blockly.previewBlock(b,MotaActionBlocks[b.type].previewBlock)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (b && MotaActionBlocks[b.type].selectPoint) { // selectPoint
|
||||||
|
editor_blockly.selectPoint(b,eval(MotaActionBlocks[b.type].selectPoint));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (b && MotaActionBlocks[b.type].material) {
|
||||||
|
editor_blockly.selectMaterial(b,JSON.parse(MotaActionBlocks[b.type].material));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (b && MotaActionBlocks[b.type].doubleclicktext) { //多行编辑
|
||||||
|
editor_blockly.doubleclicktext(b,MotaActionBlocks[b.type].doubleclicktext);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
editor_blockly.lastUsedType=[
|
editor_blockly.lastUsedType=[
|
||||||
@ -445,27 +452,26 @@ editor_blockly = function () {
|
|||||||
|
|
||||||
// ------ select point ------
|
// ------ select point ------
|
||||||
|
|
||||||
editor_blockly.selectPoint = function () {
|
editor_blockly.selectPoint = function (block,arr) {
|
||||||
var block = Blockly.selected, arr = null;
|
|
||||||
var floorId = editor.currentFloorId, pos = editor.pos, x = pos.x, y = pos.y;
|
var floorId = editor.currentFloorId, pos = editor.pos, x = pos.x, y = pos.y;
|
||||||
if (block != null && MotaActionBlocks[block.type].selectPoint) {
|
|
||||||
arr = eval(MotaActionBlocks[block.type].selectPoint);
|
|
||||||
var xv = parseInt(block.getFieldValue(arr[0])), yv = parseInt(block.getFieldValue(arr[1]));
|
var xv = parseInt(block.getFieldValue(arr[0])), yv = parseInt(block.getFieldValue(arr[1]));
|
||||||
if (block.type == 'animate_s') {
|
if (arr[0] === arr[1]) {
|
||||||
var v = block.getFieldValue(arr[0]).split(",");
|
var v = block.getFieldValue(arr[0]).split(",");
|
||||||
xv = parseInt(v[0]); yv = parseInt(v[1]);
|
xv = parseInt(v[0]); yv = parseInt(v[1]);
|
||||||
}
|
}
|
||||||
if (!isNaN(xv)) x = xv;
|
if (!isNaN(xv)) x = xv;
|
||||||
if (!isNaN(yv)) y = yv;
|
if (!isNaN(yv)) y = yv;
|
||||||
if (arr[2] != null) floorId = block.getFieldValue(arr[2]) || floorId;
|
if (arr[2] != null) floorId = block.getFieldValue(arr[2]) || floorId;
|
||||||
}
|
|
||||||
editor.uievent.selectPoint(floorId, x, y, false, function (fv, xv, yv) {
|
editor.uievent.selectPoint(floorId, x, y, false, function (fv, xv, yv) {
|
||||||
if (!arr) return;
|
if (!arr) return;
|
||||||
if (arr[2] != null) {
|
if (arr[2] != null) {
|
||||||
if (fv != editor.currentFloorId) block.setFieldValue(fv, arr[2]);
|
if (fv != editor.currentFloorId) block.setFieldValue(fv, arr[2]);
|
||||||
else block.setFieldValue(arr[3] ? fv : "", arr[2]);
|
else block.setFieldValue(arr[3] ? fv : "", arr[2]);
|
||||||
}
|
}
|
||||||
if (block.type == 'animate_s') {
|
if (arr[0] === arr[1]) {
|
||||||
block.setFieldValue(xv+","+yv, arr[0]);
|
block.setFieldValue(xv+","+yv, arr[0]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user