diff --git a/_server/MotaActionParse.js b/_server/MotaActionParse.js index 3a639310..5c9ab9c1 100644 --- a/_server/MotaActionParse.js +++ b/_server/MotaActionParse.js @@ -1022,9 +1022,9 @@ ActionParser.prototype.matchEvalCompare=function(args, isShadow){ // 按优先级依次寻找以下符号 var oplist=['<','<=','>','>=','==','!=','&&','||'].reverse() for (var index = 0,op; op=oplist[index]; index++) { - var match=new RegExp('(?<= )'+(op=='||'?'\\|\\|':op)+'(?= )').exec(str) + var match=new RegExp(' '+(op=='||'?'\\|\\|':op)+' ').exec(str) if (!match) continue; - args=[this.expandEvalBlock([raw.slice(0,match.index)],isShadow),op.replace(/&/g,'&').replace(//g,'>'),this.expandEvalBlock([raw.slice(match.index+op.length)],isShadow)] + args=[this.expandEvalBlock([raw.slice(0,match.index+1)],isShadow),op.replace(/&/g,'&').replace(//g,'>'),this.expandEvalBlock([raw.slice(match.index+1+op.length)],isShadow)] return {ret:true,xml:xml,args:args} } return {ret:false} diff --git a/_server/editor.js b/_server/editor.js index 31d1f954..de9c25ce 100644 --- a/_server/editor.js +++ b/_server/editor.js @@ -105,6 +105,7 @@ function editor() { // tile tileSize: [1,1], + startLoc: {"x":0,"y":0}, lockMode: false, // 最近使用的图块 @@ -282,6 +283,7 @@ editor.prototype.changeFloor = function (floorId, callback) { editor.viewportLoc = editor.viewportLoc || {}; var loc = editor.viewportLoc[floorId] || [], x = loc[0] || 0, y = loc[1] || 0; editor.setViewport(x, y); + editor.uifunctions.unhighlightSaveFloorButton(); editor.config.set('editorLastFloorId', floorId, function() { if (callback) callback(); @@ -682,6 +684,7 @@ editor.prototype.setSelectBoxFromInfo=function(thisevent, scrollTo){ editor.dom.dataSelection.style.left = pos.x * 32 + 'px'; editor.dom.dataSelection.style.top = pos.y * ysize + 'px'; editor.dom.dataSelection.style.height = ysize - 6 + 'px'; + editor.dom.dataSelection.style.width = 32 - 6 + 'px'; setTimeout(function(){ selectBox.isSelected(true); editor.updateLastUsedMap(); diff --git a/_server/editor_listen.js b/_server/editor_listen.js index f5994f4e..7a3b83b1 100644 --- a/_server/editor_listen.js +++ b/_server/editor_listen.js @@ -24,6 +24,8 @@ editor_listen_wrapper = function (editor) { editor.dom.iconExpandBtn.onclick = editor.uifunctions.fold_material_click editor.dom.iconLib.onmousedown = editor.uifunctions.material_ondown + editor.dom.iconLib.onmousemove = editor.uifunctions.material_onmove + editor.dom.iconLib.onmouseup = editor.uifunctions.material_onup editor.dom.iconLib.oncontextmenu = function (e) { e.preventDefault() } editor.dom.extraEvent.onmousedown = editor.uifunctions.extraEvent_click @@ -132,6 +134,14 @@ editor_listen_wrapper = function (editor) { editor.dom.moveLoc.onmousedown = null editor.dom.clearLoc.ontouchstart = editor.dom.clearLoc.onmousedown editor.dom.clearLoc.onmousedown = null + + // 不使用以下6语句, 会使得素材区手机无法拖动, 手机的框选素材只能放弃, 要通过弹框实现框选 + // editor.dom.iconLib.ontouchstart = editor.dom.iconLib.onmousedown + // editor.dom.iconLib.onmousedown = null + // editor.dom.iconLib.ontouchmove = editor.dom.iconLib.onmousemove + // editor.dom.iconLib.onmousemove = null + // editor.dom.iconLib.ontouchend = editor.dom.iconLib.onmouseup + // editor.dom.iconLib.onmouseup = null } editor.constructor.prototype.mode_listen = function (callback) { diff --git a/_server/editor_mappanel.js b/_server/editor_mappanel.js index f6c7687c..93d57fed 100644 --- a/_server/editor_mappanel.js +++ b/_server/editor_mappanel.js @@ -202,6 +202,7 @@ editor_mappanel_wrapper = function (editor) { editor.exchangeBgFg(editor.uivalues.startPos, editor.uivalues.endPos, editor.layerMod); editor.uivalues.startPos = editor.uivalues.endPos = null; editor.dom.euiCtx.clearRect(0, 0, core.__PIXELS__, core.__PIXELS__); + editor.uifunctions.unhighlightSaveFloorButton(); return false; } editor.uivalues.holdingPath = 0; @@ -274,6 +275,7 @@ editor_mappanel_wrapper = function (editor) { editor.uivalues.holdingPath = 0; editor.uivalues.stepPostfix = []; editor.dom.euiCtx.clearRect(0, 0, core.__PIXELS__, core.__PIXELS__); + editor.uifunctions.highlightSaveFloorButton(); } return false; } @@ -465,6 +467,7 @@ editor_mappanel_wrapper = function (editor) { editor.drawEventBlock(); editor_mode.showMode('loc'); printf('添加楼梯事件成功'); + editor.uifunctions.unhighlightSaveFloorButton(); }); return true; } @@ -525,6 +528,7 @@ editor_mappanel_wrapper = function (editor) { editor.drawPosSelection(); editor_mode.showMode('loc'); printf('绑定机关门事件成功'); + editor.uifunctions.unhighlightSaveFloorButton(); }); bindSpecialDoor.loc = null; bindSpecialDoor.enemys = []; @@ -577,6 +581,7 @@ editor_mappanel_wrapper = function (editor) { throw (err) } ; printf('复制事件成功'); + editor.uifunctions.unhighlightSaveFloorButton(); editor.drawPosSelection(); }); } @@ -591,6 +596,7 @@ editor_mappanel_wrapper = function (editor) { editor.savePreMap(); editor_mode.onmode(''); editor.exchangePos(editor.pos, editor.uivalues.lastRightButtonPos[1]); + editor.uifunctions.unhighlightSaveFloorButton(); } /** @@ -600,6 +606,7 @@ editor_mappanel_wrapper = function (editor) { editor.uifunctions.clearEvent_click = function (e) { e.stopPropagation(); editor.clearPos(false); + editor.uifunctions.unhighlightSaveFloorButton(); } /** @@ -609,6 +616,7 @@ editor_mappanel_wrapper = function (editor) { editor.uifunctions.clearLoc_click = function (e) { e.stopPropagation(); editor.clearPos(true); + editor.uifunctions.unhighlightSaveFloorButton(); } /** @@ -765,6 +773,15 @@ editor_mappanel_wrapper = function (editor) { }); } + editor.uifunctions.highlightSaveFloorButton=function(){ + var saveFloor = document.getElementById('saveFloor'); + saveFloor.style.background='#FFCCAA'; + } + + editor.uifunctions.unhighlightSaveFloorButton=function(){ + var saveFloor = document.getElementById('saveFloor'); + saveFloor.style.background=''; + } editor.uifunctions.saveFloor_func = function () { var saveFloor = document.getElementById('saveFloor'); @@ -776,6 +793,7 @@ editor_mappanel_wrapper = function (editor) { throw (err) } ; printf('保存成功'); + editor.uifunctions.unhighlightSaveFloorButton() }); } saveFloor.onclick = editor_mode.saveFloor; diff --git a/_server/editor_materialpanel.js b/_server/editor_materialpanel.js index 51752b9c..7aa54339 100644 --- a/_server/editor_materialpanel.js +++ b/_server/editor_materialpanel.js @@ -62,13 +62,41 @@ editor_materialpanel_wrapper = function (editor) { } } + var lastmoveE=null; /** * editor.dom.iconLib.onmousedown - * 素材区的单击事件 + * 素材区的单击/拖拽事件 */ editor.uifunctions.material_ondown = function (e) { e.stopPropagation(); e.preventDefault(); + lastmoveE=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; + editor.uivalues.startLoc={ + 'x': scrollLeft + e.clientX + editor.dom.iconLib.scrollLeft - right.offsetLeft - editor.dom.iconLib.offsetLeft, + 'y': scrollTop + e.clientY + editor.dom.iconLib.scrollTop - right.offsetTop - editor.dom.iconLib.offsetTop, + 'size': 32 + }; + } + + /** + * editor.dom.iconLib.onmousemove + * 素材区的单击/拖拽事件 + */ + editor.uifunctions.material_onmove = function (e) { + e.stopPropagation(); + e.preventDefault(); + lastmoveE=e; + } + + /** + * editor.dom.iconLib.onmouseup + * 素材区的单击/拖拽事件 + */ + editor.uifunctions.material_onup = function (ee) { + var e=lastmoveE; 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; @@ -79,6 +107,7 @@ editor_materialpanel_wrapper = function (editor) { }; editor.loc = loc; editor.uivalues.tileSize = [1,1]; + var pos0 = editor.uifunctions.locToPos(editor.uivalues.startLoc); var pos = editor.uifunctions.locToPos(loc); for (var spriter in editor.widthsX) { if (pos.x >= editor.widthsX[spriter][1] && pos.x < editor.widthsX[spriter][2]) { @@ -115,6 +144,7 @@ editor_materialpanel_wrapper = function (editor) { editor.dom.dataSelection.style.left = pos.x * 32 + 'px'; editor.dom.dataSelection.style.top = pos.y * ysize + 'px'; editor.dom.dataSelection.style.height = ysize - 6 + 'px'; + editor.dom.dataSelection.style.width = 32 - 6 + 'px'; if (pos.x == 0 && pos.y == 0) { // editor.info={idnum:0, id:'empty','images':'清除块', 'y':0}; @@ -133,21 +163,21 @@ editor_materialpanel_wrapper = function (editor) { editor.info = { 'images': pos.images, 'y': y } } - for (var ii = 0; ii < editor.ids.length; ii++) { - if ((core.tilesets.indexOf(pos.images) != -1 && editor.info.images == editor.ids[ii].images - && editor.info.y == editor.ids[ii].y && editor.info.x == editor.ids[ii].x) - || (Object.prototype.hasOwnProperty.call(autotiles, pos.images) && editor.info.images == editor.ids[ii].id - && editor.info.y == editor.ids[ii].y) - || (core.tilesets.indexOf(pos.images) == -1 && editor.info.images == editor.ids[ii].images - && editor.info.y == editor.ids[ii].y) + for (var idindex = 0; idindex < editor.ids.length; idindex++) { + if ((core.tilesets.indexOf(pos.images) != -1 && editor.info.images == editor.ids[idindex].images + && editor.info.y == editor.ids[idindex].y && editor.info.x == editor.ids[idindex].x) + || (Object.prototype.hasOwnProperty.call(autotiles, pos.images) && editor.info.images == editor.ids[idindex].id + && editor.info.y == editor.ids[idindex].y) + || (core.tilesets.indexOf(pos.images) == -1 && editor.info.images == editor.ids[idindex].images + && editor.info.y == editor.ids[idindex].y) ) { - editor.info = editor.ids[ii]; + editor.info = editor.ids[idindex]; break; } } - if (editor.info.isTile && e.button == 2) { + if (editor.info.isTile && e.button == 2) { //这段改一改之类的应该能给手机用,就不删了 var v = prompt("请输入该额外素材区域绑定宽高,以逗号分隔", "1,1"); if (v != null && /^\d+,\d+$/.test(v)) { v = v.split(","); @@ -157,9 +187,31 @@ editor_materialpanel_wrapper = function (editor) { alert("不合法的输入范围,已经越界"); } else { editor.uivalues.tileSize = [x, y]; + editor.dom.dataSelection.style.left = pos.x * 32 + 'px'; + editor.dom.dataSelection.style.top = pos.y * ysize + 'px'; + editor.dom.dataSelection.style.height = ysize*y - 6 + 'px'; + editor.dom.dataSelection.style.width = 32*x - 6 + 'px'; } } } + if (editor.info.isTile && e.button != 2) { //左键拖拽框选 + + var x = pos.x-pos0.x+1, y = pos.y-pos0.y+1; + var widthX = editor.widthsX[editor.info.images]; + // 懒得仔细处理了, 只允许左上往右下拉 + if (x <= 0 || y <= 0 || pos0.x < widthX[1]){ + + } else { + editor.info = editor.ids[idindex-(x-1)-(y-1)*(widthX[2]-widthX[1])]; + editor.uifunctions.locToPos(editor.uivalues.startLoc); //重置editor.pos + editor.uivalues.tileSize = [x, y]; + editor.dom.dataSelection.style.left = pos0.x * 32 + 'px'; + editor.dom.dataSelection.style.top = pos0.y * ysize + 'px'; + editor.dom.dataSelection.style.height = ysize*y - 6 + 'px'; + editor.dom.dataSelection.style.width = 32*x - 6 + 'px'; + } + + } } tip.infos(JSON.parse(JSON.stringify(editor.info))); diff --git a/_server/editor_ui.js b/_server/editor_ui.js index cc9588ed..1bcd019d 100644 --- a/_server/editor_ui.js +++ b/_server/editor_ui.js @@ -236,6 +236,7 @@ editor_ui_wrapper = function (editor) { throw (err) } ; printf('地图保存成功'); + editor.uifunctions.unhighlightSaveFloorButton(); }); } selectBox.isSelected(false); @@ -318,6 +319,7 @@ editor_ui_wrapper = function (editor) { editor.bgmap = JSON.parse(JSON.stringify(data.bgmap)); editor.updateMap(); editor.uivalues.postMapData.push(data); + editor.uifunctions.highlightSaveFloorButton(); printf("已撤销此操作,你可能需要重新保存地图。"); } return; @@ -332,6 +334,7 @@ editor_ui_wrapper = function (editor) { editor.bgmap = JSON.parse(JSON.stringify(data.bgmap)); editor.updateMap(); editor.uivalues.preMapData.push(data); + editor.uifunctions.highlightSaveFloorButton(); printf("已重做此操作,你可能需要重新保存地图。"); } return; @@ -349,6 +352,7 @@ editor_ui_wrapper = function (editor) { editor.uivalues.copyedInfo = editor.copyFromPos(); editor.clearPos(true, null, function () { printf('该点事件已剪切'); + editor.uifunctions.unhighlightSaveFloorButton(); }) return; } @@ -366,6 +370,7 @@ editor_ui_wrapper = function (editor) { throw (err) } ; printf('粘贴事件成功'); + editor.uifunctions.unhighlightSaveFloorButton(); editor.drawPosSelection(); }); return; @@ -373,6 +378,7 @@ editor_ui_wrapper = function (editor) { // DELETE if (e.keyCode == 46 && !selectBox.isSelected()) { editor.clearPos(true); + editor.uifunctions.unhighlightSaveFloorButton(); return; } // ESC