Skip to content

Commit

Permalink
整合最新更改,解决冲突
Browse files Browse the repository at this point in the history
Merge branch 'develop' into 4.0-flash

* develop: (68 commits)
  发布v3.4.5
  更新日语和韩语
  mac之前加的控制串口与上传Arduino按钮使能的关系,发现有问题,已去掉
  更新日语翻译
  微软认知服务json和xml判断
  修复PM2.5卡顿问题,将接收超时时间改为500ms,如果是蜂鸣器则还是5s
  update face api
  edited git ignore. for switching between 4.0 and 3.0
  更新翻译等
  修复 非串口连接不允许上传到arduiino
  fix 语句块中的模块指令,删除按钮有两个
  修正语言适配
  导出图片,遇到文件已存在,则弹出提示框询问是否替换,多个提示框则始终保持只有一个显示出来,避免造成多层蒙版叠在一起
  添加支持PM2.5传感器
  添加关闭欢迎界面函数
  在欢迎界面拖拽打开文件,要把欢迎界面移除
  fix bug #345: Arduino mode varibles
  “导出图片”菜单,遇到文件已存在的话,就会报错,现在修改为弹出提示框,是否覆盖
  upload按钮添加禁止使能样式
  fix 异常退出时自动保存当前工程,并在下一次启动时询问是否打开异常文件
  ...

Conflicts:
	.actionScriptProperties
	.gitignore
	libs/AIRSerial_mac.ane
	src/MBlock.as
	src/cc/makeblock/interpreter/RemoteCallMgr.as
	src/cc/makeblock/mbot/ui/parts/TopSystemMenu.as
	src/cc/makeblock/media/MediaManager.as
	src/extensions/ArduinoManager.as
	src/scratch/BlockMenus.as
	src/scratch/ScratchRuntime.as
	src/ui/parts/ScriptsPart.as
  • Loading branch information
Wang Yu committed Jan 9, 2017
2 parents ca068bb + 321f853 commit 3328daf
Show file tree
Hide file tree
Showing 341 changed files with 7,225 additions and 3,930 deletions.
Binary file added libs/AIRSerial_mac.ane
Binary file not shown.
5 changes: 3 additions & 2 deletions src/CSS.as
Expand Up @@ -23,7 +23,8 @@
// Styles for Scratch Editor based on the Upstatement design.

