Commit Graph

1913 Commits

Author SHA1 Message Date
David Wendt 896a5b37a5 avm2: Implement `new MovieClip()`. 2020-10-06 06:03:22 -07:00
David Wendt d399811eb8 avm2: Allow `MovieClip` to be constructed by users. 2020-10-06 06:03:22 -07:00
David Wendt 50dd9a6733 avm2: Implement the programmatically-playing flag that governs `isPlaying` behavior. 2020-10-06 06:03:22 -07:00
David Wendt 035c841eb5 tests: Add tests for `gotoAndStop` and rename the `gotoAndPlay` one 2020-10-06 06:03:22 -07:00
David Wendt 1f29497b8c tests: Add test for AS3 movieclip play 2020-10-06 06:03:22 -07:00
David Wendt 8152400a39 avm2: Implement `MovieClip.scenes`. 2020-10-06 06:03:22 -07:00
David Wendt c682868205 avm2: Implement `MovieClip.currentScene` 2020-10-06 06:03:22 -07:00
David Wendt 2483201bcd avm2: Store the lengths of each scene in a movie. 2020-10-06 06:03:22 -07:00
David Wendt 8a13d5fe10 avm2: Implement `Scene` object. 2020-10-06 06:03:22 -07:00
David Wendt 5e31c44b81 All objects should default to `toString`ing with their own classname. 2020-10-06 06:03:22 -07:00
David Wendt de186ed5f3 avm2: Implement `MovieClip.currentLabels` 2020-10-06 06:03:22 -07:00
David Wendt 77a86aef9b avm2: Implement `FrameLabel`. 2020-10-06 06:03:22 -07:00
David Wendt 86b07c0007 tests: Add tests for `prevScene` and `nextScene`. 2020-10-06 06:03:22 -07:00
David Wendt 542147d657 avm2: Run all AVM2 frame scripts on the action queue.
This is the same way that AVM1 actions run and it appears that frame scripts work exactly the same way. It fixes all outstanding bugs with movie clip navigation in AVM2 and allows me to remove a lot of weird workarounds I was writing for the old, incorrect behavior.

