地图改变大小
This commit is contained in:
parent
3d682abbcf
commit
efbf3ae3a6
@ -49,6 +49,7 @@ function editor() {
|
|||||||
selectAppend : document.getElementById('selectAppend'),
|
selectAppend : document.getElementById('selectAppend'),
|
||||||
selectFileBtn :document.getElementById('selectFileBtn'),
|
selectFileBtn :document.getElementById('selectFileBtn'),
|
||||||
changeFloorId :document.getElementById('changeFloorId'),
|
changeFloorId :document.getElementById('changeFloorId'),
|
||||||
|
changeFloorSize: document.getElementById('changeFloorSize'),
|
||||||
left1 : document.getElementById('left1'),
|
left1 : document.getElementById('left1'),
|
||||||
editModeSelect :document.getElementById('editModeSelect'),
|
editModeSelect :document.getElementById('editModeSelect'),
|
||||||
mid2 : document.getElementById('mid2'),
|
mid2 : document.getElementById('mid2'),
|
||||||
|
|||||||
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -148,6 +148,7 @@ editor_listen_wrapper = function (editor) {
|
|||||||
editor.uifunctions.createNewMaps_func()
|
editor.uifunctions.createNewMaps_func()
|
||||||
|
|
||||||
editor.uifunctions.changeFloorId_func()
|
editor.uifunctions.changeFloorId_func()
|
||||||
|
editor.uifunctions.changeFloorSize_func()
|
||||||
|
|
||||||
editor.uifunctions.fixCtx_func()
|
editor.uifunctions.fixCtx_func()
|
||||||
|
|
||||||
|
|||||||
@ -251,7 +251,8 @@ var comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
|
|||||||
"_leaf": true,
|
"_leaf": true,
|
||||||
"_type": "textarea",
|
"_type": "textarea",
|
||||||
"_range": "false",
|
"_range": "false",
|
||||||
"_data": "图块ID"
|
"_docs": "图块ID",
|
||||||
|
"_data": "图块唯一ID,可在页面底部修改"
|
||||||
},
|
},
|
||||||
"idnum": {
|
"idnum": {
|
||||||
"_leaf": true,
|
"_leaf": true,
|
||||||
@ -361,7 +362,7 @@ var comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
|
|||||||
"_type": "textarea",
|
"_type": "textarea",
|
||||||
"_range": "false",
|
"_range": "false",
|
||||||
"_docs": "楼层ID",
|
"_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": {
|
"title": {
|
||||||
"_leaf": true,
|
"_leaf": true,
|
||||||
@ -380,14 +381,14 @@ var comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
|
|||||||
"_type": "textarea",
|
"_type": "textarea",
|
||||||
"_range": "false",
|
"_range": "false",
|
||||||
"_docs": "宽度",
|
"_docs": "宽度",
|
||||||
"_data": "地图x方向大小,这里不能更改,仅能在新建地图时设置,null视为13"
|
"_data": "地图x方向大小,请在表格最下方修改,null视为13"
|
||||||
},
|
},
|
||||||
"height": {
|
"height": {
|
||||||
"_leaf": true,
|
"_leaf": true,
|
||||||
"_type": "textarea",
|
"_type": "textarea",
|
||||||
"_range": "false",
|
"_range": "false",
|
||||||
"_docs": "高度",
|
"_docs": "高度",
|
||||||
"_data": "地图y方向大小,这里不能更改,仅能在新建地图时设置,null视为13"
|
"_data": "地图y方向大小,请在表格最下方修改,null视为13"
|
||||||
},
|
},
|
||||||
"canFlyTo": {
|
"canFlyTo": {
|
||||||
"_leaf": true,
|
"_leaf": true,
|
||||||
|
|||||||
@ -134,8 +134,10 @@ var data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
|
|||||||
},
|
},
|
||||||
"startBgm": {
|
"startBgm": {
|
||||||
"_leaf": true,
|
"_leaf": true,
|
||||||
"_type": "textarea",
|
"_type": "select",
|
||||||
"_string": true,
|
"_select": {
|
||||||
|
"values": [null].concat(Object.keys(editor.core.material.bgms))
|
||||||
|
},
|
||||||
"_docs": "标题音乐",
|
"_docs": "标题音乐",
|
||||||
"_data": "在标题界面应该播放的bgm内容"
|
"_data": "在标题界面应该播放的bgm内容"
|
||||||
},
|
},
|
||||||
@ -257,7 +259,7 @@ var data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
|
|||||||
"hpmax": {
|
"hpmax": {
|
||||||
"_leaf": true,
|
"_leaf": true,
|
||||||
"_type": "textarea",
|
"_type": "textarea",
|
||||||
"_data": "初始上限"
|
"_data": "生命上限"
|
||||||
},
|
},
|
||||||
"hp": {
|
"hp": {
|
||||||
"_leaf": true,
|
"_leaf": true,
|
||||||
|
|||||||
@ -173,6 +173,11 @@
|
|||||||
<input placeholder="修改floorId为"/>
|
<input placeholder="修改floorId为"/>
|
||||||
<button>save</button>
|
<button>save</button>
|
||||||
</div>
|
</div>
|
||||||
|
<div id='changeFloorSize' style="font-size: 13px;">
|
||||||
|
修改地图大小:宽<input style="width: 25px;" value="13" />,高<input style="width: 25px;" value="13" />,
|
||||||
|
偏移x<input style="width: 25px;" value="0" /> y<input style="width: 25px;" value="0" />
|
||||||
|
<button>save</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="left5" class='leftTab' style="z-index:-1;opacity: 0;"><!-- tower -->
|
<div id="left5" class='leftTab' style="z-index:-1;opacity: 0;"><!-- tower -->
|
||||||
|
|||||||
@ -169,6 +169,11 @@
|
|||||||
<input placeholder="修改floorId为"/>
|
<input placeholder="修改floorId为"/>
|
||||||
<button>save</button>
|
<button>save</button>
|
||||||
</div>
|
</div>
|
||||||
|
<div id='changeFloorSize' style="font-size: 13px;">
|
||||||
|
修改地图大小:宽<input style="width: 25px;" value="13" />,高<input style="width: 25px;" value="13" />,
|
||||||
|
偏移x<input style="width: 25px;" value="0" /> y<input style="width: 25px;" value="0" />
|
||||||
|
<button>save</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="left5" class='leftTab' style="z-index:-1;opacity: 0;"><!-- tower -->
|
<div id="left5" class='leftTab' style="z-index:-1;opacity: 0;"><!-- tower -->
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user