From 682873673b6170e02b69cf686bd64bcc74543943 Mon Sep 17 00:00:00 2001 From: YouWei Zhao Date: Wed, 12 Dec 2018 18:27:34 -0500 Subject: [PATCH 01/13] lastusedblocks --- _server/editor_blockly.js | 50 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 3 deletions(-) diff --git a/_server/editor_blockly.js b/_server/editor_blockly.js index 864fb7fd..4d4af6a0 100644 --- a/_server/editor_blockly.js +++ b/_server/editor_blockly.js @@ -4,12 +4,13 @@ editor_blockly = function () { initscript = String.raw` (function(){ - var getCategory = function(name){ + var getCategory = function(name,custom){ for(var node of document.getElementById('toolbox').children) { if(node.getAttribute('name')==name) return node; } var node = document.createElement('category'); node.setAttribute('name',name); + if(custom)node.setAttribute('custom',custom); document.getElementById('toolbox').appendChild(node); return node; } @@ -243,15 +244,19 @@ editor_blockly = function () { } ] },'event'), - ], + '最近使用':[ + '', + ] } var toolboxgap = '' //xml_text = MotaActionFunctions.actionParser.parse(obj,type||'event') //MotaActionBlocks['idString_e'].xmlText() for (var name in toolboxObj){ - getCategory(name).innerHTML = toolboxObj[name].join(toolboxgap); + var custom = null; + if(name=='最近使用')custom='searchBlockCategory'; + getCategory(name,custom).innerHTML = toolboxObj[name].join(toolboxgap); } var blocklyArea = document.getElementById('blocklyArea'); @@ -269,6 +274,24 @@ var workspace = Blockly.inject(blocklyDiv,{ }, trashcan: false, }); + +editor_blockly.searchBlockCategoryCallback = function(workspace) { + //var colourList = ['#4286f4', '#ef0447']; + var xmlList = []; + if (Blockly.Blocks['colour_picker']) { + for (var i = 0; i < editor_blockly.lastUsedType.length; i++) { + var blockText = '' + + MotaActionBlocks[editor_blockly.lastUsedType[i]].xmlText() + + ''; + var block = Blockly.Xml.textToDom(blockText).firstChild; + xmlList.push(block); + } + } + return xmlList; +}; + +workspace.registerToolboxCategoryCallback( + 'searchBlockCategory', editor_blockly.searchBlockCategoryCallback); var onresize = function(e) { blocklyDiv.style.width = blocklyArea.offsetWidth + 'px'; @@ -291,6 +314,12 @@ document.getElementById('blocklyDiv').onmousewheel = function(e){ var doubleClickCheck=[[0,'abc']]; function omitedcheckUpdateFunction(event) { + console.log(event) + console.log(event.type) + + if(event.type==='ui'||event.type==='move'){ + editor_blockly.addIntoLastUsedType(event.blockId); + } if(event.type==='ui'){ var newClick = [new Date().getTime(),event.blockId]; var lastClick = doubleClickCheck.shift(); @@ -511,6 +540,21 @@ document.getElementById('blocklyDiv').onmousewheel = function(e){ } } + editor_blockly.lastUsedType=['comment_s']//初始空着比较难看 + editor_blockly.lastUsedTypeNum=15 + + editor_blockly.addIntoLastUsedType=function(blockId){ + var b = editor_blockly.workspace.getBlockById(blockId); + if(!b)return; + var blockType = b.type; + if(!blockType || ['pass_s','emptyshop'].indexOf(blockType)!==-1)return; + if(editor_blockly.lastUsedType.indexOf(blockType)!==-1){ + editor_blockly.lastUsedType.splice(editor_blockly.lastUsedType.indexOf(blockType),1) + } + editor_blockly.lastUsedType.unshift(blockType) + editor_blockly.lastUsedType=editor_blockly.lastUsedType.slice(0,editor_blockly.lastUsedTypeNum) + } + return editor_blockly; } //editor_blockly=editor_blockly(); \ No newline at end of file From 556dd15dc2bf36c6461ac3b5187a829c1122eb50 Mon Sep 17 00:00:00 2001 From: YouWei Zhao Date: Wed, 12 Dec 2018 18:31:59 -0500 Subject: [PATCH 02/13] delete console.log(...) --- _server/editor_blockly.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/_server/editor_blockly.js b/_server/editor_blockly.js index 4d4af6a0..c8ff17ff 100644 --- a/_server/editor_blockly.js +++ b/_server/editor_blockly.js @@ -276,7 +276,6 @@ var workspace = Blockly.inject(blocklyDiv,{ }); editor_blockly.searchBlockCategoryCallback = function(workspace) { - //var colourList = ['#4286f4', '#ef0447']; var xmlList = []; if (Blockly.Blocks['colour_picker']) { for (var i = 0; i < editor_blockly.lastUsedType.length; i++) { @@ -314,9 +313,6 @@ document.getElementById('blocklyDiv').onmousewheel = function(e){ var doubleClickCheck=[[0,'abc']]; function omitedcheckUpdateFunction(event) { - console.log(event) - console.log(event.type) - if(event.type==='ui'||event.type==='move'){ editor_blockly.addIntoLastUsedType(event.blockId); } From 560c6136f7de463c183c6ee5ddd027316f4c5385 Mon Sep 17 00:00:00 2001 From: YouWei Zhao Date: Wed, 12 Dec 2018 18:33:57 -0500 Subject: [PATCH 03/13] fix --- _server/editor_blockly.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/_server/editor_blockly.js b/_server/editor_blockly.js index c8ff17ff..dd449a91 100644 --- a/_server/editor_blockly.js +++ b/_server/editor_blockly.js @@ -277,14 +277,12 @@ var workspace = Blockly.inject(blocklyDiv,{ editor_blockly.searchBlockCategoryCallback = function(workspace) { var xmlList = []; - if (Blockly.Blocks['colour_picker']) { - for (var i = 0; i < editor_blockly.lastUsedType.length; i++) { - var blockText = '' + - MotaActionBlocks[editor_blockly.lastUsedType[i]].xmlText() + - ''; - var block = Blockly.Xml.textToDom(blockText).firstChild; - xmlList.push(block); - } + for (var i = 0; i < editor_blockly.lastUsedType.length; i++) { + var blockText = '' + + MotaActionBlocks[editor_blockly.lastUsedType[i]].xmlText() + + ''; + var block = Blockly.Xml.textToDom(blockText).firstChild; + xmlList.push(block); } return xmlList; }; From 5669197fbceeb5e885bbf75eddd3f7222a4df7b5 Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Thu, 13 Dec 2018 15:10:55 +0800 Subject: [PATCH 04/13] Last Used Items --- _server/editor_blockly.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/_server/editor_blockly.js b/_server/editor_blockly.js index dd449a91..12959257 100644 --- a/_server/editor_blockly.js +++ b/_server/editor_blockly.js @@ -282,6 +282,7 @@ editor_blockly.searchBlockCategoryCallback = function(workspace) { MotaActionBlocks[editor_blockly.lastUsedType[i]].xmlText() + ''; var block = Blockly.Xml.textToDom(blockText).firstChild; + block.setAttribute("gap", 5); xmlList.push(block); } return xmlList; @@ -311,7 +312,7 @@ document.getElementById('blocklyDiv').onmousewheel = function(e){ var doubleClickCheck=[[0,'abc']]; function omitedcheckUpdateFunction(event) { - if(event.type==='ui'||event.type==='move'){ + if(event.type==='move'){ editor_blockly.addIntoLastUsedType(event.blockId); } if(event.type==='ui'){ @@ -535,18 +536,18 @@ document.getElementById('blocklyDiv').onmousewheel = function(e){ } editor_blockly.lastUsedType=['comment_s']//初始空着比较难看 - editor_blockly.lastUsedTypeNum=15 + editor_blockly.lastUsedTypeNum=15; - editor_blockly.addIntoLastUsedType=function(blockId){ + editor_blockly.addIntoLastUsedType=function(blockId) { var b = editor_blockly.workspace.getBlockById(blockId); if(!b)return; var blockType = b.type; - if(!blockType || ['pass_s','emptyshop'].indexOf(blockType)!==-1)return; - if(editor_blockly.lastUsedType.indexOf(blockType)!==-1){ - editor_blockly.lastUsedType.splice(editor_blockly.lastUsedType.indexOf(blockType),1) - } - editor_blockly.lastUsedType.unshift(blockType) - editor_blockly.lastUsedType=editor_blockly.lastUsedType.slice(0,editor_blockly.lastUsedTypeNum) + if(!blockType || blockType.indexOf("_s")!==blockType.length-2 || blockType==='pass_s')return; + console.log(b); + editor_blockly.lastUsedType = editor_blockly.lastUsedType.filter(function (v) {return v!==blockType;}); + if (editor_blockly.lastUsedType.length >= editor_blockly.lastUsedTypeNum) + editor_blockly.lastUsedType.pop(); + editor_blockly.lastUsedType.unshift(blockType); } return editor_blockly; From ecdea0785675f0ab60b51cba05aeaf0e75905cfc Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Thu, 13 Dec 2018 15:26:01 +0800 Subject: [PATCH 05/13] Frequently & Last Used Blocks --- _server/editor_blockly.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/_server/editor_blockly.js b/_server/editor_blockly.js index 12959257..a966619f 100644 --- a/_server/editor_blockly.js +++ b/_server/editor_blockly.js @@ -245,7 +245,7 @@ editor_blockly = function () { ] },'event'), ], - '最近使用':[ + '最近使用事件':[ '', ] } @@ -255,7 +255,7 @@ editor_blockly = function () { for (var name in toolboxObj){ var custom = null; - if(name=='最近使用')custom='searchBlockCategory'; + if(name=='最近使用事件')custom='searchBlockCategory'; getCategory(name,custom).innerHTML = toolboxObj[name].join(toolboxgap); } @@ -535,7 +535,22 @@ document.getElementById('blocklyDiv').onmousewheel = function(e){ } } - editor_blockly.lastUsedType=['comment_s']//初始空着比较难看 + editor_blockly.lastUsedType=[ + 'text_0_s', + 'comment_s', + 'show_s', + 'hide_s', + 'setValue_s', + 'if_s', + 'battle_s', + 'openDoor_s', + 'choices_s', + 'setText_s', + 'exit_s', + 'revisit_s', + 'sleep_s', + 'setBlock_s' + ]; // 最常用的15个图块 editor_blockly.lastUsedTypeNum=15; editor_blockly.addIntoLastUsedType=function(blockId) { From e4d985c8b6963621d6f0cbd669297950aa350be8 Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Thu, 13 Dec 2018 17:22:56 +0800 Subject: [PATCH 06/13] Fix paint bugs --- libs/utils.js | 12 +++++++----- project/functions.js | 4 ++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/libs/utils.js b/libs/utils.js index e7ba2f23..45313e71 100644 --- a/libs/utils.js +++ b/libs/utils.js @@ -813,6 +813,12 @@ utils.prototype.encodeCanvas = function (ctx) { ////// 解析arr数组,并绘制到tempCanvas上 ////// utils.prototype.decodeCanvas = function (arr, width, height) { + // 清空tempCanvas + var tempCanvas = core.bigmap.tempCanvas; + tempCanvas.canvas.width=width; + tempCanvas.canvas.height=height; + tempCanvas.clearRect(0, 0, width, height); + if (!core.isset(arr)) return null; // to byte array var curr = 0, list = []; @@ -820,11 +826,6 @@ utils.prototype.decodeCanvas = function (arr, width, height) { for (var i=0;i threshold diff --git a/project/functions.js b/project/functions.js index 21852685..0d47e471 100644 --- a/project/functions.js +++ b/project/functions.js @@ -1040,8 +1040,8 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = ctx.drawImage(core.statusBar.icons[name], leftOffset, topOffset, 25, 25); // 文字内容 var text = (core.statusBar[name]||{}).innerText || " "; - // 斜体判定:如果不是纯数字,斜体会非常难看,需要取消 - if (!/^\d*$/.test(text)) ctx.font = 'bold 18px Verdana'; + // 斜体判定:如果不是纯数字和字母,斜体会非常难看,需要取消 + if (!/^[-+_.a-zA-Z0-9]*$/.test(text)) ctx.font = 'bold 18px Verdana'; // 绘制文字 ctx.fillText(text, leftOffset + 36, topOffset + 20); ctx.font = 'italic bold 18px Verdana'; From efacefbc587ee507ba8618e0f4d0f4d7579628e5 Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Thu, 13 Dec 2018 18:32:05 +0800 Subject: [PATCH 07/13] Fix showImage with flag --- libs/events.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/events.js b/libs/events.js index f17e8529..9998e01f 100644 --- a/libs/events.js +++ b/libs/events.js @@ -1548,7 +1548,7 @@ events.prototype.changeFloor = function (floorId, stair, heroLoc, time, callback ////// 绘制图片 ////// events.prototype.showImage = function (name, x, y) { if (core.isset(name) && core.isset(x) && core.isset(y) && core.isset(core.material.images.images[name])) { - core.canvas.image.drawImage(core.material.images.images[name], x, y); + core.canvas.image.drawImage(core.material.images.images[name], core.calValue(x), core.calValue(y)); } else core.clearMap('image'); } From 71f03ffbfe687af03210f74c6ddaa76f3d9e9d47 Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Thu, 13 Dec 2018 20:41:20 +0800 Subject: [PATCH 08/13] Search --- _server/css/editor.css | 18 +++++++++++ _server/editor_blockly.js | 63 ++++++++++++++++++++++++++++++++++++--- editor.html | 4 +++ 3 files changed, 81 insertions(+), 4 deletions(-) diff --git a/_server/css/editor.css b/_server/css/editor.css index 928a0964..c5837379 100644 --- a/_server/css/editor.css +++ b/_server/css/editor.css @@ -392,3 +392,21 @@ table.row td { [v-cloak] { display: none !important; } + +#blockSearch { + width: 100px; + background-color: #E9EBF2; + border-radius: 10px; + outline: none; + padding-left: 20px; + height: 14px; +} + +.searchLogo { + width: 15px; + height: 15px; + position: absolute; + left: 6px; + top: 7px; + background-image:url('data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIGJhc2VQcm9maWxlPSJmdWxsIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4bWxuczpldj0iaHR0cDovL3d3dy53My5vcmcvMjAwMS94bWwtZXZlbnRzIj4KPGc%2BCgk8cG9seWdvbiBmaWxsPSIjNjY2IiBwb2ludHM9IjkuMjA3LDYuMTI2IDcuNzkzLDcuNTQxIDExLjc5MywxMS41NDEgMTMuMjA3LDEwLjEyNiIgLz4KCTxwYXRoIGZpbGw9IiM2NjYiIGQ9Ik01LjkxNywyYzEuNjA4LDAsMi45MTcsMS4zMDgsMi45MTcsMi45MTdTNy41MjUsNy44MzMsNS45MTcsNy44MzNTMyw2LjUyNSwzLDQuOTE3UzQuMzA4LDIsNS45MTcsMgoJCSBNNS45MTcsMEMzLjIwMSwwLDEsMi4yMDEsMSw0LjkxN3MyLjIwMSw0LjkxNyw0LjkxNyw0LjkxN3M0LjkxNy0yLjIwMSw0LjkxNy00LjkxN0MxMC44MzMsMi4yMDEsOC42MzIsMCw1LjkxNywwTDUuOTE3LDB6IiAvPgo8L2c%2BCjwvc3ZnPgo%3D'); +} \ No newline at end of file diff --git a/_server/editor_blockly.js b/_server/editor_blockly.js index a966619f..1d12d9ad 100644 --- a/_server/editor_blockly.js +++ b/_server/editor_blockly.js @@ -277,9 +277,10 @@ var workspace = Blockly.inject(blocklyDiv,{ editor_blockly.searchBlockCategoryCallback = function(workspace) { var xmlList = []; - for (var i = 0; i < editor_blockly.lastUsedType.length; i++) { + var labels = editor_blockly.searchBlock(); + for (var i = 0; i < labels.length; i++) { var blockText = '' + - MotaActionBlocks[editor_blockly.lastUsedType[i]].xmlText() + + MotaActionBlocks[labels[i]].xmlText() + ''; var block = Blockly.Xml.textToDom(blockText).firstChild; block.setAttribute("gap", 5); @@ -310,8 +311,8 @@ document.getElementById('blocklyDiv').onmousewheel = function(e){ workspace.setScale(workspace.scale); } - var doubleClickCheck=[[0,'abc']]; - function omitedcheckUpdateFunction(event) { +var doubleClickCheck=[[0,'abc']]; +function omitedcheckUpdateFunction(event) { if(event.type==='move'){ editor_blockly.addIntoLastUsedType(event.blockId); } @@ -565,6 +566,60 @@ document.getElementById('blocklyDiv').onmousewheel = function(e){ editor_blockly.lastUsedType.unshift(blockType); } + // Index from 1 - 9 + editor_blockly.openToolbox = function(index) { + var element = document.getElementById(':'+index); + if (element == null || element.getAttribute("aria-selected")=="true") return; + element.click(); + } + editor_blockly.reopenToolbox = function(index) { + var element = document.getElementById(':'+index); + if (element == null) return; + if (element.getAttribute("aria-selected")=="true") element.click(); + element.click(); + } + + editor_blockly.closeToolbox = function() { + for (var i=1; i<=10; i++) { + var element = document.getElementById(':'+i); + if (element && element.getAttribute("aria-selected")=="true") { + element.click(); + return; + } + } + } + + var searchInput = document.getElementById("blockSearch"); + searchInput.onfocus = function () { + editor_blockly.reopenToolbox(9); + } + + searchInput.oninput = function () { + editor_blockly.reopenToolbox(9); + } + + editor_blockly.searchBlock = function (value) { + if (value == null) value = searchInput.value; + value = value.toLowerCase(); + if (value == '') return editor_blockly.lastUsedType; + var results = []; + for (var name in MotaActionBlocks) { + if (typeof name !== 'string' || name.indexOf("_s") !== name.length-2) continue; + var block = MotaActionBlocks[name]; + if(block && block.json) { + if ((block.json.type||"").toLowerCase().indexOf(value)>=0 + || (block.json.message0||"").toLowerCase().indexOf(value)>=0 + || (block.json.tooltip||"").toLowerCase().indexOf(value)>=0) { + results.push(name); + if (results.length>=editor_blockly.lastUsedTypeNum) + break; + } + } + } + + return results.length == 0 ? editor_blockly.lastUsedType : results; + } + return editor_blockly; } //editor_blockly=editor_blockly(); \ No newline at end of file diff --git a/editor.html b/editor.html index 54cdb46e..ce6bf5c2 100644 --- a/editor.html +++ b/editor.html @@ -178,6 +178,10 @@ +
+ + +
From 8d31055c5255657505935d201a7afed55168001f Mon Sep 17 00:00:00 2001 From: oc Date: Thu, 13 Dec 2018 22:43:28 +0800 Subject: [PATCH 09/13] Search Blockly --- _server/css/editor.css | 4 ++-- _server/editor_blockly.js | 27 +++++++++++++++++---------- editor-mobile.html | 5 +++++ editor.html | 2 +- 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/_server/css/editor.css b/_server/css/editor.css index c5837379..ebd4b009 100644 --- a/_server/css/editor.css +++ b/_server/css/editor.css @@ -393,7 +393,7 @@ table.row td { display: none !important; } -#blockSearch { +#searchBlock { width: 100px; background-color: #E9EBF2; border-radius: 10px; @@ -407,6 +407,6 @@ table.row td { height: 15px; position: absolute; left: 6px; - top: 7px; + top: 6px; background-image:url('data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIGJhc2VQcm9maWxlPSJmdWxsIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4bWxuczpldj0iaHR0cDovL3d3dy53My5vcmcvMjAwMS94bWwtZXZlbnRzIj4KPGc%2BCgk8cG9seWdvbiBmaWxsPSIjNjY2IiBwb2ludHM9IjkuMjA3LDYuMTI2IDcuNzkzLDcuNTQxIDExLjc5MywxMS41NDEgMTMuMjA3LDEwLjEyNiIgLz4KCTxwYXRoIGZpbGw9IiM2NjYiIGQ9Ik01LjkxNywyYzEuNjA4LDAsMi45MTcsMS4zMDgsMi45MTcsMi45MTdTNy41MjUsNy44MzMsNS45MTcsNy44MzNTMyw2LjUyNSwzLDQuOTE3UzQuMzA4LDIsNS45MTcsMgoJCSBNNS45MTcsMEMzLjIwMSwwLDEsMi4yMDEsMSw0LjkxN3MyLjIwMSw0LjkxNyw0LjkxNyw0LjkxN3M0LjkxNy0yLjIwMSw0LjkxNy00LjkxN0MxMC44MzMsMi4yMDEsOC42MzIsMCw1LjkxNywwTDUuOTE3LDB6IiAvPgo8L2c%2BCjwvc3ZnPgo%3D'); } \ No newline at end of file diff --git a/_server/editor_blockly.js b/_server/editor_blockly.js index 1d12d9ad..928c4803 100644 --- a/_server/editor_blockly.js +++ b/_server/editor_blockly.js @@ -313,7 +313,7 @@ document.getElementById('blocklyDiv').onmousewheel = function(e){ var doubleClickCheck=[[0,'abc']]; function omitedcheckUpdateFunction(event) { - if(event.type==='move'){ + if(event.type==='create'){ editor_blockly.addIntoLastUsedType(event.blockId); } if(event.type==='ui'){ @@ -559,27 +559,32 @@ function omitedcheckUpdateFunction(event) { if(!b)return; var blockType = b.type; if(!blockType || blockType.indexOf("_s")!==blockType.length-2 || blockType==='pass_s')return; - console.log(b); editor_blockly.lastUsedType = editor_blockly.lastUsedType.filter(function (v) {return v!==blockType;}); if (editor_blockly.lastUsedType.length >= editor_blockly.lastUsedTypeNum) editor_blockly.lastUsedType.pop(); editor_blockly.lastUsedType.unshift(blockType); + + document.getElementById("searchBlock").value=''; } // Index from 1 - 9 editor_blockly.openToolbox = function(index) { - var element = document.getElementById(':'+index); - if (element == null || element.getAttribute("aria-selected")=="true") return; - element.click(); + // var element = document.getElementById(':'+index); + // if (element == null || element.getAttribute("aria-selected")=="true") return; + // element.click(); + editor_blockly.workspace.toolbox_.tree_.setSelectedItem(editor_blockly.workspace.toolbox_.tree_.children_[index-1]); } editor_blockly.reopenToolbox = function(index) { - var element = document.getElementById(':'+index); - if (element == null) return; - if (element.getAttribute("aria-selected")=="true") element.click(); - element.click(); + // var element = document.getElementById(':'+index); + // if (element == null) return; + // if (element.getAttribute("aria-selected")=="true") element.click(); + // element.click(); + editor_blockly.workspace.toolbox_.tree_.setSelectedItem(editor_blockly.workspace.toolbox_.tree_.children_[index-1]); + editor_blockly.workspace.getFlyout_().show(editor_blockly.workspace.toolbox_.tree_.children_[index-1].blocks); } editor_blockly.closeToolbox = function() { + /* for (var i=1; i<=10; i++) { var element = document.getElementById(':'+i); if (element && element.getAttribute("aria-selected")=="true") { @@ -587,9 +592,11 @@ function omitedcheckUpdateFunction(event) { return; } } + */ + editor_blockly.workspace.toolbox_.clearSelection(); } - var searchInput = document.getElementById("blockSearch"); + var searchInput = document.getElementById("searchBlock"); searchInput.onfocus = function () { editor_blockly.reopenToolbox(9); } diff --git a/editor-mobile.html b/editor-mobile.html index c3396905..fedd1cb1 100644 --- a/editor-mobile.html +++ b/editor-mobile.html @@ -179,6 +179,11 @@ + +
+ + +
diff --git a/editor.html b/editor.html index ce6bf5c2..df51ae2e 100644 --- a/editor.html +++ b/editor.html @@ -180,7 +180,7 @@
- +
From 7be7d3706fa8ecbf7d3b8815d32ae7da0fed7cef Mon Sep 17 00:00:00 2001 From: oc Date: Thu, 13 Dec 2018 23:01:41 +0800 Subject: [PATCH 10/13] Loop Critical for Big Number --- libs/enemys.js | 4 +++- libs/ui.js | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/libs/enemys.js b/libs/enemys.js index a3097af3..bc1563b5 100644 --- a/libs/enemys.js +++ b/libs/enemys.js @@ -179,7 +179,9 @@ enemys.prototype.nextCriticals = function (enemy, number, x, y, floorId) { } else { // 暴力for循环法 pre = info.damage; - for (var atk=hero_atk+1;atk<=mon_hp+mon_def;atk++) { + var per_add = Math.ceil(hero_atk / 5000); + if (per_add<0) per_add = 1; + for (var atk=hero_atk+per_add;atk<=mon_hp+mon_def;atk+=per_add) { var nextInfo = this.getDamageInfo(enemy, core.status.hero.hp, atk, core.status.hero.def, core.status.hero.mdef, x, y, floorId); if (nextInfo==null) break; if (pre>nextInfo.damage) { diff --git a/libs/ui.js b/libs/ui.js index ec7c1dec..15f0bd0e 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -1645,7 +1645,7 @@ ui.prototype.drawBookDetail = function (index) { u.push(t); } }); - hints.push(JSON.stringify(u.map(function (v) {return v[0]+":"+v[1];}))); + hints.push(JSON.stringify(u.map(function (v) {return core.formatBigNumber(v[0])+":"+core.formatBigNumber(v[1]);}))); } } @@ -1679,7 +1679,7 @@ ui.prototype.drawBookDetail = function (index) { hints.push(""); var criticals = core.enemys.nextCriticals(enemyId, 10).map(function (v) { - return v[0]+":"+v[1]; + return core.formatBigNumber(v[0])+":"+core.formatBigNumber(v[1]); }); while (criticals[0]=='0:0') criticals.shift(); hints.push("临界表:"+JSON.stringify(criticals)) From e8559f3e2d07a54a2575c2b9caeef8b2cbde9dd0 Mon Sep 17 00:00:00 2001 From: oc Date: Thu, 13 Dec 2018 23:50:01 +0800 Subject: [PATCH 11/13] noGlobalAnimate --- _server/blockly/MotaAction.g4 | 11 ++++++----- _server/comment.js | 2 +- _server/editor.js | 9 ++++++++- libs/maps.js | 6 +++++- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/_server/blockly/MotaAction.g4 b/_server/blockly/MotaAction.g4 index 5b681deb..37dca134 100644 --- a/_server/blockly/MotaAction.g4 +++ b/_server/blockly/MotaAction.g4 @@ -5,22 +5,23 @@ grammar MotaAction; //事件 事件编辑器入口之一 event_m - : '事件' BGNL? Newline '覆盖触发器' Bool '启用' Bool '通行状态' B_0_List '显伤' Bool BGNL? Newline action+ BEND + : '事件' BGNL? Newline '覆盖触发器' Bool '启用' Bool '通行状态' B_0_List '动画' Bool '显伤' Bool BGNL? Newline action+ BEND /* event_m tooltip : 编辑魔塔的事件 helpUrl : https://h5mota.com/games/template/docs/#/event -default : [false,null,null,null] +default : [false,null,null,null,null] B_0_List_0=eval(B_0_List_0); var code = { 'trigger': Bool_0?'action':null, 'enable': Bool_1, 'noPass': B_0_List_0, - 'displayDamage': Bool_2, + 'animate': Bool_2, + 'displayDamage': Bool_3, 'data': 'data_asdfefw' } -if (!Bool_0 && Bool_1 && (B_0_List_0===null) && Bool_2) code = 'data_asdfefw'; +if (!Bool_0 && Bool_1 && (B_0_List_0===null) && Bool_2 && Bool_3) code = 'data_asdfefw'; code=JSON.stringify(code,null,2).split('"data_asdfefw"').join('[\n'+action_0+']\n'); return code; */; @@ -1803,7 +1804,7 @@ ActionParser.prototype.parse = function (obj,type) { if(typeof(obj)===typeof('')) obj={'data':[obj]}; if(obj instanceof Array) obj={'data':obj}; return MotaActionBlocks['event_m'].xmlText([ - obj.trigger==='action',obj.enable,obj.noPass,obj.displayDamage,this.parseList(obj.data) + obj.trigger==='action',obj.enable,obj.noPass,obj.animate,obj.displayDamage,this.parseList(obj.data) ]); case 'changeFloor': diff --git a/_server/comment.js b/_server/comment.js index c38b6cd9..41aa00ef 100644 --- a/_server/comment.js +++ b/_server/comment.js @@ -261,7 +261,7 @@ var comment_c456ea59_6018_45ef_8bcc_211a24c627dc = "_leaf": true, "_type": "textarea", "_range": "thiseval==null||(thiseval instanceof Array)", - "_data": "该图块的不可入方向\n可以在这里定义不能从哪个方向访问该图块,可以达到悬崖之类的效果\n例如 [\"down\", \"right\"] 代表不能从下或右访问此图块\n此值对背景层、事件层、前景层上的图块均有效" + "_data": "该图块的不可入方向\n可以在这里定义不能朝哪个方向进入该图块,可以达到悬崖之类的效果\n例如 [\"down\"] 代表不能从该图块的上方点朝向下进入此图块\n此值对背景层、事件层、前景层上的图块均有效" }, "faceIds": { "_leaf": true, diff --git a/_server/editor.js b/_server/editor.js index c9622e6f..f90a9b6f 100644 --- a/_server/editor.js +++ b/_server/editor.js @@ -295,11 +295,18 @@ editor.prototype.drawPosSelection = function () { } editor.prototype.updateMap = function () { + var evs = {}; + if (editor.currentFloorData && editor.currentFloorData.events) { + for (var loc in editor.currentFloorData.events) { + if (editor.currentFloorData.events[loc].animate == false) + evs[loc] = {"animate": false}; + } + } var blocks = main.editor.mapIntoBlocks(editor.map.map(function (v) { return v.map(function (v) { return v.idnum || v || 0 }) - }), {'events': {}, 'changeFloor': {}}, editor.currentFloorId); + }), {'events': evs, 'changeFloor': {}}, editor.currentFloorId); core.status.thisMap.blocks = blocks; main.editor.updateMap(); diff --git a/libs/maps.js b/libs/maps.js index 12865f76..1eff4460 100644 --- a/libs/maps.js +++ b/libs/maps.js @@ -146,9 +146,13 @@ maps.prototype.addEvent = function (block, x, y, event) { if (!core.isset(block.disable) && core.isset(event.enable)) { block.disable=!event.enable; } + // 覆盖animate + if (event.animate === false) { + block.event.animate = 1; + } // 覆盖所有属性 for (var key in event) { - if (key!="enable" && core.isset(event[key])) { + if (key!="enable" && key!="animate" && core.isset(event[key])) { block.event[key]=core.clone(event[key]); } } From f20d2e3c69acb08bfabeaa4aa518e8fac19b42bf Mon Sep 17 00:00:00 2001 From: oc Date: Fri, 14 Dec 2018 00:23:13 +0800 Subject: [PATCH 12/13] Fix battle check --- project/functions.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/project/functions.js b/project/functions.js index 0d47e471..a9fd87ac 100644 --- a/project/functions.js +++ b/project/functions.js @@ -526,9 +526,6 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = init_damage += vampire_damage; } - // 检查是否破防;否则直接返回不可战斗 - if (hero_atk <= mon_def) return null; - // 每回合怪物对勇士造成的战斗伤害 var per_damage = mon_atk - hero_def; // 魔攻:战斗伤害就是怪物攻击力 @@ -558,6 +555,10 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = // 勇士每回合对怪物造成的伤害 var hero_per_damage = hero_atk - mon_def; + + // 如果没有破防,则不可战斗 + if (hero_per_damage <= 0) return null; + // 勇士的攻击回合数;为怪物生命除以每回合伤害向上取整 var turn = Math.ceil(mon_hp / hero_per_damage); // 最终伤害:初始伤害 + 怪物对勇士造成的伤害 + 反击伤害 From 861a44ae20b098489d6ef6881d16543c20d7b61e Mon Sep 17 00:00:00 2001 From: oc Date: Fri, 14 Dec 2018 00:26:29 +0800 Subject: [PATCH 13/13] Fix battle check --- project/functions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/functions.js b/project/functions.js index a9fd87ac..9e06e527 100644 --- a/project/functions.js +++ b/project/functions.js @@ -554,7 +554,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = init_damage += Math.floor(core.values.purify * hero_mdef); // 勇士每回合对怪物造成的伤害 - var hero_per_damage = hero_atk - mon_def; + var hero_per_damage = Math.max(hero_atk - mon_def, 0); // 如果没有破防,则不可战斗 if (hero_per_damage <= 0) return null;