Auto register

This commit is contained in:
oc 2018-05-18 00:09:07 +08:00
parent b71442b099
commit 1ec381bbdc
6 changed files with 50 additions and 16 deletions

View File

@ -161,11 +161,25 @@ editor_file = function (editor, callback) {
var image = info.images;
if (image=='autotile') {
callback('不能对自动元件进行自动注册!');
return;
}
/*
if (image!='items' && image.indexOf('enemy')!=0) {
callback('只有怪物和道具才能自动注册!');
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 = [];
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++) {
if (allIds[y]) continue;
while (editor.core.maps.blocksInfo[idnum]) idnum++;
// get id num
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}])
if (image=='items')
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]);
idnum++;
}
if (iconActions.length==0) {
if (mapActions.length==0) {
callback("没有要注册的项!");
return;
}
@ -198,7 +220,7 @@ editor_file = function (editor, callback) {
var templist = [];
var tempcallback = function (err) {
templist.push(err);
if (templist.length == 2) {
if (templist.length == 3) {
if (templist[0] != null || templist[1] != null || templist[2] != null)
callback((templist[0] || '') + '\n' + (templist[1] || '') + '\n' + (templist[2] || ''));
//这里如果一个成功一个失败会出严重bug
@ -206,12 +228,17 @@ editor_file = function (editor, callback) {
callback(null);
}
}
saveSetting('icons', iconActions, tempcallback);
if (iconActions.length>0)
saveSetting('icons', iconActions, tempcallback);
else tempcallback(null);
saveSetting('maps', mapActions, tempcallback);
if (image=='items')
saveSetting('items', templateActions, tempcallback);
else
else if (image.indexOf('enemy')==0)
saveSetting('enemys', templateActions, tempcallback);
else tempcallback(null);
}
editor_file.changeIdAndIdnum = function (id, idnum, info, callback) {

View File

@ -889,8 +889,8 @@ core.prototype.debug = function() {
}
////// 重置当前地图 //////
core.prototype.resetMap = function() {
core.maps.resetMap();
core.prototype.resetMap = function(floorId) {
core.maps.resetMap(floorId);
}
////// 开始播放 //////

View File

@ -898,8 +898,15 @@ maps.prototype.drawAnimate = function (name, x, y, callback) {
}, 50);
}
maps.prototype.resetMap = function() {
var floorId = core.status.floorId;
maps.prototype.resetMap = function(floorId) {
var floorId = floorId||core.status.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+"地图重置成功");
}
}

View File

@ -27,8 +27,8 @@ icons_4665ee12_3a1f_44a4_bea3_0fccba634dc1 =
'white': 17,
'ground6': 18,
'soil': 19,
'star': 20,
'lava': 21,
'ground7': 20,
'ground8': 21,
'ice': 22,
'downFloor': 23,
'upFloor': 24,
@ -70,9 +70,9 @@ icons_4665ee12_3a1f_44a4_bea3_0fccba634dc1 =
'lavaDoor': 13,
'starDoor': 14,
'starPortal': 15,
//'exclamation': 16,
'fire': 16,
'portal': 17,
//'switch': 18,
'switch': 18,
'lavaNet': 19,
'poisonNet': 20,
'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