editor-tilesets

This commit is contained in:
YouWei Zhao 2018-10-26 23:25:51 +08:00
parent 00e2a79840
commit 94ae7f3a33
6 changed files with 27 additions and 29 deletions

View File

@ -228,14 +228,9 @@ comment_c456ea59_6018_45ef_8bcc_211a24c627dc =
}, },
"canBreak": { "canBreak": {
"_leaf": true, "_leaf": true,
"_type": "select", "_type": "checkbox",
"_select": { "_bool": "bool",
"values": [ "_data": "该图块是否可被破炸"
true,
false
]
},
"_data": "该图块是否可被破炸true代表可以false代表不可以"
} }
} }
}, },

View File

@ -81,7 +81,12 @@ editor.prototype.init = function (callback) {
editor.prototype.idsInit = function (maps, icons) { editor.prototype.idsInit = function (maps, icons) {
editor.ids = [0]; editor.ids = [0];
editor.indexs = []; editor.indexs = [];
var MAX_NUM = Math.max.apply(null,Object.keys(maps_90f36752_8815_4be8_b32b_d7fad1d0542e)); var MAX_NUM = 0;
var keys=Object.keys(maps_90f36752_8815_4be8_b32b_d7fad1d0542e);
for(var ii=0;ii<keys.length;ii++){
var v=~~keys[ii];
if(v>MAX_NUM && v<core.icons.tilesetStartOffset)MAX_NUM=v;
}
editor.MAX_NUM=MAX_NUM; editor.MAX_NUM=MAX_NUM;
var getInfoById = function (id) { var getInfoById = function (id) {
var block = maps.initBlock(0, 0, id); var block = maps.initBlock(0, 0, id);

View File

@ -476,15 +476,24 @@ editor_file = function (editor, callback) {
} }
; ;
if (isset(actionList) && actionList.length > 0) { if (isset(actionList) && actionList.length > 0) {
actionList.forEach(function (value) { var tempmap=[];
for(var ii=0;ii<actionList.length;ii++){
var value=actionList[ii];
// 是tilesets 且未定义 且在这里是第一次定义
if(idnum>=editor.core.icons.tilesetStartOffset && !isset(editor.core.maps.blocksInfo[idnum]) && tempmap.indexOf(idnum)===-1){
actionList.splice(ii,0,["add","['" + idnum + "']",{"cls": "tileset", "id": "X"+idnum, "noPass": true}]);
ii++;
}
value[1] = "['" + idnum + "']" + value[1]; value[1] = "['" + idnum + "']" + value[1];
}); }
saveSetting('maps', actionList, function (err) { saveSetting('maps', actionList, function (err) {
callback([ callback([
(function () { (function () {
var locObj = Object.assign({}, editor.core.maps.blocksInfo[idnum]); var sourceobj=editor.core.maps.blocksInfo[idnum];
if(!isset(sourceobj) && idnum>=editor.core.icons.tilesetStartOffset)sourceobj={"cls": "tileset", "id": "X"+idnum, "noPass": true}
var locObj = Object.assign({}, sourceobj);
Object.keys(editor_file.comment._data.maps._data).forEach(function (v) { Object.keys(editor_file.comment._data.maps._data).forEach(function (v) {
if (!isset(editor.core.maps.blocksInfo[idnum][v])) if (!isset(sourceobj[v]))
locObj[v] = null; locObj[v] = null;
}); });
locObj.idnum = idnum; locObj.idnum = idnum;
@ -496,9 +505,11 @@ editor_file = function (editor, callback) {
} else { } else {
callback([ callback([
(function () { (function () {
var locObj = Object.assign({}, editor.core.maps.blocksInfo[idnum]); var sourceobj=editor.core.maps.blocksInfo[idnum];
if(!isset(sourceobj) && idnum>=editor.core.icons.tilesetStartOffset)sourceobj={"cls": "tileset", "id": "X"+idnum, "noPass": true}
var locObj = Object.assign({}, sourceobj);
Object.keys(editor_file.comment._data.maps._data).forEach(function (v) { Object.keys(editor_file.comment._data.maps._data).forEach(function (v) {
if (!isset(editor.core.maps.blocksInfo[idnum][v])) if (!isset(sourceobj[v]))
locObj[v] = null; locObj[v] = null;
}); });
locObj.idnum = idnum; locObj.idnum = idnum;

View File

@ -320,18 +320,11 @@ editor_mode = function (editor) {
if (!core.isset(editor_mode.info.id)) { if (!core.isset(editor_mode.info.id)) {
// document.getElementById('table_a3f03d4c_55b8_4ef6_b362_b345783acd72').innerHTML = ''; // document.getElementById('table_a3f03d4c_55b8_4ef6_b362_b345783acd72').innerHTML = '';
document.getElementById('enemyItemTable').style.display = 'none'; document.getElementById('enemyItemTable').style.display = 'none';
document.getElementById('tilesetsDiv').style.display = 'none';
document.getElementById('newIdIdnum').style.display = 'block'; document.getElementById('newIdIdnum').style.display = 'block';
return; return;
} }
if (editor_mode.info.isTile) {
document.getElementById('enemyItemTable').style.display = 'none';
document.getElementById('tilesetsDiv').style.display = 'block';
document.getElementById('newIdIdnum').style.display = 'none';
return;
}
document.getElementById('newIdIdnum').style.display = 'none'; document.getElementById('newIdIdnum').style.display = 'none';
document.getElementById('tilesetsDiv').style.display = 'none';
document.getElementById('enemyItemTable').style.display = 'block'; document.getElementById('enemyItemTable').style.display = 'block';
var objs = []; var objs = [];

View File

@ -95,9 +95,6 @@
<h3 class="leftTabHeader">图块属性&nbsp;&nbsp;<button onclick="editor.mode.onmode('save')">保存</button> <h3 class="leftTabHeader">图块属性&nbsp;&nbsp;<button onclick="editor.mode.onmode('save')">保存</button>
</h3> </h3>
<div class="leftTabContent"> <div class="leftTabContent">
<div id='tilesetsDiv'><!-- tilesets -->
<p>tilesets不允许编辑图块属性</p>
</div>
<div id='newIdIdnum'><!-- id and idnum --> <div id='newIdIdnum'><!-- id and idnum -->
<input placeholder="新id唯一标识符"/> <input placeholder="新id唯一标识符"/>
<input placeholder="新idnum1000以内数字"/> <input placeholder="新idnum1000以内数字"/>

View File

@ -94,9 +94,6 @@
<h3 class="leftTabHeader">图块属性&nbsp;&nbsp;<button onclick="editor.mode.onmode('save')">保存</button> <h3 class="leftTabHeader">图块属性&nbsp;&nbsp;<button onclick="editor.mode.onmode('save')">保存</button>
</h3> </h3>
<div class="leftTabContent"> <div class="leftTabContent">
<div id='tilesetsDiv'><!-- tilesets -->
<p>tilesets不允许编辑图块属性</p>
</div>
<div id='newIdIdnum'><!-- id and idnum --> <div id='newIdIdnum'><!-- id and idnum -->
<input placeholder="新id唯一标识符"/> <input placeholder="新id唯一标识符"/>
<input placeholder="新idnum1000以内数字"/> <input placeholder="新idnum1000以内数字"/>