diff --git a/_server/css/editor.css b/_server/css/editor.css index df5e2670..c12e3f07 100644 --- a/_server/css/editor.css +++ b/_server/css/editor.css @@ -262,10 +262,6 @@ body { position: absolute; } -.egameCanvas { - position: absolute; -} - .gameCanvas { position: absolute; } diff --git a/_server/css/editor_mobile.css b/_server/css/editor_mobile.css index 4a46198b..c37142e1 100644 --- a/_server/css/editor_mobile.css +++ b/_server/css/editor_mobile.css @@ -247,10 +247,6 @@ body { position: absolute; } -.egameCanvas { - position: absolute; -} - .gameCanvas { position: absolute; } diff --git a/_server/editor.js b/_server/editor.js index 855688db..683200a2 100644 --- a/_server/editor.js +++ b/_server/editor.js @@ -491,4 +491,69 @@ editor.prototype.mobile_listen=function(){ // 移动至 editor_unsorted_1.js } +editor.prototype.copyFromPos = function (pos) { + var fields = Object.keys(editor.file.comment._data.floors._data.loc._data); + pos = pos || editor.pos; + var map = core.clone(editor.map[pos.y][pos.x]); + var events = {}; + fields.forEach(function(v){ + events[v] = core.clone(editor.currentFloorData[v][pos.x+','+pos.y]); + }) + return {map: map, events: events}; +} + +editor.prototype.pasteToPos = function (info, pos) { + if (info == null) return; + var fields = Object.keys(editor.file.comment._data.floors._data.loc._data); + pos = pos || editor.pos; + editor.map[pos.y][pos.x] = core.clone(info.map); + fields.forEach(function(v){ + if (info.events[v] == null) delete editor.currentFloorData[v][pos.x+","+pos.y]; + else editor.currentFloorData[v][pos.x+","+pos.y] = core.clone(info.events[v]); + }); +} + +editor.prototype.movePos = function (startPos, endPos, callback) { + if (!startPos || !endPos) return; + if (startPos.x == endPos.x && startPos.y == endPos.y) return; + var copyed = editor.copyFromPos(startPos); + editor.pasteToPos({map:0, events: {}}, startPos); + editor.pasteToPos(copyed, endPos); + editor.updateMap(); + editor.file.saveFloorFile(function (err) { + if (err) { + printe(err); + throw(err) + } + ;printf('移动事件成功'); + editor.drawPosSelection(); + if (callback) callback(); + }); +} + +editor.prototype.clearPos = function (clearPos, pos, callback) { + var fields = Object.keys(editor.file.comment._data.floors._data.loc._data); + pos = pos || editor.pos; + editor.hideMidMenu(); + editor.preMapData = null; + editor.info = 0; + editor_mode.onmode(''); + if (clearPos) + editor.map[pos.y][pos.x]=editor.info; + editor.updateMap(); + fields.forEach(function(v){ + delete editor.currentFloorData[v][pos.x+','+pos.y]; + }) + editor.file.saveFloorFile(function (err) { + if (err) { + printe(err); + throw(err) + } + ;printf(clearPos?'清空该点和事件成功':'只清空该点事件成功'); + editor.drawPosSelection(); + if (callback) callback(); + }); +} + + editor = new editor(); \ No newline at end of file diff --git a/_server/editor_mode.js b/_server/editor_mode.js index f0215cf0..aadbec9a 100644 --- a/_server/editor_mode.js +++ b/_server/editor_mode.js @@ -114,8 +114,7 @@ editor_mode = function (editor) { editor.drawEventBlock(); if (editor_mode[mode]) editor_mode[mode](); document.getElementById('editModeSelect').value = mode; - var tips = tip_in_showMode; - if (!selectBox.isSelected()) printf('tips: ' + tips[~~(tips.length * Math.random())]); + if (!selectBox.isSelected()) tip.showHelp(); } editor_mode.prototype.loc = function (callback) { diff --git a/_server/editor_unsorted_1.js b/_server/editor_unsorted_1.js index a8aaf3c9..31381e02 100644 --- a/_server/editor_unsorted_1.js +++ b/_server/editor_unsorted_1.js @@ -104,6 +104,7 @@ editor.constructor.prototype.listen=function () { holdingPath = 0; stepPostfix = []; uc.clearRect(0, 0, core.__PIXELS__, core.__PIXELS__); + startPos = endPos = null; }//用于鼠标移出canvas时的自动清除状态 eui.oncontextmenu=function(e){e.preventDefault()} @@ -116,6 +117,7 @@ editor.constructor.prototype.listen=function () { return; } + var startPos=null, endPos=null; eui.onmousedown = function (e) { if (e.button==2){ var loc = eToLoc(e); @@ -130,6 +132,10 @@ editor.constructor.prototype.listen=function () { editor_mode.onmode('loc'); //editor_mode.loc(); //tip.whichShow(1); + tip.showHelp(6); + startPos = pos; + uc.strokeStyle = '#FF0000'; + uc.lineWidth = 3; if(editor.isMobile)editor.showMidMenu(e.clientX,e.clientY); return; } @@ -149,7 +155,29 @@ editor.constructor.prototype.listen=function () { eui.onmousemove = function (e) { if (!selectBox.isSelected()) { + if (startPos == null) return; //tip.whichShow(1); + var loc = eToLoc(e); + var pos = locToPos(loc,true); + if (endPos != null && endPos.x == pos.x && endPos.y == pos.y) return; + if (endPos != null) { + uc.clearRect(Math.min(32 * startPos.x - core.bigmap.offsetX, 32 * endPos.x - core.bigmap.offsetX), + Math.min(32 * startPos.y - core.bigmap.offsetY, 32 * endPos.y - core.bigmap.offsetY), + (Math.abs(startPos.x - endPos.x) + 1) * 32, (Math.abs(startPos.y - endPos.y) + 1) * 32) + } + endPos = pos; + if (startPos != null) { + if (startPos.x != endPos.x || startPos.y != endPos.y) { + core.drawArrow('eui', + 32 * startPos.x + 16 - core.bigmap.offsetX, 32 * startPos.y + 16 - core.bigmap.offsetY, + 32 * endPos.x + 16 - core.bigmap.offsetX, 32 * endPos.y + 16 - core.bigmap.offsetY); + } + } + // editor_mode.onmode('nextChange'); + // editor_mode.onmode('loc'); + //editor_mode.loc(); + //tip.whichShow(1); + // tip.showHelp(6); return; } @@ -181,6 +209,9 @@ editor.constructor.prototype.listen=function () { eui.onmouseup = function (e) { if (!selectBox.isSelected()) { //tip.whichShow(1); + editor.movePos(startPos, endPos); + startPos = endPos = null; + uc.clearRect(0, 0, core.__PIXELS__, core.__PIXELS__); return; } holdingPath = 0; @@ -283,6 +314,7 @@ editor.constructor.prototype.listen=function () { }; var reDo = null; var shortcut = core.getLocalStorage('shortcut',{48: 0, 49: 0, 50: 0, 51: 0, 52: 0, 53: 0, 54: 0, 55: 0, 56: 0, 57: 0}); + var copyedInfo = null; document.body.onkeydown = function (e) { // UI预览 & 地图选点 @@ -317,7 +349,7 @@ editor.constructor.prototype.listen=function () { return; // 禁止快捷键的默认行为 - if (e.ctrlKey && [89, 90, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57].indexOf(e.keyCode) !== -1) + if (e.ctrlKey && [88, 67, 86, 89, 90, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57].indexOf(e.keyCode) !== -1) e.preventDefault(); if (e.altKey && [48, 49, 50, 51, 52, 53, 54, 55, 56, 57].indexOf(e.keyCode) !== -1) e.preventDefault(); @@ -343,31 +375,23 @@ editor.constructor.prototype.listen=function () { } // PGUP和PGDOWN切换楼层 - if (e.keyCode==33) { + if (e.keyCode==33 || e.keyCode==34) { e.preventDefault(); var index=editor.core.floorIds.indexOf(editor.currentFloorId); - if (index0) { - var toId = editor.core.floorIds[index-1]; + var nextIndex = index + (e.keyCode==33?1:-1); + if (nextIndex>=0 && nextIndex - + diff --git a/editor.html b/editor.html index 7ffc7df3..43200cfe 100644 --- a/editor.html +++ b/editor.html @@ -293,7 +293,7 @@ - +