diff --git a/_server/editor.js b/_server/editor.js index e4ec6928..3563a1d7 100644 --- a/_server/editor.js +++ b/_server/editor.js @@ -158,7 +158,8 @@ editor.prototype.init = function (callback) { editor_mode = editor_mode(editor); editor.mode = editor_mode; core.resetGame(core.firstData.hero, null, core.firstData.floorId, core.clone(core.initStatus.maps)); - core.changeFloor(core.status.floorId, null, core.firstData.hero.loc, null, function () { + var lastFloorId = core.getLocalStorage('editorLastFloorId', core.status.floorId); + core.changeFloor(lastFloorId, null, core.firstData.hero.loc, null, function () { afterCoreReset(); }, true); core.events.setInitData(null); @@ -256,6 +257,7 @@ editor.prototype.changeFloor = function (floorId, callback) { var loc = editor.viewportLoc[floorId] || [], x = loc[0] || 0, y = loc[1] || 0; editor.setViewport(x, y); + core.setLocalStorage('editorLastFloorId', floorId); if (callback) callback(); }); } diff --git a/_server/editor_ui.js b/_server/editor_ui.js index 2417dda6..159f7395 100644 --- a/_server/editor_ui.js +++ b/_server/editor_ui.js @@ -131,23 +131,31 @@ editor_ui_wrapper = function (editor) { || focusElement.id == 'selectFloor') { //Ctrl+z 撤销上一步undo - if (e.keyCode == 90 && e.ctrlKey && editor.uivalues.preMapData.length > 0) { + if (e.keyCode == 90 && e.ctrlKey) { e.preventDefault(); - var data = editor.uivalues.preMapData.pop(); - editor.map = JSON.parse(JSON.stringify(data.map)); - editor.fgmap = JSON.parse(JSON.stringify(data.fgmap)); - editor.bgmap = JSON.parse(JSON.stringify(data.bgmap)); - editor.uivalues.postMapData.push(data); + if (editor.uivalues.preMapData.length > 0) { + var data = editor.uivalues.preMapData.pop(); + editor.map = JSON.parse(JSON.stringify(data.map)); + editor.fgmap = JSON.parse(JSON.stringify(data.fgmap)); + editor.bgmap = JSON.parse(JSON.stringify(data.bgmap)); + editor.updateMap(); + editor.uivalues.postMapData.push(data); + printf("已撤销此操作,你可能需要重新保存地图。"); + } return; } //Ctrl+y 重做一步redo - if (e.keyCode == 89 && e.ctrlKey && editor.uivalues.postMapData.length > 0) { + if (e.keyCode == 89 && e.ctrlKey) { e.preventDefault(); - var data = editor.uivalues.postMapData.pop(); - editor.map = JSON.parse(JSON.stringify(data.map)); - editor.fgmap = JSON.parse(JSON.stringify(data.fgmap)); - editor.bgmap = JSON.parse(JSON.stringify(data.bgmap)); - editor.uivalues.preMapData.push(data); + if (editor.uivalues.postMapData.length > 0) { + var data = editor.uivalues.postMapData.pop(); + editor.map = JSON.parse(JSON.stringify(data.map)); + editor.fgmap = JSON.parse(JSON.stringify(data.fgmap)); + editor.bgmap = JSON.parse(JSON.stringify(data.bgmap)); + editor.updateMap(); + editor.uivalues.preMapData.push(data); + printf("已重做此操作,你可能需要重新保存地图。"); + } return; }