changeFloorId

This commit is contained in:
oc 2019-05-02 21:05:05 +08:00
parent 432b5354df
commit 330e031bc7
3 changed files with 43 additions and 0 deletions

View File

@ -185,6 +185,41 @@ editor_unsorted_2_wrapper=function(editor_mode){
});
}
var changeFloorId = document.getElementById('changeFloorId');
changeFloorId.children[1].onclick = function () {
var floorId = changeFloorId.children[0].value;
if (floorId) {
if (!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(floorId)) {
printe("楼层名 "+floorId+" 不合法!请使用字母、数字、下划线,且不能以数字开头!");
return;
}
if (main.floorIds.indexOf(floorId)>=0) {
printe("楼层名 "+floorId+" 已存在!");
return;
}
var currentFloorId = editor.currentFloorId;
editor.currentFloorId = floorId;
editor.currentFloorData.floorId = floorId;
editor.file.saveFloorFile(floorId, function (err) {
if (err) {
printe(err);
throw(err);
}
core.floorIds[core.floorIds.indexOf(currentFloorId)] = floorId;
editor.file.editTower([['change', "['main']['floorIds']", core.floorIds]], function (objs_) {//console.log(objs_);
if (objs_.slice(-1)[0] != null) {
printe(objs_.slice(-1)[0]);
throw(objs_.slice(-1)[0])
}
alert("修改floorId成功需要刷新编辑器生效。\n请注意原始的楼层文件没有删除请根据需要手动删除。");
window.location.reload();
});
});
} else {
printe('请输入要修改到的floorId');
}
}
var ratio = 1;
var appendPicCanvas = document.getElementById('appendPicCanvas');
var bg = appendPicCanvas.children[0];

View File

@ -162,6 +162,10 @@
</tbody>
</table>
</div>
<div id='changeFloorId'><!-- id and idnum -->
<input placeholder="修改floorId为"/>
<button>save</button>
</div>
</div>
</div>
<div id="left5" class='leftTab' style="z-index:-1;opacity: 0;"><!-- tower -->

View File

@ -158,6 +158,10 @@
</tbody>
</table>
</div>
<div id='changeFloorId'><!-- id and idnum -->
<input placeholder="修改floorId为"/>
<button>save</button>
</div>
</div>
</div>
<div id="left5" class='leftTab' style="z-index:-1;opacity: 0;"><!-- tower -->