exchangePos

This commit is contained in:
oc 2019-06-07 22:41:59 +08:00
parent 517892e90e
commit b75f475443
2 changed files with 22 additions and 14 deletions

View File

@ -531,6 +531,25 @@ editor.prototype.movePos = function (startPos, endPos, callback) {
}); });
} }
editor.prototype.exchangePos = function (startPos, endPos, callback) {
if (!startPos || !endPos) return;
if (startPos.x == endPos.x && startPos.y == endPos.y) return;
var startInfo = editor.copyFromPos(startPos);
var endInfo = editor.copyFromPos(endPos);
editor.pasteToPos(startInfo, endPos);
editor.pasteToPos(endInfo, startPos);
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) { editor.prototype.clearPos = function (clearPos, pos, callback) {
var fields = Object.keys(editor.file.comment._data.floors._data.loc._data); var fields = Object.keys(editor.file.comment._data.floors._data.loc._data);
pos = pos || editor.pos; pos = pos || editor.pos;

View File

@ -209,7 +209,8 @@ editor.constructor.prototype.listen=function () {
eui.onmouseup = function (e) { eui.onmouseup = function (e) {
if (!selectBox.isSelected()) { if (!selectBox.isSelected()) {
//tip.whichShow(1); //tip.whichShow(1);
editor.movePos(startPos, endPos); // editor.movePos(startPos, endPos);
editor.exchangePos(startPos, endPos);
startPos = endPos = null; startPos = endPos = null;
uc.clearRect(0, 0, core.__PIXELS__, core.__PIXELS__); uc.clearRect(0, 0, core.__PIXELS__, core.__PIXELS__);
return; return;
@ -747,19 +748,7 @@ editor.constructor.prototype.listen=function () {
editor.preMapData = null; editor.preMapData = null;
reDo = null; reDo = null;
editor_mode.onmode(''); editor_mode.onmode('');
var now = editor.pos, last = editor.lastRightButtonPos[1]; editor.exchangePos(editor.pos, editor.lastRightButtonPos[1]);
if (now.x == last.x && now.y == last.y) return;
editor.pasteToPos(editor.lastCopyedInfo[1], now);
editor.pasteToPos(editor.lastCopyedInfo[0], last);
editor.updateMap();
editor.file.saveFloorFile(function (err) {
if (err) {
printe(err);
throw(err)
}
;printf('两位置的事件已互换');
editor.drawPosSelection();
});
} }
var clearEvent = document.getElementById('clearEvent'); var clearEvent = document.getElementById('clearEvent');