From ca05e48846a22df66f107559abef874164543631 Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Tue, 4 Dec 2018 20:50:25 +0800 Subject: [PATCH] dblclick & highlight pos & WASD move --- _server/editor.js | 34 ++++++++++++++++++++++++++++++---- _server/editor_mode.js | 6 ++++-- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/_server/editor.js b/_server/editor.js index 89049bbd..6c92568c 100644 --- a/_server/editor.js +++ b/_server/editor.js @@ -275,6 +275,14 @@ editor.prototype.drawEventBlock = function () { } } +editor.prototype.drawPosSelection = function () { + this.drawEventBlock(); + var fg=document.getElementById('efg').getContext('2d'); + fg.strokeStyle = 'rgba(255,255,255,0.7)'; + fg.lineWidth = 4; + fg.strokeRect(32*editor.pos.x - core.bigmap.offsetX + 4, 32*editor.pos.y - core.bigmap.offsetY + 4, 24, 24); +} + editor.prototype.updateMap = function () { var blocks = main.editor.mapIntoBlocks(editor.map.map(function (v) { return v.map(function (v) { @@ -327,7 +335,7 @@ editor.prototype.moveViewport=function(x,y){ core.bigmap.offsetY = core.clamp(core.bigmap.offsetY+32*y, 0, 32*core.bigmap.height-416); core.control.updateViewport(); editor.buildMark(); - editor.drawEventBlock(); + editor.drawPosSelection(); } /////////// 通用 /////////// @@ -631,6 +639,15 @@ editor.prototype.listen = function () { eui.oncontextmenu=function(e){e.preventDefault()} + eui.ondblclick = function(e) { + // 双击地图可以选中素材 + var loc = eToLoc(e); + var pos = locToPos(loc,true); + var thisevent = editor.map[pos.y][pos.x]; + editor.setSelectBoxFromInfo(thisevent); + return; + } + eui.onmousedown = function (e) { if (e.button==2){ var loc = eToLoc(e); @@ -863,6 +880,15 @@ editor.prototype.listen = function () { printf('已保存该快捷图块, ctrl + '+(e.keyCode-48)+' 使用.') core.setLocalStorage('shortcut',shortcut); } + // wasd平移大地图 + if (e.keyCode==87) + editor.moveViewport(0,-1) + else if (e.keyCode==65) + editor.moveViewport(-1,0) + else if (e.keyCode==83) + editor.moveViewport(0,1); + else if (e.keyCode==68) + editor.moveViewport(1,0); } var dataSelection = document.getElementById('dataSelection'); @@ -1016,7 +1042,7 @@ editor.prototype.listen = function () { throw(err) } ;printf('复制事件成功'); - editor.drawEventBlock(); + editor.drawPosSelection(); }); } @@ -1062,7 +1088,7 @@ editor.prototype.listen = function () { throw(err) } ;printf('两位置的事件已互换'); - editor.drawEventBlock(); + editor.drawPosSelection(); }); } @@ -1086,7 +1112,7 @@ editor.prototype.listen = function () { throw(err) } ;printf('清空此点及事件成功'); - editor.drawEventBlock(); + editor.drawPosSelection(); }); } diff --git a/_server/editor_mode.js b/_server/editor_mode.js index 3dd40ece..94e65bee 100644 --- a/_server/editor_mode.js +++ b/_server/editor_mode.js @@ -206,7 +206,7 @@ editor_mode = function (editor) { throw(objs_.slice(-1)[0]) } ;printf('修改成功'); - editor.drawEventBlock(); + editor.drawPosSelection(); }); break; case 'enemyitem': @@ -286,6 +286,8 @@ editor_mode = function (editor) { editor_mode.dom[name].style = 'z-index:-1;opacity: 0;'; } editor_mode.dom[mode].style = ''; + // clear + editor.drawEventBlock(); if (editor_mode[mode]) editor_mode[mode](); document.getElementById('editModeSelect').value = mode; var tips = tip_in_showMode; @@ -307,7 +309,7 @@ editor_mode = function (editor) { var tableinfo = editor_mode.objToTable_(objs[0], objs[1]); document.getElementById('table_3d846fc4_7644_44d1_aa04_433d266a73df').innerHTML = tableinfo.HTML; tableinfo.listen(tableinfo.guids); - + editor.drawPosSelection(); if (Boolean(callback)) callback(); }