From efbf3ae3a629cb151ba5e799bee675e79f4c16de Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Fri, 15 May 2020 17:05:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=B0=E5=9B=BE=E6=94=B9=E5=8F=98=E5=A4=A7?= =?UTF-8?q?=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _server/editor.js | 1 + _server/editor_datapanel.js | 63 +++++++++++++++++++++++++++++++++++ _server/editor_listen.js | 1 + _server/table/comment.js | 9 ++--- _server/table/data.comment.js | 8 +++-- editor-mobile.html | 5 +++ editor.html | 5 +++ 7 files changed, 85 insertions(+), 7 deletions(-) diff --git a/_server/editor.js b/_server/editor.js index ab9abb3b..67b80e7c 100644 --- a/_server/editor.js +++ b/_server/editor.js @@ -49,6 +49,7 @@ function editor() { selectAppend : document.getElementById('selectAppend'), selectFileBtn :document.getElementById('selectFileBtn'), changeFloorId :document.getElementById('changeFloorId'), + changeFloorSize: document.getElementById('changeFloorSize'), left1 : document.getElementById('left1'), editModeSelect :document.getElementById('editModeSelect'), mid2 : document.getElementById('mid2'), diff --git a/_server/editor_datapanel.js b/_server/editor_datapanel.js index e93cf7cd..263cae55 100644 --- a/_server/editor_datapanel.js +++ b/_server/editor_datapanel.js @@ -503,8 +503,71 @@ editor_datapanel_wrapper = function (editor) { } } + editor.uifunctions.changeFloorSize_func = function () { + var children = editor.dom.changeFloorSize.children; + children[4].onclick = function () { + var width = parseInt(children[0].value); + var height = parseInt(children[1].value); + var x = parseInt(children[2].value); + var y = parseInt(children[3].value); + if (!(width >= core.__SIZE__ && height >= core.__SIZE__ && x >=0 && y >=0)) { + printe("参数错误!宽高不得小于"+core.__SIZE__+",偏移量不得小于0"); + return; + } + var currentFloorData = editor.currentFloorData; + var currWidth = currentFloorData.width; + var currHeight = currentFloorData.height; + if (width < currWidth) x = -x; + if (height < currHeight) y = -y; + // Step 1:创建一个新的地图 + var newFloorData = core.clone(currentFloorData); + newFloorData.width = width; + newFloorData.height = height; + // Step 2:更新map, bgmap和fgmap + ["bgmap", "fgmap", "map"].forEach(function (name) { + newFloorData[name] = []; + if (currentFloorData[name] && currentFloorData[name].length > 0) { + for (var j = 0; j < height; ++j) { + newFloorData[name][j] = []; + for (var i = 0; i < width; ++i) { + var oi = i - x; + var oj = j - y; + if (oi >= 0 && oi < currWidth && oj >= 0 && oj < currHeight) { + newFloorData[name][j].push(currentFloorData[name][oj][oi]); + } else { + newFloorData[name][j].push(0); + } + } + } + } + }); + // Step 3:更新所有坐标 + ["afterBattle", "afterGetItem", "afterOpenDoor", "changeFloor", "autoEvent", "cannotMove"].forEach(function (name) { + newFloorData[name] = {}; + if (!currentFloorData[name]) return; + for (var loc in currentFloorData[name]) { + var oxy = loc.split(','), ox = parseInt(oxy[0]), oy = parseInt(oxy[1]); + var nx = ox + x, ny = oy + y; + if (nx >= 0 && nx < width && ny >= 0 && ny < height) { + newFloorData[name][nx+","+ny] = core.clone(currentFloorData[name][loc]); + } + } + }); + + // Step 4:上楼点&下楼点 + ["upFloor", "downFloor"].forEach(function (name) { + if (newFloorData[name] && newFloorData[name].length == 2) { + newFloorData[name][0]+=x; + newFloorData[name][1]+=y; + } + }); + + console.log(currentFloorData); + console.log(newFloorData); + } + } diff --git a/_server/editor_listen.js b/_server/editor_listen.js index 8c80ecf0..3563b42e 100644 --- a/_server/editor_listen.js +++ b/_server/editor_listen.js @@ -148,6 +148,7 @@ editor_listen_wrapper = function (editor) { editor.uifunctions.createNewMaps_func() editor.uifunctions.changeFloorId_func() + editor.uifunctions.changeFloorSize_func() editor.uifunctions.fixCtx_func() diff --git a/_server/table/comment.js b/_server/table/comment.js index c55edea4..c6c622ea 100644 --- a/_server/table/comment.js +++ b/_server/table/comment.js @@ -251,7 +251,8 @@ var comment_c456ea59_6018_45ef_8bcc_211a24c627dc = { "_leaf": true, "_type": "textarea", "_range": "false", - "_data": "图块ID" + "_docs": "图块ID", + "_data": "图块唯一ID,可在页面底部修改" }, "idnum": { "_leaf": true, @@ -361,7 +362,7 @@ var comment_c456ea59_6018_45ef_8bcc_211a24c627dc = { "_type": "textarea", "_range": "false", "_docs": "楼层ID", - "_data": "文件名和floorId需要保持完全一致 \n楼层唯一标识符仅能由字母、数字、下划线组成,且不能由数字开头 \n推荐用法:第20层就用MT20,第38层就用MT38,地下6层就用MT_6(用下划线代替负号),隐藏3层用MT3h(h表示隐藏),等等 \n楼层唯一标识符,需要和名字完全一致 \n这里不能更改floorId,请通过另存为来实现" + "_data": "文件名和floorId需要保持完全一致,可在页面底部修改 \n楼层唯一标识符仅能由字母、数字、下划线组成,且不能由数字开头 \n推荐用法:第20层就用MT20,第38层就用MT38,地下6层就用MT_6(用下划线代替负号),隐藏3层用MT3h(h表示隐藏),等等" }, "title": { "_leaf": true, @@ -380,14 +381,14 @@ var comment_c456ea59_6018_45ef_8bcc_211a24c627dc = { "_type": "textarea", "_range": "false", "_docs": "宽度", - "_data": "地图x方向大小,这里不能更改,仅能在新建地图时设置,null视为13" + "_data": "地图x方向大小,请在表格最下方修改,null视为13" }, "height": { "_leaf": true, "_type": "textarea", "_range": "false", "_docs": "高度", - "_data": "地图y方向大小,这里不能更改,仅能在新建地图时设置,null视为13" + "_data": "地图y方向大小,请在表格最下方修改,null视为13" }, "canFlyTo": { "_leaf": true, diff --git a/_server/table/data.comment.js b/_server/table/data.comment.js index a32e5ee6..33e5d336 100644 --- a/_server/table/data.comment.js +++ b/_server/table/data.comment.js @@ -134,8 +134,10 @@ var data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = { }, "startBgm": { "_leaf": true, - "_type": "textarea", - "_string": true, + "_type": "select", + "_select": { + "values": [null].concat(Object.keys(editor.core.material.bgms)) + }, "_docs": "标题音乐", "_data": "在标题界面应该播放的bgm内容" }, @@ -257,7 +259,7 @@ var data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = { "hpmax": { "_leaf": true, "_type": "textarea", - "_data": "初始上限" + "_data": "生命上限" }, "hp": { "_leaf": true, diff --git a/editor-mobile.html b/editor-mobile.html index 909ea08a..5d908a89 100644 --- a/editor-mobile.html +++ b/editor-mobile.html @@ -173,6 +173,11 @@ +
+ 修改地图大小:宽,高, + 偏移x y + +
diff --git a/editor.html b/editor.html index f6d81925..f183568f 100644 --- a/editor.html +++ b/editor.html @@ -169,6 +169,11 @@
+
+ 修改地图大小:宽,高, + 偏移x y + +