diff --git a/_server/comment.js b/_server/comment.js index e7e80b72..72474062 100644 --- a/_server/comment.js +++ b/_server/comment.js @@ -1,14 +1,14 @@ var comment_c456ea59_6018_45ef_8bcc_211a24c627dc = { - "_leaf": false, + "_type": "object", "_data": { "items": { - "_leaf": false, + "_type": "object", "_data": { "items": { - "_leaf": false, + "_type": "object", "_data": { "cls": { @@ -89,7 +89,7 @@ var comment_c456ea59_6018_45ef_8bcc_211a24c627dc = }, "items_template" : {'cls': 'items', 'name': '新物品'}, "enemys": { - "_leaf": false, + "_type": "object", "_data": { "name": { @@ -197,7 +197,7 @@ var comment_c456ea59_6018_45ef_8bcc_211a24c627dc = }, "enemys_template" : {'name': '新敌人', 'hp': 0, 'atk': 0, 'def': 0, 'money': 0, 'experience': 0, 'point': 0, 'special': 0}, "maps": { - "_leaf": false, + "_type": "object", "_data": { "id": { @@ -271,11 +271,11 @@ var comment_c456ea59_6018_45ef_8bcc_211a24c627dc = } }, "floors": { - "_leaf": false, + "_type": "object", "_data": { "floor": { - "_leaf": false, + "_type": "object", "_data": { "floorId": { @@ -407,7 +407,7 @@ var comment_c456ea59_6018_45ef_8bcc_211a24c627dc = } }, "loc": { - "_leaf": false, + "_type": "object", "_data": { "events": { diff --git a/_server/css/editor.css b/_server/css/editor.css index ffd78e80..3ad43d05 100644 --- a/_server/css/editor.css +++ b/_server/css/editor.css @@ -254,6 +254,22 @@ body { overflow: auto; } +#edata{ + position: absolute; + z-index:0; + left: 0; + top: 0; +} + +#iconImages { + z-index: 0; + overflow: hidden; +} + +#iconImages img { + position: absolute; +} + .egameCanvas { position: absolute; } diff --git a/_server/css/editor_mobile.css b/_server/css/editor_mobile.css index 9f3f81ff..0aba4685 100644 --- a/_server/css/editor_mobile.css +++ b/_server/css/editor_mobile.css @@ -238,6 +238,22 @@ body { overflow: auto; } +#edata{ + position: absolute; + z-index:0; + left: 0; + top: 0; +} + +#iconImages { + z-index: 0; + overflow: hidden; +} + +#iconImages img { + position: absolute; +} + .egameCanvas { position: absolute; } diff --git a/_server/data.comment.js b/_server/data.comment.js index 17cad58a..8f157bcf 100644 --- a/_server/data.comment.js +++ b/_server/data.comment.js @@ -1,10 +1,10 @@ var data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = { - "_leaf": false, + "_type": "object", "_data": { "main": { - "_leaf": false, + "_type": "object", "_data": { "floorIds": { @@ -125,7 +125,7 @@ var data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = } }, "firstData": { - "_leaf": false, + "_type": "object", "_data": { "title": { @@ -154,7 +154,7 @@ var data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = "_data": "初始楼层的ID" }, "hero": { - "_leaf": false, + "_type": "object", "_data": { "name": { @@ -214,7 +214,7 @@ var data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = "_data": "初始装上的装备,此处建议请直接留空数组" }, "items": { - "_leaf": false, + "_type": "object", "_data": { "keys": { @@ -245,7 +245,7 @@ var data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = "_data": "初始可飞的楼层;一般留空数组即可" }, "loc": { - "_leaf": false, + "_type": "object", "_data": { "direction": { @@ -316,7 +316,7 @@ var data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = } }, "values": { - "_leaf": false, + "_type": "object", "_data": { "lavaDamage": { @@ -407,7 +407,7 @@ var data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = } }, "flags": { - "_leaf": false, + "_type": "object", "_data": { "enableFloor": { diff --git a/_server/editor.js b/_server/editor.js index 66731a6d..884efd3c 100644 --- a/_server/editor.js +++ b/_server/editor.js @@ -417,7 +417,46 @@ editor.prototype.drawInitData = function (icons) { if (fullWidth > edata.width) edata.style.width = (edata.width = fullWidth) / ratio + 'px'; edata.style.height = (edata.height = fullHeight) / ratio + 'px'; - var dc = edata.getContext('2d'); + iconImages.style.width = (iconImages.width = fullWidth) / ratio + 'px'; + iconImages.style.height = (iconImages.height = fullHeight) / ratio + 'px'; + var dc = {drawImage:function(){ + var image, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight; + var a=Array.from(arguments) + if(arguments.length==3){ + // [image, dx, dy]=arguments + // [sx, sy, sWidth, sHeight, dWidth, dHeight]=[0,0,image.width,image.height,image.width,image.height] + image=a[0] + a=[a[0],0,0,image.width,image.height,a[1],a[2],image.width,image.height] + } + if(arguments.length==5){ + // [image, dx, dy, dWidth, dHeight]=arguments + // [sx, sy, sWidth, sHeight]=[0,0,image.width,image.height] + image=a[0] + a=[a[0],0,0,image.width,image.height,a[1],a[2],a[3],a[4]] + } + if(arguments.length==9){ + // [image, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight]=arguments + } + image=a[0]; + sx=a[1]; + sy=a[2]; + sWidth=a[3]; + sHeight=a[4]; + dx=a[5]; + dy=a[6]; + dWidth=a[7]; + dHeight=a[8]; + //放弃对 dWidth, dHeight 的支持, 始终画一样大的 + var dimg=new Image() + dimg.src = image.src; + dimg.style.clip=['rect(',sy,'px,',sx+sWidth,'px,',sy+sHeight,'px,',sx,'px)'].join('') + dimg.style.top=dy-sy+'px' + dimg.style.left=dx-sx+'px' + dimg.width=image.width/ratio + dimg.height=image.height/ratio + iconImages.appendChild(dimg) + }} + // var dc = edata.getContext('2d'); var nowx = 0; var nowy = 0; for (var ii = 0; ii < imgNames.length; ii++) { diff --git a/_server/editor_file.js b/_server/editor_file.js index 0304d2f1..2fe185c5 100644 --- a/_server/editor_file.js +++ b/_server/editor_file.js @@ -82,7 +82,7 @@ editor_file = function (editor, callback) { callback('未选中文件或无数据'); } */ var filename = 'project/floors/' + editor.currentFloorId + '.js'; - var datastr = ['main.floors.', editor.currentFloorId, '=\n{']; + var datastr = ['main.floors.', editor.currentFloorId, '=\n']; if (editor.currentFloorData.map == 'new') { /* editor.currentFloorData.map = editor.map.map(function (v) { @@ -108,14 +108,18 @@ editor_file = function (editor, callback) { editor.currentFloorData[name]=mapArray; } } - for (var ii in editor.currentFloorData) - if (editor.currentFloorData.hasOwnProperty(ii)) { - if (['map','bgmap','fgmap'].indexOf(ii)!==-1) - datastr = datastr.concat(['\n"', ii, '": [\n', formatMap(editor.currentFloorData[ii],ii!='map'), '\n],']); - else - datastr = datastr.concat(['\n"', ii, '": ', JSON.stringify(editor.currentFloorData[ii], null, 4), ',']); - } - datastr = datastr.concat(['\n}']); + // format 更改实现方式以支持undefined删除 + var tempJsonObj=Object.assign({},editor.currentFloorData); + var tempMap=[['map',editor.guid()],['bgmap',editor.guid()],['fgmap',editor.guid()]]; + tempMap.forEach(function(v){ + v[2]=tempJsonObj[v[0]]; + tempJsonObj[v[0]]=v[1]; + }); + var tempJson=JSON.stringify(tempJsonObj, null, 4); + tempMap.forEach(function(v){ + tempJson=tempJson.replace('"'+v[1]+'"','[\n'+ formatMap(v[2],v[0]!='map')+ '\n]') + }); + datastr = datastr.concat([tempJson]); datastr = datastr.join(''); alertWhenCompress(); fs.writeFile(filename, encode(datastr), 'base64', function (err, data) { @@ -626,7 +630,7 @@ editor_file = function (editor, callback) { actionList.forEach(function (value) { value[1] = value[1] + "['" + x + "," + y + "']"; }); - saveSetting('floors', actionList, function (err) { + saveSetting('floorloc', actionList, function (err) { callback([ (function () { var locObj = {}; @@ -745,7 +749,7 @@ editor_file = function (editor, callback) { if (isset(editor.main[v])) locObj.main[v] = data_obj.main[v]; else - locObj[v] = null; + locObj.main[v] = null; }); return locObj; })(), @@ -761,7 +765,7 @@ editor_file = function (editor, callback) { if (isset(editor.main[v])) locObj.main[v] = data_obj.main[v]; else - locObj[v] = null; + locObj.main[v] = null; }); return locObj; })(), @@ -976,13 +980,18 @@ editor_file = function (editor, callback) { }); return; } - if (file == 'floors') { + if (file == 'floorloc') { actionList.forEach(function (value) { // 检测null/undefined - if (core.isset(value[2])) - eval("editor.currentFloorData" + value[1] + '=' + JSON.stringify(value[2])); - else - eval("delete editor.currentFloorData"+value[1]); + if (!core.isset(value[2]))value[2]=undefined; + eval("editor.currentFloorData" + value[1] + '=' + JSON.stringify(value[2])); + }); + editor_file.saveFloorFile(callback); + return; + } + if (file == 'floors') { + actionList.forEach(function (value) { + eval("editor.currentFloorData" + value[1] + '=' + JSON.stringify(value[2])); }); editor_file.saveFloorFile(callback); return; diff --git a/_server/editor_mode.js b/_server/editor_mode.js index 63cf5fce..45dd604f 100644 --- a/_server/editor_mode.js +++ b/_server/editor_mode.js @@ -18,6 +18,7 @@ editor_mode = function (editor) { this.mode = ''; this.info = {}; this.appendPic = {}; + this.doubleClickMode='change'; } editor_mode.prototype.init = function (callback) { @@ -91,9 +92,25 @@ editor_mode = function (editor) { * @param {Object} pcobj */ var recursionParse = function (pfield, pcfield, pvobj, pcobj) { + var keysForTableOrder={}; + var voidMark={}; // 1. 按照pcobj排序生成 + if (pcobj && pcobj['_data']){ + for (var ii in pcobj['_data']) keysForTableOrder[ii]=voidMark; + } // 2. 对每个pvobj且不在pcobj的,再添加到最后 - var generate = function (ii) { + keysForTableOrder=Object.assign(keysForTableOrder,pvobj) + for (var ii in keysForTableOrder) { + // 3. 对于pcobj有但是pvobj中没有的, 弹出提示, (正常情况下editor_file会补全成null) + // 事实上能执行到这一步工程没崩掉打不开,就继续吧.. + if(keysForTableOrder[ii]===voidMark){ + if(typeof id_815975ad_ee6f_4684_aac7_397b7e392702==="undefined"){ + alert('comment和data不匹配,请在群 HTML5造塔技术交流群 959329661 内反馈') + console.error('comment和data不匹配,请在群 HTML5造塔技术交流群 959329661 内反馈') + id_815975ad_ee6f_4684_aac7_397b7e392702=1; + } + pvobj[ii]=null; + } var field = pfield + "['" + ii + "']"; var cfield = pcfield + "['_data']['" + ii + "']"; var vobj = pvobj[ii]; @@ -113,7 +130,7 @@ editor_mode = function (editor) { if (cobj[key] instanceof Function) cobj[key] = cobj[key](args); } // 标记为_hide的属性不展示 - if (cobj._hide) return; + if (cobj._hide)continue; if (!cobj._leaf) { // 不是叶节点时, 插入展开的标记并继续遍历, 此处可以改成按钮用来添加新项或折叠等 outstr.push(["