Commit graph

1289 commits

Author SHA1 Message Date
Karishma Chadha
9ce6040b0f Fix lint error... 2018-04-06 16:57:52 -04:00
Karishma Chadha
1861b5a262 Can't have hyphens in identifiers. 2018-04-06 16:51:46 -04:00
Karishma Chadha
e92db8fa1e Don't really need level 9 compression. 2018-04-06 15:47:24 -04:00
Karishma Chadha
44b1a2f798 List limit should apply to insert block as well. 2018-04-06 15:31:10 -04:00
Karishma Chadha
5d46f8de99 Not providing a zip to deserialize asset functions is not an error. 2018-04-06 15:04:03 -04:00
Michael "Z" Goddard
0591b475f2
Merge pull request #1020 from gnarf/sb2-spec-when-video-motion
Allow specmap to have methods to branch into multiple sb3 opcodes
2018-04-06 14:28:17 -04:00
Eric Rosenbaum
25f1c1a5e6
Merge pull request #1017 from ericrosenbaum/bugfix/clones-inherit-instrument
Clones inherit music custom state
2018-04-06 13:38:03 -04:00
Karishma Chadha
8c1e6095cb Remove code that was temporarily accomodating for the old version of the default project in gui. 2018-04-06 11:33:44 -04:00
Karishma Chadha
4ec25b32b1 Code cleanup and commenting. 2018-04-06 11:33:44 -04:00
Karishma Chadha
9892dac904 Custom state (e.g. tempo, volume, video related state) should show up in a target that has been 'flattened' via JSON.stringify. 2018-04-06 11:33:44 -04:00
Karishma Chadha
2dbcdc2244 The stage should always be called 'Stage'. 2018-04-06 11:33:44 -04:00
Karishma Chadha
b436b5fd82 Add a limit to the number of items a list can have. No-op on 'addToList' block if trying to add to a list that is already at the limit. 2018-04-06 11:33:44 -04:00
Karishma Chadha
6c0d257a63 Deserialize tempo, volume, and video related state. 2018-04-06 11:33:44 -04:00
Karishma Chadha
4dd83cf717 Todo comment for clarity... 2018-04-06 11:33:44 -04:00
Karishma Chadha
118c6f0356 Use bitmap asset type and 'png' for various costume formats. 2018-04-06 11:33:44 -04:00
Karishma Chadha
d61ea23e1e Deserialize compressed primitives. 2018-04-06 11:33:44 -04:00
Karishma Chadha
21d60604ac Some block serialization compression -- compress primitives. This is a WIP since we don't deserialize blocks serialized in this way. 2018-04-06 11:33:44 -04:00
Karishma Chadha
334058b081 Block and variable compression. No need to serialize uid of block and shadow if they are the same, reduce duplication of information. 2018-04-06 11:33:44 -04:00
kchadha
4b62a938c4
Merge pull request #1000 from kchadha/deserialize-assets-in-sb2
Deserialize sb2 assets while loading local .sb2.
2018-04-06 11:33:00 -04:00
Ray Schamp
efb1bdb1ea Remove video motion icon until we have one 2018-04-06 09:55:16 -04:00
Michael "Z" Goddard
91747fd229
Add back missing Scratch3VideoSensingBlocks.INTERVAL
The INTERVAL time defines how often to analyze a frame. Without the value the
test whether a frame should be analyzed will always be false.
2018-04-05 17:47:07 -04:00
Corey Frang
78199c41a5 Allow specmap to have methods to branch into multiple sb3 opcodes 2018-04-05 15:39:41 -04:00
Christopher Willis-Ford
3be16eddb1 Add code to load 'core' extensions 2018-04-05 12:20:03 -07:00
Christopher Willis-Ford
f8db6c3f02 Support extension translation
The new `maybeFormatMessage` function detects whether its argument
looks like a message descriptor object and, if so, will call
`formatMessage` on it. This is now used for all user-visible text fields
in extensions.

