Merge branch 'v2.x' of https://github.com/ckcz123/mota-js into v2.x
This commit is contained in:
commit
c6d2bbeea5
2
_server/blockly/Converter.bundle.min.js
vendored
2
_server/blockly/Converter.bundle.min.js
vendored
File diff suppressed because one or more lines are too long
@ -69,6 +69,11 @@ function editor() {
|
||||
mouseOutCheck : 2,
|
||||
startPos:null,
|
||||
endPos:null,
|
||||
lastMoveE:{buttons:0,clientX:0,clientY:0},
|
||||
// 材料区拖动有关
|
||||
lastMoveMaterE:null,
|
||||
tileSize: [1,1],
|
||||
startLoc: null,
|
||||
// 撤销/恢复
|
||||
preMapData : [],
|
||||
preMapMax: 10,
|
||||
@ -101,8 +106,6 @@ function editor() {
|
||||
},
|
||||
|
||||
// tile
|
||||
tileSize: [1,1],
|
||||
startLoc: null,
|
||||
lockMode: false,
|
||||
|
||||
// 最近使用的图块
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
editor_blockly = function () {
|
||||
|
||||
var editor_blockly = {};
|
||||
var editor_blockly = {entryType:'event'};
|
||||
|
||||
/////////////////initscript start/////////////////////////////
|
||||
// do not use String.raw because of highlighting
|
||||
@ -21,6 +21,7 @@ editor_blockly = function () {
|
||||
|
||||
var toolboxObj = {
|
||||
'入口方块':[
|
||||
'<label text="入口方块会根据当前类型在此数组中筛选,具体控制在editor_blockly.entranceCategoryCallback中"></label>',
|
||||
MotaActionFunctions.actionParser.parse([
|
||||
"欢迎使用事件编辑器",
|
||||
"本事件触发一次后会消失",
|
||||
@ -343,6 +344,7 @@ editor_blockly = function () {
|
||||
for (var name in toolboxObj){
|
||||
var custom = null;
|
||||
if(name=='最近使用事件')custom='searchBlockCategory';
|
||||
if(name=='入口方块')custom='entranceCategory';
|
||||
getCategory(name,custom).innerHTML = toolboxObj[name].join(toolboxgap);
|
||||
}
|
||||
|
||||
@ -362,6 +364,23 @@ var workspace = Blockly.inject(blocklyDiv,{
|
||||
trashcan: false,
|
||||
});
|
||||
|
||||
editor_blockly.entranceCategoryCallback = function(workspace) {
|
||||
var list=toolboxObj['入口方块']
|
||||
var xmlList = [];
|
||||
var eventType = 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;
|
||||
block.setAttribute("gap", 5);
|
||||
xmlList.push(block);
|
||||
}
|
||||
}
|
||||
return xmlList;
|
||||
}
|
||||
|
||||
workspace.registerToolboxCategoryCallback(
|
||||
'entranceCategory', editor_blockly.entranceCategoryCallback);
|
||||
|
||||
editor_blockly.searchBlockCategoryCallback = function(workspace) {
|
||||
var xmlList = [];
|
||||
var labels = editor_blockly.searchBlock();
|
||||
@ -418,7 +437,7 @@ function omitedcheckUpdateFunction(event) {
|
||||
editor_blockly.setValue('入口方块只能有一个');
|
||||
return;
|
||||
}
|
||||
var eventType = document.getElementById('entryType').value;
|
||||
var eventType = editor_blockly.entryType;
|
||||
if(editor_blockly.workspace.topBlocks_.length==1){
|
||||
var blockType = editor_blockly.workspace.topBlocks_[0].type;
|
||||
if(blockType!==eventType+'_m'){
|
||||
@ -465,8 +484,7 @@ function omitedcheckUpdateFunction(event) {
|
||||
if(noinput) input = '';
|
||||
if(inputType!=='field') {
|
||||
var subList = false;
|
||||
var subrulename = rule.args[ii];
|
||||
subrulename=subrulename.split('_').slice(0,-1).join('_');
|
||||
var subrulename = rule.argsGrammarName[ii];
|
||||
var subrule = MotaActionBlocks[subrulename];
|
||||
if (subrule instanceof Array) {
|
||||
subrulename=subrule[subrule.length-1];
|
||||
@ -605,7 +623,7 @@ function omitedcheckUpdateFunction(event) {
|
||||
eval('obj=' + codeAreaHL.getValue().replace(/[<>&]/g, function (c) {
|
||||
return {'<': '<', '>': '>', '&': '&'}[c];
|
||||
}).replace(/\\(r|f|i|c|d|e|z)/g,'\\\\$1')),
|
||||
document.getElementById('entryType').value
|
||||
editor_blockly.entryType
|
||||
);
|
||||
}
|
||||
|
||||
@ -620,7 +638,7 @@ function omitedcheckUpdateFunction(event) {
|
||||
if (!type) return false;
|
||||
editor_blockly.id = id_;
|
||||
editor_blockly.setValue(input.value);
|
||||
document.getElementById('entryType').value = type;
|
||||
editor_blockly.entryType = type;
|
||||
editor_blockly.parse();
|
||||
editor_blockly.show();
|
||||
return true;
|
||||
@ -668,7 +686,7 @@ function omitedcheckUpdateFunction(event) {
|
||||
editor_blockly.setValue('入口方块只能有一个');
|
||||
return;
|
||||
}
|
||||
var eventType = document.getElementById('entryType').value;
|
||||
var eventType = editor_blockly.entryType;
|
||||
if(editor_blockly.workspace.topBlocks_.length==1){
|
||||
var blockType = editor_blockly.workspace.topBlocks_[0].type;
|
||||
if(blockType!==eventType+'_m'){
|
||||
|
||||
@ -75,6 +75,7 @@ editor_mappanel_wrapper = function (editor) {
|
||||
* + 绘图时画个矩形在那个位置
|
||||
*/
|
||||
editor.uifunctions.map_ondown = function (e) {
|
||||
editor.uivalues.lastMoveE=e;
|
||||
var loc = editor.uifunctions.eToLoc(e);
|
||||
var pos = editor.uifunctions.locToPos(loc, true);
|
||||
if (editor.uivalues.bindSpecialDoor.loc != null) {
|
||||
@ -89,10 +90,10 @@ editor_mappanel_wrapper = function (editor) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (e.button == 2) {
|
||||
editor.uifunctions.showMidMenu(e.clientX, e.clientY);
|
||||
return false;
|
||||
}
|
||||
// if (e.buttons == 2) { // 挪到onup
|
||||
// editor.uifunctions.showMidMenu(e.clientX, e.clientY);
|
||||
// return false;
|
||||
// }
|
||||
if (!selectBox.isSelected()) {
|
||||
editor_mode.onmode('nextChange');
|
||||
editor_mode.onmode('loc');
|
||||
@ -122,6 +123,7 @@ editor_mappanel_wrapper = function (editor) {
|
||||
* + 绘图模式时找到与队列尾相邻的鼠标方向的点画个矩形
|
||||
*/
|
||||
editor.uifunctions.map_onmove = function (e) {
|
||||
editor.uivalues.lastMoveE=e;
|
||||
if (!selectBox.isSelected()) {
|
||||
if (editor.uivalues.startPos == null) return;
|
||||
//tip.whichShow(1);
|
||||
@ -136,9 +138,25 @@ editor_mappanel_wrapper = function (editor) {
|
||||
editor.uivalues.endPos = pos;
|
||||
if (editor.uivalues.startPos != null) {
|
||||
if (editor.uivalues.startPos.x != editor.uivalues.endPos.x || editor.uivalues.startPos.y != editor.uivalues.endPos.y) {
|
||||
core.drawArrow('eui',
|
||||
32 * editor.uivalues.startPos.x + 16 - core.bigmap.offsetX, 32 * editor.uivalues.startPos.y + 16 - core.bigmap.offsetY,
|
||||
32 * editor.uivalues.endPos.x + 16 - core.bigmap.offsetX, 32 * editor.uivalues.endPos.y + 16 - core.bigmap.offsetY);
|
||||
if (e.buttons == 2) {
|
||||
// 右键拖拽: 画选的区域
|
||||
var x0 = editor.uivalues.startPos.x;
|
||||
var y0 = editor.uivalues.startPos.y;
|
||||
var x1 = editor.uivalues.endPos.x;
|
||||
var y1 = editor.uivalues.endPos.y;
|
||||
if (x0 > x1) { x0 ^= x1; x1 ^= x0; x0 ^= x1; }//swap
|
||||
if (y0 > y1) { y0 ^= y1; y1 ^= y0; y0 ^= y1; }//swap
|
||||
// draw rect
|
||||
editor.dom.euiCtx.clearRect(0, 0, editor.dom.euiCtx.canvas.width, editor.dom.euiCtx.canvas.height);
|
||||
editor.dom.euiCtx.fillStyle = 'rgba(0, 127, 255, 0.4)';
|
||||
editor.dom.euiCtx.fillRect(32 * x0 - core.bigmap.offsetX, 32 * y0 - core.bigmap.offsetY,
|
||||
32 * (x1 - x0) + 32, 32 * (y1 - y0) + 32);
|
||||
}else{
|
||||
// 左键拖拽: 画箭头
|
||||
core.drawArrow('eui',
|
||||
32 * editor.uivalues.startPos.x + 16 - core.bigmap.offsetX, 32 * editor.uivalues.startPos.y + 16 - core.bigmap.offsetY,
|
||||
32 * editor.uivalues.endPos.x + 16 - core.bigmap.offsetX, 32 * editor.uivalues.endPos.y + 16 - core.bigmap.offsetY);
|
||||
}
|
||||
}
|
||||
}
|
||||
// editor_mode.onmode('nextChange');
|
||||
@ -192,17 +210,31 @@ editor_mappanel_wrapper = function (editor) {
|
||||
* + 非绘图模式时, 交换首末点的内容
|
||||
* + 绘图模式时, 根据画线/画矩形/画tileset 做对应的绘制
|
||||
*/
|
||||
editor.uifunctions.map_onup = function (e) {
|
||||
editor.uifunctions.map_onup = function (ee) {
|
||||
console.log(1)
|
||||
var e=editor.uivalues.lastMoveE;
|
||||
if (!selectBox.isSelected()) {
|
||||
//tip.whichShow(1);
|
||||
// editor.movePos(editor.uivalues.startPos, editor.uivalues.endPos);
|
||||
if (editor.layerMod == 'map')
|
||||
editor.exchangePos(editor.uivalues.startPos, editor.uivalues.endPos);
|
||||
else
|
||||
editor.exchangeBgFg(editor.uivalues.startPos, editor.uivalues.endPos, editor.layerMod);
|
||||
editor.uivalues.startPos = editor.uivalues.endPos = null;
|
||||
if (e.buttons == 2) {
|
||||
if (editor.uivalues.endPos==null || editor.uivalues.startPos.x == editor.uivalues.endPos.x && editor.uivalues.startPos.y == editor.uivalues.endPos.y){
|
||||
// 右键点击: 弹菜单
|
||||
editor.uifunctions.showMidMenu(e.clientX, e.clientY);
|
||||
} else {
|
||||
// 右键拖拽: 选中区域
|
||||
printf('已经选中该区域')
|
||||
// 后续的处理
|
||||
}
|
||||
} else {
|
||||
// 左键拖拽: 交换
|
||||
//tip.whichShow(1);
|
||||
// editor.movePos(editor.uivalues.startPos, editor.uivalues.endPos);
|
||||
if (editor.layerMod == 'map')
|
||||
editor.exchangePos(editor.uivalues.startPos, editor.uivalues.endPos);
|
||||
else
|
||||
editor.exchangeBgFg(editor.uivalues.startPos, editor.uivalues.endPos, editor.layerMod);
|
||||
editor.uifunctions.unhighlightSaveFloorButton();
|
||||
}
|
||||
editor.dom.euiCtx.clearRect(0, 0, core.__PIXELS__, core.__PIXELS__);
|
||||
editor.uifunctions.unhighlightSaveFloorButton();
|
||||
editor.uivalues.startPos = editor.uivalues.endPos = null;
|
||||
return false;
|
||||
}
|
||||
editor.uivalues.holdingPath = 0;
|
||||
|
||||
@ -62,7 +62,6 @@ editor_materialpanel_wrapper = function (editor) {
|
||||
}
|
||||
}
|
||||
|
||||
var lastmoveE=null;
|
||||
/**
|
||||
* editor.dom.iconLib.onmousedown
|
||||
* 素材区的单击/拖拽事件
|
||||
@ -70,7 +69,7 @@ editor_materialpanel_wrapper = function (editor) {
|
||||
editor.uifunctions.material_ondown = function (e) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
lastmoveE=e;
|
||||
editor.uivalues.lastMoveMaterE=e;
|
||||
if (!editor.isMobile && e.clientY >= editor.dom.iconLib.offsetHeight - editor.uivalues.scrollBarHeight) return;
|
||||
var scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft;
|
||||
var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
|
||||
@ -90,7 +89,7 @@ editor_materialpanel_wrapper = function (editor) {
|
||||
editor.uifunctions.material_onmove = function (e) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
lastmoveE=e;
|
||||
editor.uivalues.lastMoveMaterE=e;
|
||||
if (!editor.uivalues.startLoc) return;
|
||||
var pos0 = editor.uifunctions.locToPos(editor.uivalues.startLoc);
|
||||
|
||||
@ -109,7 +108,7 @@ editor_materialpanel_wrapper = function (editor) {
|
||||
var startLoc = editor.uivalues.startLoc;
|
||||
editor.uivalues.startLoc = null;
|
||||
|
||||
var e=lastmoveE;
|
||||
var e=editor.uivalues.lastMoveMaterE;
|
||||
if (!editor.isMobile && e.clientY >= editor.dom.iconLib.offsetHeight - editor.uivalues.scrollBarHeight) return;
|
||||
var scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft;
|
||||
var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
|
||||
|
||||
@ -204,25 +204,6 @@
|
||||
<button onclick="editor_blockly.showXML()">Show XML</button>
|
||||
<button onclick="editor_blockly.runCode()">console.log(obj=code)</button>
|
||||
-->
|
||||
<select id="entryType" disabled="disabled" style="display: none">
|
||||
<option value="event">event</option>
|
||||
<option value="autoEvent">autoEvent</option>
|
||||
<option value="changeFloor">changeFloor</option>
|
||||
<option value="level">level</option>
|
||||
<option value="shop">shop</option>
|
||||
<option value="afterBattle">afterBattle</option>
|
||||
<option value="afterGetItem">afterGetItem</option>
|
||||
<option value="afterOpenDoor">afterOpenDoor</option>
|
||||
<option value="firstArrive">firstArrive</option>
|
||||
<option value="eachArrive">eachArrive</option>
|
||||
<option value="commonEvent">commonEvent</option>
|
||||
<option value="item">item</option>
|
||||
<option value="levelChoose">levelChoose</option>
|
||||
<option value="equip">equip</option>
|
||||
<option value="floorImage">floorImage</option>
|
||||
<option value="doorInfo">doorInfo</option>
|
||||
<option value="faceIds">faceIds</option>
|
||||
</select>
|
||||
<button onclick="editor_blockly.confirm()">确认</button>
|
||||
<button id='blocklyParse' onclick="editor_blockly.parse()">解析</button>
|
||||
<button onclick="editor_blockly.cancel()">取消</button>
|
||||
|
||||
19
editor.html
19
editor.html
@ -200,25 +200,6 @@
|
||||
<button onclick="editor_blockly.showXML()">Show XML</button>
|
||||
<button onclick="editor_blockly.runCode()">console.log(obj=code)</button>
|
||||
-->
|
||||
<select id="entryType" disabled="disabled" style="display: none">
|
||||
<option value="event">event</option>
|
||||
<option value="autoEvent">autoEvent</option>
|
||||
<option value="changeFloor">changeFloor</option>
|
||||
<option value="level">level</option>
|
||||
<option value="shop">shop</option>
|
||||
<option value="afterBattle">afterBattle</option>
|
||||
<option value="afterGetItem">afterGetItem</option>
|
||||
<option value="afterOpenDoor">afterOpenDoor</option>
|
||||
<option value="firstArrive">firstArrive</option>
|
||||
<option value="eachArrive">eachArrive</option>
|
||||
<option value="commonEvent">commonEvent</option>
|
||||
<option value="item">item</option>
|
||||
<option value="levelChoose">levelChoose</option>
|
||||
<option value="equip">equip</option>
|
||||
<option value="floorImage">floorImage</option>
|
||||
<option value="doorInfo">doorInfo</option>
|
||||
<option value="faceIds">faceIds</option>
|
||||
</select>
|
||||
<button onclick="editor_blockly.confirm()">确认</button>
|
||||
<button id='blocklyParse' onclick="editor_blockly.parse()">解析</button>
|
||||
<button onclick="editor_blockly.cancel()">取消</button>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user