Last Used Items

This commit is contained in:
ckcz123 2018-12-13 15:10:55 +08:00
parent 08683c9156
commit 5669197fbc

View File

@ -282,6 +282,7 @@ editor_blockly.searchBlockCategoryCallback = function(workspace) {
MotaActionBlocks[editor_blockly.lastUsedType[i]].xmlText() + MotaActionBlocks[editor_blockly.lastUsedType[i]].xmlText() +
'</xml>'; '</xml>';
var block = Blockly.Xml.textToDom(blockText).firstChild; var block = Blockly.Xml.textToDom(blockText).firstChild;
block.setAttribute("gap", 5);
xmlList.push(block); xmlList.push(block);
} }
return xmlList; return xmlList;
@ -311,7 +312,7 @@ document.getElementById('blocklyDiv').onmousewheel = function(e){
var doubleClickCheck=[[0,'abc']]; var doubleClickCheck=[[0,'abc']];
function omitedcheckUpdateFunction(event) { function omitedcheckUpdateFunction(event) {
if(event.type==='ui'||event.type==='move'){ if(event.type==='move'){
editor_blockly.addIntoLastUsedType(event.blockId); editor_blockly.addIntoLastUsedType(event.blockId);
} }
if(event.type==='ui'){ if(event.type==='ui'){
@ -535,18 +536,18 @@ document.getElementById('blocklyDiv').onmousewheel = function(e){
} }
editor_blockly.lastUsedType=['comment_s']//初始空着比较难看 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); var b = editor_blockly.workspace.getBlockById(blockId);
if(!b)return; if(!b)return;
var blockType = b.type; var blockType = b.type;
if(!blockType || ['pass_s','emptyshop'].indexOf(blockType)!==-1)return; if(!blockType || blockType.indexOf("_s")!==blockType.length-2 || blockType==='pass_s')return;
if(editor_blockly.lastUsedType.indexOf(blockType)!==-1){ console.log(b);
editor_blockly.lastUsedType.splice(editor_blockly.lastUsedType.indexOf(blockType),1) editor_blockly.lastUsedType = editor_blockly.lastUsedType.filter(function (v) {return v!==blockType;});
} if (editor_blockly.lastUsedType.length >= editor_blockly.lastUsedTypeNum)
editor_blockly.lastUsedType.unshift(blockType) editor_blockly.lastUsedType.pop();
editor_blockly.lastUsedType=editor_blockly.lastUsedType.slice(0,editor_blockly.lastUsedTypeNum) editor_blockly.lastUsedType.unshift(blockType);
} }
return editor_blockly; return editor_blockly;