Commit Graph

5198 Commits

Author SHA1 Message Date
Tom Schuster 3d29b81a8c avm2: Support any name in XML get_property_local
Fixes #9999
2023-03-12 18:32:11 -05:00
Tom Schuster f53c83cfa4 Partly implement XML child and elements
This makes #3294 (rollercoaster-creator-2) fully playable.

Missing is any (*) matching for child()/elements() and the existing attributes() method.
Also missing is support for number indexes with child().
2023-03-12 18:06:13 -05:00
Jay Sackwild 1deebc87e8
Support click events on movie clips containing text fields (#9995)
Remove code that prevents click events from working on text fields within movie clips
2023-03-11 22:19:48 +00:00
Lord-McSweeney 120f24b2ba avm2: Implement flash.text.CSMSettings 2023-03-11 12:27:28 -06:00
Marty_SVK 8668d83ea6 progresses Resort Empire
now it is blocked by unimplemented BitmapData.threshold
2023-03-11 15:41:46 +01:00
nosamu be153b2417 avm2: Stub Stage.fullScreenWidth and fullScreenHeight 2023-03-11 15:02:03 +01:00
Aaron Hill 7b932ca84b avm2: Implement special XML/XMLList method calling behavior
When an XML object has simple content, you can call non-XML
methods directly on it - it will internally be stringified,
and the method will be called on the resulting string.
This lets `new XML("<p>Some content</p>".split(' ')` work.

Similarly, an XMLList object with a single XML child will
forward non-XML method calls to that object.

This PR implements this logic (based heavily on avmplus)
2023-03-11 00:51:45 -06:00
Aaron Hill a8198c0fab avm2: Remove `run_frame_avm2` and FramePhase::Update
These were unused for all AVM2 objects.
I've renamed the `run_frame` method to `run_frame_avm1`,
as it's only used for AVM1-specific logic.
2023-03-10 19:37:19 -07:00
Aaron Hill 80b98a055e avm2: Stub NetConnection and Responder
These are needed for BTD5
2023-03-10 16:58:15 -06:00
Lord-McSweeney 522e781e3c avm2: Fix stub types for Font 2023-03-10 20:55:54 +01:00
Aaron Hill 8c91c734c3 core: Only apply 'unload' and 'removed' logic to AVM1
I've also renamed these methods to 'avm1_unload' and
'avm1_removed', to make it clear that they don't
apply to AVM2.

This was causing us to incorrectly skip mouse picks,
and remove masks.
2023-03-09 12:34:16 -06:00
Aaron Hill fc223e959b avm2: Implement avmplus.getQualifiedClassName
This appears to be the same function as
'flash.utils.getQualifiedClassName'
2023-03-08 16:59:40 -06:00
Aaron Hill 8ac64289b3 avm2: Handle coercing to a class while it's being initialized
I think this might have been broken by
https://github.com/ruffle-rs/ruffle/pull/9506, but we didn't have
proper test coverage.

If we execute a 'coerce' opcode for a class while it's being
initialized (which can happen by running a method from a static
initializer), we'll be unable to resolve the ClassObject using
`resolve_type`.

This is the only case where this can happen - any
superinterfaces/superclass will already be fully initialized
when we're running a class initializer. Therefore, we can
try to lookup the class from the `Domain`, and check if it
directly matches the class of the object we're coercing
(ignoring superclasses and interfaces).
2023-03-08 16:38:24 -06:00
Aaron Hill c6c021f7f6 core: Fix setting certain DisplayObject properties to NaN
This doesn't perfectly match Flash's behavior - I haven't been
able to reproduce the values produces when the DisplayObject
starts out with certain 'Matrix' values (a non-zero 'b' or 'd').

Howver, when the 'b' and 'd' matrix values are both 0, setting
'dobj.rotation = NaN' has no effect on the matrix, while
'dobj.scaleX = NaN' and 'dobj.scaleY = NaN' both treat 'NaN'
as 0 for the purposes of updating the matrix.

This fixes the tack shooter in Bloons Tower Defense 3, which
tries to set 'rotation = NaN' for spawned tacks.
2023-03-08 16:17:38 -06:00
Aaron Hill 2c1936db18 avm2: Fix QName::from_qualified_name for Vector.<some_ns::Type>
We weren't handling names like
`__AS3__.vec::Vector.<rs.ruffle.CustomClass>`
2023-03-08 15:15:55 -06:00
EmperorBale 683f6cc890 avm2: Implement `unescape` 2023-03-07 23:49:55 -08:00
EmperorBale cbb2d81240 avm2: Add Mutex.isSupported property 2023-03-07 23:38:24 -08:00
Aaron Hill 7ab7c31bb6 avm2: Run orphan framescripts that didn't get a chance to run
This is necessary to make Steambirds get past the preloader screen.
All of the previous tests continue to pass with this change.

This commit modifies the existing test to start from within
the symbol_class constructor, instead of a frame script. In
this situation, a freshly-created orphan with a framescript will
run directly after the constructor returns, *before* an enterFrame
handler for the same orphan. I've verified that this modified test
fails without my change.
2023-03-07 18:29:23 -06:00
Aaron Hill 93834b63de avm2: Don't allow mouse picking to hit a mask
Masks restrict the region where the maskee can be hit,
but the mask cannot itself be the target of a mouse click
(assuming that it's on the stage).
2023-03-07 17:34:06 -06:00
Aaron Hill b27bcf367c avm2: Fix handling of completed timers
It's possible to call 'start()' on a timer
that has currentCount >= repeatCount. This will
cause the timer to tick exactly once, and then stop agian.

We were incorrectly reporting 'timer.running' in such a scenario:
'running' should be reported as 'true' up until just before the
'TimerEvent.TIMER_COMPLETE' is fired.

This fixes gaining money from bloon popping / level completion
in BTD5.
2023-03-07 16:56:29 -06:00
Aaron Hill 92776645b8 avm2: Initialize LoaderStream and Loader child before catchup_display_object_to_frame
Depending on when loading completes, calling
`catchup_display_object_to_frame` might trigger an
`addedToStageEvent` inside the loaded SWF. The event listener
will expect the SWF content to have 'DisplayObject.stage' accessible,
so we need to make sure that we've added our loaded content as
a child of the `Loader` *before* any event handlers run.

I've been unable to come up with a self-contained test for this,
but it's necessary for Bloons Tower Defense 5
2023-03-07 16:36:21 -06:00
Aaron Hill b8f0de8171
avm2: Export Vector classes in public __AS3__.vec namespace (#9879)
Previously, the Vector$ classes were only exported in the internal 'AS3.vec' namespace, which is used by older ActionScript code. However, newer ActionScript code can also access these classes through the public 'AS3.vec' namespace, via 'getDefintionByName'.

We now export these classes in both namespaces. In the public 'AS3.vec' namespace, they are exported like 'Vector.' instead of 'Vector$uint'
2023-03-07 22:22:24 +00:00
Jesse Talavera-Greenberg 17688dd652
core: Derive Clone and Copy in PlayerEvent (#9882) 2023-03-07 16:37:56 +00:00
Nathan Adams b15463d3fd avm2: Stub BitmapData.hitTest 2023-03-07 09:10:26 -06:00
Aaron Hill 1a7022c30b avm2: Consider noninteractive child/drawing when mouseEnabled=false
We still want to propagate these hits to the parent, which may
be able to handle them. My existing tests missed this case,
since all of the parent objects had content which was
behind the child content. When the only clickable content
comes from a child with 'mouseEnabled=false', we should
still fire an event targeting the parent (when applicable
based on the parent's flags).

This fixes dragging on the background (without any scenery present)
in Steambirds.
2023-03-07 08:14:22 -06:00
Lord-McSweeney 046af7bc4a avm2: Add EventPhase to globals.as
This was missed
2023-03-06 23:13:12 -06:00
Aaron Hill d72a8e7125 core: Run frames for 'orphan' AVM2 MovieClips
When a MovieClip is an 'orphan' (it has no parent),
it still has frames run (including frame scripts). Some SWFS
like SteamBirds and 'This is the Only Level TOO' rely on this behavior,
so we need to implement it.

The overall idea is straightforward - we keep a global list of
orphan movies, which we add to whenever we unset the parent for a movie.
This list stores weak references for consistency with Flash.
When we run a frame, we process entries in the root movie list,
in addition to the normal recursive processing from the `Stage`.

However, exactly matching Flash's output turned out to be quite tricky.
The particular sequence of calls I make in `run_all_phases_avm2` makes Ruffle
pass two complicated test cases, but there could still be lurking bugs.

This is enough to get SteamBirds to the first level (which doesn't
render due to a different error).
2023-03-06 20:53:35 -06:00
Aaron Hill fde46a72a4 avm2: Fix mouse picking on MovieClip in 'button mode'
We were previously performing a redundant 'self.hit_test_shape'
call in 'avm2_mouse_pick'. All of the logic in that function
is handled in `avm2_mouse_pick.` Additionally, this call happened
before we tested out children, which would result in us targeting
a parent's drawing instead of aa child.
2023-03-06 15:57:46 -06:00
Adrian Wielgosik be2d5faa6f avm2: Implement proxy.isAttribute() 2023-03-06 19:48:23 +01:00
Lord-McSweeney 3cb307bfb0
avm2: Implement String.toString (#9872)
Some SWFs use this property
2023-03-06 05:57:02 +00:00
EmperorBale 2b1918316d avm2: Require multinames to be passed explicitly to QNameObject 2023-03-05 21:32:40 -08:00
EmperorBale ac9106ccb4 chore: Cleanup multiname creation in XML 2023-03-05 21:32:40 -08:00
EmperorBale f95599b816 avm2: Store Multiname instead of QName in QNameObject
avm2: Fix QName constructor
2023-03-05 21:32:40 -08:00
renovate[bot] 130144a76d fix(deps): update rust dependencies 2023-03-05 20:43:46 -06:00
Aaron Hill bb5e568333 avm2: Stop after the first DisplayObject-linked class in the chain
Surprisingly, Flash allows mutliple classes in an inheritance chain
to hav a linked `class_symbol`. When we instantiate a `DisplayObject`,
we need to stop at the first such `class_symbol` we find. This means
that any fields set from named children will *only* be set in the
first class we find, not in any of the parent classes (as their
corresponding library symbol will not be instantiated).

Previously, we would continue looping even after we found a
`class_symbol`, resulting in the furthest ancestor *winning*
the `set_object2` call.
2023-03-05 18:04:02 -06:00
Lord-McSweeney b919889174 avm2: Stub DisplayObject.scale9Grid 2023-03-04 19:29:11 -08:00
Aaron Hill e6bbb627d7 avm2: Implement KeyboardEvent.keyLocation getter/setter 2023-03-04 18:30:12 -06:00
relrelb 83c15b8033 render: Replace `BoundingBox` with `swf::Rectangle` 2023-03-04 21:54:23 +02:00
relrelb 5756c847cd swf: Make `Twips::new` a `const fn` 2023-03-04 21:54:23 +02:00
Aaron Hill 3c03a769dc avm2: Format Matrix3D.as 2023-03-03 18:32:04 -06:00
Aaron Hill a4c8f27743 avm2: Implement Matrix3D.appendScale
This is based off the the MIT-licensed OpenFL code, which
just needed a few tweaks to convert it from Haxe to ActionScript.
2023-03-03 18:32:04 -06:00
Aaron Hill 1ef539e31b avm2: Implement Capabilities.isDebugger and stub System.disposeXML
These are needed for Solarmax 2
2023-03-03 16:51:54 -06:00
Aaron Hill 2748b95c86 avm2: Improve Stage3D support for textures, register types, and opcodes
This is a very large diff, but most of it comes from test files and
output.

This PR ads partial support for the following Stage3D shader features:
* Normal (square), rectangle, and cube textures
* Varying and temporary registers
* Lots of opcodes

The combination of these allows us to get a raytracing program
fully working in Ruffle. I've included it as image test.
Currently, this test is very slow (about 90 seconds on my machine),
as the code I'm using (https://github.com/saharan/OGSL) includes
its own shader language and compiler. THe raytracing demo
first compiles its own shader language to AGAL, and then starts
rendering the scene.

Limitations:
* Many opcodes are still unimplemented
* Most non-default texture options (e.g. mipmaps) are not implemented
2023-03-03 15:58:46 -06:00
Aaron Hill 1d883688e0 avm2: Correctly check when toJSON is missing, and use vtable properties
We were previously calling `get_property` to determine if a `toJSON`
property exists, but that produces an error if the method is missing
on a sealed class.

Additionally, JSON serialization wasn't taking into account properties
from the vtable. All public properties (including fields, const fields,
and getter methods) get serialized.

Unfortunately, our vtable property order currently doesn't match
Flash's. I've hand-edited the test output for now (all of the actual
properties are there, just in a different order), and added a note
2023-03-03 15:34:26 -06:00
Adrian Wielgosik 1ba3ec0bf0 avm2: Implement BitmapData.getVector 2023-03-03 12:47:54 +01:00
Aaron Hill a07ff36726 avm2: Implement describeType
This includes all of the XML elements described in 'describeType' docs.
Unfortunately, the order of elements produced by Flash depends on
the iteration order of internal hashtables. As a result, the test
manually stringifies an XML object, sorting the stringified children,
to produce consistent output between Flash and Ruffle.
2023-03-02 20:37:59 -06:00
Lord-McSweeney a2150cbbbf avm2: Implement IExternalizable interface 2023-03-02 01:32:43 -06:00
Nathan Adams fcaa17308c avm2: Workaround haxe calling addChild(this) before super() 2023-03-02 00:38:24 +01:00
Nathan Adams bcc4e63144 core: Inline to_un_multiplied_alpha_accurate 2023-03-01 23:24:35 +01:00
Nathan Adams 6bcb64e52a core: Use slightly more accurate to_un_multiplied_alpha version in copy_pixels to fix tests 2023-03-01 23:24:35 +01:00
Nathan Adams 6e5e8b13fc core: Use a lookup table in Color::to_un_multiplied_alpha to match Flash's output 2023-03-01 23:24:35 +01:00
CUB3D ceda614add avm1: Don't use stack_push when the pushed value can't be an Object 2023-03-01 22:36:39 +01:00
CUB3D 4723c0414b avm1: Remove resolved todos, add comment and test about known reference launder issue 2023-03-01 22:36:39 +01:00
CUB3D af9810c22e avm1: More scope fixes 2023-03-01 22:36:39 +01:00
CUB3D 6a5eb43274 avm1: Fix getVariable when path is an object+var and object is a clip 2023-03-01 22:36:39 +01:00
CUB3D ca0e2488cb avm1: Dont double borrow the cache, update test output 2023-03-01 22:36:39 +01:00
CUB3D ae9538c3c7 avm1: Fix beta clippy 2023-03-01 22:36:39 +01:00
CUB3D 6d4c04c1c3 avm1: Cleanup todos, add even more tests 2023-03-01 22:36:39 +01:00
CUB3D 0d5258fa2a avm1: Remove some mc todos 2023-03-01 22:36:39 +01:00
CUB3D 6ba75d6045 avm1: Refactor movieclip path logic 2023-03-01 22:36:39 +01:00
CUB3D 693e29a82d avm1: Fix test failures 2023-03-01 22:36:39 +01:00
CUB3D d1d38091ff avm1: Fixup clippy lints and formatting 2023-03-01 22:36:39 +01:00
CUB3D c6ff8a801b avm1: Fallback to resolving properties on _root when the are not in the current scope 2023-03-01 22:36:39 +01:00
CUB3D 3d3f279160 avm1: In swfv5, resolving a non MovieClip path, should resolve to the first MovieClip parent 2023-03-01 22:36:39 +01:00
CUB3D 611c86df94 avm1: Temporary fix, block events when clips are removed 2023-03-01 22:36:39 +01:00
CUB3D a282d06ab7 avm1: Locals on removed DisplayObjects can't be accessed, should be undef 2023-03-01 22:36:39 +01:00
CUB3D a67976f601 avm1: Fix add2 coerce 2023-03-01 22:36:39 +01:00
CUB3D 1fdd8f1a82 avm1: Timers attached to clips don't fire when the clip is removed 2023-03-01 22:36:39 +01:00
CUB3D 9b850e7615 avm1: Correctly invalidate cache on clip removal 2023-03-01 22:36:39 +01:00
CUB3D cb3d9f99a7 avm1: Cache MovieClips in Value::MovieClip, this is required to correctly handle changing DO._name and for perf 2023-03-01 22:36:39 +01:00
CUB3D 6a9e13814a avm1: Don't convert SuperObjects to Value::MovieClip, or you break classes 2023-03-01 22:36:39 +01:00
CUB3D de86a51edd avm1: AS-instantiated clips with unload handlers need to have delayed removal, fixes mochi preloader 2023-03-01 22:36:39 +01:00
CUB3D f3cb1fc79e avm1: Treat MovieClips as strings in add2 2023-03-01 22:36:39 +01:00
CUB3D e6d3a99d80 avm1: MovieClips are indirectly referenced by string paths 2023-03-01 22:36:39 +01:00
Nathan Adams 6a8846ef19 chore: Appease clippy 2023-03-01 21:25:19 +01:00
Nathan Adams e33fdfb765 core: Add test to assert that *.foo.example.com matches foo.example.com 2023-03-01 21:25:19 +01:00
Nathan Adams 07ac03eb6c core: Add names to compatibility rulesets 2023-03-01 21:25:19 +01:00
Nathan Adams ca9749d1f2 core: Change from regex to custom domain matching in swf compatibility rewrites 2023-03-01 21:25:19 +01:00
Nathan Adams b10d4876d3 web: Add compatibilityRules config option to disable all compatibility rules 2023-03-01 21:25:19 +01:00
Nathan Adams ef42a391f5 core: Add default_compatibility_rules as a feature, and document when we add rules 2023-03-01 21:25:19 +01:00
Nathan Adams 1aedb7ff8d core: Add CompatibilityRules struct for on-the-fly replacements for compatibility. Initially konggames -> kongregate.com rules 2023-03-01 21:25:19 +01:00
Aaron Hill f282331204 core: Call `overwrite_cpu_pixels_from_gpu` just before we draw
If we bail out early, we want to preserve the current GPU -> CPU
sync.
2023-03-01 12:30:22 -06:00
Aaron Hill 076016b1be avm2: Get XMLList 'filter' syntax working
This requires the ability to do a limited 'set_property',
as well as `get_enumerant_value`.

To prevent modification of XMLLists derived from queries,
I've introduced a `target` field on `XMLList`. This is
`None` for lists created with `new XMLList()`, and `Some`
when the list was derived from a query on an existing `XML`
/`XMLList`. We only allow `set_property` when `target` is `None`:
this is enough for filtering to work, and prevents silent incorrect
execution when trying to modify an existing node.
2023-03-01 12:04:02 -06:00
Aaron Hill 44a301e16a avm2: Add `attribute` and `attributes` methods to `XML/XMLList` 2023-03-01 10:51:21 -06:00
Aaron Hill 1099218fdd avm2: Stub Mouse.supportsCursor and Mouse.supportsNativeCursor
Since these are static properties, Ruffle previously (correctly)
returned `undefined` for SWFs that tried to access them, intead
of throwing an error.
2023-03-01 09:30:10 -06:00
Aaron Hill 78c9de7b8f avm2: Fix constructing empty XMLList
A default empty text node should only be created for XML.
2023-03-01 15:57:34 +01:00
Daniel Jacobs 584cb4c1cf web/ui: Open the virtual keyboard when clicking an editable EditText 2023-03-01 08:15:58 +02:00
Aaron Hill 61a664fec6 core: Produce an error when BitmapData.draw call is unsupported 2023-02-28 18:20:53 -06:00
EmperorBale 9338f1daa8 avm2: Fix default domain when loading movieclip 2023-02-28 13:04:24 -08:00
Marty_SVK 9c844678b5 avm2: Stub TextField.condenseWhite 2023-02-28 21:25:01 +01:00
relrelb 203788c1c8 core: Move `F64Extension` to `avm1`
Since it's only used there. Also rename the trait to `Clamp`.
2023-02-28 19:22:37 +02:00
relrelb fe23eb0553 core: Introduce and use `F64Extension::clamp_to_i32`
Previously there were multiple implementations scattered across the
codebase. Unify them to a single place, in a more "Rusty" way (now
it's called via dot notation, rather than as a free function).
2023-02-28 19:22:37 +02:00
relrelb b3fd1a47c6 core: Require `SwfMovie::url` 2023-02-28 19:05:20 +02:00
Lord-McSweeney c01edc90bc
avm2: Stub `flash.text.StyleSheet` (#9747) 2023-02-28 16:35:47 +00:00
relrelb cf0c32bd70 core: Remove some unused `RenderContext` fields 2023-02-28 17:48:57 +02:00
Nathan Adams 91a54f9e41 avm2: Use flags.set(foo) instead of |= foo 2023-02-28 16:25:12 +01:00
Nathan Adams 545193b098 swf: Deduplicate GradientFilter again 2023-02-28 16:25:12 +01:00
Nathan Adams 07d441a750 core: Don't impl FilterAvm2Ext for individual Filter structs 2023-02-28 16:25:12 +01:00
Nathan Adams f79015e201 render: Use swf Filter types where possible. Gradient types had to be split into duplicate classes to allow for different trait impls based on which gradient filter type it is. 2023-02-28 16:25:12 +01:00
Nathan Adams b8f7c66980 core: map_point in DisplacementMapFilter is i32 not u32 2023-02-28 16:25:12 +01:00
Nathan Adams 30a114a441 tests: Add avm2/convolution_filter test for swf->core->avm2 and avm2->core->avm2 testing 2023-02-28 16:25:12 +01:00
Nathan Adams 3777210117 core: Angle from swf tag is in radians, convert it to degrees 2023-02-28 16:25:12 +01:00
Nathan Adams acc3180db7 core: Strength in filters is a f32, not u8 2023-02-28 16:25:12 +01:00
Nathan Adams fc00ae8eb6 core: Load filters from PlaceObject tag 2023-02-28 16:25:12 +01:00
Nathan Adams 1408252ca3 core: Switch DisplayObjectBase::filters from avm2 objects to Vec<Filter> 2023-02-28 16:25:12 +01:00
Nathan Adams e39fbe871d render: Add Filter::GradientGlowFilter 2023-02-28 16:25:12 +01:00
Nathan Adams bb38a7fa55 render: Add Filter::GradientBevelFilter 2023-02-28 16:25:12 +01:00
Nathan Adams c8030d047d render: Add Filter::GlowFilter 2023-02-28 16:25:12 +01:00
Nathan Adams c9656c429e render: Add Filter::DropShadowFilter 2023-02-28 16:25:12 +01:00
Nathan Adams dbe2efff00 render: Add Filter::DisplacementMapFilter 2023-02-28 16:25:12 +01:00
Nathan Adams f9c7303f01 render: Add Filter::ConvolutionFilter 2023-02-28 16:25:12 +01:00
Nathan Adams 9c1f6ea129 render: Add Filter::BevelFilter 2023-02-28 16:25:12 +01:00
Nathan Adams 5ee3a4b512 avm2: Extract out the Value -> Filter logic into a trait 2023-02-28 16:25:12 +01:00
Aaron Hill 54eb6e33ca avm2: Ignore XML comments and processing instructions by default
This matches the default value of the settings on XML.
2023-02-27 15:53:39 -06:00
EmperorBale 4adb7853b7 avm2: Add concurrent classes 2023-02-27 12:27:37 -08:00
EmperorBale d166295ee1 avm2: Add Telemetry class 2023-02-27 12:13:16 -08:00
Aaron Hill 82d03b4062 avm2: Ignore XML declaration and doctype
These are completely ignored by AVM2
2023-02-27 13:41:18 -06:00
Aaron Hill c04b463f1f avm2: Implement XML.children, XMLList.children, and related methods 2023-02-27 13:25:16 -06:00
Aaron Hill 7f58b92348 avm2: Implement encodeURI and encodeURIComponent 2023-02-27 12:40:39 -06:00
Nathan Adams cfcd257932 avm2: Xml(foo) converts foo to string 2023-02-27 17:37:28 +01:00
Nathan Adams 38d1478ffa avm2: Implement Sprite.hitArea 2023-02-27 16:28:14 +01:00
renovate[bot] 71e24eedba fix(deps): update rust dependencies 2023-02-27 11:48:53 +02:00
relrelb dc9ec40d31 chore: Allow `clippy::bool_to_int_with_if`
Seems like Clippy no longer complains about it.
2023-02-26 13:23:38 +02:00
Lord-McSweeney 6630222ba9
avm2: Stub flash.profiler.showRedrawRegions (#9732) 2023-02-25 19:52:45 -05:00
Aaron Hill f9fc4b3179
avm2: Store interfaces from superclases/superinterfaces in ClassObject (#9728) 2023-02-25 23:57:50 +00:00
Aaron Hill c7709dffec avm2: Handle Event::CData when parsing XML 2023-02-25 17:26:31 -06:00
Adrian Wielgosik 55c59da6ac avm2: Convert TextFormat to AS 2023-02-25 23:55:43 +01:00
Adrian Wielgosik 35120e9fdc avm2: Convert Graphics to AS 2023-02-25 23:55:43 +01:00
Adrian Wielgosik b9dc8a4d52 avm2: Do not box primitives when doing AS-level coercions 2023-02-25 23:31:17 +01:00
Adrian Wielgosik e063d5b5a8 avm2: Fix coerce_to_boolean on boxed primitives 2023-02-25 23:31:17 +01:00
Lord-McSweeney 16b724246c Remove stub mention from BitmapData 2023-02-25 23:12:39 +01:00
Lord-McSweeney f14ef0a4dd Cleanup globals.as 2023-02-25 23:12:39 +01:00
Lord-McSweeney 9c8f99e9ce Use AvmError instead of RustError when throwing argumentError in Stage. 2023-02-25 23:12:39 +01:00
Lord-McSweeney 91ae3ae31e Port Stage overrides to ActionScript
And throw IllegalOperationError s.
2023-02-25 23:12:39 +01:00
Lord-McSweeney e72a935f1b Move IllegalOperationError up so Stage can use it 2023-02-25 23:12:39 +01:00
Aaron Hill b26f2fd6fb
avm2: Initial incomplete implementation of XML (#9647) 2023-02-25 20:06:36 +00:00
Aaron Hill dfee80e981
avm2: Mention interfaces in globals.as ordering comment 2023-02-24 16:08:29 -06:00
Aaron Hill 82a3f473d9
avm2: Move some class definitions after playerglobal is loaded 2023-02-24 16:08:29 -06:00
Aaron Hill 62767213a6
avm2: Use 'flash.events' internal namespace for EventDispatcher 2023-02-24 16:08:29 -06:00
Aaron Hill 24e231ae06
avm2: Convert TextField to AS 2023-02-24 16:08:29 -06:00
Aaron Hill 337149ff0e
avm2: Add TextFormat AS stub 2023-02-24 16:08:29 -06:00
Aaron Hill bc240db517
avm2: Convert SimpleButton to AS 2023-02-24 16:08:29 -06:00
Aaron Hill d31c686360
avm2: Convert MovieClip to AS 2023-02-24 16:08:29 -06:00
Aaron Hill aa7dc52b82
avm2: Convert Sprite to AS 2023-02-24 16:08:28 -06:00
Aaron Hill d996aecb04
avm2: Convert Shape to AS 2023-02-24 16:08:28 -06:00
Aaron Hill 39063a5a04
avm2: Add Graphics stub 2023-02-24 16:08:28 -06:00
Aaron Hill 8831042e8f
avm2: Convert LoaderInfo to AS 2023-02-24 16:08:28 -06:00
Aaron Hill be16286407
avm2: Convert several flash.display and flash.events classes to AS
These classes all reference each other, so it's difficult to convert
them individually.
2023-02-24 16:08:28 -06:00
Aaron Hill 6ce7bd3277
avm2: Convert EventDispatcher and IEventDispatcher to AS 2023-02-24 16:08:28 -06:00
Aaron Hill cd2770ce7e
avm2: Add SoundTransform stub 2023-02-24 14:48:51 -06:00
EmperorBale 99aa274e0f avm2: Stop loading scripts in reverse order 2023-02-24 11:55:58 -08:00
EmperorBale 5bc3c696b5 avm2: Ignore duplicate definitions 2023-02-24 11:55:58 -08:00
feos 871a4d053d core: add framerate to SWF load log
fixes #8531
2023-02-24 12:13:00 +02:00
TÖRÖK Attila 5a7cd92bfe avm2: Use a lookup table for cosine in SoundMixer.computeSpectrum()
This results in 128 times fewer calls to the builtin cosf function.
2023-02-23 23:51:55 +01:00
Aaron Hill 5f4bf7b5fa avm2: Stub Capabilities.manufacturer and Capabilities.language
These are needed by Steambirds: Survival
2023-02-23 12:25:34 -06:00
Nathan Adams 3a29ebc600 avm2: Comment where our RangeErrors have different-to-flash text in DOC 2023-02-23 08:12:42 -06:00
Nathan Adams 5f7978cfa5 avm2: Use avm errors for RangeErrors inside DisplayObjectContainer 2023-02-23 08:12:42 -06:00
Nathan Adams e17b154d47 avm2: Iterate the inheritance chain for class-symbol linkage 2023-02-22 22:27:13 +01:00
Aaron Hill 203d4cd3aa avm2: Use Value::Undefined for out-of-range Vector enumerant index
This makes Vector consistenht with the other implementations
of `get_enumerant_name`. This also fixes a bug where AMF object
serialization would loop all te way to `u32::MAX` when serializing
a vector, because it would never see `Value::Undefined` and break.
2023-02-22 15:03:09 -06:00
Aaron Hill f1b0247de7 avm2: Remove install_trait_late 2023-02-22 14:41:01 -06:00
Aaron Hill c52f1082c4 avm2: Make `early_resolve_interface` take in a `domain` directly 2023-02-22 14:41:01 -06:00
Aaron Hill c258423dc3 avm2: Allow resolving interfaces before ClassObjects are available
The Adobe Animate compiler can emit a 'newclass' opcode for
a concrete class before the 'newclass' opcodes for the interfaces
it implements. As a result, we cannot rely on looking up an interface
`ClassObject` when resolving a class's interfaces.

We now store a map of exported classes in `Domain`, and use this
to lookup interfaces before their `ClassObject`s have been created.

Additionally, `link_interfaces` was failing to consider superinterfaces,
which meant that methods from superinterfaces were not being copied
into the vtable. I've fixed this along with the other changes.
2023-02-22 14:41:01 -06:00
Bale 2cfa97e84d
avm2: ByteArray.readUTF/readUTFBytes should cut off after null byte (#9673)
* avm2: Fix #9668

* tests: Extend ByteArray test
2023-02-22 18:47:59 +00:00
Marty_SVK fac7fc0666 Stub System.pauseForGCIfCollectionImminent
This progresses Papas Scooperia
2023-02-22 12:34:13 -06:00
Nathan Adams e8fcc8b194 avm2: Don't reset SimpleButtons that are created by scripts 2023-02-22 18:49:04 +01:00
Nathan Adams aef466f8f3 avm2: Implemented BitmapData.drawWithQuality 2023-02-22 17:36:55 +01:00
Nathan Adams 6539262db7 render: Add Quality option to RenderBackend::render_offscreen 2023-02-22 17:36:55 +01:00
nosamu 70bf0a816a core: Add options to set and force stage scale mode 2023-02-22 12:13:20 +02:00
nosamu a505d7a6d3 core: Fix off-by-one bug with clipDepth 2023-02-21 16:39:42 +02:00
Adrian Wielgosik f7a12698b9 core: Implement Color::to_premultiplied_alpha without floats 2023-02-19 22:25:34 +01:00
Adrian Wielgosik 92e52f2d0a avm2: Add missing imports 2023-02-19 19:06:54 +01:00
Lord-McSweeney 89792865d0
avm2: Stub Loader.close 2023-02-18 18:35:20 +00:00
Aaron Hill 3327a9a3fd core: Set clipDepth to 0 when swapDepths affects a clip
This makes "Garfield's Comic Creator" properly show
panels when you close the editor.
2023-02-17 23:11:57 -06:00
EmperorBale 158de01c92 avm2: `goto_frame` should use the movieclips scene by default 2023-02-17 18:46:43 -08:00
Aaron Hill 071306f107 avm2: Also register EventDispatcher methods in ns "flash.events:IEventDispatcher"
This is needed by "Steambirds: Survival"
2023-02-17 20:32:27 -06:00
EmperorBale bc165a81ff chore: Add comment explaining why we skip the first scope 2023-02-18 01:37:12 +01:00
EmperorBale 7ef56c1d16 avm2: Search global scope after everything else 2023-02-18 01:37:12 +01:00
CUB3D f7b0c021a9 avm1: The this property should be mutable 2023-02-17 14:39:10 -06:00
Aaron Hill 4149913967
core: Introduce dedicated avm2 mouse picking logic (#9565)
The mouse picking behavior in AVM2 interacts in complicated
ways with `mouseEnabled` and `mouseChildren.` It's sufficiently
different from AVM1 that I decided to split the logic into separate
`mouse_pick_avm1` and `mouse_pick_avm2` methods.

The `mouseChildren` property is now fully implemented.
Additionally, the `click_block` tests now work correctly
under Ruffle.

Combined with the orphan-movie PR, this is enough to make
SteamBirds fully playable (though performance greatly degrades
over a course of a level).
2023-02-17 19:04:52 +00:00
Lord-McSweeney 559ec8356d
Port Video to Actionscript 2023-02-16 22:46:11 +02:00
relrelb a7235febea core: Use unnamed field in `Character::Bitmap`
Since `initial_data` was removed from `Character::Bitmap` in #9143,
it now holds a single field. Move back to an unnamed field, which
aligns with the other `Character` enum variants.
2023-02-16 19:02:57 +02:00
TÖRÖK Attila 77cfb5ab4c core: Fix a clippy lint when building without the "mp3" feature. 2023-02-16 06:23:35 +01:00
EmperorBale 0ffdef48ab avm2: Implement `finddef` opcode 2023-02-14 14:22:02 -08:00
Nathan Adams eb35d6217b avm2: DoAbc (72) seems to imply lazy loading 2023-02-14 08:51:45 +01:00
Nathan Adams 94fdc8bdb5 avm2: Support older DoAbc tag (72) 2023-02-14 08:51:45 +01:00
Nathan Adams 69f93f926e swf: Rename DoAbc to DoAbc2 2023-02-14 08:51:45 +01:00
Adrian Wielgosik 5eb887c628 avm2: Stub describeType to have .@name work 2023-02-13 23:55:00 +01:00
Nathan Adams a4fc39efcd avm2: Copy Regexp methods to the Regexp prototype 2023-02-13 21:31:46 +01:00
Nathan Adams 899635f658 avm2: Copy Array methods to the Array prototype 2023-02-13 21:31:46 +01:00
Aaron Hill a52a41de97 core: Fix stageX and stageY getters for MouseEvent
These getters were previously calling `local_to_global`
with the unused localX/localY coordinate set to 0. Howver,
`local_to_global` does a matrix multiplication, which in general
will depend on both the x and y values. This was causing the getters
to return incorrect results when any of the `transform.matrix` values
included a non-diagonal matrix.

We now call `local_to_transform` with the real `localX` and `localY`
values.
2023-02-13 21:19:20 +01:00
Nathan Adams 081387e047 avm2: Stub TouchEvent 2023-02-13 05:35:18 +01:00
renovate[bot] a27bd66b58 fix(deps): update rust dependency patches 2023-02-13 04:59:31 +01:00
Aaron Hill c597f9f996 core: Fix Clippy lints on nightly 2023-02-13 03:38:54 +01:00
renovate[bot] fed24aa243 fix(deps): update rust dependencies - wasm-bindgen related 2023-02-13 02:57:52 +01:00
Lord-McSweeney b848ab6860 Fix stub in DisplayObjectContainer
In mouse_children
2023-02-13 00:42:28 +01:00
Lord-McSweeney eb7a96f55b Fix stub types in security.rs
Change from avm2_stub_getter to avm2_stub_method
2023-02-13 00:42:28 +01:00
Adrian Wielgosik 561e118ffe avm2: Export private traits normally, remove private_trait_scripts hack 2023-02-12 17:49:14 +01:00
Adrian Wielgosik f717b99599 avm2: Compare private namespaces by pointer. Refactor rust-avm field sharing. 2023-02-12 17:49:14 +01:00
Adrian Wielgosik e0e653e463 avm2: make Namespace a GC type 2023-02-12 17:49:14 +01:00
Aaron Hill 4e0dce2efa core: Make SandboxType configurable, and set to 'remote' on web
The Newgrounds API checks `Security.sandboxType` to see if it should
run in debug mode or not (which determines whether or not medals
can actually be unlocked).

For now, desktop continues to use `localTrusted` as the default,
while web now uses `remote`. We might want to make this configurable
at some point, but this should be good enough for now (and better
match Flash's behavior).
2023-02-11 14:44:11 -06:00
Aaron Hill 9bce6b78d5 core: Queue up Sound and SoundChannel methods during loading
Flash supports calling `Sound.play`, `SoundChannel.stop`, and
`SoundChannel.soundTransform` while a sound load is in progress
(e.g. immediately after calling `Sound.load`).

To support this, we queue up information inside `SoundObject`
and `SoundChannelObject` when a load is in progress. When a load
completes, we trigger any queued `Sound.play` and `SoundChannel.stop`
calls, and apply the most recent `SoundChannel.soundTransform`
2023-02-11 11:53:56 -06:00
Aaron Hill 51fe1e9754 core: Handle `DirtyState::CpuModified` in `overwrite_cpu_pixels`
If we're going to overwrite the CPU pixels with the result of a
GPU operation, make sure the GPU texture is up to date with the
latest CPU pixels. I've also renamed the method to
`overwrite_cpu_pixels_from_gpu` to better reflect how it should
be used.
2023-02-11 11:37:00 -06:00
Bale 73e9fd55fb
avm2: Make sure scripts get initialized after all scripts have been loaded when lazy init is disabled (#9478)
* avm2: Initialize scripts **after** all scripts have been loaded

* tests: Add test for eager initialization
2023-02-11 00:38:38 +00:00
Aaron Hill 4b76d1b32a
core: Support using URLVariables as a POST request body (#9489)
This is needed by the Newgrounds API. We don't have the ability
to make fake requests to HTTP urls in our test frameworks,
so I haven't added any tests for this. However, I tested locally
that this allows the Newgrounds API to work (and got a medal
in Cloud Wars).
2023-02-11 00:18:10 +00:00
nosamu c1fe3ded25 chore: remove unnecessary FromStr impl for LoadBehavior 2023-02-10 00:56:17 -08:00
nosamu 1a65a0942c desktop: Add --letterbox option 2023-02-09 23:43:25 -08:00
EmperorBale e7612f571d avm2: Implement ScopeChain caching 2023-02-09 10:51:12 -08:00
golfinq 37ec94f95b Avm2: Implement Stage.invalidate 2023-02-08 17:47:21 -07:00
Aaron Hill a818dd0918 core: Use colorTransform in DisplayObject.setTransform 2023-02-08 20:56:46 +01:00
Adrian Wielgosik 61a5161a20 avm2: Convert most errors in get/set/initproperty to AVM errors 2023-02-07 18:50:15 -06:00
Adrian Wielgosik c844d2ab6f avm2: Only store actually-passed arguments to 'arguments' 2023-02-07 18:35:30 -06:00
Nathan Adams ac9b6e3ecb avm2: Mark Dictionary(true) and TimerEvent.updateAfterEvent() as stubs 2023-02-07 20:34:59 +01:00
Nathan Adams e5f44b0f05 avm2: Replaced stubs in actionscript with new stub system 2023-02-07 20:34:59 +01:00
Nathan Adams bdbf54ecd4 core: Added ability to mark stubs inside actionscript 2023-02-07 20:34:59 +01:00
Nathan Adams dff558170e avm2: Implement BitmapData.getPixels() 2023-02-07 19:10:25 +01:00
Nathan Adams 25cc6f3243 avm2: Change MovieClip::frame_scripts to Vec<Option<Avm2Object>>, where index is frame num 2023-02-07 18:26:27 +01:00
Nathan Adams 43d9c3deed avm2: Make sure SoundChannel.soundTransform always returns a value 2023-02-07 18:26:27 +01:00
Nathan Adams bc7773596b avm2: addFrameScript allows null to unset the script, and only allows one script per frame 2023-02-07 18:26:27 +01:00
CUB3D 48f4df51a5 avm1: Correct depth calculation for AVM1 clips pending removal and add tests 2023-02-06 10:53:45 -07:00
CUB3D 2d11a250da avm1: Retrieving the child of a container should prioritise lowest depth 2023-02-06 10:53:45 -07:00
CUB3D a356be15fe avm1: Only delay removals on AVM1, check for dynamic unload handlers 2023-02-06 10:53:45 -07:00
CUB3D 755425ebfa avm1: Delay clip removals when a child has an unload listener
When removing a clip, first check if it has an unload event listener somewhere
it's hierarchy.
If it does, enqueue the removal to happen on the next frame, by moving it to a negative depth.
2023-02-06 10:53:45 -07:00
Nathan Adams 50fd7aeff5 core: Add quality options to the context menu 2023-02-06 16:08:04 +01:00
Nathan Adams a220703618 core: Made PlayerBuilder take quality instead of setting it after the Player was made 2023-02-06 16:08:04 +01:00
Nathan Adams d8e924affc render: Add RenderBackend::set_quality method, and call it from core 2023-02-06 16:08:04 +01:00
Nathan Adams 12bd38b338 core: Changed Player::set_quality to take in a StageQuality directly 2023-02-06 16:08:04 +01:00
Nathan Adams b270d1bbd7 render: Move StageQuality from core to render 2023-02-06 16:08:04 +01:00
Nathan Adams 00c7e8f634 avm2: Fixed bytearray compress/decompress methods setting position of resulting bytearray 2023-02-05 19:22:01 +01:00
Nathan Adams e798d69299 avm2: Convert ByteArray EOF to avm error 2023-02-05 19:22:01 +01:00
Nathan Adams c14f022837 core: Use overwrite_cpu_pixels in apply_filter 2023-02-05 18:41:43 +01:00
Nathan Adams 7476b3b0e0 avm2: Added a bunch of missing filter classes 2023-02-05 18:41:43 +01:00
Nathan Adams 42f3ee923f avm2: Mark unsupported filters as stubs 2023-02-05 18:41:43 +01:00
Nathan Adams 3411a04cef render: Made render specific Filter enum & structs, as swf ones don't map 1:1 to potential filters 2023-02-05 18:41:43 +01:00
Nathan Adams b5a250e16f render: Changed render_offscreen to return an Option instead of an Result 2023-02-05 18:41:43 +01:00
Nathan Adams e73389aa71 wgpu: Implement blur filter 2023-02-05 18:41:43 +01:00
Nathan Adams 284a58c817 avm2: Implement BitmapData.apply_filter for ColorMatrixFilter 2023-02-05 18:41:43 +01:00
Lord-McSweeney a369e71af6 Appease clippy again 2023-02-03 23:32:22 +01:00
Lord-McSweeney 83087f9f23 Change stubs to use new macro method 2023-02-03 23:32:22 +01:00
Lord-McSweeney a6ea1ef4a7 Appease clippy 2023-02-03 23:32:22 +01:00
Lord-McSweeney add115e97f State "Stub" instead of "Implement"
...and fix a format issue.
2023-02-03 23:32:22 +01:00
Lord-McSweeney 963f3240f2 Stub DisplayObject.opaqueBackground 2023-02-03 23:32:22 +01:00
nosamu 12c67d5068 desktop: Improve --help messages 2023-02-03 21:17:56 +01:00
Nathan Adams 198e40fd2e avm2: Changed return values of a bunch of stubs per PR feedbck 2023-02-01 21:45:12 +01:00
Nathan Adams 8e917c473e avm2: Replaced stubs in Proxy with new format 2023-02-01 21:45:12 +01:00
Nathan Adams b28e921fb9 avm2: Replaced stubs in Keyboard with new format 2023-02-01 21:45:12 +01:00
Nathan Adams 99e723a1cb avm2: Replaced stubs in TextField with new format 2023-02-01 21:45:12 +01:00
Nathan Adams 2a36f9b871 avm2: Replaced stubs in StaticText with new format 2023-02-01 21:45:12 +01:00
Nathan Adams ff768a1e73 avm2: Replaced stubs in Font with new format 2023-02-01 21:45:12 +01:00
Nathan Adams af73a1a292 avm2: Replaced stubs in Security with new format 2023-02-01 21:45:12 +01:00
Nathan Adams e48926799c avm2: Replaced stubs in SharedObject with new format 2023-02-01 21:45:12 +01:00