diff --git a/_server/editor_unsorted_2.js b/_server/editor_unsorted_2.js index ceb3bf16..17b8092e 100644 --- a/_server/editor_unsorted_2.js +++ b/_server/editor_unsorted_2.js @@ -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(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]; diff --git a/editor-mobile.html b/editor-mobile.html index 563c0b7e..67db31dd 100644 --- a/editor-mobile.html +++ b/editor-mobile.html @@ -162,6 +162,10 @@ +
+ + +
diff --git a/editor.html b/editor.html index 7af5e35d..4ea3654f 100644 --- a/editor.html +++ b/editor.html @@ -158,6 +158,10 @@
+
+ + +