Also, messages may use "select" to check the target type with a message
like this: '{targetType, select, stage {text for stage} sprite {text for
sprite} other {text for other}'. Note that the "other" clause is
required by `formatMessage`.
2018-04-05 12:17:05 -07:00
Eric Rosenbaum
2a90e5868d Fix runtime scope and unit test 2018-04-05 15:01:52 -04:00
Ray Schamp
41955913aa
Merge pull request #1007 from mzgoddard/motion-detect-2
Motion detect 2
2018-04-05 11:59:59 -04:00
Eric Rosenbaum
88b13e218d Clones inherit music custom state 2018-04-05 11:27:54 -04:00
Christopher Willis-Ford
defdd42c47 Add TargetType enum for use by/with extensions 2018-04-04 23:45:26 -07:00
Christopher Willis-Ford
de9e2be265 Add EVENT extension block type
An EVENT block is like a HAT block but it has no implementation
function. Its stack runs when the VM emits the corresponding event.
2018-04-04 23:44:59 -07:00
Christopher Willis-Ford
af058b8146 Support LOOP and CONDITIONAL blocks in extensions
A LOOP block is like a conditional, but the LOOP block will be
re-evaluated after any child branch runs.

Also:
- Support using '---' as a block separator
- Refactor common code from `_registerExtensionPrimitives` and
  `_refreshExtensionPrimitives` into new `_fillExtensionCategory`
- Improve error reporting during block conversion
2018-04-04 22:19:48 -07:00
Eric Rosenbaum
21ae14c499
Merge pull request #1014 from ericrosenbaum/bugfix/video-state
Import and store video state
2018-04-04 19:59:14 -04:00
Eric Rosenbaum
5dc8e51c6d Import and store video state 2018-04-03 16:36:58 -04:00
Michael "Z" Goddard
d4bffcbddb
Rename playground/motion.html to video-sensing.html 2018-04-03 16:19:52 -04:00
Michael "Z" Goddard
6d2c29530f
Document VideoMotionView 2018-04-03 16:19:52 -04:00
Michael "Z" Goddard
9a2e937271
Document VideoMotion class
- Rename video_sensing/lib.js to video_sensing/library.js
2018-04-03 16:19:52 -04:00
Michael "Z" Goddard
a32b15a8f9
Add VideoSensing math module
- motionVector takes motion component and returns a 2d vector
- scratchAtan2 takes a y and x value and returns an angle in degrees
  referencing Scratch's coordinate system
2018-04-03 16:19:52 -04:00
Michael "Z" Goddard
b46c956203
Comment items in Scratch3VideoSensingBlocks 2018-04-03 16:19:51 -04:00
Michael "Z" Goddard
c291a04cc7
Add file comment block to video_sensing/debug.js 2018-04-03 16:19:51 -04:00
Michael "Z" Goddard
e65b7985cb
Add whenMotionGreaterThan hat block to video sensing ext 2018-04-03 16:19:51 -04:00
Michael "Z" Goddard
cfd74a7c7f
Add checkboxes for each video sensing debug view 2018-04-03 16:19:51 -04:00
Michael "Z" Goddard
b012d60689
Add video sensing debug C_CELL and AB_CELL views
- Rename UV to UV_CELL, UV cannot be rendered in a non-cell format

