Merge pull request #119 from zhaouv/v2.x

menu
This commit is contained in:
Zhang Chen 2018-05-11 18:22:35 +08:00 committed by GitHub
commit 3f13ab9031
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 232 additions and 4 deletions

View File

@ -340,6 +340,50 @@ table.row td {
background-color: rgba(76, 34, 27, .5);
}
#menuDiv * { margin: 0; padding: 0; }
#midMenu{
background: #fff;
border-color: #ccc #666 #666 #ccc;
border-style: solid;
border-width: 1px;
cursor: default;
font: normal 13px Arial, sans-serif;
margin: 0;
outline: none;
padding: 4px 0;
position: absolute;
overflow-y: auto;
overflow-x: hidden;
max-height: 100%;
z-index: 101;
border-radius: 4px;
}
#midMenu .menuitem{
color: #000;
font: normal 13px Arial, sans-serif;
list-style: none;
margin: 0;
padding: 4px 7em 4px 28px;
white-space: nowrap;
/* padding-left: 12px; */
/* padding-right: 20px; */
}
#midMenu .menuitem:hover{
background-color: #d6e9f8;
border-color: #d6e9f8;
border-style: dotted;
border-width: 1px 0;
padding-bottom: 3px;
padding-top: 3px;
}
#midMenu .menuitem-content{
color: #000;
font: normal 13px Arial, sans-serif;
}
/* for vue dom */
[v-cloak] {
display: none !important;

View File

@ -348,6 +348,7 @@ editor.prototype.updateMap = function () {
} else drawTile(eventCtx, x, y, tileInfo);
}
// 绘制地图 end
}
editor.prototype.changeFloor = function (floorId, callback) {
@ -427,14 +428,22 @@ 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){
var loc = eToLoc(e);
var pos = locToPos(loc);
editor.showMidMenu(e.clientX,e.clientY);
return;
}
if (!selectBox.isSelected) {
var loc = eToLoc(e);
var pos = locToPos(loc);
editor_mode.onmode('nextChange');
editor_mode.onmode('loc');
//editor_mode.loc();
tip.whichShow = 1;
//tip.whichShow = 1;
return;
}
@ -452,7 +461,7 @@ editor.prototype.listen = function () {
eui.onmousemove = function (e) {
if (!selectBox.isSelected) {
// tip.whichShow = 1;
//tip.whichShow = 1;
return;
}
@ -483,13 +492,13 @@ editor.prototype.listen = function () {
eui.onmouseup = function (e) {
if (!selectBox.isSelected) {
tip.whichShow = 1;
//tip.whichShow = 1;
return;
}
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 +544,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 +612,168 @@ editor.prototype.listen = function () {
}
}
var midMenu=document.getElementById('midMenu');
midMenu.oncontextmenu=function(e){e.preventDefault()}
editor.lastRightButtonPos=[{x:0,y:0},{x:0,y:0}];
editor.showMidMenu=function(x,y){
editor.lastRightButtonPos=JSON.parse(JSON.stringify(
[editor.pos,editor.lastRightButtonPos[0]]
));
var locStr='('+editor.lastRightButtonPos[1].x+','+editor.lastRightButtonPos[1].y+')';
var scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft;
var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
copyLoc.children[0].innerHTML='复制此事件到'+locStr;
moveLoc.children[0].innerHTML='移动此事件到'+locStr;
midMenu.style='top:'+(y+scrollTop)+'px;left:'+(x+scrollLeft)+'px;';
}
editor.hideMidMenu=function(){midMenu.style='display:none';}
var chooseThis = document.getElementById('chooseThis');
chooseThis.onmousedown = function(e){
editor.hideMidMenu();
e.stopPropagation();
selectBox.isSelected = false;
var loc = eToLoc(e);
var pos = locToPos(loc);
editor_mode.onmode('nextChange');
editor_mode.onmode('loc');
//editor_mode.loc();
//tip.whichShow = 1;
}
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;
if(thisevent==0){
//选中清除块
editor.info = 0;
editor.pos=pos;
} else {
var ids=editor.indexs[thisevent.idnum];
ids=ids[0]?ids[0]:ids;
editor.info=editor.ids[ids];
pos.x=editor.widthsX[thisevent.images][1];
pos.y=editor.info.y;
if(thisevent.images=='terrains')pos.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');
}
var fields = Object.keys(editor.file.comment._data.floors._data.loc._data);
var copyLoc = document.getElementById('copyLoc');
copyLoc.onmousedown = function(e){
editor.hideMidMenu();
e.stopPropagation();
preMapData = null;
reDo = null;
var thisevent = editor.map[editor.pos.y][editor.pos.x];
if(thisevent==0){
editor.info = 0;
} else {
var ids=editor.indexs[thisevent.idnum];
ids=ids[0]?ids[0]:ids;
editor.info=editor.ids[ids];
}
editor_mode.onmode('');
var now = editor.pos;
var last = editor.lastRightButtonPos[1];
editor.map[last.y][last.x]=editor.info;
editor.updateMap();
fields.forEach(function(v){
editor.currentFloorData[v][last.x+','+last.y]=editor.currentFloorData[v][now.x+','+now.y]
})
editor.file.saveFloorFile(function (err) {
if (err) {
printe(err);
throw(err)
}
;printf('复制事件成功');
editor.drawEventBlock();
});
}
var moveLoc = document.getElementById('moveLoc');
moveLoc.onmousedown = function(e){
editor.hideMidMenu();
e.stopPropagation();
preMapData = null;
reDo = null;
var thisevent = editor.map[editor.pos.y][editor.pos.x];
if(thisevent==0){
editor.info = 0;
} else {
var ids=editor.indexs[thisevent.idnum];
ids=ids[0]?ids[0]:ids;
editor.info=editor.ids[ids];
}
editor_mode.onmode('');
var now = editor.pos;
var last = editor.lastRightButtonPos[1];
var lastevent = editor.map[last.y][last.x];
var lastinfo = 0;
if(lastevent==0){
lastinfo = 0;
} else {
var ids=editor.indexs[lastevent.idnum];
ids=ids[0]?ids[0]:ids;
lastinfo=editor.ids[ids];
}
editor.map[last.y][last.x]=editor.info;
editor.map[now.y][now.x]=lastinfo;
editor.updateMap();
fields.forEach(function(v){
var temp_atsfcytaf=editor.currentFloorData[v][now.x+','+now.y];
editor.currentFloorData[v][now.x+','+now.y]=editor.currentFloorData[v][last.x+','+last.y];
editor.currentFloorData[v][last.x+','+last.y]=temp_atsfcytaf
})
editor.file.saveFloorFile(function (err) {
if (err) {
printe(err);
throw(err)
}
;printf('两位置的事件已互换');
editor.drawEventBlock();
});
}
var clearLoc = document.getElementById('clearLoc');
clearLoc.onmousedown = function(e){
editor.hideMidMenu();
e.stopPropagation();
preMapData = null;
reDo = null;
editor.info = 0;
editor_mode.onmode('');
var now = editor.pos;
editor.map[now.y][now.x]=editor.info;
editor.updateMap();
fields.forEach(function(v){
editor.currentFloorData[v][now.x+','+now.y]=null;
})
editor.file.saveFloorFile(function (err) {
if (err) {
printe(err);
throw(err)
}
;printf('清空此点及事件成功');
editor.drawEventBlock();
});
}
}//绑定事件
/*

View File

@ -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();

View File

@ -266,6 +266,15 @@
</div>
</div>
</div>
<div id="menuDiv">
<div id="midMenu" style="display:none">
<div id='chooseThis' class="menuitem"><div class="menuitem-content">选中此点</div></div>
<div id='chooseInRight' class="menuitem"><div class="menuitem-content">在素材区选中此图块</div></div>
<div id='copyLoc' class="menuitem"><div class="menuitem-content">复制此事件</div></div>
<div id='moveLoc' class="menuitem"><div class="menuitem-content">移动此事件</div></div>
<div id='clearLoc' class="menuitem"><div class="menuitem-content">清空此点及事件</div></div>
</div>
</div>
</div>
<!-- <script>/* -->
<div id='gameGroup' style='display:none'>