create multiple floors
This commit is contained in:
parent
1b1b64463b
commit
20bedabd05
@ -58,7 +58,7 @@ body {
|
||||
#editArea {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 70%;
|
||||
height: 400px;
|
||||
left: 0;
|
||||
top: 0;
|
||||
/* padding: 10px 5px; */
|
||||
@ -68,7 +68,7 @@ body {
|
||||
#pout {
|
||||
display: block;
|
||||
width: 410px;
|
||||
height: 100%;
|
||||
height: 380px;
|
||||
box-sizing: border-box;
|
||||
margin-left: 22px;
|
||||
margin-top: 23px;
|
||||
@ -84,9 +84,28 @@ body {
|
||||
#editTip {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
margin-bottom: 120px;
|
||||
bottom: 0;
|
||||
left: 10px;
|
||||
top: 430px;
|
||||
}
|
||||
|
||||
#editBtns {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
left: 10px;
|
||||
top: 465px;
|
||||
}
|
||||
|
||||
#newMaps {
|
||||
position: absolute;
|
||||
left: 10px;
|
||||
top: 505px;
|
||||
}
|
||||
|
||||
#newFloors {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
left: 10px;
|
||||
top: 530px;
|
||||
}
|
||||
|
||||
#editArea p {
|
||||
|
||||
@ -45,6 +45,7 @@ body {
|
||||
top: 0;
|
||||
/* padding: 10px 5px; */
|
||||
box-sizing: border-box;
|
||||
display: none;
|
||||
}
|
||||
|
||||
#pout {
|
||||
@ -72,12 +73,39 @@ body {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
#editTip {
|
||||
position: absolute;
|
||||
width: 95vw;
|
||||
left: 4vw;
|
||||
top: 4vw;
|
||||
}
|
||||
|
||||
#editTip .btn {
|
||||
float: right;
|
||||
margin-right: 20px;
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
#editBtns {
|
||||
position: absolute;
|
||||
width: 95vw;
|
||||
left: 4vw;
|
||||
top: 20vw;
|
||||
}
|
||||
|
||||
#newMaps {
|
||||
position: absolute;
|
||||
left: 4vw;
|
||||
top: 35vw;
|
||||
}
|
||||
|
||||
#newFloors {
|
||||
position: absolute;
|
||||
width: 95vw;
|
||||
left: 4vw;
|
||||
top: 43vw;
|
||||
}
|
||||
|
||||
#mid {
|
||||
position: absolute;
|
||||
}
|
||||
@ -279,6 +307,7 @@ div.col .coltd {
|
||||
width: 95vw;
|
||||
height: 16px;
|
||||
font-size: 13px;
|
||||
display: none;
|
||||
}
|
||||
|
||||
#mapColMark {
|
||||
@ -334,6 +363,7 @@ div.row .rowtd .rowtext{
|
||||
width: 4vw;
|
||||
height: 62vw;
|
||||
font-size: 12px;
|
||||
display: none;
|
||||
}
|
||||
|
||||
#mapRowMark {
|
||||
|
||||
@ -174,6 +174,82 @@ editor_file = function (editor, callback) {
|
||||
editor.currentFloorId = saveFilename;
|
||||
editor_file.saveFloorFile(callback);
|
||||
}
|
||||
editor_file.saveNewFiles = function (floorIdList, from, to, callback) {
|
||||
if (!isset(callback)) {
|
||||
printe('未设置callback');
|
||||
throw('未设置callback')
|
||||
};
|
||||
var currData=editor.currentFloorData;
|
||||
var saveStatus = document.getElementById('newMapsStatus').checked;
|
||||
|
||||
var calValue = function (text, i) {
|
||||
return text.replace(/\${(.*?)}/g, function (word, value) {
|
||||
return eval(value);
|
||||
});
|
||||
}
|
||||
|
||||
var width = parseInt(document.getElementById('newMapsWidth').value);
|
||||
var height = parseInt(document.getElementById('newMapsHeight').value);
|
||||
|
||||
var row = [], map = [];
|
||||
for (var i=0;i<width;i++) row.push(0);
|
||||
for (var i=0;i<height;i++) map.push(row);
|
||||
|
||||
var filenames = floorIdList.map(function (v) {return "project/floors/"+v+".js";});
|
||||
var datas = [];
|
||||
for (var i=from;i<=to;i++) {
|
||||
var datastr = ['main.floors.', floorIdList[i-from], '=\n{'];
|
||||
var data = {
|
||||
floorId: floorIdList[i-from],
|
||||
title: calValue(document.getElementById('newFloorTitles').value, i),
|
||||
name: calValue(document.getElementById('newFloorNames').value, i),
|
||||
width: width,
|
||||
height: height,
|
||||
map: map,
|
||||
canFlyTo: saveStatus?currData.canFlyTo:true,
|
||||
canUseQuickShop: saveStatus?currData.canUseQuickShop:true,
|
||||
cannotViewMap: saveStatus?currData.cannotViewMap:false,
|
||||
cannotMoveDirectly: saveStatus?currData.cannotMoveDirectly:false,
|
||||
images: [],
|
||||
item_ratio: saveStatus?currData.item_ratio:1,
|
||||
defaultGround: saveStatus?currData.defaultGround:"ground",
|
||||
bgm: saveStatus?currData.bgm:null,
|
||||
upFloor: null,
|
||||
downFloor: null,
|
||||
color: saveStatus?currData.color:null,
|
||||
weather: saveStatus?currData.weather:null,
|
||||
firstArrive: [],
|
||||
eachArrive: [],
|
||||
parallelDo: "",
|
||||
events: {},
|
||||
changeFloor: {},
|
||||
afterBattle: {},
|
||||
afterGetItem: {},
|
||||
afterOpenDoor: {},
|
||||
cannotMove: {}
|
||||
};
|
||||
Object.keys(data).forEach(function (t) {
|
||||
if (!core.isset(data[t]))
|
||||
delete data[t];
|
||||
else {
|
||||
if (t=='map') {
|
||||
datastr = datastr.concat(['\n"', t, '": [\n', formatMap(data[t]), '\n],']);
|
||||
}
|
||||
else {
|
||||
datastr = datastr.concat(['\n"', t, '": ', JSON.stringify(data[t], null, 4), ',']);
|
||||
}
|
||||
}
|
||||
});
|
||||
datastr = datastr.concat(['\n}']);
|
||||
datastr = datastr.join('');
|
||||
datas.push(encode(datastr));
|
||||
}
|
||||
alertWhenCompress();
|
||||
fs.writeMultiFiles(filenames, datas, function (err, data) {
|
||||
callback(err);
|
||||
});
|
||||
}
|
||||
|
||||
//callback(err:String)
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -497,6 +497,71 @@ editor_mode = function (editor) {
|
||||
});
|
||||
}
|
||||
|
||||
var newMaps = document.getElementById('newMaps');
|
||||
var newFloors = document.getElementById('newFloors');
|
||||
newMaps.onclick = function () {
|
||||
if (newFloors.style.display == 'none') newFloors.style.display = 'block';
|
||||
else newFloors.style.display = 'none';
|
||||
}
|
||||
|
||||
var createNewMaps = document.getElementById('createNewMaps');
|
||||
createNewMaps.onclick = function () {
|
||||
var floorIds = document.getElementById('newFloorIds').value;
|
||||
if (!floorIds) return;
|
||||
var from = parseInt(document.getElementById('newMapsFrom').value),
|
||||
to = parseInt(document.getElementById('newMapsTo').value);
|
||||
if (!core.isset(from) || !core.isset(to) || from>to || from<0 || to<0) {
|
||||
printe("请输入有效的起始和终止楼层");
|
||||
return;
|
||||
}
|
||||
if (to-from >= 100) {
|
||||
printe("一次最多创建99个楼层");
|
||||
return;
|
||||
}
|
||||
var floorIdList = [];
|
||||
for (var i = from; i<=to; i++) {
|
||||
var floorId = floorIds.replace(/\${(.*?)}/g, function (word, value) {
|
||||
return eval(value);
|
||||
});
|
||||
if (core.floorIds.indexOf(floorId)>=0) {
|
||||
printe("要创建的楼层 "+floorId+" 已存在!");
|
||||
return;
|
||||
}
|
||||
if (!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(floorId)) {
|
||||
printe("楼层名 "+floorId+" 不合法!请使用字母、数字、下划线,且不能以数字开头!");
|
||||
return;
|
||||
}
|
||||
if (floorIdList.indexOf(floorId)>=0) {
|
||||
printe("尝试重复创建楼层 "+floorId+" !");
|
||||
return;
|
||||
}
|
||||
floorIdList.push(floorId);
|
||||
}
|
||||
|
||||
var width = parseInt(document.getElementById('newMapsWidth').value);
|
||||
var height = parseInt(document.getElementById('newMapsHeight').value);
|
||||
if (!core.isset(width) || !core.isset(height) || width<13 || height<13 || width*height>1000) {
|
||||
printe("新建地图的宽高都不得小于13,且宽高之积不能超过1000");
|
||||
return;
|
||||
}
|
||||
editor_mode.onmode('');
|
||||
|
||||
editor.file.saveNewFiles(floorIdList, from, to, function (err) {
|
||||
if (err) {
|
||||
printe(err);
|
||||
throw(err)
|
||||
}
|
||||
core.floorIds = core.floorIds.concat(floorIdList);
|
||||
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])
|
||||
}
|
||||
;printe('批量创建 '+floorIdList[0]+'~'+floorIdList[floorIdList.length-1]+' 成功,请F5刷新编辑器生效');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
var ratio = 1;
|
||||
var appendPicCanvas = document.getElementById('appendPicCanvas');
|
||||
var bg = appendPicCanvas.children[0];
|
||||
|
||||
@ -22,30 +22,48 @@
|
||||
<textarea cols="10" rows="10" id="pout" v-model="mapArr"></textarea>
|
||||
<!-- <p class="warnText" v-if="error">{{ errors[error-1] }}</p> -->
|
||||
</div>
|
||||
<div id="editTip" style="position: absolute; width: 95vw;margin-bottom: 10%;bottom: 0;left: 4vw;">
|
||||
<input type="button" value="新建空白地图" id='newMap'/>
|
||||
<input id='newFileName' placeholder="新楼层id" style="width: 70px"/>
|
||||
<div id="editTip">
|
||||
<input id='newFileName' placeholder="新楼层id" style="width: 100px"/>
|
||||
<span style="vertical-align: bottom">宽</span>
|
||||
<input id='newMapWidth' value="13" style="width: 20px"/>
|
||||
<span style="vertical-align: bottom">高</span>
|
||||
<input id='newMapHeight' value="13" style="width: 20px"/>
|
||||
<input type="checkbox" id='newMapStatus' checked='checked' style='vertical-align: bottom'/>
|
||||
<span style='vertical-align: bottom; margin-left: -4px'>保留属性</span>
|
||||
<span style='vertical-align: bottom;'>保留楼层属性</span>
|
||||
<br/>
|
||||
<input type="button" value="新建空白地图" id='newMap'/>
|
||||
</div>
|
||||
<div style="position: absolute;left: 10px;bottom:0; margin-bottom: 0%">
|
||||
<div id='editBtns'>
|
||||
<input type="button" value="导出地图" id="exportMap" v-on:click="exportMap"/>
|
||||
<input type="button" value="复制地图" id="copyMap" v-on:click="copyMap"/>
|
||||
<input type="button" value="清除地图" id='clearMap' v-on:click="clearMap"/>
|
||||
<input type="button" value="删除地图" id="deleteMap" v-on:click="deleteMap"/>
|
||||
</div>
|
||||
<input type="button" value="批量创建空白地图 ↓" id='newMaps'/>
|
||||
<div id='newFloors' style='display:none'>
|
||||
<span style="vertical-align: bottom">楼层ID格式: </span>
|
||||
<input id='newFloorIds' style="width: 70px" value='MT${i}'/>
|
||||
<br/>
|
||||
<span style="vertical-align: bottom">地图中文名格式: </span>
|
||||
<input id='newFloorTitles' style="width: 100px" value='主塔 ${i} 层'/>
|
||||
<br/>
|
||||
<span style="vertical-align: bottom">状态栏名称: </span>
|
||||
<input id='newFloorNames' style="width: 70px" value='${i}'/>
|
||||
<br/>
|
||||
<span style="vertical-align: bottom">宽</span>
|
||||
<input id='newMapsWidth' value="13" style="width: 20px"/>
|
||||
<span style="vertical-align: bottom">高</span>
|
||||
<input id='newMapsHeight' value="13" style="width: 20px"/>
|
||||
<input type="checkbox" id='newMapsStatus' checked='checked' style='vertical-align: bottom'/>
|
||||
<span style='vertical-align: bottom; margin-left: -4px'>保留楼层属性</span>
|
||||
<br/>
|
||||
<span style="vertical-align: bottom">从 i=</span>
|
||||
<input id='newMapsFrom' value="1" style="width: 20px"/>
|
||||
<span style="vertical-align: bottom">到</span>
|
||||
<input id='newMapsTo' value="5" style="width: 20px"/>
|
||||
<input type="button" value="确认创建" id='createNewMaps'>
|
||||
</div>
|
||||
</div>
|
||||
<div id="objDataEditor">
|
||||
|
||||
</div>
|
||||
<div id="eventEditor">
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="left1" class='leftTab' style="z-index:-1;opacity: 0;"><!-- appendpic -->
|
||||
<h3 class="leftTabHeader">追加素材</h3>
|
||||
|
||||
31
editor.html
31
editor.html
@ -31,20 +31,35 @@
|
||||
<input type="checkbox" id='newMapStatus' checked='checked' style='vertical-align: bottom'/>
|
||||
<span style='vertical-align: bottom; margin-left: -4px'>保留楼层属性</span>
|
||||
</div>
|
||||
<div style="position: absolute;left: 10px;bottom:0; margin-bottom: 90px">
|
||||
<div id="editBtns">
|
||||
<input type="button" value="导出地图" id="exportMap" v-on:click="exportMap"/>
|
||||
<input type="button" value="复制地图" id="copyMap" v-on:click="copyMap"/>
|
||||
<input type="button" value="清除地图" id='clearMap' v-on:click="clearMap"/>
|
||||
<input type="button" value="删除地图" id="deleteMap" v-on:click="deleteMap"/>
|
||||
</div>
|
||||
<input type="button" value="批量创建空白地图 ↓" id='newMaps'/>
|
||||
<div id='newFloors' style='display:none'>
|
||||
<span style="vertical-align: bottom">楼层ID格式: </span>
|
||||
<input id='newFloorIds' style="width: 70px" value='MT${i}'/>
|
||||
<span style="vertical-align: bottom">地图中文名格式: </span>
|
||||
<input id='newFloorTitles' style="width: 100px" value='主塔 ${i} 层'/>
|
||||
<br/>
|
||||
<span style="vertical-align: bottom">状态栏名称: </span>
|
||||
<input id='newFloorNames' style="width: 70px" value='${i}'/>
|
||||
<span style="vertical-align: bottom">宽</span>
|
||||
<input id='newMapsWidth' value="13" style="width: 20px"/>
|
||||
<span style="vertical-align: bottom">高</span>
|
||||
<input id='newMapsHeight' value="13" style="width: 20px"/>
|
||||
<input type="checkbox" id='newMapsStatus' checked='checked' style='vertical-align: bottom'/>
|
||||
<span style='vertical-align: bottom; margin-left: -4px'>保留楼层属性</span>
|
||||
<br/>
|
||||
<span style="vertical-align: bottom">从 i=</span>
|
||||
<input id='newMapsFrom' value="1" style="width: 20px"/>
|
||||
<span style="vertical-align: bottom">到</span>
|
||||
<input id='newMapsTo' value="5" style="width: 20px"/>
|
||||
<input type="button" value="确认创建" id='createNewMaps'>
|
||||
</div>
|
||||
</div>
|
||||
<div id="objDataEditor">
|
||||
|
||||
</div>
|
||||
<div id="eventEditor">
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="left1" class='leftTab' style="z-index:-1;opacity: 0;"><!-- appendpic -->
|
||||
<h3 class="leftTabHeader">追加素材</h3>
|
||||
|
||||
@ -8,7 +8,7 @@ main.floors.sample0=
|
||||
"defaultGround": "ground",
|
||||
"images": [],
|
||||
"bgm": "bgm.mp3",
|
||||
"item_ratio": 2,
|
||||
"item_ratio": 1,
|
||||
"map": [
|
||||
[ 0, 0,220, 0, 0, 20, 87, 3, 65, 64, 44, 43, 42],
|
||||
[ 0,246, 0,246, 0, 20, 0, 3, 58, 59, 60, 61, 41],
|
||||
|
||||
Loading…
Reference in New Issue
Block a user