Commit Graph

1155 Commits

Author SHA1 Message Date
Mike Welsh ce73b4eaa7 core: Recursively unload child display objects
Child movie clips should run their unload actions when the parent
is removed.
2020-06-11 23:39:16 -07:00
Mike Welsh 9b0881edb7 core: Set $version on root
_root has a $version property that should matches
`System.capabilites.version`. This allows Nanaca Crash to boot.
2020-06-11 10:03:29 -07:00
Mike Welsh faa35a53e9 tests: Add test for getBounds with empty children 2020-06-10 17:17:08 -07:00
Mike Welsh b5daf3d020 core: Fix BoundingBox::union for invalid bounds 2020-06-10 17:17:08 -07:00
dependabot-preview[bot] f03e75951a build(deps): bump syn from 1.0.30 to 1.0.31
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.30 to 1.0.31.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.30...1.0.31)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-06-09 22:14:57 -07:00
CUB3D fa11ef1e81 core: Add remaining capabilities 2020-06-09 23:57:46 +01:00
CUB3D dd5d2976ea core: Add missing functions to System.security 2020-06-09 23:03:13 +01:00
CUB3D 07d4f3a8eb core: Fix build 2020-06-09 22:41:11 +01:00
CUB3D ad3bc612aa chore: Fix clippy lints 2020-06-09 22:41:11 +01:00
CUB3D 4987cfdaac core: Refactor enums, Add unknown windows os support and fix attributes
Now using Display to convert enums.
Also added support for a fallback "Windows" os for when the current version can't be detected
2020-06-09 22:41:11 +01:00
CUB3D 48bef91917 core: Remove clear_clipboard, format and fix tests 2020-06-09 22:41:11 +01:00
CUB3D bc1055e381 core: Create system protos in globals.rs, fix version-dependant output
Make get_server_string output order match flash, also make language and manufacturer output respect emulated player version
2020-06-09 22:41:11 +01:00
CUB3D de013426bc core: Url encode serverString 2020-06-09 22:41:11 +01:00
CUB3D 887e09337f core: Add dummy impl of System.security 2020-06-09 22:41:11 +01:00
CUB3D fc8cd1139a core: Add initial System.IME implementation 2020-06-09 22:41:11 +01:00
CUB3D 94a53f3506 core: Store System.capabilities in SystemProperties 2020-06-09 22:41:11 +01:00
CUB3D af41ac5602 core: Add clipboard support to input backend 2020-06-09 22:41:11 +01:00
CUB3D 0f0f778830 core: Retain properties for System in the player 2020-06-09 22:41:11 +01:00
CUB3D 8471523e49 core: Add basic System.capabilities implementation 2020-06-09 22:41:11 +01:00
CUB3D 50abbe1887 core: Implement basic System global 2020-06-09 22:41:10 +01:00
Nathan Adams 58df56e4a4 core: Add `Value::get` shortcut that resolves Objects or returns Undefined 2020-06-08 15:12:05 -07:00
Nathan Adams d0ad1b57fe core: Replace `toString`/`valueOf` calls with `call_method` 2020-06-08 15:12:05 -07:00
Nathan Adams c592b5fb2a core: `Value::call_method` no longer requires you to resolve after calling it 2020-06-08 15:12:05 -07:00
Nathan Adams d39ffcfadc core: `Value::call` no longer requires you to resolve after calling it 2020-06-08 15:12:05 -07:00
Nathan Adams fe55c5a264 core: `TObject::call_method` no longer requires you to resolve after calling it 2020-06-08 15:12:05 -07:00
Nathan Adams da3e2bb0a0 core: `TObject::call` no longer requires you to resolve after calling it 2020-06-08 15:12:05 -07:00
Nathan Adams 26590d4c63 core: `TObject::get_local` no longer requires you to resolve after retrieving it 2020-06-08 15:12:05 -07:00
Nathan Adams a121a3a4d0 core: `TObject::get` no longer requires you to resolve after retrieving it 2020-06-08 15:12:05 -07:00
dependabot-preview[bot] 36fb0cd43c build(deps): bump quote from 1.0.6 to 1.0.7
Bumps [quote](https://github.com/dtolnay/quote) from 1.0.6 to 1.0.7.
- [Release notes](https://github.com/dtolnay/quote/releases)
- [Commits](https://github.com/dtolnay/quote/compare/1.0.6...1.0.7)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-06-07 17:17:32 -07:00
Mike Welsh 359df6860f tests: Add String.charCodeAt tests
Tests the fix provided in #634.
2020-06-04 16:02:55 -07:00
Nathan Adams 34cf21289b avm1: Fixed some missing behaviours with flash.geom.Rectangle 2020-06-02 18:49:01 -07:00
Nathan Adams f5765f2bac avm1: Implement all of flash.geom.Rectangle + tests (#305) 2020-06-02 18:49:01 -07:00
Nathan Adams 226a97ef4b core: Don't panic on `new DoesntExist()` 2020-06-02 18:49:01 -07:00
dependabot-preview[bot] 4b22fc723d build(deps): bump indexmap from 1.3.2 to 1.4.0
Bumps [indexmap](https://github.com/bluss/indexmap) from 1.3.2 to 1.4.0.
- [Release notes](https://github.com/bluss/indexmap/releases)
- [Commits](https://github.com/bluss/indexmap/compare/1.3.2...1.4.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-06-01 13:42:08 -07:00
dependabot-preview[bot] cf4df4058f build(deps): bump png from 0.16.3 to 0.16.4
Bumps [png](https://github.com/image-rs/image-png) from 0.16.3 to 0.16.4.
- [Release notes](https://github.com/image-rs/image-png/releases)
- [Changelog](https://github.com/image-rs/image-png/blob/master/CHANGES.md)
- [Commits](https://github.com/image-rs/image-png/compare/v0.16.3...v0.16.4)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-06-01 12:23:21 -07:00
dependabot-preview[bot] 078c64c201 build(deps): bump syn from 1.0.28 to 1.0.30
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.28 to 1.0.30.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.28...1.0.30)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-06-01 12:19:30 -07:00
dependabot-preview[bot] 0e7b0f8467 build(deps): bump libflate from 1.0.0 to 1.0.1
Bumps [libflate](https://github.com/sile/libflate) from 1.0.0 to 1.0.1.
- [Release notes](https://github.com/sile/libflate/releases)
- [Commits](https://github.com/sile/libflate/compare/1.0.0...1.0.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-06-01 11:24:15 -07:00
Nathan Adams 0d53f0a952 chore: Fix new clippy lint about short variable names - fixes #668 2020-06-01 10:31:46 -07:00
Mike Welsh 3a8c705e95 chore: Fix clippy lints 2020-05-30 03:47:12 -07:00
Nathan Adams 4c1ce6d765 core: Print swf version on startup, and warn when we run into avm2 2020-05-30 02:48:54 -07:00
dependabot-preview[bot] c0593ce081 build(deps): bump syn from 1.0.27 to 1.0.28
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.27 to 1.0.28.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.27...1.0.28)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-29 09:49:49 -07:00
dependabot-preview[bot] 97f69e8ed2 build(deps): bump syn from 1.0.25 to 1.0.27
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.25 to 1.0.27.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.25...1.0.27)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-27 07:24:00 +00:00
Nathan Adams ddf2aa3ec1 avm1: Implement all of flash.geom.Point (#304) 2020-05-27 00:23:45 -07:00
Nathan Adams 2e25fec099 tests: Add test coverage for flash.geom.Point 2020-05-27 00:23:45 -07:00
Nathan Adams df6764a69c chore: Add license metadata to all packages & crates 2020-05-27 00:11:02 -07:00
dependabot-preview[bot] 458ca2a478 build(deps): bump syn from 1.0.24 to 1.0.25
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.24 to 1.0.25.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.24...1.0.25)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-25 20:36:01 +00:00
CUB3D 590321133f core: Fix incorrect String.charCodeAt bounds check (close #633) 2020-05-25 13:35:41 -07:00
dependabot-preview[bot] 4712446314 build(deps): bump syn from 1.0.23 to 1.0.24
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.23 to 1.0.24.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.23...1.0.24)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-25 01:42:44 +00:00
Mike Welsh 993421e732 core: Children run an initial frame when changing button states
There was a one-frame-off flicker when a button changed states.
Now children will tick a frame so that they are properly created
immediately when the parent button changes state.
2020-05-24 08:57:30 -07:00
Mike Welsh 932ad30570 core: Flatten ClipActions into a single event per action
Previously a MovieClip's clip action would have a set of events
that would trigger it. Now we flatten these out into a single
event per action, because this is by far the common case. If an
action does happen to have >1 event, it will be duplicated for each.
2020-05-24 08:57:30 -07:00
Mike Welsh c427d55dbb core: Clean up clip event handlers
Remove ButtonEvent and subsume it in ClipEvent. Player now tosses
ClipEvents down the display tree, cleaning up some of the event code.
2020-05-24 08:57:30 -07:00
Mike Welsh 6929cea996 core: Implement button event handlers for movie clips 2020-05-24 08:57:30 -07:00
Mike Welsh 09ca11f788 webgl: Implement linear RGB gradients 2020-05-22 11:03:16 -07:00
Mike Welsh 97db518fb1
core: First pass of drawing API (merge #611) 2020-05-22 08:54:55 -07:00
Nathan Adams 3346accb9c core: More accurate shape_bounds/edge_bounds in drawing api 2020-05-21 20:34:48 +02:00
Nathan Adams 62a1914c3e core: BoundingBox::encompass should properly convert invalid BBs to valid BBs.
This means that encompassing 100,100 on an invalid BB should create a BB of 100,100-100,100, and not 0,0-100,100
2020-05-21 20:19:26 +02:00
Nathan Adams 279c07d9b8 core: Update drawings on render instead of on tick 2020-05-21 18:38:10 +02:00
Nathan Adams 55215273e8 core: Stretch edge & shape bounds separately and avoid a clone, in rendering api 2020-05-21 18:38:10 +02:00
Nathan Adams 04690581ba core: Refactor common code in drawing api 2020-05-21 18:38:10 +02:00
Nathan Adams 1f8abc92fd core: Keep track of cursor position in drawings 2020-05-21 18:38:10 +02:00
Nathan Adams 99574cfa72 core: Move drawing api out from `movie_clip` into `drawing` 2020-05-21 18:38:10 +02:00
Nathan Adams 4f69566f77 tests: Add test coverage for flash.geom.Matrix 2020-05-21 18:38:08 +02:00
dependabot-preview[bot] 898232394b build(deps): bump syn from 1.0.22 to 1.0.23
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.22 to 1.0.23.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.22...1.0.23)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-21 03:49:03 +00:00
Nathan Adams 31b0a5ae76 avm1: Implement gradient matrix types 2020-05-20 14:54:41 +02:00
Nathan Adams 5098eb079d avm1: Implement most of flash.geom.Matrix (#303) 2020-05-20 14:54:41 +02:00
Nathan Adams 14331da71b avm1: Add flash.geom.Matrix and methods to convert between this and swf::Matrix 2020-05-20 14:54:41 +02:00
Nathan Adams eda862c719 swf: Merged core::Matrix into swf::Matrix 2020-05-20 14:54:41 +02:00
Nathan Adams 61e464099c core: Add initial drawing API to MovieClip 2020-05-20 14:54:40 +02:00
Nathan Adams 7ab6703fc9 render: Add RenderBackend::replace_shape method 2020-05-20 14:54:40 +02:00
Nathan Adams 4c80ae150c core: Make DistilledShape use Boundingbox and not Rectangle
Rectangle more represents compressed swf data and isn't suited for performing operations, and the drawing api will be generating these dynamically
2020-05-20 14:54:33 +02:00
Nathan Adams f7b5f14f65 core: Make RenderBack::register_bitmap* methods return a Result (fixes #531) 2020-05-19 07:12:36 -07:00
dependabot-preview[bot] 6134ae091f build(deps): bump generational-arena from 0.2.7 to 0.2.8
Bumps [generational-arena](https://github.com/fitzgen/generational-arena) from 0.2.7 to 0.2.8.
- [Release notes](https://github.com/fitzgen/generational-arena/releases)
- [Changelog](https://github.com/fitzgen/generational-arena/blob/master/CHANGELOG.md)
- [Commits](https://github.com/fitzgen/generational-arena/compare/0.2.7...0.2.8)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-18 23:54:45 -07:00
dependabot-preview[bot] 41a8b01fe7 build(deps): bump quote from 1.0.5 to 1.0.6
Bumps [quote](https://github.com/dtolnay/quote) from 1.0.5 to 1.0.6.
- [Release notes](https://github.com/dtolnay/quote/releases)
- [Commits](https://github.com/dtolnay/quote/compare/1.0.5...1.0.6)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-18 08:38:24 +00:00
dependabot-preview[bot] 3b163c2b6e build(deps): bump syn from 1.0.21 to 1.0.22
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.21 to 1.0.22.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.21...1.0.22)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-16 09:46:08 +00:00
dependabot-preview[bot] 1f0e695465 build(deps): bump fnv from 1.0.6 to 1.0.7
Bumps [fnv](https://github.com/servo/rust-fnv) from 1.0.6 to 1.0.7.
- [Release notes](https://github.com/servo/rust-fnv/releases)
- [Commits](https://github.com/servo/rust-fnv/compare/v1.0.6...v1.0.7)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-14 19:05:48 +00:00
dependabot-preview[bot] 1641d05d00 build(deps): bump syn from 1.0.20 to 1.0.21
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.20 to 1.0.21.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.20...1.0.21)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-13 17:18:29 +00:00
dependabot-preview[bot] e22da9ac4c build(deps): bump quote from 1.0.4 to 1.0.5
Bumps [quote](https://github.com/dtolnay/quote) from 1.0.4 to 1.0.5.
- [Release notes](https://github.com/dtolnay/quote/releases)
- [Commits](https://github.com/dtolnay/quote/compare/1.0.4...1.0.5)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-13 14:42:48 +00:00
Mike Welsh 031f5d6501 core: Avoid undefined behavior in f64_to_wrapping functions 2020-05-13 02:41:50 -07:00
Mike Welsh b59140ee01 render: Add support for GIF decoding in DefineBitsJPEG tags 2020-05-13 00:15:09 -07:00
Mike Welsh 5d84d33710 render: Handle PNG data in DefineBitsJPEG tags (fix #530) 2020-05-13 00:15:09 -07:00
dependabot-preview[bot] f68edb37b5 build(deps): bump syn from 1.0.19 to 1.0.20
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.19 to 1.0.20.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.19...1.0.20)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-12 00:10:19 -07:00
Nathan Adams b82b869950 core: Don't panic when NullNavigatorBackend can't do futures 2020-05-11 01:09:07 -07:00
Nathan Adams 2343074c56 core: Make RenderBackend downcastable 2020-05-11 01:09:07 -07:00
Nathan Adams edcd1e6d65 core: Add keyboard shortcut to dump every variable (ctrl+alt+V, same as Flash Player) 2020-05-10 23:39:54 -07:00
Nathan Adams c787e28fcd render: Introduce a DistilledShape and use that instead of swf::Shape for the rendering API 2020-05-10 22:03:56 -07:00
Nathan Adams 5767fb1772 swf: Added utility method for `Color::from_rgb(rgb, alpha)` 2020-05-10 22:03:56 -07:00
Nathan Adams 601715aa19 render: Merge begin_frame and clear as they're always called together 2020-05-10 22:03:56 -07:00
dependabot-preview[bot] 60ca1da468 build(deps): bump syn from 1.0.18 to 1.0.19
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.18 to 1.0.19.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.18...1.0.19)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-11 03:12:14 +00:00
Nathan Adams 054e6f1ac6 chore: Fix new rust check lint about std::mem::replace 2020-05-10 03:29:25 -07:00
Nathan Adams bac99368be chore: Fix new clippy lints about cloning 2020-05-10 03:29:25 -07:00
dependabot-preview[bot] a81adfa336 build(deps): bump num_enum from 0.4.3 to 0.5.0
Bumps [num_enum](https://github.com/illicitonion/num_enum) from 0.4.3 to 0.5.0.
- [Release notes](https://github.com/illicitonion/num_enum/releases)
- [Commits](https://github.com/illicitonion/num_enum/compare/0.4.3...0.5.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-10 10:27:38 +00:00
dependabot-preview[bot] 08a786a213 build(deps): bump libflate from 0.1.27 to 1.0.0
Bumps [libflate](https://github.com/sile/libflate) from 0.1.27 to 1.0.0.
- [Release notes](https://github.com/sile/libflate/releases)
- [Commits](https://github.com/sile/libflate/compare/0.1.27...1.0.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-05 08:12:26 +00:00
Nathan Adams 47a44a5fe8 desktop: Prime window with known width/height of the movie 2020-05-04 16:07:38 -07:00
Nathan Adams 51d9f3ef36 core: Change Player::new to take in a SwfMovie, not &[u8] 2020-05-04 16:07:38 -07:00
Nathan Adams 84f6b4d06e core: Set init_object values after prototype but before constructor 2020-05-03 12:46:55 -07:00
Nathan Adams 96d1f8fd30 tests: Add test for order of init_object vs constructor when attaching movies 2020-05-03 12:46:55 -07:00
Nathan Adams 0152f384ea core: Run any on(construct) events at the appropriate time 2020-05-03 12:46:55 -07:00
Nathan Adams 2b9219e8f9 tests: Add test for undocumented on(construct) property (note: this swf is hand-crafted) 2020-05-03 12:46:55 -07:00
Mike Welsh f09bd8c079 core: Clean up tick/render loop
Don't call `render` from `Player::tick`; instead, require the
frontends to explicitly call `render` when they wish to redraw.
The frontend can query `Player::needs_render` to see if the stage
is dirty and needs a redraw. Update desktop and web to use this
new method.

This fits better with the newer winit event loop model, which
requires explicitly calling `request_redraw`, and should avoid
spurious renders.
2020-05-02 04:25:21 -07:00
Mike Welsh 6339c74d67
render: Add wgpu backend (merge #527)
Adds a wgpu-rs render backend.
2020-05-02 03:42:05 -07:00
Nathan Adams 8384847084 avm1: Deleting on a non-object is a silent failure & warning, not a hard error 2020-04-30 14:18:54 -07:00
dependabot-preview[bot] 04660a9540 build(deps): bump quote from 1.0.3 to 1.0.4
Bumps [quote](https://github.com/dtolnay/quote) from 1.0.3 to 1.0.4.
- [Release notes](https://github.com/dtolnay/quote/releases)
- [Commits](https://github.com/dtolnay/quote/compare/1.0.3...1.0.4)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-04-30 21:18:17 +00:00
Nathan Adams 99d15aef0d render: Cache color transforms in wgpu backend, don't re-upload unchanged values 2020-04-30 16:33:41 +02:00
dependabot-preview[bot] 014df249a8 build(deps): bump jpeg-decoder from 0.1.18 to 0.1.19
Bumps [jpeg-decoder](https://github.com/image-rs/jpeg-decoder) from 0.1.18 to 0.1.19.
- [Release notes](https://github.com/image-rs/jpeg-decoder/releases)
- [Changelog](https://github.com/image-rs/jpeg-decoder/blob/master/CHANGELOG.md)
- [Commits](https://github.com/image-rs/jpeg-decoder/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-04-28 04:54:23 +00:00
Mike Welsh 8aa12d181f render: Remove RenderBackend::draw_pause_overlay 2020-04-27 04:45:53 -07:00
David Wendt ed29b1c3bb It turns out Macromedia just used an undocumented but user-modifiable property called `__constructor__` to store the constructor.
A previous version of this PR (whose history has been scrubbed, but go check 918d88abe68b7467a4194738b95e5bf3e9b5bb72 if you're curious) implemented a new `TObject` property which basically every line of code that dealt with object construction had to populate. It was terrible.
2020-04-25 14:37:24 -04:00
David Wendt bb879870ec Add test for the constructor property on v6 and v7 SWFs 2020-04-25 13:25:21 -04:00
Nathan Adams b3322acc8c tests: Copy as2_super_and_this test for manual prototype setting, used by mx (currently broken) 2020-04-25 13:25:20 -04:00
David Wendt aaa6f481ac Add a v6 version of the super-and-this test, which is exactly the same source compiled to SWF version 6. 2020-04-25 13:25:20 -04:00
David Wendt 17d96a0fa6 Constructing a new object sets `constructor` on that object for SWFv6 and lower. 2020-04-25 13:25:20 -04:00
David Wendt b8fd1eac9c Invoke virtual setters defined in the prototype chain.
This is accomplished via two new `TObject` methods: `has_own_virtual` and `call_setter`. If an object does not contain it's own version of a property, it will first crawl the prototype chain to see if there is an overwritable virtual. If so, it will invoke that prototype's setter.

A bit of borrow finangling was required to do this; `super` now no longer caches it's proto and constr values and instead dynamically constructs them. This also means it can't be downcasted to `Executable` anymore.

With this commit, virtual setters and super-setters now work correctly.
2020-04-25 13:25:19 -04:00
David Wendt 35197f889f `Property.set` should return a `ReturnValue` as it can potentially execute AVM code 2020-04-25 13:25:19 -04:00
David Wendt e76ba4de87 Method calls on `super` objects should substitute the child object instead of itself as `this`. 2020-04-25 13:25:19 -04:00
David Wendt 869cbd17da Extend `as2_super_and_this` to cover accessing object properties in super-methods, super-getters, and super-setters. 2020-04-25 13:25:18 -04:00
David Wendt 9c5cd79e2c Refactor how `SuperObject` works to use `base_proto` and avoid handing copies of itself as `this`.
This allows supercalled functions to properly read and mutate the object they were called on.
2020-04-25 13:25:18 -04:00
David Wendt f3b3db51cb Alter AVM1 to keep track of each function call's *base prototype*: the object from which a particular function was retrieved from.
A base prototype is only applicable in cases where a method is being called as a property on an object. Bare function calls, `apply`/`call` calls, and so on do not generate a base prototype.

We also add a convenience method, `call_method`, to all objects. This method automatically calculates the correct base prototype for a method call on an object, which is the only operation that should generate base prototypes.
2020-04-25 13:25:18 -04:00
David Wendt 15a19f4cf8 Add test from @Dinnerbone that checks to make sure super-called functions can still initialize the object they are a part of. 2020-04-25 13:25:17 -04:00
dependabot-preview[bot] c5a8402eae build(deps): bump syn from 1.0.17 to 1.0.18
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.17 to 1.0.18.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.17...1.0.18)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-04-25 10:19:18 +00:00
Mike Welsh fd114959f9 core: Fix regressions from init order changes in #498
Revert to the old action queue method of popping off actions in a
loop, as new actions can be queued while iterating. Store proto
changes in a separate queue to maintain the high priority behavior.
2020-04-25 03:06:54 -07:00
Mike Welsh bad34c4d8f tests: Fix tests for regressions caused by #498
Changes to the action queue caused actions queued during other
actions to run too late. These regressions weren't caught by the
tests because many of the goto tests ran for more frames than was
necessary, allowing the late actions to still run.
2020-04-25 03:06:54 -07:00
Mike Welsh c1dc69c6b7 chore: rustfmt 2020-04-24 22:16:16 -07:00
dependabot-preview[bot] 24a26541a3 build(deps): bump smallvec from 1.3.0 to 1.4.0
Bumps [smallvec](https://github.com/servo/rust-smallvec) from 1.3.0 to 1.4.0.
- [Release notes](https://github.com/servo/rust-smallvec/releases)
- [Commits](https://github.com/servo/rust-smallvec/compare/v1.3.0...v1.4.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-04-24 12:20:39 +00:00
Nathan Adams b43d0c2430 core: Pass SwfMovies along to empty movie clips 2020-04-21 05:49:25 -07:00
Nathan Adams a673e7108d tests: Add test for movieclip.createEmptyMovieClip().attachMovie()` 2020-04-21 05:49:25 -07:00
Nathan Adams 8b34fbdd81 chore: Removed debug code from a test 2020-04-21 05:48:17 -07:00
Nathan Adams 330e6b40f0 core: post_instantiation should happen after properties are set, but before first frame or actions 2020-04-17 23:48:58 -07:00
Nathan Adams 9318290336 core: Execute init actions immediately, do not queue them up
Clip initializers can and will influence how the next clips are loaded, and must execute before that

This fixes #418
2020-04-17 23:48:58 -07:00
Nathan Adams fe6b79a9b7 chore: Make avm1 accessible to MovieClip::preload 2020-04-17 23:48:58 -07:00
Nathan Adams 46d31548b0 chore: Move MovieClipData::do_init_action to MovieClip::do_init_action
No functional changes, just replaces `self` with `self.0.read()` and removed `self_display_object` argument
2020-04-17 23:48:58 -07:00
Nathan Adams c0d1dec7dd chore: Move MovieClipData::preload to MovieClip::preload
No functional changes, just replaced `self` with `self.0.read/write`.
2020-04-17 23:48:58 -07:00
Nathan Adams 601fcbfebd core: Queue up changes of movieclip prototypes, don't execute it immediately (but at a higher priority than normal actions) 2020-04-17 23:48:58 -07:00
Nathan Adams 6b48e77b61 avm1: Add TObject::set_proto 2020-04-17 23:48:58 -07:00
Nathan Adams 6316d7e0b3 tests: Add (currently failing) test for init order when combined with register_class 2020-04-17 23:48:58 -07:00
Nathan Adams d0fd26a89c avm1: Fix panic with [].unshift(x) 2020-04-17 21:17:13 -07:00
Nathan Adams bf639e1802 avm1: Don't crash when enumerating non-objects, it's a silent fail 2020-04-15 05:26:09 -07:00
Mike Welsh b7d464f367 chore: Bump enumset to 1.0.0 2020-04-13 04:14:29 -07:00
dependabot-preview[bot] 2146c42863 build(deps): bump smallvec from 1.2.0 to 1.3.0
Bumps [smallvec](https://github.com/servo/rust-smallvec) from 1.2.0 to 1.3.0.
- [Release notes](https://github.com/servo/rust-smallvec/releases)
- [Commits](https://github.com/servo/rust-smallvec/compare/v1.2.0...v1.3.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-04-09 21:19:11 +00:00
Mike Welsh 47e936fcc2 tests: Add tests for Array.sort 2020-04-01 18:46:12 -07:00
Mike Welsh bd0d2031bc avm1: Implement Array.sort and constants 2020-04-01 18:46:12 -07:00
Mike Welsh 2bdbac9247 tests: Test that Color has no effect when target is undefined 2020-03-30 01:09:05 -07:00
Mike Welsh e47c2aa356 avm1: Color object has no effect if target is undefined/empty 2020-03-30 01:01:37 -07:00
Mike Welsh d5bd7c2dd8 avm1: Math.round rounds towards infinity 2020-03-29 18:44:28 -07:00
Mike Welsh 0c0d3dfd41 core: Add Navigator::time_since_launch to use for getTimer
Change `ActionGetTime` (`getTimer`) to use a new backend method.
This allows it to return updated times if it is called multiple
times in a single frame. This fixes hangs caused by games that use
busy-loop "frame limiter" code.
2020-03-28 22:28:07 -07:00
Mike Welsh f7375c3700 avm1: Use `PropertyMap::get_index` for stage object properties 2020-03-28 16:22:02 -07:00
Mike Welsh 4ea609cca1 tests: Don't special case enumeration tests 2020-03-28 16:22:02 -07:00
Mike Welsh 8da9487c0a avm1: Match Flash's property enumeration order (fix #153) 2020-03-28 16:22:02 -07:00
Mike Welsh 2cdf780e6f avm1: Handle case sensitivity in DisplayObject children
Alter `get_child_by_name` and alter `get_level_by_path` to respect
case sensitivity.
2020-03-28 16:22:02 -07:00
Mike Welsh 81a0bb370b tests: Add test for SWF<=6 case insensitivty 2020-03-28 16:22:02 -07:00
Mike Welsh ea245895b0 avm1: Use PropertyMap for stage object magic properties 2020-03-28 16:22:02 -07:00
Mike Welsh 7d848f4f34 avm1: Add avm parameter to TObject methods
This is necessary to get the current SWF version for properly
handing case sensitivity.
2020-03-28 16:22:02 -07:00
Mike Welsh 1ef698f2ea core: Add PropertyMap for handling AVM1 object properties
`PropertyMap` wraps over `IndexMap` to handle object properties in
AVM1. All insert/remove/get methods require and `swf_version`
parameter, and the `PropertyMap` will take care of handling case
senstivity and maintaing iteration order based on the SWF version.
2020-03-28 16:22:02 -07:00
Mike Welsh d42a402522 avm1: Add display object methods to TextField 2020-03-26 14:19:18 -07:00
Mike Welsh 7865ec1021 avm1: Implement Button object
First implementation of Button object. Hook up to the button
display object and run onRelease etc. methods as appropriate.

Pull out common display object methods into globals::display_object.
2020-03-26 00:21:21 -07:00
Mike Welsh 4df1128c19
core: Implement Object.registerClass (merge #344)
Implement Object.registerClass
2020-03-25 18:55:49 -07:00
dependabot-preview[bot] ef5ee3a889 build(deps): bump syn from 1.0.16 to 1.0.17
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.16 to 1.0.17.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.16...1.0.17)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-03-21 01:37:48 +00:00
Mike Welsh e9cb05aeb4 avm1: Correct order of modulo operands
Addresses part of #458.
2020-03-20 16:00:28 -07:00
hthh a16885d84b avm1: Fix string-to-number octal and whitespace handling
This conversion allows negative octal values, but not negative
hex values, and ignores only leading ASCII whitespace. A test
for this behavior is included.
2020-03-20 04:27:41 -07:00
Nathan Adams b4624fddce avm1: GetVariable and SetVariable look through the scope chain. Fixes #414
GetVariable and SetVariable attempt to resolve paths on each scope
in the scope chain.
2020-03-19 19:58:16 -07:00
Mike Welsh 454cd29ed6 chore: EditText::font takes self by value 2020-03-17 19:42:57 -07:00
Mike Welsh 068f4c3bee core: Edit text uses device fonts when outline flag isn't set
Specifically fall back to the device font when the UseOutlines
flag is not set in DefineEditText (SWF19 p.172). Fixes #451.

Note that since we only use a single font for "device" rendering,
this may sometimes be a different font than is specified in the
Flash IDE.
2020-03-17 19:13:20 -07:00
dependabot-preview[bot] da3398c832 build(deps): bump bitstream-io from 0.8.4 to 0.8.5
Bumps [bitstream-io](https://github.com/tuffy/bitstream-io) from 0.8.4 to 0.8.5.
- [Release notes](https://github.com/tuffy/bitstream-io/releases)
- [Commits](https://github.com/tuffy/bitstream-io/commits/v0.8.5)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-03-17 17:08:59 +00:00
dependabot-preview[bot] 2bfa2502a9 build(deps): bump num_enum from 0.4.2 to 0.4.3
Bumps [num_enum](https://github.com/illicitonion/num_enum) from 0.4.2 to 0.4.3.
- [Release notes](https://github.com/illicitonion/num_enum/releases)
- [Commits](https://github.com/illicitonion/num_enum/compare/0.4.2...0.4.3)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-03-17 17:07:35 +00:00
Mike Welsh c2ce9892b1 core: Clamp RGBA when un-multiplying alpha
Fixes some bad pixels sometimes appearing in decoded JPEGs (such
as in #437 and in Dad 'n' Me).
2020-03-16 16:11:59 -07:00
dependabot-preview[bot] 0f7f36681d build(deps): bump quick-xml from 0.17.2 to 0.18.1
Bumps [quick-xml](https://github.com/tafia/quick-xml) from 0.17.2 to 0.18.1.
- [Release notes](https://github.com/tafia/quick-xml/releases)
- [Changelog](https://github.com/tafia/quick-xml/blob/master/Changelog.md)
- [Commits](https://github.com/tafia/quick-xml/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-03-16 05:34:45 +00:00
Mike Welsh 24a557807d chore: Fix more clippy lints 2020-03-12 21:40:48 -07:00
Mike Welsh 13b039fa34 chore: Fix clippy iter-nth-zero warnings
New lint added in latest clippy versions.
2020-03-12 21:16:30 -07:00
Mike Welsh 098bf33068 chore: Bump quote to 1.0.3 2020-03-08 18:58:39 -07:00
dependabot-preview[bot] a0ee19fd37 build(deps): bump syn from 1.0.14 to 1.0.16
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.14 to 1.0.16.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.14...1.0.16)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-03-02 20:26:50 +00:00
dependabot-preview[bot] ba185d3d43 build(deps): bump minimp3 from 0.3.3 to 0.3.5
Bumps [minimp3](https://github.com/germangb/minimp3-rs) from 0.3.3 to 0.3.5.
- [Release notes](https://github.com/germangb/minimp3-rs/releases)
- [Commits](https://github.com/germangb/minimp3-rs/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-03-02 19:07:25 +00:00
dependabot-preview[bot] 3f28554285 build(deps): bump enumset from 0.4.4 to 0.4.5
Bumps [enumset](https://github.com/Lymia/enumset) from 0.4.4 to 0.4.5.
- [Release notes](https://github.com/Lymia/enumset/releases)
- [Changelog](https://github.com/Lymia/enumset/blob/master/RELEASES.md)
- [Commits](https://github.com/Lymia/enumset/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-03-02 18:14:25 +00:00
Nathan Adams 751b15beec chore: Raise errors during Object.registerClass 2020-02-29 23:13:02 +01:00
Nathan Adams 7bed4d4940 chore: Document each trace in attach_movie avm1 tests 2020-02-29 23:05:17 +01:00
Nathan Adams 041bb6b44c avm1: Implement `Object.registerClass` 2020-02-29 23:05:17 +01:00
Nathan Adams d850443c84 avm1: Refactor to expose `avm, context` in `post_instantiate` 2020-02-29 23:05:15 +01:00
David Wendt fdce33ff5e Return an `Err` when decompression fails, rather than just logging it and returning an empty vec. 2020-02-26 18:18:24 -05:00
David Wendt ded7737ac0 `SwfMovie::from_data` is falliable and we should not hide those errors behind panics. 2020-02-26 18:15:01 -05:00
David Wendt 0313225164 Don't allow movie loads to be removed from the load manager unless they have completed or errored. 2020-02-26 18:03:45 -05:00
David Wendt a023e161fc Don't panic if our target handle was removed from the load manager. Instead, return an `Err` so that it can be properly reported on the console without killing the player. 2020-02-26 17:38:31 -05:00
Mike Welsh 223edb9bc1 core: Matrix translation is in twips 2020-02-26 12:47:47 -08:00
Mike Welsh c4c02260fb core: Implement keyUp event 2020-02-26 03:48:07 -08:00
Mike Welsh db9bd1616e chore: Remove unused deref impl from AudioBackend 2020-02-26 02:00:28 -08:00
Mike Welsh 86ec2c6cb8 input: Add InputBackend::set_mouse_cursor. Change cursor on buttons
It doesn't feel like Flash without having the hand cursor display
when hovering over buttons. First pass at implementing this;
core communicates which mouse cursor to use via
`InputBackend::set_mouse_cursor`.

TODO: Hand cursor only displayed for Button display objects
currently. Movie clips should also display this when they are in
"button mode" (when a button mouse event is set on them in AVM1,
or `buttonMode` property in AVM2).
2020-02-25 02:50:26 -08:00
Mike Welsh a917fa4028 tests: Add temporary test for MovieClip.getRect
This is just testing that it exists and returns the same values as
getBounds for shapes without strokes.

TODO: When it is properly implemented for strokes, add stroked
shapes to testing.
2020-02-24 14:12:48 -08:00
Mike Welsh d8079ac04a core: Stub out MovieClip.getRect
Just defer to getBounds for now. TODO: getRect should return bounds
ignoring strokes, so in reality it is <= getBounds.
2020-02-24 14:12:48 -08:00
Mike Welsh 993c05cf19 core: Calculate bounds for each morphshape frame 2020-02-24 14:12:48 -08:00
Mike Welsh a5c08f2e59 avm1: Implement MovieClip.getBounds and clean up bounding box methods
Implements MovieClip.getBounds, and also reorganized the
DisplayObject AABB methods:

 * `self_bounds` calculates the inherent untransfomed bounds of
 the object without children. All `DisplayObject`s must implement
 this method. For example, `Bitmap` returns the size of bitmap.
 Composite objects like `MovieClip` return a null AABB because they
 are made up of only children.
 * `bounds` calculates the untransformed bounds including children.
 * `local_bounds` calculates the bounds relative to the object's
 parent.
 * `world_bounds` calculates the bounds in global stage space.
 * `bounds_with_transform` calculates a tight AABB for the object
 with a given transform, and is used to implement the above.
2020-02-24 14:12:48 -08:00
Mike Welsh 73a9a0e771 tests: Add test for MovieClip.getBounds 2020-02-24 14:12:48 -08:00
Mike Welsh 8c486b7544 chore: Use free functions for movie_clip methods
Try to keep style more consistent by using functions for all MC
methods. Previous was a mix of closures and functions (we're still
a little bad with this elsewhere)
2020-02-24 11:17:40 -08:00
Mike Welsh f163afc5b4 core: Use collect to copy level pointers 2020-02-24 02:28:27 -08:00
Mike Welsh 1b08fb538d chore: Rename layer -> level
Unify mix of 'layer' and 'level' in the code, and it's probably
better to stick with Flash nomenclature.
2020-02-23 23:41:55 -08:00
David Wendt 05e5fbb69c For some reason, this color transform code broke on the moviefetch branch 2020-02-22 00:02:52 -05:00
David Wendt abc1d00276 Fix incorrect preload of `_root` in `DefineFunction2` function calls.
This is caused by the fact that `avm.root_object` references the *current* stack frame, not the one we are about to introduce. Ergo, we need to pull the base clip of the *new* stack frame and find it's root.

This particular behavior only crops up in situations where there can be multiple root objects, at least until we implement `_lockroot`.
2020-02-22 00:02:51 -05:00
David Wendt 766ded6dfd When replacing a movie clip with another movie, don't wipe out the entire display object base as that disassociates us from our parent, siblings, and most importantly, *layer depth*. 2020-02-22 00:02:51 -05:00
David Wendt e0b4a0f193 Top-level layers are referenced via their path (`_leveln`) rather than name - in fact, their name is always the empty string. 2020-02-22 00:02:51 -05:00
David Wendt 00f88f9e87 Use the depth to indicate which layer a particular root clip is, and then use that to calculate it's `_leveln` path. 2020-02-22 00:02:50 -05:00
David Wendt 8ef759d377 Top-level layers do not get an instance name of `_leveln`. 2020-02-22 00:02:50 -05:00
David Wendt 9adf0f43d7 Allow levels to be read as scope variables, and add a test for this. 2020-02-22 00:02:50 -05:00
David Wendt 5a7e530c91 Add a test for cross-movie `_root`.
This test does not pass yet. Other layers need to resolve as target paths in order for this to happen.
2020-02-22 00:02:48 -05:00
David Wendt aa6aba13dd Abolish `context.root` completely.
`_root` is calculated dynamically based on the clip the currently executing function was called in.

Other things that used `context.root` have been changed to either update all layers or just update layer 0, which is the former `context.root`.
2020-02-22 00:02:46 -05:00
David Wendt 33d26b9149 Shorten `Pin<Box<dyn Future<Output=Result<T,E>> + 'static>>` into `OwnedFuture<T,E>`.
This is technically stricter on `fetch` impls, but right now we can't support non-`'static` futures at all.
2020-02-22 00:02:45 -05:00
David Wendt aab339880d Implement `XML.load()`, with tests.
Interestingly enough, very little actually has to be done inside the async process for XML. The async process basically just fetches data and fires an event handler when it's done. Everything else is handled via a system builtin, `XML.onData`.
2020-02-22 00:02:45 -05:00
David Wendt 538a5f05e5 Add tests for various forms of `loadVariables`.
Surprisingly enough these tests passed without any changes, somehow.
2020-02-22 00:02:43 -05:00
David Wendt c00ecccd1f Basic, stub implementation of `MovieClipLoader.getProgress`, plus test.
This implementation just returns the size of the current loaded movie. The test is also deliberately written to be loose on timings so that it likely won't see a partially loaded movie. (I don't want it to be a test of load events, so I just wait a few frames, rather than the correct way of waiting for `onLoadComplete`.)

Until we support streaming file loads, we can't faithfully support these properties. Still, it's better to have them, just in case.
2020-02-22 00:02:42 -05:00
David Wendt 3f7e3a9ed8 Implement `MovieClipLoader.unloadClip`, with tests. 2020-02-22 00:02:41 -05:00
David Wendt a132226da4 Run `onLoadInit` at the *end* of a frame, rather than before the movie clip's own actions.
This is technically better, but it may make more sense to trigger `ClipEvent::Load` at the start of the next frame instead. Furthermore, I don't know if other forms of load events should trigger on the next frame (or end of the current one) like this.
2020-02-22 00:02:39 -05:00
David Wendt 55734619f7 `GetUrl2` can accept a `DisplayObject` as target in `LoadTargetFlag` mode.
I have no idea what happens to non-MovieClip objects, or if I'm really supposed to `coerce_to_string` here.
2020-02-22 00:02:36 -05:00
David Wendt d49c0e9bf7 Rewrite some of the unload and cliploader tests to be more generous with load timing.
Loads in Flash Player, like all web technologies, are asynchronous tasks of some kind (probably a separate thread). They appear to operate on some kind of a delay. If I `trace` each frame out, like in the previous version of `mcl_loadclip`, you get a series of events that look like this:

1. Parent frame 1
2. Parent frame 2
3. Event: onLoadStart
4. Event: onLoadProgress
5. Event: onLoadComplete
6. Parent frame 3
7. Event: onLoadInit

If I run that version of the test on Ruffle, everything happens after frame 1. This is an artifact of how we're testing asynchronous behavior in Ruffle. In order to guarantee test determinism, we have a dummy implementation of `fetch` that does a blocking load, and we poll all futures every frame of execution. This means that there is a very specific order of execution with these tests, which is good for testing, but probably isn't 100% accurate.

Flash Player appears to delay all loads by at least one frame, even loads that are coming from disk which should load immediately. I don't know if this is intentional or not, so I don't want to implement a load delay just for the sake of making tests pass. Ergo, I'm loosening the tests to just test the ability to load and unload movies, and fire events from a loader.

Specifically:

1. `mcl_loadclip` no longer traces out frames of the parent timeline
2. `unloadmovie` et. all use a target movie that doesn't fail the test until 10 frames have passed.

If someone can find a movie network that breaks with fast loading, then I'll consider implementing explicit frame delays for async tasks. Otherwise, this is how we're testing this.
2020-02-22 00:01:22 -05:00
David Wendt 8ece2d1b31 Add another ignored test, this time measuring the timing of load events broadcasted by `MovieClipLoader`. We're loading too early, which is why this is ignored. 2020-02-22 00:01:20 -05:00
David Wendt b56c3b6aed Fire events directly onto `broadcastMessage` instead of the individual event handlers on the `MovieClipLoader`, so that listeners run correctly.
Also, this fixes a double-borrow for `onClipInit`.
2020-02-22 00:01:19 -05:00
David Wendt 89e5dd97f3 Implement `MovieClipLoader.loadClip` 2020-02-22 00:01:19 -05:00
David Wendt 162b6b70f8 Allow unloading a movie by sending `None` to `replace_with_movie`.
This also adjusts `MovieClip.unloadMovie` to do just that, instead of removing the clip from the display list. We also have to unload clips when loading new movies into them, since `unloadMovie` desugars to loading `""` as the URL.
2020-02-22 00:01:19 -05:00
David Wendt 8ef4a94672 Add new tests for `unloadMovie`, `unloadMovieNum`, and `MovieClip.unloadMovie`.
They currently fail in Ruffle, so they're ignored.
2020-02-22 00:01:18 -05:00
David Wendt cc5dff4254 Add a test for `MovieClip.loadMovie`. 2020-02-22 00:01:17 -05:00
David Wendt 82d305a0f5 Add test for `loadmovienum` 2020-02-22 00:01:16 -05:00
David Wendt a9621da47d Add tests for `loadMovie`.
This test also includes changes to the SWF testing environment to allow asynchronous movie loads to execute.
2020-02-22 00:01:15 -05:00
David Wendt a8545ee277 Implement `onLoadInit` by pulling `LoadManager` into all clip load events. 2020-02-22 00:01:14 -05:00
David Wendt 7ff885a0de Implement `MovieClipLoader` event broadcasts for `onLoadStart`, `onLoadProgress`, `onLoadComplete`, and `onLoadError`.
Note that we do not implement `onLoadInit` yet - this requires some ability to trigger an event when another movie clip loads.
2020-02-22 00:01:14 -05:00
David Wendt db41bec91e Implement `MovieClipLoader`'s `addListener`, `removeListener`, and `broadcastMessage` methods.
Interestingly, this constitutes an implementation of `AsBroadcaster`. It appears Macromedia decided to implement event handling on `MovieClipLoader` in a very similar fashion to `AsBroadcaster`, down to invoking `broadcastMessage` and searching a `_listeners` property for listeners.
2020-02-22 00:01:12 -05:00
David Wendt b7d318a897 Implement `MovieClip.loadMovie`, `MovieClip.loadVariables`, and `MovieClip.unloadMovie`.
*De*implement the free function versions of the above, as well as their `Num` variants, since they don't actually exist as callables. Instead, the ActionScript compiler treats them as preprocessor functions that represent various forms of `ActionGetURL`/`ActionGetURL2`.
2020-02-21 23:59:13 -05:00
David Wendt 31b1364b82 Implement `unloadMovie` / `unloadMovieNum` 2020-02-21 23:58:00 -05:00
David Wendt b2b2a165fc Implement `loadVariables` and `loadVariablesNum`. 2020-02-21 23:58:00 -05:00
David Wendt c7539872f7 Add the ability to POST data from `fetch`, and allow methods that read AVM locals into form data to `GET` or `POST` them. 2020-02-21 23:58:00 -05:00
David Wendt 3fe6884c90 Refactor layer resolution into a separate function.
This function is part of `Avm1`, rather than a hypothetical `LayerManager`, because we're going to need to eventually construct layers differently for AVM2.
2020-02-21 23:57:59 -05:00
David Wendt ea28c2c4a2 Impl `loadMovie` / `loadMovieNum` (sans local variable support) 2020-02-21 23:57:59 -05:00
David Wendt 07637fe676 Replaced movies should start out playing. This fixes a regression from a previous rebase. 2020-02-21 23:57:58 -05:00
David Wendt 64b787b73f Implement `Collect` for `Loader`. (How did this compile without that?) 2020-02-21 23:57:58 -05:00
David Wendt d84e11ed40 Introduce a new top-level object, `LoadManager`, which is responsible for all asynchronous behavior in the program. Migrate the existing async impls to it. 2020-02-21 23:57:58 -05:00
David Wendt 2d7a4fef28 `Sound` methods that reference sounds by library export name should default to `_layer0`'s library if the `Sound` was created without a movie clip target. 2020-02-21 23:57:57 -05:00
David Wendt 6b78ec6e03 More thoroughly clean `MovieClip`s that have movies loaded into them. This does everything except wipe the object it's attached to - I need further testing to see how Flash handles that. 2020-02-21 23:57:57 -05:00
David Wendt 2a82d21966 Change the layer list from a static array to a `BTreeMap`.
Flash allows creating layers at any 31-bit height without issue, so this should support similar limitations.
2020-02-21 23:57:57 -05:00
David Wendt f4e4171ebe Make spawned futures falliable, and report those errors. 2020-02-21 23:57:56 -05:00
David Wendt 5ce499d11e Add separate libraries for each loaded movie. 2020-02-21 23:57:56 -05:00
David Wendt e0c0779bd0 Make sure to preload all loaded clips. 2020-02-21 23:57:55 -05:00
David Wendt 6da374c567 Implement loading movies into `_leveln` via `ActionGetUrl` 2020-02-21 23:57:55 -05:00
David Wendt ed799fd2b9 Split the player up into nine layers, each of which is a separate root movie clip. 2020-02-21 23:57:55 -05:00
David Wendt 8c9d290db7 Implement the MovieClip loading portion of `ActionGetURL2`. 2020-02-21 23:57:54 -05:00
David Wendt 5ed5876e9a Merge SWF data and version into a single structure. Refactor everything that interacts with it to use `SwfSlice`s. 2020-02-21 23:57:53 -05:00
David Wendt 250ec13c12 Implement LoadVariablesFlag.
This has some subtle problems: we cannot hold references to garbage-collected data in Futures, so we have to arrange for the AVM itself to forcibly root them for us. Then we get them back when our async code is ready to do something to the AVM.
2020-02-21 23:44:06 -05:00
David Wendt 55149b7b7e Reference count the Player and provide a weak reference in UpdateContext.
This allows the formation of `'static` futures that can still interact with a player. Async code will need to upgrade the weak reference in order to be able to interact with the player.
2020-02-21 23:44:06 -05:00
David Wendt 491d94c947 Pinbox all Futures.
Due to some strangeness with the way Rust implemented unsafe-to-move behavior, boxed futures are implicitly `Unpin`. Which is useless to us.

The reason for this is a little counter-intuitive. Actually, the fact that Rust supports memory pinning at all is a little odd, because the core language explicitly requires all types be movable. To get around this, Pin requires that all !Unpin types be *born pinned*. This is because you can't re-pin an already unpinned value in memory.

Anyway, this necessitates this silly API change.
2020-02-21 23:44:05 -05:00
David Wendt 00d25a768c Extremely basic impl of fetch/spawn methods for getting data off the web 2020-02-21 23:44:05 -05:00
David Wendt 2137b9f1fd Migrate `set_frame_rate` into the core `AudioBackend` trait 2020-02-21 23:44:05 -05:00
David Wendt c1cf73ccb3 Add a public method to trigger a player update.
User-defined player updates are treated the same as if a stage frame had been run: queued actions are executed and garbage is collected.
2020-02-21 23:44:04 -05:00
Mike Welsh f80c188048 core: Stop stream sounds when a clip is removed 2020-02-21 19:24:45 -08:00
Mike Welsh 6b503ac053 avm1: Fix DefineFunction2 preload order when _parent is undefined
The order is misdocumented in SWF19 (and also miscompiled assuming
this incorrect order by the Flash IDE!).

`_global` gets preloaded before `_parent`.
2020-02-20 12:58:26 -08:00
Mike Welsh dc1f99e2ba tests: Add test for misdocumented DefineFunction2 register preload 2020-02-20 12:58:26 -08:00
Mike Welsh 10fb6c7c04 tests: Add define_function2_preload test 2020-02-19 23:22:33 -08:00
Mike Welsh 19d0bf64a9 avm1: Preload _parent directly from base clip
When `_parent` is preloaded  in a `DefineFunction2` action,
we previously resolve it on the scope chain. This could cause
double borrow panics as the parent object could already be
borrowed, and also this matches the behavior of the official Flash
player.

Addresses #398.
2020-02-19 23:22:33 -08:00
Mike Welsh 8d7e58011e avm1: undefined coerces to "" in SWFv6 and below
Except in the AVM1 trace op, which will print out "undefined".
2020-02-19 10:47:43 -08:00
Mike Welsh dfde98da7d tests: Add tests for coercing undefined to string in SWF6 2020-02-19 10:47:43 -08:00