diff --git a/_server/comment.js b/_server/comment.js index 982424a4..42422d46 100644 --- a/_server/comment.js +++ b/_server/comment.js @@ -245,6 +245,18 @@ comment_c456ea59_6018_45ef_8bcc_211a24c627dc = "_type": "textarea", "_data": "显示在状态栏中的层数" }, + "width": { + "_leaf": true, + "_type": "textarea", + "_range": "false", + "_data": "地图x方向大小,这里不能更改,仅能在新建地图时设置,null视为13" + }, + "height": { + "_leaf": true, + "_type": "textarea", + "_range": "false", + "_data": "地图y方向大小,这里不能更改,仅能在新建地图时设置,null视为13" + }, "canFlyTo": { "_leaf": true, "_type": "checkbox", diff --git a/_server/editor.js b/_server/editor.js index 8343e596..08795309 100644 --- a/_server/editor.js +++ b/_server/editor.js @@ -163,9 +163,10 @@ editor.prototype.mapInit = function () { ec.clearRect(0, 0, core.bigmap.width*32, core.bigmap.height*32); document.getElementById('event2').getContext('2d').clearRect(0, 0, core.bigmap.width*32, core.bigmap.height*32); editor.map = []; - for (var y = 0; y < 13; y++) { + var sy=editor.currentFloorData.map.length,sy=editor.currentFloorData.map[0].length; + for (var y = 0; y < sy; y++) { editor.map[y] = []; - for (var x = 0; x < 13; x++) { + for (var x = 0; x < sx; x++) { editor.map[y][x] = 0; } } @@ -202,7 +203,7 @@ editor.prototype.drawEventBlock = function () { for (var i=0;i<13;i++) { for (var j=0;j<13;j++) { var color=null; - var loc=i+","+j; + var loc=(i+core.bigmap.offsetX/32)+","+(j+core.bigmap.offsetY/32); if (core.isset(editor.currentFloorData.events[loc])) color = '#FF0000'; else if (core.isset(editor.currentFloorData.changeFloor[loc])) @@ -255,8 +256,8 @@ editor.prototype.updateMap = function () { } // 绘制地图 start var eventCtx = document.getElementById('event').getContext("2d"); - for (var y = 0; y < 13; y++) - for (var x = 0; x < 13; x++) { + for (var y = 0; y < editor.map.length; y++) + for (var x = 0; x < editor.map[0].length; x++) { var tileInfo = editor.map[y][x]; if (false && isAutotile(tileInfo)) { addIndexToAutotileInfo(x, y); @@ -848,6 +849,7 @@ editor.prototype.listen = function () { core.bigmap.offsetY = core.clamp(core.bigmap.offsetY+32*y, 0, 32*core.bigmap.height-416); core.control.updateViewport(); editor.buildMark(); + editor.drawEventBlock(); } var viewportButtons=document.getElementById('viewportButtons'); diff --git a/_server/editor_file.js b/_server/editor_file.js index 82247ee0..46b2fe6b 100644 --- a/_server/editor_file.js +++ b/_server/editor_file.js @@ -695,19 +695,20 @@ editor_file = function (editor, callback) { } var formatMap = function (mapArr) { - //把13*13或者1*169数组格式化 + //把二维数组格式化 var formatArrStr = ''; var arr = JSON.stringify(mapArr).replace(/\s+/g, '').split('],['); - for (var i = 0; i < 13; i++) { + var si=mapArr.length-1,sk=mapArr[0].length-1; + for (var i = 0; i <= si; i++) { var a = []; formatArrStr += ' ['; - if (i == 0 || i == 12) a = arr[i].split(/\D+/).join(' ').trim().split(' '); + if (i == 0 || i == si) a = arr[i].split(/\D+/).join(' ').trim().split(' '); else a = arr[i].split(/\D+/); - for (var k = 0; k < 13; k++) { + for (var k = 0; k <= sk; k++) { var num = parseInt(a[k]); - formatArrStr += Array(Math.max(4 - String(num).length, 0)).join(' ') + num + (k == 12 ? '' : ','); + formatArrStr += Array(Math.max(4 - String(num).length, 0)).join(' ') + num + (k == sk ? '' : ','); } - formatArrStr += ']' + (i == 12 ? '' : ',\n'); + formatArrStr += ']' + (i == si ? '' : ',\n'); } return formatArrStr; } diff --git a/_server/vm.js b/_server/vm.js index a95e1cfa..27e0aa6f 100644 --- a/_server/vm.js +++ b/_server/vm.js @@ -67,11 +67,12 @@ var exportMap = new Vue({ methods: { exportMap: function () { editor.updateMap(); + var sx=editor.map.length-1,sy=editor.map[0].length-1; var filestr = ''; - for (var yy = 0; yy < 13; yy++) { + for (var yy = 0; yy <= sy; yy++) { filestr += '[' - for (var xx = 0; xx < 13; xx++) { + for (var xx = 0; xx <= sx; xx++) { var mapxy = editor.map[yy][xx]; if (typeof(mapxy) == typeof({})) { if ('idnum' in mapxy) mapxy = mapxy.idnum; @@ -86,10 +87,10 @@ var exportMap = new Vue({ } mapxy = String(mapxy); mapxy = Array(Math.max(4 - mapxy.length, 0)).join(' ') + mapxy; - filestr += mapxy + (xx == 12 ? '' : ',') + filestr += mapxy + (xx == sx ? '' : ',') } - filestr += ']' + (yy == 12 ? '' : ',\n'); + filestr += ']' + (yy == sy ? '' : ',\n'); } pout.value = filestr; editArea.mapArr = filestr; @@ -104,7 +105,7 @@ var editArea = new Vue({ data: { mapArr: '', errors: [ // 编号1,2,3,4 - "格式错误!请使用正确格式(13*13数组,如不清楚,可先点击生成地图查看正确格式)", + "格式错误!请使用正确格式(width*height数组,如不清楚,可先点击生成地图查看正确格式)", "当前有未定义ID(在地图区域显示红块),请修改ID或者到icons.js和maps.js中进行定义!", "ID越界(在地图区域显示红块),当前编辑器暂时支持编号小于400,请修改编号!", // "发生错误!", @@ -145,8 +146,9 @@ var editArea = new Vue({ // var mapArray = that.mapArr.split(/\D+/).join(' ').trim().split(' '); var mapArray = JSON.parse('[' + that.mapArr + ']'); - for (var y = 0; y < 13; y++) - for (var x = 0; x < 13; x++) { + var sy=editor.map.length,sx=editor.map[0].length; + for (var y = 0; y < sy; y++) + for (var x = 0; x < sx; x++) { var num = mapArray[y][x]; if (num == 0) editor.map[y][x] = 0; @@ -166,25 +168,26 @@ var editArea = new Vue({ var formatArrStr = ''; var that = this; clearTimeout(that.formatTimer); - if (this.mapArr.split(/\D+/).join(' ').trim().split(' ').length != 169) return false; + var si=this.mapArr.length,sk=this.mapArr[0].length; + if (this.mapArr.split(/\D+/).join(' ').trim().split(' ').length != si*sk) return false; var arr = this.mapArr.replace(/\s+/g, '').split('],['); - if (arr.length != 13) return; - for (var i = 0; i < 13; i++) { + if (arr.length != si) return; + for (var i = 0; i < si; i++) { var a = []; formatArrStr += '['; - if (i == 0 || i == 12) a = arr[i].split(/\D+/).join(' ').trim().split(' '); + if (i == 0 || i == si-1) a = arr[i].split(/\D+/).join(' ').trim().split(' '); else a = arr[i].split(/\D+/); - if (a.length != 13) { + if (a.length != sk) { formatArrStr = ''; return; } - for (var k = 0; k < 13; k++) { + for (var k = 0; k < sk; k++) { var num = parseInt(a[k]); - formatArrStr += Array(Math.max(4 - String(num).length, 0)).join(' ') + num + (k == 12 ? '' : ','); + formatArrStr += Array(Math.max(4 - String(num).length, 0)).join(' ') + num + (k == sk-1 ? '' : ','); } - formatArrStr += ']' + (i == 12 ? '' : ',\n'); + formatArrStr += ']' + (i == si-1 ? '' : ',\n'); } return formatArrStr; }