I'm also removing the "last run script frame" rule as `run_frame_internal` already had rules to prevent stopped clips from rerunning actions.
2020-10-06 06:03:22 -07:00
David Wendt 996d7528d5 avm2: Implement `prevScene` and `nextScene`. 2020-10-06 06:03:22 -07:00
David Wendt 864c6a37f9 avm2: Dynamic properties should be retrievable before they are actually set. 2020-10-06 06:03:22 -07:00
David Wendt 6d0befad97 avm2: Implement `prevFrame` and `nextFrame`, with tests. 2020-10-06 06:03:22 -07:00
David Wendt bcf08b5bf7 avm2: Frame scripts should run when the frame number has changed, regardless of playhead state. 2020-10-06 06:03:22 -07:00
David Wendt 97048fb8bd avm2: Implement `stop` and `play`, with tests for the former. 2020-10-06 06:03:22 -07:00
David Wendt c8cd4d09cd core: Don't run frame scripts on stopped movie clips. 2020-10-06 06:03:22 -07:00
David Wendt 556c951b1c avm2: Implement `gotoAndPlay`/`gotoAndStop`, with test. 2020-10-06 06:03:22 -07:00
David Wendt 3513918149 avm2: Allow typechecking by prototype, rather than just by constructor. 2020-10-06 06:03:22 -07:00
David Wendt e837840bba core: Always skip frames after the current frame when getting the current scene or label. 2020-10-06 06:03:22 -07:00
David Wendt 5b83f6b4cc avm2: Add test for movieclip-specific properties. 2020-10-06 06:03:22 -07:00
David Wendt 3b6f8cff4e avm2: Implement `framesLoaded`, `isPlaying`, and `totalFrames`. 2020-10-06 06:03:22 -07:00
David Wendt 7ca34452a1 avm2: Implement `currentFrameLabel` and `currentFrame`. 2020-10-06 06:03:22 -07:00
David Wendt 6124ed468f core: Add `current_label` for getting the current label on a given clip.
This also fixes `current_scene` as well.
2020-10-06 06:03:22 -07:00
David Wendt c1b14b7639 avm2: Implement `currentFrame`. 2020-10-06 06:03:22 -07:00
David Wendt 7756fd530d core: Allow grabbing the movieclip's current scene, if scene labels are defined. 2020-10-06 06:03:22 -07:00
David Wendt d747ef7914 core: Store scene and frame labels generated by the `DefineSceneAndFrameLabelData` tag. 2020-10-06 06:03:22 -07:00
David Wendt 55fec14a1c tests: Add tests for timeline scripts. 2020-10-06 06:03:22 -07:00
David Wendt c04bf7d53c `addFrameScript` indexes by zero, not by one. 2020-10-06 06:03:22 -07:00
David Wendt ab45b9084d avm2: Parse `SymbolClass` package paths correctly. 2020-10-06 06:03:22 -07:00
David Wendt a1a21500d8 core: Warn when a movie clip is AVM2-constructed without an accompanying symbol class. 2020-10-06 06:03:22 -07:00
David Wendt 8c67260e68 core: Special-case ID 0 as the current movie timeline.
Note: This relies on the fact that SWF files do not stick `SymbolClass` declarations in child movieclips. If this isn't the case, then it will fail horribly, and we would then need to actually store clip 0 in the library somehow.
2020-10-06 06:03:22 -07:00
David Wendt f2c3466026 avm2: The AVM2 constructor should be an actual Class, not it's prototype. 2020-10-06 06:03:22 -07:00
David Wendt e915a07d4f core: ABC files should resolve at the time of discovery, not on the action queue. 2020-10-06 06:03:22 -07:00
David Wendt 7e898457b0 avm2: Implement `addFrameScript`. 2020-10-06 06:03:22 -07:00
David Wendt d991c49774 Implement `addFrameScript`. 2020-10-06 06:03:22 -07:00
David Wendt 664152d739 avm2: Mark `EventDispatcher` as implementing `IEventDispatcher`.
This doesn't actually implement any of it's methods yet, which *would* cause an error *if* we were verifying that.
2020-10-06 06:03:22 -07:00
David Wendt e72c9776ec avm2: Implement `IEventDispatcher`. 2020-10-06 06:03:22 -07:00
David Wendt c899b3080a avm2: Add function to unwrap a `StageObject` as it's underlying `DisplayObject`. 2020-10-06 06:03:22 -07:00
David Wendt a70e1be466 Add code to instantiate AVM2 movie clips correctly.
This also includes several bits to build an effective VM barrier.
2020-10-06 06:03:22 -07:00
David Wendt 247e79e61a core: Track the VM each movie has pledged to execute on.
This uses a "VM tendency" system wherein the presence of `DoAction` or `DoInitAction` tags defaults the movie to AVM1, while the presence of `DoABC` defaults to AVM2. The presence of a `FileAttributes` tag allows setting the VM tendency in the same manner using it's AS3 bit.