package {
import flash.text.*;
import flash.text.TextFormat;

import assets.Resources;

public class CSS {
Expand All @@ -42,7 +43,7 @@ public class CSS {
public static const onColor:int = textColor; // 0x4C4D4F
public static const overColor:int = 0x179FD7;
public static const arrowColor:int = 0xA6A8AC;

public static const disableColor:uint = 0xEEEEEE;
// Fonts
public static const font:String = Resources.chooseFont(['微软雅黑','Arial', 'Verdana', 'DejaVu Sans','Microsoft Yahei']);
public static const menuFontSize:int = 13;
Expand Down
4 changes: 2 additions & 2 deletions src/MBlock-app.xml
Expand Up @@ -15,7 +15,7 @@

<!-- A universally unique application identifier. Must be unique across all AIR applications.
Using a reverse DNS-style name as the id is recommended. (Eg. com.example.ExampleApplication.) Required. -->
<id>com.makeblock.Scratch3.4.2</id>
<id>com.makeblock.Scratch3.4.5</id>

<!-- Used as the filename for the application. Required. -->
<filename>mBlock</filename>
Expand All @@ -30,7 +30,7 @@
<!-- A string value of the format <0-999>.<0-999>.<0-999> that represents application version which can be used to check for application upgrade.
Values can also be 1-part or 2-part. It is not necessary to have a 3-part value.
An updated version of application must have a versionNumber value higher than the previous version. Required for namespace >= 2.5 . -->
<versionNumber>3.4.2</versionNumber>
<versionNumber>3.4.5</versionNumber>
<supportedProfiles>extendedDesktop</supportedProfiles>
<!-- A string value (such as "v1", "2.5", or "Alpha 1") that represents the version of the application, as it should be shown to users. Optional. -->

Expand Down
4 changes: 2 additions & 2 deletions src/assets/blockSpec.xml
Expand Up @@ -205,8 +205,8 @@
<command category="8" type="b" opcode="=" spec="%s = %s">["",""]</command>
<command category="8" type="b" opcode=">" spec="%s > %s">["",""]</command>
<command/>
<command category="8" type="b" opcode="&amp;" spec="%b and %b"/>
<command category="8" type="b" opcode="|" spec="%b or %b"/>
<command category="8" type="b" opcode="&amp;&amp;" spec="%b and %b"/>
<command category="8" type="b" opcode="||" spec="%b or %b"/>
<command category="8" type="b" opcode="not" spec="not %b"/>
<command/>
<command category="8" type="r" opcode="concatenate:with:" spec="join %s %s">["hello ","world"]</command>
Expand Down
4 changes: 2 additions & 2 deletions src/assets/html/index.html
Expand Up @@ -148,9 +148,9 @@
<table style="width:100%;font-size:12px;">
<tr><td>
<fieldset><legend name="send encode mode">send encode mode</legend>
<input type="radio" name="send" id="send_binary" onchange="onSendEncodeTypeChange()" />
<input type="radio" name="send" id="send_binary" checked="checked" onchange="onSendEncodeTypeChange()" />
<label for="send_binary" name="binary mode">binary</label>
<input type="radio" name="send" id="send_text" checked="checked" onchange="onSendEncodeTypeChange()" />
<input type="radio" name="send" id="send_text" onchange="onSendEncodeTypeChange()" />
<label for="send_text" name="char mode">text</label>
</fieldset>
</td><td>
Expand Down
6 changes: 5 additions & 1 deletion src/blocks/BlockIO.as
Expand Up @@ -123,7 +123,11 @@ public class BlockIO {
var hadSpriteRef:Boolean;
if(cmd[0].indexOf(".showDraw") > 0){
args = cmd.slice(1,-1);
args.push(spec[4][3]);
//这里原本有bug,有时候spec[4][3]并没有内容导致catch an error,然后整个block变成一个不携带参数的undefined,导致后面再切换含有该模块的主板的时候,无法正常显示。所以这里要加个安全判断
if(spec[4] && spec[4][3])
{
args.push(spec[4][3]);
}
b = new Block(label, spec[1], Specs.blockColor(spec[2]), spec[3], args);
for(i=0; i<args.length-1;i++){
if(args[i] is Array){
Expand Down
30 changes: 29 additions & 1 deletion src/cc/makeblock/interpreter/BlockInterpreter.as
Expand Up @@ -53,6 +53,12 @@ package cc.makeblock.interpreter
}

blockList.push.apply(null, converter.printBlockList(block));
var allBlockOp:Array = [];
getAllBlocksOp(blockList,allBlockOp);
for(var i:int=0;i<allBlockOp.length;i++)
{
MBlock.app.track("/blocks/"+allBlockOp[i]);
}
// trace("begin==================");
// trace(JSON.stringify(blockList));
// var codeList:Array = realInterpreter.compile(blockList);
Expand All @@ -62,7 +68,29 @@ package cc.makeblock.interpreter
thread.userData = new ThreadUserData(targetObj, block);
return thread;
}

private function getAllBlocksOp(blist:Array,resultArr:Array):void
{
for(var i:int=0;i<blist.length;i++)
{
if(blist[i].code)
{
resultArr.push(blist[i].type);
getAllBlocksOp(blist[i].code,resultArr);
}
if(blist[i].condition)
{
getAllBlocksOp([blist[i].condition],resultArr);
}
if(blist[i].argList)
{
getAllBlocksOp(blist[i].argList,resultArr);
}
if(blist[i].method)
{
resultArr.push(blist[i].method);
}
}
}
public function stopAllThreads():void
{
realInterpreter.stopAllThreads();
Expand Down
2 changes: 1 addition & 1 deletion src/cc/makeblock/interpreter/FunctionList.as
Expand Up @@ -181,7 +181,7 @@ internal class FunctionList {

private function listarg(obj:ScratchObj, argList:Array, i:int):ListWatcher {
var listName:String = argList[i];
if (listName.length == 0) return null;
if (!listName || listName.length == 0) return null;
var result:ListWatcher = obj.listCache[listName];
if (!result) {
result = obj.listCache[listName] = obj.lookupOrCreateList(listName);
Expand Down
12 changes: 10 additions & 2 deletions src/cc/makeblock/interpreter/PrimInit.as
Expand Up @@ -49,9 +49,17 @@ package cc.makeblock.interpreter
var receivers:Array = [];
msg = msg.toLowerCase();
function findReceivers(stack:Block, obj:ScratchObj):void {
if ((stack.op == "whenIReceive") && (stack.args[0].argValue.toLowerCase() == msg)) {
receivers.push([stack, obj]);
//有个sb2文件随便一点都会报错,这里先加个catch处理 by谭启亮 20161123
try{
if ((stack.op == "whenIReceive") && (stack.args[0].argValue.toLowerCase() == msg)) {
receivers.push([stack, obj]);
}
}
catch(err:Error)
{
trace("error come");
}

}
MBlock.app.runtime.allStacksAndOwnersDo(findReceivers);
var threadList:Array = [];
Expand Down
48 changes: 42 additions & 6 deletions src/cc/makeblock/interpreter/RemoteCallMgr.as
Expand Up @@ -6,22 +6,49 @@ package cc.makeblock.interpreter
import blockly.runtime.Thread;

import extensions.ScratchExtension;
// import extensions.SerialDevice;
// import extensions.SocketManager;

public class RemoteCallMgr
{
static public const Instance:RemoteCallMgr = new RemoteCallMgr();

private const requestList:Array = [];
private var timerId:uint;

private var reader:PacketParser;
private var oldValue:Object=0;
public function RemoteCallMgr()
{
reader = new PacketParser(onPacketRecv);
}

public function init():void
{
//TODO: huzige: 需要重新调整,用了Air Runtime不支持目前的flash环境
// SerialDevice.sharedDevice().dataRecvSignal.add(__onSerialRecv);
}


//TODO: huzige: 需要重新调整,用了Air Runtime不支持目前的flash环境
/*
public function interruptThread():void
{
if(requestList.length <= 0){
return;
}
var info:Array = requestList.shift();
var thread:Thread = info[0];
thread.interrupt();
clearTimeout(timerId);
send();
}
private function __onSerialRecv(bytes:Array):void
{
if(SocketManager.sharedManager().isConnected){
}else{
reader.append(bytes);
}
}
*/

public function onPacketRecv(value:Object=null):void
{
if(requestList.length <= 0){
Expand All @@ -41,6 +68,7 @@ package cc.makeblock.interpreter
}
clearTimeout(timerId);
send();
oldValue = value||oldValue;
}

public function call(thread:Thread, method:String, param:Array, ext:ScratchExtension, retCount:int):void
Expand All @@ -59,8 +87,16 @@ package cc.makeblock.interpreter
}
var info:Array = requestList[0];
var ext:ScratchExtension = info[3];
ext.js.call(info[1], info[2], ext);
timerId = setTimeout(onTimeout, 5000);
ext.js.call(info[1], info[2], null);
if(info[1]=="runBuzzer")
{
timerId = setTimeout(onTimeout, 5000);
}
else
{
timerId = setTimeout(onTimeout, 500);
}

}

private function onTimeout():void
Expand All @@ -70,7 +106,7 @@ package cc.makeblock.interpreter
}
var info:Array = requestList[0];
if(info[4] > 0){
onPacketRecv(0);
onPacketRecv(oldValue);
}else{
onPacketRecv();
}
Expand Down
Expand Up @@ -130,7 +130,7 @@ package cc.makeblock.mbot.uiwidgets.extensionMgr

static private function showErrorAlert():void
{
JOptionPane.showMessageDialog(Translator.map("Warning"), "file is not a valid extension zip!");
JOptionPane.showMessageDialog(Translator.map("Warning"), Translator.map("file is not a valid extension zip!"));
}

static private var extensionDir:String;
Expand Down
85 changes: 59 additions & 26 deletions src/cc/makeblock/services/msoxford/EmotionDetection.as
@@ -1,5 +1,7 @@
package cc.makeblock.services.msoxford
{
import com.google.analytics.core.Utils;

import flash.display.BitmapData;
import flash.display.JPEGEncoderOptions;
import flash.events.Event;
Expand All @@ -15,6 +17,7 @@ package cc.makeblock.services.msoxford
import flash.net.URLRequestMethod;
import flash.utils.ByteArray;

import util.JSON;
import util.SharedObjectManager;

public class EmotionDetection
Expand All @@ -35,6 +38,9 @@ package cc.makeblock.services.msoxford
}else{
return;
}
if(!_vid){
return;
}
var bmd:BitmapData = new BitmapData(_vid.width,_vid.height,true,0);
var matrix:Matrix = new Matrix;
matrix.a = -1;
Expand Down Expand Up @@ -68,41 +74,68 @@ package cc.makeblock.services.msoxford
urlloader.load(req);
}
private function onRequestComplete(evt:Event):void{
var ret:XML = new XML(evt.target.data);
if (ret.namespace("") != undefined)
{
default xml namespace = ret.namespace("");
}
MBlock.app.track("/OxfordAi/emotion/success/"+_source);
var len:uint = ret.FaceRecognitionResult.length();
var ret:*;
if(evt.target.data.toString().indexOf("xmlns")>-1){
try{
ret = new XML(evt.target.data);
if (ret.namespace("") != undefined)
{
default xml namespace = ret.namespace("");
}
var len:uint = ret.FaceRecognitionResult.length();
var result:Array = [];
for(var i:uint=0;i<len;i++){
var h:uint = ret.FaceRecognitionResult[i].faceRectangle.height;
var w:uint = ret.FaceRecognitionResult[i].faceRectangle.width;
var l:uint = ret.FaceRecognitionResult[i].faceRectangle.left;
var t:uint = ret.FaceRecognitionResult[i].faceRectangle.top;
var obj:Object = {};
obj.x = l;
obj.y = t;
obj.width = w;
obj.height = h;
obj.anger = Math.round(ret.FaceRecognitionResult[i].scores.anger*100);
obj.contempt = Math.round(ret.FaceRecognitionResult[i].scores.contempt*100);
obj.disgust = Math.round(ret.FaceRecognitionResult[i].scores.disgust*100);
obj.fear = Math.round(ret.FaceRecognitionResult[i].scores.fear*100);
obj.happiness = Math.round(ret.FaceRecognitionResult[i].scores.happiness*100);
obj.neutral = Math.round(ret.FaceRecognitionResult[i].scores.neutral*100);
obj.sadness = Math.round(ret.FaceRecognitionResult[i].scores.sadness*100);
obj.surprise = Math.round(ret.FaceRecognitionResult[i].scores.surprise*100);
result.push(obj);
}
if(len>0){
MBlock.app.extensionManager.extensionByName("Microsoft Cognitive Services").stateVars["emotionResultReceived"] = result;
MBlock.app.runtime.emotionResultReceived.notify(true);
}
}catch(e:*){

}
return;
}
ret = util.JSON.parse(evt.target.data);
var len:uint = ret.length;
var result:Array = [];
for(var i:uint=0;i<len;i++){
var h:uint = ret.FaceRecognitionResult[i].faceRectangle.height;
var w:uint = ret.FaceRecognitionResult[i].faceRectangle.width;
var l:uint = ret.FaceRecognitionResult[i].faceRectangle.left;
var t:uint = ret.FaceRecognitionResult[i].faceRectangle.top;
var h:uint = ret[i].faceRectangle.height;
var w:uint = ret[i].faceRectangle.width;
var l:uint = ret[i].faceRectangle.left;
var t:uint = ret[i].faceRectangle.top;
var obj:Object = {};
obj.x = l;
obj.y = t;
obj.width = w;
obj.height = h;
obj.anger = Math.round(ret.FaceRecognitionResult[i].scores.anger*100);
obj.contempt = Math.round(ret.FaceRecognitionResult[i].scores.contempt*100);
obj.disgust = Math.round(ret.FaceRecognitionResult[i].scores.disgust*100);
obj.fear = Math.round(ret.FaceRecognitionResult[i].scores.fear*100);
obj.happiness = Math.round(ret.FaceRecognitionResult[i].scores.happiness*100);
obj.neutral = Math.round(ret.FaceRecognitionResult[i].scores.neutral*100);
obj.sadness = Math.round(ret.FaceRecognitionResult[i].scores.sadness*100);
obj.surprise = Math.round(ret.FaceRecognitionResult[i].scores.surprise*100);
obj.anger = Math.round(ret[i].scores.anger*100);
obj.contempt = Math.round(ret[i].scores.contempt*100);
obj.disgust = Math.round(ret[i].scores.disgust*100);
obj.fear = Math.round(ret[i].scores.fear*100);
obj.happiness = Math.round(ret[i].scores.happiness*100);
obj.neutral = Math.round(ret[i].scores.neutral*100);
obj.sadness = Math.round(ret[i].scores.sadness*100);
obj.surprise = Math.round(ret[i].scores.surprise*100);
result.push(obj);
// var output:String = "用户("+(i+1)+")愤怒:"+Math.round(ret.FaceRecognitionResult[i].scores.anger*100)+"% ";
// output += "鄙视:"+Math.round(ret.FaceRecognitionResult[i].scores.contempt*100)+"% ";
// output += "厌恶:"+Math.round(ret.FaceRecognitionResult[i].scores.disgust*100)+"% ";
// output += "恐惧:"+Math.round(ret.FaceRecognitionResult[i].scores.fear*100)+"%\r";
// output += "开心:"+Math.round(ret.FaceRecognitionResult[i].scores.happiness*100)+"% ";
// output += "中立:"+Math.round(ret.FaceRecognitionResult[i].scores.neutral*100)+"% ";
// output += "悲伤:"+Math.round(ret.FaceRecognitionResult[i].scores.sadness*100)+"% ";
// output += "吃惊:"+Math.round(ret.FaceRecognitionResult[i].scores.surprise*100)+"%\r";
}
if(len>0){
MBlock.app.extensionManager.extensionByName("Microsoft Cognitive Services").stateVars["emotionResultReceived"] = result;
Expand Down

0 comments on commit 3328daf

Please sign in to comment.