From 330e031bc799481aa2d214503fd1e30b82cdfa45 Mon Sep 17 00:00:00 2001 From: oc Date: Thu, 2 May 2019 21:05:05 +0800 Subject: [PATCH 1/2] changeFloorId --- _server/editor_unsorted_2.js | 35 +++++++++++++++++++++++++++++++++++ editor-mobile.html | 4 ++++ editor.html | 4 ++++ 3 files changed, 43 insertions(+) diff --git a/_server/editor_unsorted_2.js b/_server/editor_unsorted_2.js index ceb3bf16..c21864a3 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(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]; 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 @@
+
+ + +
From 2c0e0ba307a9a7a16c4bcf995f655daae625f37d Mon Sep 17 00:00:00 2001 From: oc Date: Thu, 2 May 2019 21:06:44 +0800 Subject: [PATCH 2/2] changeFloorId --- _server/editor_unsorted_2.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_server/editor_unsorted_2.js b/_server/editor_unsorted_2.js index c21864a3..17b8092e 100644 --- a/_server/editor_unsorted_2.js +++ b/_server/editor_unsorted_2.js @@ -200,7 +200,7 @@ editor_unsorted_2_wrapper=function(editor_mode){ var currentFloorId = editor.currentFloorId; editor.currentFloorId = floorId; editor.currentFloorData.floorId = floorId; - editor.file.saveFloorFile(floorId, function (err) { + editor.file.saveFloorFile(function (err) { if (err) { printe(err); throw(err);