Particularly malformed SWFs may cause execution issues if Flash Player uses a dramatically different system from this.
2020-10-06 06:03:22 -07:00
David Wendt 3128bbcda6 core: Implement `SymbolClass` tag. 2020-10-06 06:03:22 -07:00
David Wendt edd31c4b83 core: Allow pulling the AVM2 Object out of a participating movie clip. 2020-10-06 06:03:22 -07:00
David Wendt f85319aa4c core: Allow `DisplayObject` to hold AVM2 objects.
This requires the use of an intermediary enum called `AvmObject` which can hold either object representation. Currently, it's mostly just being unwrapped as AVM1 objects, which we will need to fix.
2020-10-06 06:03:22 -07:00
David Wendt 63f411d231 avm2: Add `StageObject` object implementation for holding display objects in AVM2. 2020-10-06 06:03:22 -07:00
David Wendt 3fb186e5c0 avm1: Remove fscommand debug code 2020-10-01 13:53:00 -07:00
David Wendt 1a77874e04 avm1: For good measure, also unload on empty URL in `ActionGetURL`. 2020-10-01 13:53:00 -07:00
David Wendt bb5c367e91 chore: Remove dbg statement in loaders 2020-10-01 13:53:00 -07:00
David Wendt e73cdd7987 avm1: Actually unload movies when we get an empty URL in `GetURL2` and the target is a sprite. 2020-10-01 13:53:00 -07:00
CUB3D f0a02f00b5 core: Changes from review 2020-09-29 11:06:56 -07:00
CUB3D 110b9ec551 core: Fix edge cases and implement rest of bevel filter 2020-09-29 11:06:56 -07:00
CUB3D 2c3ee4d94b core: Add flash.filters.BevelFilter 2020-09-29 11:06:56 -07:00
Sean-Thomas 5701312527 desktop: Implement play/pause for CPAL backend
- removed default implementations for `play()` and `pause()` methods for AudioBackend trait
- Implemented `play()` and `pause()` methods for CPAL audio backend
- Implemented empty block for `play()` and `pause()` methods for NULL audio backend
2020-09-29 11:05:23 -07:00
Sean-Thomas a9538f81d0 web: Renamed "prime_audio" and "suspend_audio"
Renamed "prime_audio" and "suspend_audio" to "play" and "pause" respectfully.
2020-09-29 11:05:23 -07:00
Sean-Thomas 6b54cc4311 web: Add pause method for web player
Adds a suspend_audio method to compliment prime_audio on WebAudioBackend, as well as logic in player.rs on the set_is_playing method to suspend audio when is_playing is set to false. Exposes pause method for the ruffle player in JavaScript with logic to display the play button when paused.
2020-09-29 11:05:23 -07:00
Mike Welsh ead845ff33 chore: Appease clippy 2020-09-26 18:19:37 -07:00
Mike Welsh 98d2651e62 tests: Add tests for Array single-param ctor 2020-09-26 14:13:06 -07:00
Mike Welsh 366e8aa926 Array: Fix Array single-param ctor
The Array constructor with a single param sets the length if the
parameter is a number (no coercion is done); otherwise, it is
creates an 1-length Array containing the parameter. Previously
we coerced the parameter to a float.
2020-09-26 14:13:06 -07:00
Mike Welsh 9e13058e04 avm1: Fix list of elements in Array ctor (fix #1195) 2020-09-26 14:13:06 -07:00
David Wendt 6bb6bcab7a core: Store rotations in degrees to avoid floating-point conversion discrepancies. 2020-09-26 14:12:49 -07:00
David Wendt 28bf84bd8b core: Store object scale as percentages to avoid floating point precision problems.
Fixes a specific pattern of preloader design where animations were handled by just making the box bigger every frame until it's 100. Of course, direct equality of f64 is a terrible idea, but it works in Flash, which apparantly must store scale in percentages. So we must, too.
2020-09-26 14:12:49 -07:00
David Wendt f6f084098e tests: Add a test for floating point errors in the AVM1 representation of `_xscale`, `_yscale`, and `_rotation`. 2020-09-26 14:12:49 -07:00
dependabot-preview[bot] c5135fc737 build(deps): bump syn from 1.0.41 to 1.0.42
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.41 to 1.0.42.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.41...1.0.42)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-09-26 14:11:01 -07:00
dependabot-preview[bot] 0dfac7b1ac build(deps): bump gif from 0.11.0 to 0.11.1
Bumps [gif](https://github.com/image-rs/image-gif) from 0.11.0 to 0.11.1.
- [Release notes](https://github.com/image-rs/image-gif/releases)
- [Changelog](https://github.com/image-rs/image-gif/blob/master/Changes.md)
- [Commits](https://github.com/image-rs/image-gif/compare/v0.11.0...v0.11.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-09-25 13:22:07 -07:00
Mike Welsh 802636fbbf chore: Bump to gif 0.11.0 2020-09-21 18:30:27 -07:00
Luca Weiss 8a8075ca99
avm1: Fix registered function names for Sound object (#1209)
The functions are just stubs currently so this shouldn't change any
behavior.
2020-09-19 16:21:50 -07:00
Nathan Adams 4a83641a6c core: Support \r newlines in texts - fixes #1071, #808 2020-09-19 16:18:35 -07:00
Luca Weiss d5cb396331 *: fix spelling mistakes 2020-09-19 16:17:58 -07:00
Mike Welsh 2f84d468ee text: Default text span color should be black
Previosuly color defaulted to 0% alpha, causing text to be
invisible if the text field did not specify a defualt color.
2020-09-18 18:58:09 -07:00
Mike Welsh 6f2655cf95 tests: Add test for SWF4 string ops 2020-09-17 16:03:51 -07:00
Mike Welsh 7eeba10bef avm1: Clean up SWF4 string ops
Clean up SWF4 string ops:
 * Operate on UTF-16 code units (in SWF6+)
 * StringExtract indices are 1-based
2020-09-17 16:03:51 -07:00
Mike Welsh 4f6c017bc0 avm1: Move utf16 util methods to string_utils 2020-09-17 16:03:51 -07:00
Nathan Adams ef3d5c1538 core: Apply a mask when rendering text, fixes parts of #1167 2020-09-17 16:03:16 -07:00
Nathan Adams e008603426 core: Add draw_rect to the render backend API 2020-09-17 16:03:16 -07:00
Mike Welsh 3cc43265bf core: Always recurse down into movieclips when mouse picking
Was only consdering the world bounds, but buttons can have separate
hit areas that don't actually affect the bounds of the parent clip.
(TODO: Could have keep track of a separate mouse_bounds instead.)

Fixes regression in Mini-Putt 2 (#1120).
2020-09-15 02:34:32 -07:00
Mike Welsh 4593320d36 tests: Add more tests to hittest_shapeflag test 2020-09-15 02:34:32 -07:00
Mike Welsh fe3bf5cb59 core: Implement hit_test_shape for MorphShape 2020-09-15 02:34:32 -07:00
Mike Welsh 4d26ebe9b4 core: Implement hit_test_shape for EditText 2020-09-15 02:34:32 -07:00
Mike Welsh e9a2ef5d82 core: DisplayObject::hit_test_shape now takes UpdateContext
Make default implementation the same as hit_test_bounds.
2020-09-15 02:34:32 -07:00
Mike Welsh 0d111ca92f avm1: _target of root should be /
Also, levels other than 0 should be appened in slash syntax, e.g
_level1/clip
2020-09-15 02:20:24 -07:00
David Wendt f2380d828a chore: Don't capitalize our type arguments. 2020-09-15 02:20:11 -07:00
David Wendt 7e91c45950 avm2: Move trait methods into the AS3 namespace.
`toString`, `toLocaleString`, and `valueOf` are still `public`, because they're not supposed to be trait methods at all.
2020-09-15 02:20:11 -07:00
David Wendt 27eda5cdf1 avm2: Remove `ArrayIterator` trait.
I originally added this with the anticipation that `impl` return syntax only allowed one trait plus OIBITs. This was prior experience in Rust but apparantly the compiler accepts this just fine, so I suppose my defensive coding practice was a bad/outdated idea.
2020-09-15 02:20:11 -07:00
David Wendt de0bc93839 Fix `hasOwnProperty` yielding false on populated non-hole array indicies. 2020-09-15 02:20:11 -07:00
David Wendt e581704559 avm2: `new Array()` should reject negative and `NaN` length arguments as errors. 2020-09-15 02:20:11 -07:00
David Wendt 582df3bd7d avm2: Misc perf fixes and nits in Array globals. 2020-09-15 02:20:11 -07:00
David Wendt 07e14463e2 avm2: Array `join` and `toString` treat `undefined` and `null` as empty strings. 2020-09-15 02:20:11 -07:00
David Wendt 3b7922d222 avm2: Implement `Array.sortOn` 2020-09-15 02:20:11 -07:00
David Wendt 0aa2c50118 avm2: Implement `Array.sort` 2020-09-15 02:20:11 -07:00
David Wendt bb19699739 avm2: Add convenience method for converting a `Value` into an `EnumSet`. 2020-09-15 02:20:11 -07:00
David Wendt a653a62a93 avm2: Add array sorting constants. 2020-09-15 02:20:11 -07:00
David Wendt ca4982029b avm2: Impl `Array.toLocaleString`. 2020-09-15 02:20:11 -07:00
David Wendt 2ae3b6445b avm2: Partially implement `toLocaleString` insamuch as is necessary to run Array tests on it.
This appears to work almost like it's own TObject method; you can run `Object.prototype.toLocaleString` on all sorts of things and it has separate behavior to what the class method for it might be. I have attempted to match Flash Player as best as I can.
2020-09-15 02:20:11 -07:00
David Wendt dbaef812fa avm2: Impl `Array.splice`. 2020-09-15 02:20:11 -07:00
David Wendt 53b564bb52 avm2: Implement `Array.slice`. 2020-09-15 02:20:11 -07:00
David Wendt 685fbc12e0 tests: `Array.reverse`'s test should also include a check for holes. 2020-09-15 02:20:11 -07:00
David Wendt 036f7cbb90 avm2: Implement `Array.shift` and `Array.unshift`.
This also updates `Array.push` to support it's ability to push multiple arguments at once.
2020-09-15 02:20:11 -07:00