diff --git a/_server/css/editor.css b/_server/css/editor.css index 90dde66c..6cf8473f 100644 --- a/_server/css/editor.css +++ b/_server/css/editor.css @@ -340,6 +340,29 @@ table.row td { background-color: rgba(76, 34, 27, .5); } +#menuDiv * { margin: 0; padding: 0; } +#midMenu{ + z-index: 101; + width: 10em; + background: rgba(255, 255, 255, 0.65); + position: absolute; + /* display: none; */ +} +#midMenu ul{ + width: 100%; + list-style: none; + border: 1px solid #000; + border-bottom: 0px; +} +#midMenu ul li{ + /* height: 30px; */ + /* font-size: 16px; */ + color: #000; + /* line-height: 30px; */ + /* text-align: center; */ + border-bottom: 1px solid #000; +} + /* for vue dom */ [v-cloak] { display: none !important; diff --git a/_server/editor.js b/_server/editor.js index 75f6bbbd..1c343943 100644 --- a/_server/editor.js +++ b/_server/editor.js @@ -427,7 +427,15 @@ editor.prototype.listen = function () { uc.clearRect(0, 0, 416, 416); }//用于鼠标移出canvas时的自动清除状态 + eui.oncontextmenu=function(e){e.preventDefault()} + eui.onmousedown = function (e) { + if (e.button==2){ + editor.showMidMenu(e.clientX,e.clientY); + var loc = eToLoc(e); + var pos = locToPos(loc); + return; + } if (!selectBox.isSelected) { var loc = eToLoc(e); var pos = locToPos(loc); @@ -489,7 +497,7 @@ editor.prototype.listen = function () { holdingPath = 0; e.stopPropagation(); var loc = eToLoc(e); - if (stepPostfix.length) { + if (stepPostfix && stepPostfix.length) { preMapData = JSON.parse(JSON.stringify(editor.map)); currDrawData.pos = JSON.parse(JSON.stringify(stepPostfix)); currDrawData.info = JSON.parse(JSON.stringify(editor.info)); @@ -535,6 +543,7 @@ editor.prototype.listen = function () { } } + var dataSelection = document.getElementById('dataSelection'); edata.onmousedown = function (e) { e.stopPropagation(); var scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft; @@ -602,6 +611,42 @@ editor.prototype.listen = function () { } } + var midMenu=document.getElementById('midMenu'); + midMenu.oncontextmenu=function(e){e.preventDefault()} + editor.showMidMenu=function(x,y){ + var scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft; + var scrollTop = document.documentElement.scrollTop || document.body.scrollTop; + midMenu.style='top:'+(y+scrollTop)+'px;left:'+(x+scrollLeft)+'px;'; + } + editor.hideMidMenu=function(){midMenu.style='display:none';} + + var chooseInRight = document.getElementById('chooseInRight'); + chooseInRight.onmousedown = function(e){ + editor.hideMidMenu(); + e.stopPropagation(); + var thisevent = editor.map[editor.pos.y][editor.pos.x]; + var pos={x: 0, y: 0, images: "terrains"}; + var ysize = 32; + console.log(thisevent) + if(thisevent==0){ + //选中清除块 + editor.info = 0; + editor.pos=pos; + } else { + editor.info=editor.ids[editor.indexs[thisevent.idnum]]; + pos.x=editor.widthsX[thisevent.images][1]; + pos.y=editor.info.y; + ysize = thisevent.images.indexOf('48') === -1 ? 32 : 48; + } + setTimeout(function(){selectBox.isSelected = true;}); + dataSelection.style.left = pos.x * 32 + 'px'; + dataSelection.style.top = pos.y * ysize + 'px'; + dataSelection.style.height = ysize - 6 + 'px'; + tip.infos = JSON.parse(JSON.stringify(editor.info)); + editor_mode.onmode('nextChange'); + editor_mode.onmode('emenyitem'); + } + }//绑定事件 /* diff --git a/_server/vm.js b/_server/vm.js index 64471533..e23fd65d 100644 --- a/_server/vm.js +++ b/_server/vm.js @@ -29,6 +29,9 @@ document.body.onmousedown = function (e) { } //editor.mode.onmode(''); editor.info = {}; + if (e.button!=2){ + editor.hideMidMenu(); + } } iconLib.onmousedown = function (e) { e.stopPropagation(); diff --git a/editor.html b/editor.html index b296cbbb..05719170 100644 --- a/editor.html +++ b/editor.html @@ -266,6 +266,16 @@ +