Auto register

This commit is contained in:
oc 2018-05-07 00:09:14 +08:00
parent 6db581b929
commit 06dfa942ec
6 changed files with 85 additions and 10 deletions

View File

@ -144,6 +144,67 @@ editor_file = function (editor, callback) {
////////////////////////////////////////////////////////////////////
editor_file.autoRegister = function (info, callback) {
var iconActions = [];
var mapActions = [];
var templateActions = [];
var image = info.images;
if (image!='items' && image.indexOf('enemy')!=0) {
callback('只有怪物和道具才能自动注册!');
return;
}
var c=image=='items'?'I':'M';
var allIds = [];
editor.ids.forEach(function (v) {
if (v.images==image) {
allIds[v.y]=true;
}
})
var per_height = image.indexOf('48')>=0?48:32;
var idnum=300;
for (var y=0; y<editor.widthsX[image][3]/per_height;y++) {
if (allIds[y]) continue;
while (editor.core.maps.blocksInfo[idnum]) idnum++;
var id = c+idnum;
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
templateActions.push(["add", "['" + id + "']", editor_file.comment._data.enemys_template]);
idnum++;
}
if (iconActions.length==0) {
callback("没有要注册的项!");
return;
}
var templist = [];
var tempcallback = function (err) {
templist.push(err);
if (templist.length == 2) {
if (templist[0] != null || templist[1] != null || templist[2] != null)
callback((templist[0] || '') + '\n' + (templist[1] || '') + '\n' + (templist[2] || ''));
//这里如果一个成功一个失败会出严重bug
else
callback(null);
}
}
saveSetting('icons', iconActions, tempcallback);
saveSetting('maps', mapActions, tempcallback);
if (image=='items')
saveSetting('items', templateActions, tempcallback);
else
saveSetting('enemys', templateActions, tempcallback);
}
editor_file.changeIdAndIdnum = function (id, idnum, info, callback) {
if (!isset(callback)) {
printe('未设置callback');

View File

@ -308,11 +308,13 @@ editor_mode = function (editor) {
if (Object.keys(editor.info).length !== 0) editor_mode.info = editor.info;//避免editor.info被清空导致无法获得是物品还是怪物
if (!core.isset(editor_mode.info.id)) {
document.getElementById('table_a3f03d4c_55b8_4ef6_b362_b345783acd72').innerHTML = '';
document.getElementById('newIdIdnum').style.display = '';
// document.getElementById('table_a3f03d4c_55b8_4ef6_b362_b345783acd72').innerHTML = '';
document.getElementById('enemyItemTable').style.display = 'none';
document.getElementById('newIdIdnum').style.display = 'block';
return;
}
document.getElementById('newIdIdnum').style.display = 'none';
document.getElementById('enemyItemTable').style.display = 'block';
var objs = [];
if (editor_mode.info.images == 'enemys' || editor_mode.info.images == 'enemy48') {
@ -405,6 +407,16 @@ editor_mode = function (editor) {
}
}
newIdIdnum.children[4].onclick = function () {
editor.file.autoRegister(editor_mode.info, function (err) {
if (err) {
printe(err);
throw(err)
}
printe('该列所有剩余项全部自动注册成功,请F5刷新编辑器');
})
}
var selectFloor = document.getElementById('selectFloor');
editor.file.getFloorFileList(function (floors) {
var outstr = [];

View File

@ -86,8 +86,10 @@
<input placeholder="新id唯一标识符"/>
<input placeholder="新idnum1000以内数字"/>
<button>save</button>
<br/>
<button style="margin-top: 10px">自动注册</button>
</div>
<div><!-- enemy and item -->
<div id="enemyItemTable"><!-- enemy and item -->
<div class='etable'>
<table>
<tbody id='table_a3f03d4c_55b8_4ef6_b362_b345783acd72'>

View File

@ -354,8 +354,8 @@ utils.prototype.rand2 = function (num) {
var value;
if (core.status.replay.replaying) {
var action = core.status.replay.toReplay.shift();
if (action.indexOf("input:")==0 ) {
value=parseInt(action.substring(6));
if (action.indexOf("random:")==0 ) {
value=parseInt(action.substring(7));
}
else {
core.stopReplay();

View File

@ -2,7 +2,7 @@ function main() {
//------------------------ 用户修改内容 ------------------------//
this.version = "2.1.1"; // 游戏版本号如果更改了游戏内容建议修改此version以免造成缓存问题。
this.version = "2.2"; // 游戏版本号如果更改了游戏内容建议修改此version以免造成缓存问题。
this.useCompress = false; // 是否使用压缩文件
// 当你即将发布你的塔时请使用“JS代码压缩工具”将所有js代码进行压缩然后将这里的useCompress改为true。

View File

@ -3,16 +3,16 @@
事件坐标可用变量指定 √
全局商店也可以使用图块编辑 √
高亮显示有事件的格子 √
自动注册所有未注册的素材
自动注册所有未注册的素材
便捷PS工具对于白底图片可自动调整为透明背景 √
等待用户点击事件 √
图片移动事件 √
事件设置BGM音量 √
提供core.rand()和core.rand2()两个随机数函数 √
作弊处理 √
状态栏绘制 √
六倍速播放 √
播放视频时可以C键查看怪物手册 √
自定义状态栏绘制 √
最高六倍速播放 √
播放录像时可以C键查看怪物手册 √
修复标题文字太长导致无法开始游戏的问题 √
新增纯新手简易造塔流程 √
部分效果和性能的优化 √