Fix Ctrl+Z
This commit is contained in:
parent
e5a7c9e10c
commit
3d2e0c06bb
@ -235,6 +235,7 @@ editor.prototype.changeFloor = function (floorId, callback) {
|
|||||||
});
|
});
|
||||||
editor.currentFloorData[name]=mapArray;
|
editor.currentFloorData[name]=mapArray;
|
||||||
}
|
}
|
||||||
|
editor.preMapData = null;
|
||||||
core.changeFloor(floorId, null, {"x": 0, "y": 0, "direction": "up"}, null, function () {
|
core.changeFloor(floorId, null, {"x": 0, "y": 0, "direction": "up"}, null, function () {
|
||||||
core.bigmap.offsetX=0;
|
core.bigmap.offsetX=0;
|
||||||
core.bigmap.offsetY=0;
|
core.bigmap.offsetY=0;
|
||||||
@ -728,7 +729,7 @@ editor.prototype.listen = function () {
|
|||||||
holdingPath = 0;
|
holdingPath = 0;
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
if (stepPostfix && stepPostfix.length) {
|
if (stepPostfix && stepPostfix.length) {
|
||||||
preMapData = JSON.parse(JSON.stringify({map:editor.map,fgmap:editor.fgmap,bgmap:editor.bgmap}));
|
editor.preMapData = JSON.parse(JSON.stringify({map:editor.map,fgmap:editor.fgmap,bgmap:editor.bgmap}));
|
||||||
if(editor.brushMod!=='line'){
|
if(editor.brushMod!=='line'){
|
||||||
var x0=stepPostfix[0].x;
|
var x0=stepPostfix[0].x;
|
||||||
var y0=stepPostfix[0].y;
|
var y0=stepPostfix[0].y;
|
||||||
@ -822,7 +823,7 @@ editor.prototype.listen = function () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var preMapData = {};
|
editor.preMapData = null;
|
||||||
var currDrawData = {
|
var currDrawData = {
|
||||||
pos: [],
|
pos: [],
|
||||||
info: {}
|
info: {}
|
||||||
@ -836,18 +837,18 @@ editor.prototype.listen = function () {
|
|||||||
if (e.altKey && [48, 49, 50, 51, 52, 53, 54, 55, 56, 57].indexOf(e.keyCode) !== -1)
|
if (e.altKey && [48, 49, 50, 51, 52, 53, 54, 55, 56, 57].indexOf(e.keyCode) !== -1)
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
//Ctrl+z 撤销上一步undo
|
//Ctrl+z 撤销上一步undo
|
||||||
if (e.keyCode == 90 && e.ctrlKey && preMapData && currDrawData.pos.length && selectBox.isSelected) {
|
if (e.keyCode == 90 && e.ctrlKey && editor.preMapData && currDrawData.pos.length && selectBox.isSelected) {
|
||||||
editor.map = JSON.parse(JSON.stringify(preMapData.map));
|
editor.map = JSON.parse(JSON.stringify(editor.preMapData.map));
|
||||||
editor.fgmap = JSON.parse(JSON.stringify(preMapData.fgmap));
|
editor.fgmap = JSON.parse(JSON.stringify(editor.preMapData.fgmap));
|
||||||
editor.bgmap = JSON.parse(JSON.stringify(preMapData.bgmap));
|
editor.bgmap = JSON.parse(JSON.stringify(editor.preMapData.bgmap));
|
||||||
editor.updateMap();
|
editor.updateMap();
|
||||||
reDo = JSON.parse(JSON.stringify(currDrawData));
|
reDo = JSON.parse(JSON.stringify(currDrawData));
|
||||||
currDrawData = {pos: [], info: {}};
|
currDrawData = {pos: [], info: {}};
|
||||||
preMapData = null;
|
editor.preMapData = null;
|
||||||
}
|
}
|
||||||
//Ctrl+y 重做一步redo
|
//Ctrl+y 重做一步redo
|
||||||
if (e.keyCode == 89 && e.ctrlKey && reDo && reDo.pos.length && selectBox.isSelected) {
|
if (e.keyCode == 89 && e.ctrlKey && reDo && reDo.pos.length && selectBox.isSelected) {
|
||||||
preMapData = JSON.parse(JSON.stringify({map:editor.map,fgmap:editor.fgmap,bgmap:editor.bgmap}));
|
editor.preMapData = JSON.parse(JSON.stringify({map:editor.map,fgmap:editor.fgmap,bgmap:editor.bgmap}));
|
||||||
for (var j = 0; j < reDo.pos.length; j++)
|
for (var j = 0; j < reDo.pos.length; j++)
|
||||||
editor.map[reDo.pos[j].y][reDo.pos[j].x] = JSON.parse(JSON.stringify(reDo.info));
|
editor.map[reDo.pos[j].y][reDo.pos[j].x] = JSON.parse(JSON.stringify(reDo.info));
|
||||||
|
|
||||||
@ -1027,7 +1028,7 @@ editor.prototype.listen = function () {
|
|||||||
copyLoc.onmousedown = function(e){
|
copyLoc.onmousedown = function(e){
|
||||||
editor.hideMidMenu();
|
editor.hideMidMenu();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
preMapData = null;
|
editor.preMapData = null;
|
||||||
reDo = null;
|
reDo = null;
|
||||||
editor_mode.onmode('');
|
editor_mode.onmode('');
|
||||||
var now = editor.pos;
|
var now = editor.pos;
|
||||||
@ -1060,7 +1061,7 @@ editor.prototype.listen = function () {
|
|||||||
moveLoc.onmousedown = function(e){
|
moveLoc.onmousedown = function(e){
|
||||||
editor.hideMidMenu();
|
editor.hideMidMenu();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
preMapData = null;
|
editor.preMapData = null;
|
||||||
reDo = null;
|
reDo = null;
|
||||||
var thisevent = editor.map[editor.pos.y][editor.pos.x];
|
var thisevent = editor.map[editor.pos.y][editor.pos.x];
|
||||||
if(thisevent==0){
|
if(thisevent==0){
|
||||||
@ -1106,7 +1107,7 @@ editor.prototype.listen = function () {
|
|||||||
clearLoc.onmousedown = function(e){
|
clearLoc.onmousedown = function(e){
|
||||||
editor.hideMidMenu();
|
editor.hideMidMenu();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
preMapData = null;
|
editor.preMapData = null;
|
||||||
reDo = null;
|
reDo = null;
|
||||||
editor.info = 0;
|
editor.info = 0;
|
||||||
editor_mode.onmode('');
|
editor_mode.onmode('');
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user