Modify C and AB views as well to better represent in color the work being done.
If you watch the debug views with XY_CELL, AB_CELL, C_CELL, and UV_CELL you can
see how AB_CELL and C_CELL affect UV_CELL in similar color patterns.
2018-04-03 16:19:51 -04:00
Michael "Z" Goddard
0a58a6d806
Merge pull request #1001 from mzgoddard/motion-detect
Motion detect
2018-04-03 16:19:26 -04:00
Michael "Z" Goddard
f3d19dc1a1
Use videoSensing extension for sb2 senseVideoMotion 2018-03-29 19:02:07 -04:00
Michael "Z" Goddard
c206dc3241
Add motion playground page for debugging video sensing 2018-03-29 19:02:07 -04:00
Paul Kaplan
2d9bd92140
Merge pull request #930 from ericrosenbaum/bugfix/loudness-performance
Only measure loudness once per step
2018-03-29 16:27:10 -04:00
Michael "Z" Goddard
3c473f6ba8
Translate scratch 2 video sensing into scratch 3 extension
- Add videoSensing extension to extension-manager
2018-03-29 15:15:11 -04:00
kchadha
51306e3492
Merge pull request #963 from towerofnix/foreach-vm
Implement for-each block
2018-03-28 10:52:14 -04:00
Karishma Chadha
b8e67a7727 Hookup sb2 import code to deserialize assets from local sb2 file. 2018-03-25 18:14:30 -04:00
Paul Kaplan
13641297fd
Merge pull request #996 from paulkaplan/fix-bubble-bounds
Position the speech bubble more tightly.
2018-03-23 14:36:52 -04:00
Paul Kaplan
ea534b35ea Position the speech bubble more tightly. 2018-03-23 10:51:19 -04:00
kchadha
dbc7b9597f
Merge pull request #979 from kchadha/serialization-cleanup
SB3 Serialization & Load Project
2018-03-23 10:11:49 -04:00
Paul Kaplan
a27ed888d2
Merge pull request #992 from paulkaplan/stage-clicked
Make "when clicked" blocks  target dependent.
2018-03-23 09:20:22 -04:00
Chris Willis-Ford
9dc3df1fda
Merge pull request #994 from cwillisf/looks-extension-support
Looks extension support
2018-03-22 15:16:21 -07:00
Florrie
1db4a2c7a7 Compatibility implementation 2018-03-22 18:55:36 -03:00
Eric Rosenbaum
4e3c5c7f2e
Merge pull request #991 from ericrosenbaum/bugfix/clones-share-activesoundplayers
Clones share their parent’s activeSoundPlayers object
2018-03-22 16:49:04 -04:00
Karishma Chadha
c4ad76eef1 Turns out ArrayBuffers are not views of themselves. 2018-03-22 16:19:36 -04:00
Karishma Chadha
3a4f620318 Check if loadProject input is any typed array using ArrayBuffer.isView. This allows us to pass a project's asset.data (from storage) directly instead of calling toString on it first. 2018-03-22 14:04:58 -04:00
Karishma Chadha
2c3e3472ed Add warning to 'fromJSON' function since it is now just a wrapper around loadProject. Change vm sb3_serialization test to use 'loadProject' function instead of 'fromJSON'. 2018-03-21 17:55:02 -04:00
Karishma Chadha
ce6ef92eb5 Clear runtime after validation success instead of before. 2018-03-21 17:46:39 -04:00
Karishma Chadha
ab863096cd Remove cruft and fix for..in loops. 2018-03-21 17:42:01 -04:00
Karishma Chadha
9d3a3fd12f When serializing md5+ext, the name should reflect that. Deserializing translates this name back to what vm and other components currently expect. 2018-03-21 16:51:40 -04:00
Karishma Chadha
24e248d4fb Removing cruft... 2018-03-21 14:46:21 -04:00
Christopher Willis-Ford
26bc7851bb Rename ReporterScope.SPRITE to TARGET & add JSDoc 2018-03-20 15:30:34 -07:00
Christopher Willis-Ford
d3352ac54d Add JSDoc tags for ArgumentType & BlockType 2018-03-20 15:26:27 -07:00
Christopher Willis-Ford
1049e90a8f Wrap extension menu function to provide context
When the extension system calls a function to retrieve extension menu
items, it now provides the ID of the current editing target. There's
also now a little bit of error-checking on the results.
2018-03-20 15:26:27 -07:00
Christopher Willis-Ford
2932f232c4 Improve developer feedback for missing block func 2018-03-20 15:26:12 -07:00
Christopher Willis-Ford
4201f212d3 Add JSDoc for extension metadata format
This is a first pass and is probably not 100% correct. It also contains
the new (experimental?) reporter scope field.
2018-03-20 15:05:21 -07:00
Christopher Willis-Ford
6a06984678 Add enum for reporter scope
Some reporters are sprite-specific, such as the costume name/number or
X position of the sprite. Others are global. This enum allows an
extension author to specify the scope of a reporter.
2018-03-20 15:05:21 -07:00
Paul Kaplan
140094a7ad Make "when clicked" blocks target dependent.
This involves adding a new opcode, event_whenstageclicked, and adding a
method to the blocks container to update the opcode pair depending on
whether the target is the stage. This method is then called in two
places: first after the sb2 import parses the blocks (not done in the
sb2 parsing itself because no other blocks are target specific) and then
again when blocks are shared between targets.

