diff --git a/2.0diff.md b/2.0diff.md index ebc3c1c3..2eb12662 100644 --- a/2.0diff.md +++ b/2.0diff.md @@ -139,14 +139,11 @@ $textarea(evalstr)$end # todo & 目前的bug + `event`,`after...`在地图上没有标记,可以在右下角加类似于无`id`的红问号类似的绿色星号小标记 -+ 添加新图块只对地形好使,添加的新物品还是需要手动在`project/items.js`中加东西 -+ 目前未做$range(evalstr:thiseval)$end的检查 ++ [x] 添加新图块只对地形好使,添加的新物品还是需要手动在`project/items.js`中加东西 ++ [x] 目前未做$range(evalstr:thiseval)$end的检查 + 通过`core.values.redJewel`的方式设置物品加的数值,在全GUI下反而会不直观 + `idnum`上限改到`999`,不需要在`.js`中手动设置`idnum`的话,根据数字范围来约定类型意义不大,而且`400`内随便输个数就发现已经被占了,体验极差 + `editor.html`中独立换背景的功能不再需要,待移除 + 全GUI下编辑要经常保存修改后F5 -+ 目前的报错只是throw,如果不开F12注意不到有错误发生,修改没有生效 -+ 有待美化,以及做成标签页式的模式切换 -+ replay模式,这个功能对于魔塔网站以及贴吧活动很有意义 - -前三条我会尽快修复(添加) \ No newline at end of file ++ [x] 目前的报错只是throw,如果不开F12注意不到有错误发生,修改没有生效 ++ [x] 有待美化,以及做成标签页式的模式切换 \ No newline at end of file diff --git a/_server/README.md b/_server/README.md index ec9d1981..e75cf35d 100644 --- a/_server/README.md +++ b/_server/README.md @@ -18,7 +18,7 @@ editor.file.loadFloorFile editor.file.saveFloorFile editor.file.saveFloorFileAs ``` -6个编辑模式有关的查询 +编辑模式有关的查询 ```javascript editor.file.editItem('redJewel',[],function(a){console.log(a)}); editor.file.editEnemy('redBat',[],function(a){console.log(a)}); @@ -27,7 +27,7 @@ editor.file.editFloor([],function(a){console.log(a)}); editor.file.editTower([],function(a){console.log(a)}); editor.file.editFunctions([],function(a){console.log(a)}); ``` -6个编辑模式有关的编辑 +编辑模式有关的编辑 ```javascript editor.info={images: "terrains", y: 9}; editor.file.changeIdAndIdnum('yellowWall2',16,editor.info,function(a){console.log(a)}); @@ -50,14 +50,19 @@ editor.mode.functions(); ``` 切换模式 ```javascript -editor.mode.onmode(''); +editor.mode.onmode('');//清空 +editor.mode.onmode('save');//保存 +editor.mode.onmode('nextChange');//下次onmode时前端进行切换 + editor.mode.onmode('loc'); editor.mode.onmode('emenyitem'); editor.mode.onmode('floor'); editor.mode.onmode('tower'); editor.mode.onmode('functions'); +editor.mode.onmode('map'); +editor.mode.onmode('appendpic'); ``` -在切换模式时,改动才会保存到文件,并且需要刷新页面使得`editor`能看到改动 +在`onmode('save')`时,改动才会保存到文件,涉及到图片的改动需要刷新页面使得`editor`能看到 表格的`onchange`的实现中,获得当前模式的方式.不注意的话,修改`index.html`中页面的结构,会被坑 ```javascript @@ -83,8 +88,8 @@ editor_blockly.confirm(); ### 待调整 -多行文本编辑器独立作为组件 -editor_multi.js ++ [x] 多行文本编辑器独立作为组件 ++ [x] editor_multi.js ## z-index diff --git a/_server/editor_blockly.js b/_server/editor_blockly.js index 5348669e..86dbe348 100644 --- a/_server/editor_blockly.js +++ b/_server/editor_blockly.js @@ -312,7 +312,8 @@ editor_blockly.import = function(id_){ "['afterGetItem']":'afterGetItem', "['afterOpenDoor']":'afterOpenDoor', - "['firstData']['shops']":'shop', + //"['firstData']['shops']":'shop', + "--shop--未完成数组的处理":'shop', "['firstArrive']":'firstArrive', "['firstData']['startText']":'firstArrive', diff --git a/_server/editor_mode.js b/_server/editor_mode.js index c3f23bc9..6fffe579 100644 --- a/_server/editor_mode.js +++ b/_server/editor_mode.js @@ -38,11 +38,25 @@ editor_mode.prototype.init_dom_ids = function(callback){ editor_mode.prototype.objToTable = function(obj,commentObj){ var outstr=["\n条目注释值\n"]; var guids=[]; + var checkIsLeaf = function(obj,commentObj,field){ + var thiseval = eval('obj'+field); + if (thiseval == null || thiseval == undefined)return true;//null,undefined + if (typeof(thiseval) == typeof(''))return true;//字符串 + if (Object.keys(thiseval).length == 0)return true;//数字,true,false,空数组,空对象 + try { + var comment = eval('commentObj'+field); + if( comment.indexOf('$leaf') != -1){ + evalstr = comment.split('$leaf')[1].split('$end')[0]; + if(eval(evalstr) === true)return true; + } + } catch (error) {} + return false; + } //深度优先遍历 var recursionParse = function(tfield) { for(var ii in eval("obj"+tfield)){ var field = tfield+"['"+ii+"']"; - var isleaf = editor_mode.checkIsLeaf(obj,commentObj,field); + var isleaf = checkIsLeaf(obj,commentObj,field); if (isleaf) { var leafnode = editor_mode.objToTr(obj,commentObj,field); outstr.push(leafnode[0]); @@ -54,6 +68,13 @@ editor_mode.prototype.objToTable = function(obj,commentObj){ } } recursionParse(""); + var checkRange = function(comment,thiseval){ + if( comment.indexOf('$range') !== -1){ + var evalstr = comment.split('$range')[1].split('$end')[0]; + return eval(evalstr); + } + return true; + } var listen = function(guids) { guids.forEach(function(guid){ // tr>td[title=field] @@ -69,12 +90,12 @@ editor_mode.prototype.objToTable = function(obj,commentObj){ node = node.parentNode; } editor_mode.onmode(editor_mode._ids[node.getAttribute('id')]); - editor_mode.addAction(['change',field,JSON.parse(input.value)]); - //尚未完成,不完善,目前还没做$range的检查 - - // /*临时*/editor_mode.onmode('');/*临时*/ - //临时改为立刻写入文件,删去此句的时,切换模式才会真正写入 - //现阶段这样会更实用,20180218 + var thiseval = JSON.parse(input.value); + if(checkRange(comment,thiseval)){ + editor_mode.addAction(['change',field,thiseval]); + } else { + printe('输入的值不合要求,请鼠标放置在注释上查看说明'); + } } input.ondblclick = function(){ if(!editor_blockly.import(guid)) @@ -86,21 +107,6 @@ editor_mode.prototype.objToTable = function(obj,commentObj){ return {"HTML":outstr.join(''),"guids":guids,"listen":listen}; } -editor_mode.prototype.checkIsLeaf = function(obj,commentObj,field){ - var thiseval = eval('obj'+field); - if (thiseval == null || thiseval == undefined)return true;//null,undefined - if (typeof(thiseval) == typeof(''))return true;//字符串 - if (Object.keys(thiseval).length == 0)return true;//数字,true,false,空数组,空对象 - try { - var comment = eval('commentObj'+field); - if( comment.indexOf('$leaf') != -1){ - evalstr = comment.split('$leaf')[1].split('$end')[0]; - if(eval(evalstr) === true)return true; - } - } catch (error) {} - return false; -} - editor_mode.prototype.objToTr = function(obj,commentObj,field){ var guid = editor.guid(); var thiseval = eval('obj'+field); @@ -197,6 +203,12 @@ editor_mode.prototype.showMode = function (mode) { editor_mode.dom[mode].style=''; if(editor_mode[mode])editor_mode[mode](); document.getElementById('editModeSelect').value=mode; + var tips = [ + '涉及图片的更改需要F5刷新浏览器来生效', + '文本域可以通过双击,在文本编辑器或事件编辑器中编辑', + '事件编辑器中的显示文本和自定义脚本的方块也可以双击', + ]; + if(!selectBox.isSelected)printf('tips: '+tips[~~(tips.length*Math.random())]); } editor_mode.prototype.loc = function(callback){ @@ -462,7 +474,7 @@ editor_mode.prototype.listen = function(callback){ var imgbase64 = sprite.toDataURL().split(',')[1]; fs.writeFile('./project/images/'+editor_mode.appendPic.imageName+'.png',imgbase64,'base64',function(err,data){ if(err){printe(err);throw(err)} - printe('追加素材成功,请刷新编辑器'); + printe('追加素材成功,请F5刷新编辑器'); }); } diff --git a/project/comment.js b/project/comment.js index 4bf4c47e..dfd1aed8 100644 --- a/project/comment.js +++ b/project/comment.js @@ -37,13 +37,13 @@ comment_c456ea59_6018_45ef_8bcc_211a24c627dc = "name": "显示在状态栏中的层数 ", "canFlyTo": "该楼能否被楼传器飞到(不能的话在该楼也不允许使用楼传器) \n$select({\"values\":[true,false]})$end", "canUseQuickShop": "该层是否允许使用快捷商店 \n$select({\"values\":[true,false]})$end", - "defaultGround": "默认地面的图块ID(terrains中) ", + "defaultGround": "默认地面的图块ID(terrains中) \n$select({\"values\":Object.keys(editor.core.icons.icons.terrains)})$end", "png": "背景图;你可以选择一张png图片来作为背景素材。详细用法请参见文档“自定义素材”中的说明。 \n$leaf(true)$end", "color": "该层的默认画面色调。本项可不写(代表无色调),如果写需要是一个RGBA数组。 \n$leaf(true)$end", "weather": "该层的默认天气。本项可忽略表示晴天,如果写则第一项为\"rain\"或\"snow\"代表雨雪,第二项为1-10之间的数代表强度。 \n$leaf(true)$end", "bgm": "到达该层后默认播放的BGM。本项可忽略。 ", //"map": "地图数据,需要是13x13,建议使用地图生成器来生成 ", - "item_ratio": "每一层的宝石/血瓶效果,即获得宝石和血瓶时框内\"ratio\"的值。", + "item_ratio": "每一层的宝石/血瓶效果,即获得宝石和血瓶时框内\"ratio\"的值。$range((thiseval==~~thiseval && thiseval>0)||thiseval==null)$end", "firstArrive": "第一次到该楼层触发的事件 \n$leaf(true)$end", }, 'loc' : {