blockly selectPoint
This commit is contained in:
parent
af9e541268
commit
cbad40d773
@ -1087,7 +1087,7 @@ changePos_0_s
|
||||
/* changePos_0_s
|
||||
tooltip : changePos: 当前位置切换
|
||||
helpUrl : https://h5mota.com/games/template/_docs/#/event?id=changepos%EF%BC%9A%E5%BD%93%E5%89%8D%E4%BD%8D%E7%BD%AE%E5%88%87%E6%8D%A2%E5%8B%87%E5%A3%AB%E8%BD%AC%E5%90%91
|
||||
default : ["","",null]
|
||||
default : ["0","0",null]
|
||||
colour : this.dataColor
|
||||
DirectionEx_List_0 = DirectionEx_List_0 && (', "direction": "'+DirectionEx_List_0+'"');
|
||||
var code = '{"type": "changePos", "loc": ['+PosString_0+','+PosString_1+']'+DirectionEx_List_0+'},\n';
|
||||
|
||||
@ -624,6 +624,10 @@ function omitedcheckUpdateFunction(event) {
|
||||
} catch (e) {main.log(e);}
|
||||
return;
|
||||
}
|
||||
if (b && b.type in selectPointBlocks) { // selectPoint
|
||||
this.selectPoint();
|
||||
return;
|
||||
}
|
||||
|
||||
var textStringDict = {
|
||||
'text_0_s': 'EvalString_0',
|
||||
@ -728,6 +732,55 @@ function omitedcheckUpdateFunction(event) {
|
||||
return results.length == 0 ? editor_blockly.lastUsedType : results;
|
||||
}
|
||||
|
||||
// ------ select point ------
|
||||
|
||||
// id: [x, y, floorId]
|
||||
var selectPointBlocks = {
|
||||
"changeFloor_m": ["Number_0", "Number_1", "IdString_0"],
|
||||
"jumpHero_s": ["PosString_0", "PosString_1"],
|
||||
"changeFloor_s": ["PosString_0", "PosString_1", "IdString_0"],
|
||||
"changePos_0_s": ["PosString_0", "PosString_1"],
|
||||
"battle_1_s": ["PosString_0", "PosString_1"],
|
||||
"openDoor_s": ["PosString_0", "PosString_1", "IdString_0"],
|
||||
"closeDoor_s": ["PosString_0", "PosString_1"],
|
||||
"show_s": ["EvalString_0", "EvalString_1", "IdString_0"],
|
||||
"hide_s": ["EvalString_0", "EvalString_1", "IdString_0"],
|
||||
"setBlock_s": ["PosString_0", "PosString_1"],
|
||||
"move_s": ["PosString_0", "PosString_1"],
|
||||
"jump_s": ["PosString_2", "PosString_3"], // 跳跃暂时只考虑终点
|
||||
"showBgFgMap_s": ["EvalString_0", "EvalString_1", "IdString_0"],
|
||||
"hideBgFgMap_s": ["EvalString_0", "EvalString_1", "IdString_0"],
|
||||
"setBgFgBlock_s": ["PosString_0", "PosString_1", "IdString_0"],
|
||||
"showFloorImg_s": ["EvalString_0", "EvalString_1", "IdString_0"],
|
||||
"hideFloorImg_s": ["EvalString_0", "EvalString_1", "IdString_0"],
|
||||
"trigger_s": ["PosString_0", "PosString_1"],
|
||||
"insert_2_s": ["PosString_0", "PosString_1", "IdString_0"]
|
||||
}
|
||||
|
||||
editor_blockly.selectPoint = function () {
|
||||
var block = Blockly.selected, x_area = null, y_area = null, floor_area = null;
|
||||
var floorId = editor.currentFloorId, pos = editor.pos, x = pos.x, y = pos.y;
|
||||
if (block != null && block.type in selectPointBlocks) {
|
||||
var arr = selectPointBlocks[block.type];
|
||||
x_area = arr[0];
|
||||
y_area = arr[1];
|
||||
floor_area = arr[2];
|
||||
var xv = parseInt(block.getFieldValue(x_area)), yv = parseInt(block.getFieldValue(y_area));
|
||||
if (!isNaN(xv)) x = xv;
|
||||
if (!isNaN(yv)) y = yv;
|
||||
if (floor_area != null) floorId = block.getFieldValue(floor_area) || floorId;
|
||||
}
|
||||
uievent.selectPoint(floorId, x, y, floor_area == null, function (fv, xv, yv) {
|
||||
if (x_area == null || y_area == null) return;
|
||||
if (floor_area != null) {
|
||||
if (fv != editor.currentFloorId) block.setFieldValue(fv, floor_area);
|
||||
else block.setFieldValue("", floor_area);
|
||||
}
|
||||
block.setFieldValue(xv, x_area);
|
||||
block.setFieldValue(yv, y_area);
|
||||
});
|
||||
}
|
||||
|
||||
return editor_blockly;
|
||||
}
|
||||
//editor_blockly=editor_blockly();
|
||||
@ -211,6 +211,7 @@
|
||||
<input class="color" id="colorPicker" value="255,215,0,1"/>
|
||||
<button onclick="confirmColor()">确定</button>
|
||||
</div>
|
||||
<button class="cpPanel" onclick="editor_blockly.selectPoint()" style="margin-left:5px">地图选点</button>
|
||||
</div>
|
||||
<xml id="toolbox" style="display:none">
|
||||
</xml>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user