From f9bb3367690a7704f0a7684b1ba5a0b8cd3b6441 Mon Sep 17 00:00:00 2001 From: oc Date: Tue, 5 Jun 2018 23:10:50 +0800 Subject: [PATCH] Mouse wheel to changefloor --- _server/editor.js | 37 +++++++++++++++++++++++++++++++++---- docs/start.md | 1 + 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/_server/editor.js b/_server/editor.js index d2a6b517..549d5c55 100644 --- a/_server/editor.js +++ b/_server/editor.js @@ -514,6 +514,35 @@ editor.prototype.listen = function () { } } + document.getElementById('mid').onmousewheel = function (e) { + e.preventDefault(); + var wheel = function (direct) { + var index=editor.core.floorIds.indexOf(editor.currentFloorId); + var toId = editor.currentFloorId; + + if (direct>0 && index0) + toId = editor.core.floorIds[index-1]; + else return; + + editor_mode.onmode('nextChange'); + editor_mode.onmode('floor'); + document.getElementById('selectFloor').value = toId; + editor.changeFloor(toId); + } + + try { + if (e.wheelDelta) + wheel(Math.sign(e.wheelDelta)) + else if (e.detail) + wheel(Math.sign(e.detail)); + } + catch (ee) { + console.log(ee); + } + } + var preMapData = {}; var currDrawData = { pos: [], @@ -546,8 +575,8 @@ editor.prototype.listen = function () { if (e.keyCode==33) { e.preventDefault(); var index=editor.core.floorIds.indexOf(editor.currentFloorId); - if (index>0) { - var toId = editor.core.floorIds[index-1]; + if (index0) { + var toId = editor.core.floorIds[index-1]; editor_mode.onmode('nextChange'); editor_mode.onmode('floor'); document.getElementById('selectFloor').value = toId; diff --git a/docs/start.md b/docs/start.md index 20b50a23..75b190a6 100644 --- a/docs/start.md +++ b/docs/start.md @@ -204,6 +204,7 @@ HTML5的塔都是可以进行控制台调试的。 - `core.changeFloor('MT2', 'downFloor')` 立刻执行楼层切换到MT2层的下楼点位置。 - `core.changeFloor('MT5', null, {'x': 4, 'y': 7})` 立刻切换楼层到MT5层的(4,7)点。 - `core.getBlock(3, 5, 'MT1')` 获得当前地图上某一个块的信息。第三个参数为floorId,可省略表示当前楼层。 +- `core.getBlockId(3, 5, 'MT1')` 获得当前地图上某一个点的图块ID。第三个参数为floorId,可省略表示当前楼层。 - `core.resetMap()` 重置当前层地图。**当修改地图后再读档,修改的地图不会立刻生效,此时可以使用resetMap来重置当前楼层的地图。** - `localStorage` 获得所有的存档数据。可以用 `core.getLocalStorage('save1')` 来具体获得某个存档。 - ……