Auto register
This commit is contained in:
parent
b71442b099
commit
1ec381bbdc
@ -161,11 +161,25 @@ editor_file = function (editor, callback) {
|
|||||||
|
|
||||||
var image = info.images;
|
var image = info.images;
|
||||||
|
|
||||||
|
if (image=='autotile') {
|
||||||
|
callback('不能对自动元件进行自动注册!');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
/*
|
||||||
if (image!='items' && image.indexOf('enemy')!=0) {
|
if (image!='items' && image.indexOf('enemy')!=0) {
|
||||||
callback('只有怪物和道具才能自动注册!');
|
callback('只有怪物和道具才能自动注册!');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var c=image=='items'?'I':'M';
|
*/
|
||||||
|
var c=image.toUpperCase().charAt(0);
|
||||||
|
|
||||||
|
// terrains id
|
||||||
|
var terrainsId = [];
|
||||||
|
Object.keys(core.material.icons.terrains).forEach(function (id) {
|
||||||
|
terrainsId[core.material.icons.terrains[id]]=id;
|
||||||
|
})
|
||||||
|
//console.log(terrainsId);
|
||||||
|
//return;
|
||||||
|
|
||||||
var allIds = [];
|
var allIds = [];
|
||||||
editor.ids.forEach(function (v) {
|
editor.ids.forEach(function (v) {
|
||||||
@ -180,17 +194,25 @@ editor_file = function (editor, callback) {
|
|||||||
for (var y=0; y<editor.widthsX[image][3]/per_height;y++) {
|
for (var y=0; y<editor.widthsX[image][3]/per_height;y++) {
|
||||||
if (allIds[y]) continue;
|
if (allIds[y]) continue;
|
||||||
while (editor.core.maps.blocksInfo[idnum]) idnum++;
|
while (editor.core.maps.blocksInfo[idnum]) idnum++;
|
||||||
|
|
||||||
|
// get id num
|
||||||
var id = c+idnum;
|
var id = c+idnum;
|
||||||
iconActions.push(["add", "['" + image + "']['" + id + "']", y])
|
|
||||||
|
if (image=='terrains' && core.isset(terrainsId[y])) {
|
||||||
|
id=terrainsId[y];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
iconActions.push(["add", "['" + image + "']['" + id + "']", y])
|
||||||
|
}
|
||||||
mapActions.push(["add", "['" + idnum + "']", {'cls': image, 'id': id}])
|
mapActions.push(["add", "['" + idnum + "']", {'cls': image, 'id': id}])
|
||||||
if (image=='items')
|
if (image=='items')
|
||||||
templateActions.push(["add", "['items']['" + id + "']", editor_file.comment._data.items_template]);
|
templateActions.push(["add", "['items']['" + id + "']", editor_file.comment._data.items_template]);
|
||||||
else
|
else if (image.indexOf('enemy')==0)
|
||||||
templateActions.push(["add", "['" + id + "']", editor_file.comment._data.enemys_template]);
|
templateActions.push(["add", "['" + id + "']", editor_file.comment._data.enemys_template]);
|
||||||
idnum++;
|
idnum++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iconActions.length==0) {
|
if (mapActions.length==0) {
|
||||||
callback("没有要注册的项!");
|
callback("没有要注册的项!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -198,7 +220,7 @@ editor_file = function (editor, callback) {
|
|||||||
var templist = [];
|
var templist = [];
|
||||||
var tempcallback = function (err) {
|
var tempcallback = function (err) {
|
||||||
templist.push(err);
|
templist.push(err);
|
||||||
if (templist.length == 2) {
|
if (templist.length == 3) {
|
||||||
if (templist[0] != null || templist[1] != null || templist[2] != null)
|
if (templist[0] != null || templist[1] != null || templist[2] != null)
|
||||||
callback((templist[0] || '') + '\n' + (templist[1] || '') + '\n' + (templist[2] || ''));
|
callback((templist[0] || '') + '\n' + (templist[1] || '') + '\n' + (templist[2] || ''));
|
||||||
//这里如果一个成功一个失败会出严重bug
|
//这里如果一个成功一个失败会出严重bug
|
||||||
@ -206,12 +228,17 @@ editor_file = function (editor, callback) {
|
|||||||
callback(null);
|
callback(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
saveSetting('icons', iconActions, tempcallback);
|
if (iconActions.length>0)
|
||||||
|
saveSetting('icons', iconActions, tempcallback);
|
||||||
|
else tempcallback(null);
|
||||||
|
|
||||||
saveSetting('maps', mapActions, tempcallback);
|
saveSetting('maps', mapActions, tempcallback);
|
||||||
|
|
||||||
if (image=='items')
|
if (image=='items')
|
||||||
saveSetting('items', templateActions, tempcallback);
|
saveSetting('items', templateActions, tempcallback);
|
||||||
else
|
else if (image.indexOf('enemy')==0)
|
||||||
saveSetting('enemys', templateActions, tempcallback);
|
saveSetting('enemys', templateActions, tempcallback);
|
||||||
|
else tempcallback(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
editor_file.changeIdAndIdnum = function (id, idnum, info, callback) {
|
editor_file.changeIdAndIdnum = function (id, idnum, info, callback) {
|
||||||
|
|||||||
@ -889,8 +889,8 @@ core.prototype.debug = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
////// 重置当前地图 //////
|
////// 重置当前地图 //////
|
||||||
core.prototype.resetMap = function() {
|
core.prototype.resetMap = function(floorId) {
|
||||||
core.maps.resetMap();
|
core.maps.resetMap(floorId);
|
||||||
}
|
}
|
||||||
|
|
||||||
////// 开始播放 //////
|
////// 开始播放 //////
|
||||||
|
|||||||
13
libs/maps.js
13
libs/maps.js
@ -898,8 +898,15 @@ maps.prototype.drawAnimate = function (name, x, y, callback) {
|
|||||||
}, 50);
|
}, 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
maps.prototype.resetMap = function() {
|
maps.prototype.resetMap = function(floorId) {
|
||||||
var floorId = core.status.floorId;
|
var floorId = floorId||core.status.floorId;
|
||||||
core.status.maps[floorId] = this.loadFloor(floorId);
|
core.status.maps[floorId] = this.loadFloor(floorId);
|
||||||
this.drawMap(floorId)
|
if (floorId==core.status.floorId) {
|
||||||
|
this.drawMap(floorId, function () {
|
||||||
|
core.drawTip("地图重置成功");
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
core.drawTip(floorId+"地图重置成功");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -27,8 +27,8 @@ icons_4665ee12_3a1f_44a4_bea3_0fccba634dc1 =
|
|||||||
'white': 17,
|
'white': 17,
|
||||||
'ground6': 18,
|
'ground6': 18,
|
||||||
'soil': 19,
|
'soil': 19,
|
||||||
'star': 20,
|
'ground7': 20,
|
||||||
'lava': 21,
|
'ground8': 21,
|
||||||
'ice': 22,
|
'ice': 22,
|
||||||
'downFloor': 23,
|
'downFloor': 23,
|
||||||
'upFloor': 24,
|
'upFloor': 24,
|
||||||
@ -70,9 +70,9 @@ icons_4665ee12_3a1f_44a4_bea3_0fccba634dc1 =
|
|||||||
'lavaDoor': 13,
|
'lavaDoor': 13,
|
||||||
'starDoor': 14,
|
'starDoor': 14,
|
||||||
'starPortal': 15,
|
'starPortal': 15,
|
||||||
//'exclamation': 16,
|
'fire': 16,
|
||||||
'portal': 17,
|
'portal': 17,
|
||||||
//'switch': 18,
|
'switch': 18,
|
||||||
'lavaNet': 19,
|
'lavaNet': 19,
|
||||||
'poisonNet': 20,
|
'poisonNet': 20,
|
||||||
'weakNet': 21,
|
'weakNet': 21,
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 29 KiB |
Loading…
Reference in New Issue
Block a user