From b75f4754436426bb57aca98ac1ee2017886b29f5 Mon Sep 17 00:00:00 2001 From: oc Date: Fri, 7 Jun 2019 22:41:59 +0800 Subject: [PATCH 1/5] exchangePos --- _server/editor.js | 19 +++++++++++++++++++ _server/editor_unsorted_1.js | 17 +++-------------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/_server/editor.js b/_server/editor.js index 683200a2..3641c236 100644 --- a/_server/editor.js +++ b/_server/editor.js @@ -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) { var fields = Object.keys(editor.file.comment._data.floors._data.loc._data); pos = pos || editor.pos; diff --git a/_server/editor_unsorted_1.js b/_server/editor_unsorted_1.js index ef27a102..f8ad9f3e 100644 --- a/_server/editor_unsorted_1.js +++ b/_server/editor_unsorted_1.js @@ -209,7 +209,8 @@ editor.constructor.prototype.listen=function () { eui.onmouseup = function (e) { if (!selectBox.isSelected()) { //tip.whichShow(1); - editor.movePos(startPos, endPos); + // editor.movePos(startPos, endPos); + editor.exchangePos(startPos, endPos); startPos = endPos = null; uc.clearRect(0, 0, core.__PIXELS__, core.__PIXELS__); return; @@ -747,19 +748,7 @@ editor.constructor.prototype.listen=function () { editor.preMapData = null; reDo = null; editor_mode.onmode(''); - var now = editor.pos, last = 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(); - }); + editor.exchangePos(editor.pos, editor.lastRightButtonPos[1]); } var clearEvent = document.getElementById('clearEvent'); From 2080b7a8856d06ccbb2ce32640370d9561464f4f Mon Sep 17 00:00:00 2001 From: oc Date: Sat, 8 Jun 2019 20:15:12 +0800 Subject: [PATCH 2/5] block name --- _docs/event.md | 2 +- _server/table/comment.js | 6 ++++++ libs/maps.js | 8 ++++++-- libs/ui.js | 2 +- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/_docs/event.md b/_docs/event.md index 87b7503f..8ffcf85b 100644 --- a/_docs/event.md +++ b/_docs/event.md @@ -190,7 +190,7 @@ 从V2.5.2以后,新增了绘制大头像的功能。绘制大头像图的基本写法是`\t[1.png]`或者`\t[标题,1.png]`。 -从V2.6开始,所有图块都允许只写ID,对于非怪物则没有标题。 +从V2.6开始,所有图块都允许只写ID,对于非怪物则仅当图块属性中设置了name才有标题(否则不显示标题)。 ``` js [ diff --git a/_server/table/comment.js b/_server/table/comment.js index ef03953d..abbf3b7d 100644 --- a/_server/table/comment.js +++ b/_server/table/comment.js @@ -225,6 +225,12 @@ var comment_c456ea59_6018_45ef_8bcc_211a24c627dc = { "_range": "false", "_data": "图块类别" }, + "name": { + "_leaf": true, + "_type": "textarea", + "_string": true, + "_data": "图块名称" + }, "trigger": { "_leaf": true, "_type": "select", diff --git a/libs/maps.js b/libs/maps.js index ffa3f590..4617651a 100644 --- a/libs/maps.js +++ b/libs/maps.js @@ -1223,7 +1223,7 @@ maps.prototype.getBlockInfo = function (block) { if (block == 0) return null; block = this.initBlock(0, 0, block, true); } - var number = block.id, id = block.event.id, cls = block.event.cls, + var number = block.id, id = block.event.id, cls = block.event.cls, name = block.event.name, image = null, posX = 0, posY = 0, animate = block.event.animate, height = block.event.height || 32, faceIds = {}; @@ -1231,6 +1231,7 @@ maps.prototype.getBlockInfo = function (block) { else if (id == 'airwall') { if (!core.material.images.airwall) return null; image = core.material.images.airwall; + name = "空气墙"; } else if (cls == 'tileset') { var offset = core.icons.getTilesetOffset(id); @@ -1246,9 +1247,12 @@ maps.prototype.getBlockInfo = function (block) { image = core.material.images[cls]; posY = core.material.icons[cls][id]; faceIds = block.event.faceIds || {}; + if (core.material.enemys[id]) { + name = core.material.enemys[id].name; + } } - return {number: number, id: id, cls: cls, image: image, posX: posX, posY: posY, height: height, faceIds: faceIds, animate: animate}; + return {number: number, id: id, cls: cls, name: name, image: image, posX: posX, posY: posY, height: height, faceIds: faceIds, animate: animate}; } ////// 搜索某个图块出现的所有位置 ////// diff --git a/libs/ui.js b/libs/ui.js index ec48eb26..5ee7166f 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -535,7 +535,7 @@ ui.prototype._getTitleAndIcon = function (content) { else { var blockInfo = core.getBlockInfo(s4); if (blockInfo != null) { - if (core.material.enemys[s4]) title = core.material.enemys[s4].name; + if (blockInfo.name) title = blockInfo.name; image = blockInfo.image; icon = blockInfo.posY; height = blockInfo.height; From 9f96a841fb5650c284e5adedc3039df6a7518db5 Mon Sep 17 00:00:00 2001 From: oc Date: Sat, 8 Jun 2019 20:39:46 +0800 Subject: [PATCH 3/5] block name --- _docs/event.md | 5 ++++- libs/ui.js | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/_docs/event.md b/_docs/event.md index 8ffcf85b..9c40d646 100644 --- a/_docs/event.md +++ b/_docs/event.md @@ -192,6 +192,8 @@ 从V2.6开始,所有图块都允许只写ID,对于非怪物则仅当图块属性中设置了name才有标题(否则不显示标题)。 +另外注意的是,名字可以用null从而只显示动画而不显示标题。 + ``` js [ "一段普通文字", @@ -204,7 +206,8 @@ "\t[1.png]绘制1.png这个头像图", "\t[标题,1.png]同时绘制标题和1.png这个头像图", "\t[sword1]获得铁剑,没有标题", - "\t[man]没有标题的npc动画" + "\t[man]没有标题的npc动画", + "\t[null,greenSlime]只绘制怪物动画而不显示标题" ] ``` diff --git a/libs/ui.js b/libs/ui.js index 5ee7166f..25391dbe 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -544,7 +544,10 @@ ui.prototype._getTitleAndIcon = function (content) { else title = s4; } } - if (s3) title = s3; + if (s3 != null) { + title = s3; + if (title == 'null') title = null; + } return ""; }); return { From 1d756fd2231e031e4b96fd5eee537d170092315a Mon Sep 17 00:00:00 2001 From: oc Date: Sat, 8 Jun 2019 20:56:51 +0800 Subject: [PATCH 4/5] preventDefault --- _server/editor_unsorted_1.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/_server/editor_unsorted_1.js b/_server/editor_unsorted_1.js index f8ad9f3e..91f754c7 100644 --- a/_server/editor_unsorted_1.js +++ b/_server/editor_unsorted_1.js @@ -123,7 +123,7 @@ editor.constructor.prototype.listen=function () { var loc = eToLoc(e); var pos = locToPos(loc,true); editor.showMidMenu(e.clientX,e.clientY); - return; + return false; } if (!selectBox.isSelected()) { var loc = eToLoc(e); @@ -137,20 +137,19 @@ editor.constructor.prototype.listen=function () { uc.strokeStyle = '#FF0000'; uc.lineWidth = 3; if(editor.isMobile)editor.showMidMenu(e.clientX,e.clientY); - return; + return false; } - holdingPath = 1; mouseOutCheck = 2; setTimeout(clear1); - e.stopPropagation(); uc.clearRect(0, 0, core.__PIXELS__, core.__PIXELS__); var loc = eToLoc(e); var pos = locToPos(loc,true); stepPostfix = []; stepPostfix.push(pos); fillPos(pos); + return false; } eui.onmousemove = function (e) { @@ -178,14 +177,13 @@ editor.constructor.prototype.listen=function () { //editor_mode.loc(); //tip.whichShow(1); // tip.showHelp(6); - return; + return false; } if (holdingPath == 0) { - return; + return false; } mouseOutCheck = 2; - e.stopPropagation(); var loc = eToLoc(e); var pos = locToPos(loc,true); var pos0 = stepPostfix[stepPostfix.length - 1] @@ -204,6 +202,7 @@ editor.constructor.prototype.listen=function () { stepPostfix.push(pos); fillPos(pos); } + return false; } eui.onmouseup = function (e) { @@ -213,10 +212,9 @@ editor.constructor.prototype.listen=function () { editor.exchangePos(startPos, endPos); startPos = endPos = null; uc.clearRect(0, 0, core.__PIXELS__, core.__PIXELS__); - return; + return false; } holdingPath = 0; - e.stopPropagation(); if (stepPostfix && stepPostfix.length) { editor.preMapData = JSON.parse(JSON.stringify({map:editor.map,fgmap:editor.fgmap,bgmap:editor.bgmap})); if(editor.brushMod!=='line'){ @@ -259,6 +257,7 @@ editor.constructor.prototype.listen=function () { stepPostfix = []; uc.clearRect(0, 0, core.__PIXELS__, core.__PIXELS__); } + return false; } /* @@ -280,7 +279,6 @@ editor.constructor.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; @@ -306,6 +304,7 @@ editor.constructor.prototype.listen=function () { catch (ee) { console.log(ee); } + return false; } editor.preMapData = null; From eeb9c6a912d0400a24afde86f65b86c7f99b023e Mon Sep 17 00:00:00 2001 From: oc Date: Sun, 9 Jun 2019 00:00:01 +0800 Subject: [PATCH 5/5] Fix uievent drawThumbnail --- _server/editor_unsorted_3.js | 2 ++ libs/maps.js | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/_server/editor_unsorted_3.js b/_server/editor_unsorted_3.js index fd6ec89e..b0adaa5c 100644 --- a/_server/editor_unsorted_3.js +++ b/_server/editor_unsorted_3.js @@ -481,6 +481,8 @@ uievent.selectPoint = function (floorId, x, y, hideFloor, callback) { uievent.updateSelectPoint = function (redraw) { uievent.elements.title.innerText = '地图选点 ('+uievent.values.x+","+uievent.values.y+')'; if (redraw) { + core.setAlpha('uievent', 1); + core.clearMap('uievent'); core.drawThumbnail(uievent.values.floorId, null, null, {ctx: 'uievent', centerX: uievent.values.left + core.__HALF_SIZE__, centerY: uievent.values.top + core.__HALF_SIZE__}); diff --git a/libs/maps.js b/libs/maps.js index 4617651a..81a70157 100644 --- a/libs/maps.js +++ b/libs/maps.js @@ -363,7 +363,8 @@ maps.prototype._getBgFgMapArray = function (name, floorId, noCache) { return core.status[name + "maps"][floorId]; var arr = core.clone(core.floors[floorId][name + "map"] || []); - if (main.mode == 'editor') arr = core.clone(editor[name + "map"]) || arr; + if (main.mode == 'editor' && !(uievent && uievent.isOpen)) + arr = core.clone(editor[name + "map"]) || arr; for (var x = 0; x < width; x++) { for (var y = 0; y < height; y++) { arr[y] = arr[y] || [];