Also added tests for the block container method, and a fixture project
that tests the opcode splitting on sb2 import.
2018-03-20 10:41:50 -04:00
Eric Rosenbaum
2b985fa083
Merge pull request #975 from ericrosenbaum/bugfix/move-volume-to-rendered-target
Move volume to rendered target
2018-03-19 16:45:25 -04:00
Eric Rosenbaum
2527c804ea Clones get ref to parent’s activeSoundPlayers obj 2018-03-19 16:44:49 -04:00
Chris Willis-Ford
4c0e968bec
Merge pull request #978 from cwillisf/fix-saythink-and-wait
Fix say/think and wait
2018-03-19 10:36:01 -07:00
Paul Kaplan
979c8b05e0
Merge pull request #965 from bartljak/issue#960
fixed issue 960
2018-03-19 06:06:00 -07:00
Karishma Chadha
b4f6f24926 Fix up tests. 2018-03-16 11:43:27 -04:00
Florrie
6517bd0974 Make 'key pressed?' block import correctly 2018-03-16 11:58:25 -03:00
Karishma Chadha
003ed01015 Update VM to use scratch-parser callback interface 2018-03-15 22:40:40 -04:00
Andrew Sliwinski
1d90c82fcf
Merge pull request #945 from picklesrus/translate-extension
Translate extension block
2018-03-15 08:36:39 -04:00
kchadha
a3ed4cad99 Remove todo 2018-03-14 22:52:00 -04:00
kchadha
0d55e4c74f Modifying apis to accomodate existing tests. 2018-03-14 22:52:00 -04:00
kchadha
22be2b15f3 Major refactor of project loading. Removed loadProjectLocal, in favor of going back to single API (loadProject). loadProject uses scratch-parser to unpack and validate project. Scratch-parser is getting updated to return validated project, with appended project metadata, and unpacked zip (JSZip object) if provided a buffer. 2018-03-14 22:52:00 -04:00
kchadha
2c551d1739 Some more cleanup. 2018-03-14 22:51:59 -04:00
kchadha
09c8110923 Always serialize parent and next on a block even if they're null. 2018-03-14 22:51:59 -04:00
kchadha
4f6ece9fa8 Be specific about what we're serializing. Flatten targets first by turning them into JSON strings and re-parsing them, and then only serialize the properties necessary for saving and loading. 2018-03-14 22:51:59 -04:00
Christopher Willis-Ford
4210c6dd4c Fix stack check in stepThread
The previous logic seemed to be expecting `peekStack` to return 0 when
the stack was empty, but its return type is `?string` and it returns
`undefined` when the stack is empty. The `!== 0` check would never pass,
then, leading to problems with (for example) the "say/think and wait"
blocks.
2018-03-14 16:17:29 -07:00
Christopher Willis-Ford
b61c6a8f76 Don't render say/think bubbles during tests
This change makes say & think commands work during headless tests.
2018-03-14 16:07:05 -07:00
Eric Rosenbaum
a652156032 Sensing-of block gets target volume 2018-03-13 11:45:11 -04:00
Eric Rosenbaum
f8c2771776 Use target volume, not custom state 2018-03-13 11:43:53 -04:00
Eric Rosenbaum
a7c6c430b8 Add volume to rendered target 2018-03-13 11:43:33 -04:00
Andrew Sliwinski
2ae788ca28
Merge pull request #968 from gnarf/instanceof-fix
ensure this.workerClass exists before instanceof check
2018-03-12 12:45:09 -04:00
Andrew Sliwinski
6039f1b7e7
Merge pull request #969 from gnarf/fix-music-no-audio
Ensure music extension _decodeSound is promise
2018-03-12 12:44:16 -04:00
picklesrus
39d2559e37 Initial version of translate extension. 2018-03-11 12:18:21 -07:00
kchadha
adfbeddcab
Merge pull request #964 from kchadha/save-load
Preliminary Save and Load Work
2018-03-09 09:34:44 -05:00
Corey Frang
1d414dd5a0 Ensure music extension _decodeSound is promise
Currently if there is no audio engine detected this returns undefined,
which in turn causes the line above to fail trying to call `.then` on
it.
2018-03-08 12:32:01 -05:00
kchadha
d59a4ffd55 VM receives input buffer representing project to load and unpacks it as zip. This functionality will eventually move to storage. 2018-03-08 10:25:58 -05:00
Corey Frang
9b8a8647f0 ensure this.workerClass exists before instanceof check
This avoids an error I was running into in a node environment:

