Commit Graph

136 Commits

Author SHA1 Message Date
David Wendt dc46885021 Implement `autoSize`.
This doesn't work right yet because the resulting width doesn't apply correctly to the field. This is because `EditText`'s `_width` and `_height` change it's intrinsic bounds rather than it's X and Y scale (like it would with a button or a movie clip).
2020-06-20 19:48:00 -04:00
Nathan Adams b2b57c1540 core: Make Value::as_object always return a (possibly boxed) object 2020-06-19 12:48:28 -07:00
Mike Welsh 62cfeb3754 core: Assign default name to unnamed clips (fix #66) 2020-06-18 16:26:36 -07:00
Mike Welsh 77cb186357 avm1: Constructors queue to run after a goto
If a class is registered to a clip that is placed on the timeline
during a goto, that constructor should run after the frame is
completely constructed. In order to tell whether to run the
constructor immediately, add a parameter to `post_instantiation`
to indicate if the clip is instantiated from the AVM or via a
standard timeline seek.
2020-06-16 14:53:44 -07:00
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 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
Nathan Adams eda862c719 swf: Merged core::Matrix into swf::Matrix 2020-05-20 14:54:41 +02:00
Nathan Adams 84f6b4d06e core: Set init_object values after prototype but before constructor 2020-05-03 12:46:55 -07:00
Mike Welsh c1dc69c6b7 chore: rustfmt 2020-04-24 22:16:16 -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
Nathan Adams d850443c84 avm1: Refactor to expose `avm, context` in `post_instantiate` 2020-02-29 23:05:15 +01:00
Mike Welsh 223edb9bc1 core: Matrix translation is in twips 2020-02-26 12:47:47 -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 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 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 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 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 5ce499d11e Add separate libraries for each loaded movie. 2020-02-21 23:57:56 -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
Mike Welsh 2ff76775e0 core: Empty movie clips can not be used as a mask
When a movie clip or button is used as a mask, the masking will be
disabled if that object has no children; the maskee will be
completely visible. An empty movie clip inside an empty movie clip
successfully masks.

An EditText can also not be used as a masker (although it can be
wrapped inside a movie clip, and then the text successfully masks).

Add a `TDisplayObject::allow_mask` trait method that will
return whether the object can be used as a mask.

This fixes characters not being visible in Dad 'n' Me.
2020-02-01 01:15:31 -08:00
Mike Welsh 2751b89d4e avm1: Root clip should not have a name
Previously we set the name of the root clip to `_level0`. Top-level
clips should actually have no name (`_root._name` returns `""`).

However, when constructing a dot path, `_level0` still gets inserted
by `DisplayObject::path` for the top-level, so that `trace(_root)`
still correctly prints `_level0`.

TODO: When `loadMovieNum` gets merged in, the proper level # needs
to be returned by `.DisplayObject::path`.
2020-01-27 23:35:41 -08:00
Mike Welsh 87158647d1 core: Implement keyPress button events 2019-12-24 03:06:03 -08:00
Mike Welsh 4bd54cc2ea core: Fix DisplayObject::global_to_local and local_to_global 2019-12-21 16:28:41 -08:00
Mike Welsh 540b03090a avm1: hitTest point is actually in root coordinates (fix #185) 2019-12-19 12:35:56 -08:00
Nathan Adams f6f358b4de avm1: Expose TextFields and allow setting their .text 2019-12-19 10:19:43 -08:00
Mike Welsh 2af76e10f8 core: Mark scale/rotation as dirty when matrix changes 2019-12-17 22:06:34 -08:00
Mike Welsh 1476930e0c avm1: Implement MovieClip.removeMovieClip 2019-12-17 03:20:01 -08:00
Mike Welsh d0504104b7 core: Use i32 for display object depth 2019-12-17 02:48:55 -08:00
Nathan Adams 84ff69854a avm1: Pass mouse events down to movie clips 2019-12-16 10:11:23 -08:00
Nathan Adams c8e42123cf avm1: Implemented `_xmouse` and `_ymouse` 2019-12-16 10:11:23 -08:00
Mike Welsh eb3aa1c878 core: Move `ClipAction` into crate::events 2019-12-15 19:22:23 -08:00
Mike Welsh 76e94dda1c core: Implement "unload" clip event
Fire unload clip event when a movie clip is removed. Added
`ActionType` enum used by `ActionQueue::queue_actions` that
determines the type of action that is running (replaces `is_init`
parameter).
2019-12-15 19:00:16 -08:00
Mike Welsh 38ebdd9d05 core: Fire "load" and "enterFrame" clip events
MovieClips will now fire their "load" and "enterFrame" clip events.
Added `MovieClipFlags` to store various flags for the movie clip.
2019-12-15 19:00:16 -08:00
Mike Welsh 3c83d9ac9d docs: Shuffle some docs in DisplayObject 2019-12-15 10:17:33 -08:00
Mike Welsh d7393dc81d core: Add DisplayObjectFlags::TransformedByScript
This is set when a DisplayObject is dynamically moved by AS code,
which causes further modification from PlaceObject tags to be
ignored.
2019-12-15 10:17:33 -08:00
Mike Welsh 8c27097240 core: Implement _target property
Add DisplayObject::slash_path to get the Flash 4-style slash path
to the clip. This fixes the tellTarget regression test and removes
the superfluous `target_path` from `UpdateContext`.
2019-12-15 10:17:33 -08:00
Mike Welsh c9864eb557 core: Add StageObject properties 2019-12-15 10:17:33 -08:00
Mike Welsh 783ede6f79 core: Add DisplayObject::path 2019-12-15 08:54:26 -08:00
Mike Welsh 73604a891e core: Move get_child_by_name to DisplayObject 2019-12-15 08:54:26 -08:00
Mike Welsh 71e4eb87d7 core: Remove as_*_mut methods on DisplayObject/Object 2019-12-10 01:36:02 -08:00
Mike Welsh 30ecbd0ecc core: Use enum_trait_object for DisplayObject 2019-12-10 01:36:01 -08:00
Mike Welsh 23ca66a7e3 avm1: Use enum_trait_object for avm1::Object 2019-12-10 01:36:01 -08:00
David Wendt d25bdbacf8 Separate `Object` into an interface trait and a standard implementation. Host object implementations may bypass `ScriptObject` and directly interface with the AVM using this trait.
Note that host objects that do so will *not* have access to their standard representation from within member functions - you will need to extend the interface to accomodate for them. This is due to long-standing limitations with type IDs and downcasting with types that bear lifetimes - it's entirely an unsafe operation and exposing such a facility to safe Rust is unsound. However, this will at least let us separate out several things from ScriptObject that don't need to be there for the time being.
2019-11-26 14:51:05 -05:00
David Wendt 2f965d1c64 First stab at moving system builtins to explicit prototypes 2019-11-26 14:51:03 -05:00
Nathan Adams ae064b62be chore: Change to no_drop from empty_drop for new gc-arena 2019-11-22 17:53:05 +00:00
Mike Welsh 01f47d675c core: Move UpdateContext into context submodule 2019-10-27 13:49:47 -07:00
Mike Welsh c4c895c6c9 core: Move display objects to display_object module 2019-10-26 15:04:52 -07:00
Mike Welsh a4bed6c643 core: Improve execution order of AS 2019-10-26 01:52:42 -07:00
David Wendt 911de06584 Only version MovieClips. Unversioned display objects recursively read their parents' versions, or the default version otherwise. 2019-10-13 17:27:04 -04:00
David Wendt feaa3dd203 Add a version parameter to every DisplayObject impl 2019-10-12 10:39:52 -04:00
Mike Welsh f0e345bea8 core: Improve handing of gotos (fix #33)
Display objects will now properly persist during gotos instead
of erroneously being recreated.
2019-09-16 22:03:34 -05:00
Mike Welsh 94afcfb2e1 core: Add DisplayObject::id 2019-09-15 11:35:04 -07:00
Mike Welsh 28f0ce3c83 Mask work 2019-09-09 20:42:08 -05:00
Mike Welsh 0849826c48 core: Add static data for morph shape and text 2019-09-06 15:15:34 -07:00
Nathan Adams 002272d7b5 Functions return `[type Function]` when converted to strings 2019-08-31 18:28:28 +02:00
Nathan Adams 7a18ece455 `DisplayObject`s all have a AVM1 `Value`. Added `toString()` default method for Objects (but not functions) 2019-08-31 17:54:15 +02:00
Nathan Adams 2eca394a58 Implemented `typeof` for movieclips and functions 2019-08-31 14:09:37 +02:00
Nathan Adams 2fd7d456a4 Movie clip access from AS. Functions are now callable objects, and receive `this`. 2019-08-30 20:37:48 +02:00
Mike Welsh 0143d9716e core: Button work 2019-08-19 22:27:38 -07:00
Mike Welsh d8ddf78bdc avm1: Implement _rotation and improve SetProperty
Implement _rotation and add SetProperty/GetProperty for these
values.
2019-08-19 22:27:38 -07:00
Mike Welsh 6c923930e6 avm1: Stub out ActionSetProperty
Rough impl of ActionSetProperty action. Not all properties
implemented. Add DisplayObject::matrix_mut.
2019-08-19 22:27:38 -07:00
Mike Welsh 0ab20e01c1 Add dyn 2019-08-19 22:27:38 -07:00
Mike Welsh ce606cece8 core: Re-enable AVM1 2019-08-19 22:27:37 -07:00
Mike Welsh 5bba546a53 core: Add BoundingBox calculations
TODO: Add dirty flag and cache matrices.
2019-08-19 17:29:55 -07:00
Mike Welsh 2c7e3c835f core: Add parent to DisplayObjectBase 2019-08-19 17:29:55 -07:00
Mike Welsh 4666d211a7 core: Add dyn to fix Rust 1.37 warnings
Omitting dyn on trait objects now emits a warning, so add missing
dyn where necessary.
2019-08-15 13:54:20 -07:00
Mike Welsh 725cdae6c5 Begin AVM1 cleanup 2019-08-08 15:58:45 -07:00
Mike Welsh ce5faefe1f Work 2019-08-08 15:57:10 -07:00
Mike Welsh 6673527b0a core: Add clip depth to DisplayObject 2019-05-12 13:48:00 -04:00
Mike Welsh 79b3a7007d core: Initial morph shape implementation 2019-05-12 12:55:48 -04:00
Mike Welsh efe3270ce0 web: Decode streams completely on preload (for now) 2019-05-09 12:43:26 -07:00
Mike Welsh 12d6d3342b core: Switch to rust-gc 2019-05-08 18:10:43 -07:00
Mike Welsh e6e8536672 Clean up DisplayObject traits 2019-05-07 03:34:17 -07:00
Mike Welsh 60b673986b Work 2019-05-06 23:31:34 -07:00
Mike Welsh 598b342106 core: Add name property to DisplayObject 2019-05-06 11:15:52 -07:00
Mike Welsh a0c478379d Preload assets for web
Run through all definition tags to preload assets on web.
TODO: Keep track of which assets are done loading.
2019-05-05 17:35:00 -07:00
Mike Welsh 2480469c2c First pass of static text 2019-05-04 11:45:11 -07:00
Mike Welsh 1dfedae485 Add some button functionality 2019-05-03 11:44:12 -07:00
Mike Welsh d6e68dd43e Add initial AVM1 implementation 2019-05-01 17:46:49 -07:00
Mike Welsh 5e88f43280 Color transforms 2019-05-01 09:55:54 -07:00
Mike Welsh ed3797f28c work 2019-04-28 22:55:44 -07:00
Mike Welsh ee64cc77bc Reforactor 2019-04-27 23:08:59 -07:00