From 2080b7a8856d06ccbb2ce32640370d9561464f4f Mon Sep 17 00:00:00 2001 From: oc Date: Sat, 8 Jun 2019 20:15:12 +0800 Subject: [PATCH] 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;