```
TypeError: Right-hand side of 'instanceof' is not an object
```
2018-03-07 18:13:15 -05:00
kchadha
cc2bf1dfc7
Merge pull request #957 from kchadha/mouse-up-drag-end
Use flag to selectively activate 'when this sprite clicked' hat on mouse up
2018-03-07 13:26:28 -05:00
Chris Willis-Ford
219f083a29
Merge pull request #934 from picklesrus/extensions-dynamic-menu
Extensions dynamic menu
2018-03-06 16:33:26 -05:00
Jake Bartles
11e12cca4f fixed issue 960 2018-03-05 20:15:49 -05:00
Karishma Chadha
d6e248aab8 VM should do the heavy lifting of saving project to a zip file, and return a promise of the zip to gui. 2018-03-05 17:20:36 -05:00
Florrie
00b151b9ff Add doForLoop to sb2 specmap 2018-03-05 17:36:17 -04:00
Karishma Chadha
c0afcd2ab3 Ensure that md5 and assetId stay in sync. 2018-03-05 15:16:06 -05:00
Karishma Chadha
605ce4b16d Configuring scratch-vm to use changes made to scratch-parser. 2018-03-05 15:16:06 -05:00
Karishma Chadha
e0b23cde31 Can load saved sb3 files (including sounds and costumes that were modified in the 3.0 editors and saved in the sb3 zip when the project was saved). Tests still need to be fixed. 2018-03-05 15:16:06 -05:00
Karishma Chadha
089df0a50f Sounds get updated in storage and vm runtime when they are updated in the sound editor. The updateSvg function ensures that the costume that was edited has an updated dataFormat property in the vm runtime. This is specifically for when pngs get edited in the vector editor. Their file format should then get updated to svg. 2018-03-05 15:16:06 -05:00
Karishma Chadha
52c77d9fb0 Updating asset serialization code to get data format from stored asset rather than vm state. Storage seems to be more up to date than vm in the case of editing the blank backdrop, which is stored as a png instead of an svg. 2018-03-05 15:16:06 -05:00
Karishma Chadha
525a8c2ce7 Serializing sounds and costumes into file descriptors upon 'saveProjectSb3'. 2018-03-05 15:16:06 -05:00
Florrie
928df260ff Fix lint errors 2018-03-05 15:46:54 -04:00
Florrie
defcc45419 Implement foreach block 2018-03-05 15:36:26 -04:00
DD Liu
97d3785554 Temporarily return real costumes array. GUI currently relies on this behavior somewhere 2018-03-05 11:07:50 -05:00
picklesrus
16ecaab1be Fix up comment. 2018-03-02 11:07:22 -08:00
picklesrus
026b9dc282 Stop wrapping function for no reason. 2018-03-02 11:02:56 -08:00
kchadha
a0c7d9aeb3
Merge pull request #956 from kchadha/validate-sb2
Validate sb2
2018-03-02 10:28:53 -05:00
DD
b885402081 Merge branch 'develop' into privateSprite 2018-03-01 17:27:10 -05:00
Eric Rosenbaum
5d658b5ecb
Merge pull request #953 from ericrosenbaum/bugfix/load-tempo-from-sb2
Load tempo from sb2
2018-03-01 13:20:37 -05:00
Eric Rosenbaum
981fc57a43
Merge pull request #950 from ericrosenbaum/bugfix/import-music-menus
Fix music extension menu import
2018-02-28 18:47:30 -05:00
kchadha
8bebc1f5a2
Merge pull request #952 from kchadha/duplicate-sprite-names
Duplicating sprite should give new sprite a fresh name.
2018-02-28 17:13:19 -05:00
Karishma Chadha
d9fb315e3b Removing log messages. 2018-02-28 17:10:54 -05:00
Ray Schamp
4e933eed81
Merge pull request #878 from davidaylaian/reduce-peekstack-calls
Optimize stepThread by reducing the number of calls to peekStack
2018-02-28 16:50:20 -05:00
Karishma Chadha
d51a2ad39f Use wasDragged flag to selectively activate 'when this sprite clicked' block on mouse up. 2018-02-28 16:45:26 -05:00
Karishma Chadha
7c7b016643 scratch-parser expects json string... 2018-02-28 11:52:22 -05:00
Karishma Chadha
59d1c2a0b3 Code cleanup and actually throw errors when project fails to load. Depends on scratch-gui loading sb3 version of default project. 2018-02-28 10:02:02 -05:00
Eric Rosenbaum
db795abfbc Use tempo stored in stage 2018-02-27 11:48:49 -05:00
Eric Rosenbaum
7e5e43fbe1 Load tempo from sb2 2018-02-27 11:48:23 -05:00
Eric Rosenbaum
237616490f Add tempo property to rendered target 2018-02-27 11:48:14 -05:00
Karishma Chadha
8c5c68b896 Duplicating sprite should give new sprite a fresh name. 2018-02-26 23:17:25 -05:00
Karishma Chadha
79169c81b3 Use scratch-parser to validate structure of project json files. 2018-02-26 22:43:55 -05:00
Eric Rosenbaum
651d46fff0 Add default values for obscured shadows 2018-02-26 17:28:20 -05:00
Paul Kaplan
1f3c6ac6ad
Merge pull request #939 from fsih/blockDrag
Block drag
2018-02-26 16:26:53 -05:00
Eric Rosenbaum
8b18ff7ae9 make inputOP, arg name and menu name the same 2018-02-26 15:56:37 -05:00
DD
9a65df4c12 Make index optional 2018-02-23 16:24:18 -05:00
DD
10789cd779 Bring in Karishmas changes from save-load to ensure the sound gets updated in storage when edited 2018-02-23 16:21:07 -05:00
DD
bb0394a668 Fix lint 2018-02-23 16:09:38 -05:00
DD
0a5ccbf42f Use existing UID util 2018-02-23 12:07:07 -05:00
DD
8355dd662f Switch to sending end drag event to be handled by gui 2018-02-23 11:57:19 -05:00
DD
2239d1b92b Use promises 2018-02-23 11:09:19 -05:00
DD
75cf6407d4 Duplicate costume 2018-02-23 10:50:45 -05:00
DD
d6bcfae526 Remove costume ID 2018-02-23 10:25:14 -05:00
DD
b4d6db0ad9 Fix tests 2018-02-22 15:45:41 -05:00
DD
729fc3d303 Make sprite.costumes private so that I can enforce that when you add costumes, they get assigned a unique ID 2018-02-21 19:59:35 -05:00
DD
51fd97ee54 fix lint 2018-02-20 16:09:08 -05:00
DD
2545d1955d Repopulate blocks with ids 2018-02-20 16:09:08 -05:00
DD
31def7d03d Track hovered sprite. End drag may transfer blocks from one sprite to another. 2018-02-20 16:09:08 -05:00
DD
fe4b3d3c01 Pass through block drag event 2018-02-20 16:09:08 -05:00
Chris Willis-Ford
8e1719b716
Merge pull request #920 from towerofnix/scroll-detection
Scroll wheel detection for "when key (up/down) pressed" blocks
2018-02-16 12:21:27 -08:00
picklesrus
1910968b13 Fix lint errors. 2018-02-16 10:49:26 -08:00
Eric Rosenbaum
ca08cd69e9
Merge pull request #936 from ericrosenbaum/feature/require-music-assets
Feature/require music assets
2018-02-16 10:25:31 -05:00
Eric Rosenbaum
e67743a4ba Require assets inside a try/catch 2018-02-16 10:05:54 -05:00
Eric Rosenbaum
063ac39019 Load music extension assets with require 2018-02-14 17:53:05 -05:00
Eric Rosenbaum
22038c947c When getting sprite by name, skip the stage 2018-02-12 15:33:27 -05:00
kchadha
9675a1b8cf
Merge pull request #931 from kchadha/bugfix-912
Renaming sprite/costume/sound/backdrop updates corresponding blocks.
2018-02-12 11:53:50 -05:00