From e20723994f9fe776ca087741b58f5e96716708d5 Mon Sep 17 00:00:00 2001 From: Corey Frang Date: Thu, 5 Apr 2018 15:10:16 -0400 Subject: [PATCH] fix sb2 conversion to load into correct VIDEO_STATE --- src/extensions/scratch3_video_sensing/index.js | 5 ++--- src/serialization/sb2.js | 10 ++++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/extensions/scratch3_video_sensing/index.js b/src/extensions/scratch3_video_sensing/index.js index 5fca73e53..36a91ef59 100644 --- a/src/extensions/scratch3_video_sensing/index.js +++ b/src/extensions/scratch3_video_sensing/index.js @@ -339,14 +339,13 @@ class Scratch3VideoSensingBlocks { } videoToggle (args) { - // imported blocks have VIDEO_STATE "off", "on", "on-flipped" as opposed to the numerics? const state = Number(args.VIDEO_STATE); // 1 == off, 2 & 3 are on (3 is flipped) - if (args.VIDEO_STATE === 'off' || state === 1) { + if (state === 1) { this.runtime.ioDevices.video.disableVideo(); } else { this.runtime.ioDevices.video.enableVideo(); - this.runtime.ioDevices.video.mirror = args.VIDEO_STATE === 'on' || state === 2; + this.runtime.ioDevices.video.mirror = state === 2; } } diff --git a/src/serialization/sb2.js b/src/serialization/sb2.js index b4b55ad8f..74b1ff36d 100644 --- a/src/serialization/sb2.js +++ b/src/serialization/sb2.js @@ -627,6 +627,16 @@ const parseBlock = function (sb2block, addBroadcastMsg, getVariableId, extension } else if (fieldValue === 'this sprite') { fieldValue = 2; } + } else if (expectedArg.inputOp === 'videoSensing.menu.VIDEO_STATE') { + if (shadowObscured) { + fieldValue = 2; + } else if (fieldValue === 'off') { + fieldValue = 1; + } else if (fieldValue === 'on') { + fieldValue = 2; + } else if (fieldValue === 'on-flipped') { + fieldValue = 3; + } } else if (shadowObscured) { // Filled drop-down menu. fieldValue = '';