Commit Graph

2971 Commits

Author SHA1 Message Date
relrelb e8e0467673 avm1: Replace `get` + `call` with `call_method` 2021-07-18 23:19:19 +03:00
relrelb 3576a199cd avm1: Replace `set` + `set_attributes` with `define_value` 2021-07-18 23:19:19 +03:00
relrelb c609fa937d avm1: Remove unnecessary type annotations 2021-07-18 23:19:19 +03:00
relrelb ea73dbc367 avm1: Remove `StageObject::as_executable`
It was identical to the default implementation of `TObject`, and
thus unnecessary.
2021-07-18 23:19:19 +03:00
relrelb 0367f6a8d4 avm1: Correct `ASSetPropFlags`
* The properties parameter is evaluated last. This is observable by
the order the `toString`/`valueOf` methods of the parameters are
called.
* Only `null` in the property list parameter configures all properties,
as opposed to `undefined`, `null`, numbers and booleans previously.
* Objects in the property list parameter are not handled specially.
Instead, they're also coerced to string and split by comma.
2021-07-18 20:03:52 +03:00
dependabot[bot] c241ac6ace chore: Bump regress from 0.3.0 to 0.4.1
Bumps [regress](https://github.com/ridiculousfish/regress) from 0.3.0 to 0.4.1.
- [Release notes](https://github.com/ridiculousfish/regress/releases)
- [Commits](https://github.com/ridiculousfish/regress/commits)

---
updated-dependencies:
- dependency-name: regress
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-07-12 23:37:11 +03:00
relrelb 76849c485e core: Cleanup `tag_utils.rs` 2021-07-12 23:09:29 +03:00
relrelb 3d7199d81e core: Remove unused `SwfMovie::from_movie_and_subdata` 2021-07-12 23:09:29 +03:00
Chris Midgley 8e7ce18cc2 avm1: alphabetise text_field properties 2021-07-10 21:19:20 +03:00
Chris Midgley 156a4494aa avm1: update attributes of text_field properties 2021-07-10 21:19:20 +03:00
Adrian Wielgosik 633c23c7f3 avm2: Do timeout check every 2000 actions, same as avm1 2021-07-09 22:09:13 +02:00
relrelb 1cbbdecccf swf: Introduce and use `Color::to_rgba` 2021-07-09 19:56:52 +03:00
relrelb 580d8c3562 chore: Use to_le_bytes in more places 2021-07-09 19:56:52 +03:00
relrelb 87e9dda250 chore: Use from_le_bytes in more places 2021-07-09 19:56:52 +03:00
relrelb 29b3225772 core: Fix ADPCM decoder
Store samples and steps as i16 instead of i32.
2021-07-09 19:55:09 +03:00
relrelb 25b8013a99 core: Refactor PCM decoder a bit
Extract a `read_sample` method to avoid code duplication, and use
the byteorder crate as already done in other places.
2021-07-09 19:52:30 +03:00
Callum Thomson 939d467897
avm1: Correct ToInteger
* Coerce objects as well.
* Wrap numbers around i32.
2021-07-09 03:39:07 +03:00
Chris Midgley ac0fc40345
avm1: implement scroll, maxscroll and bottomScroll for TextField (#4698)
* tests: add tests for scroll

* avm1: implement scroll, maxscroll, bottomScroll

* chore: fmt

* docs: note that scroll is 1-based

* fix: non-word wrapped text with manual breaks is scrollable

* chore: move magic number to const

* chore: avoid mut with extra if

* chore: moving clamping behaviour into core

* refactor: eagerly compute line data

* fix: make scroll work when text is aligned right

* chore: clippy

* docs: add more information about line_data

* tests: add more test cases for scroll
2021-07-08 19:23:30 +02:00
EmperorBale d334e30259
avm1: Fix apply_to_display_object (#4377) (#4743)
* avm1: Fix apply_to_display_object
2021-07-06 17:32:14 +02:00
TÖRÖK Attila 20080dda4e Fix minor bug/typo in `action_get_url_2`
The current version just doesn't make any sense.
The fixed version is akin to the `target.starts_with("_level") && target.len() > 6` line a bit earlier in this file.
2021-07-03 22:43:29 +02:00
relrelb 3a43957db5 chore: Minor cleanups 2021-07-03 17:26:34 +03:00
relrelb 169c79fa3a chore: Minor cleanups 2021-06-26 23:05:11 +03:00
relrelb e3f1fe2004 chore: Prefer spelling "Graphic" 2021-06-24 14:36:45 +03:00
relrelb 7b37bf6809 chore: Avoid spelling "movieclip"
* Prefer "MovieClip" in comments.
* Prefer "mc" for variable names.
2021-06-24 14:36:45 +03:00
relrelb 8b35aad657 core: Take advantage of or patterns
Rust 1.53.0 ships with or patterns, which allow a little more
elegant code:
https://blog.rust-lang.org/2021/06/17/Rust-1.53.0.html#or-patterns
2021-06-24 01:15:22 -07:00
relrelb 3845679e6c core: Remove `branch = "main"` in Cargo.toml
Cargo no longer assumes the default `HEAD` of git repositories is named
`master` (https://blog.rust-lang.org/2021/06/17/Rust-1.53.0.html#head-branch-name-support-in-cargo).
This means we no longer need to specify `branch = "main"`.
2021-06-24 01:15:22 -07:00
relrelb 59970bf7ac avm1: Shorten integers values
The .0 suffix can be omitted since into() supports integers as well.
2021-06-24 01:11:16 -07:00
relrelb 38a2650c0e chore: Use Value into() in more places 2021-06-24 01:11:16 -07:00
Adrian Wielgosik 1a132eb22d avm1: Don't attempt to serialize MovieClips 2021-06-23 19:18:49 -07:00
relrelb 0fd1c05fd5 chore: Use into() in more places 2021-06-22 11:49:41 -07:00
relrelb 13977d9d22 avm1: Correct some Array set_length cases
Array builtins (pop, shift, unshift) doesn't update the length of
non-Array objects. However, push does update the length for all
objects.
2021-06-22 10:43:10 -07:00
relrelb c383b70336 avm1: Merge array_function with constructor 2021-06-22 10:43:10 -07:00
relrelb 7948d872dc avm1: Correct AsBroadcaster removeListener 2021-06-22 10:43:10 -07:00
relrelb 8742f288cb avm1: Correct AsBroadcaster addListener 2021-06-22 10:43:10 -07:00
relrelb b0b48b5b0c avm1: Cleanup ScriptObject constructors 2021-06-22 10:43:10 -07:00
relrelb ab5f5b4878 avm1: Use custom array index parsing method
Indices can be of arbitrary size (by overflowing around i32), but
Rust's `parse` is limited to the i32 range.
2021-06-22 10:43:10 -07:00
relrelb 95c30b85e1 avm1: Extract ArrayObject 2021-06-22 10:43:10 -07:00
Chris Midgley b7de03b5c8
avm1: implement hscroll and maxhscroll for TextField 2021-06-22 01:43:02 -07:00
EmperorBale 1ee61cca57
avm2: ByteArray updates 2021-06-22 01:26:27 -07:00
danharris-stu e010775099 core: Fix documentation spelling 2021-06-21 20:57:49 +03:00
dependabot[bot] a66dce3548 chore: Bump rand from 0.8.3 to 0.8.4
Bumps [rand](https://github.com/rust-random/rand) from 0.8.3 to 0.8.4.
- [Release notes](https://github.com/rust-random/rand/releases)
- [Changelog](https://github.com/rust-random/rand/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-random/rand/compare/0.8.3...0.8.4)

---
updated-dependencies:
- dependency-name: rand
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-20 03:10:42 -07:00
dependabot[bot] c22c18b809 chore: Bump bitstream-io from 1.0.0 to 1.1.0
Bumps [bitstream-io](https://github.com/tuffy/bitstream-io) from 1.0.0 to 1.1.0.
- [Release notes](https://github.com/tuffy/bitstream-io/releases)
- [Commits](https://github.com/tuffy/bitstream-io/commits)

---
updated-dependencies:
- dependency-name: bitstream-io
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-20 03:10:31 -07:00
Mike Welsh e886756aab avm1: Wire up _soundbuftime
Store the `_soundbuftime` property in the audio manager. This is
currently unused by Ruffle, but the value will now be stored.
2021-06-20 01:25:27 -07:00
Mike Welsh e3d0538999 core: Add AudioManager::stream_buffer_time 2021-06-20 01:25:27 -07:00
relrelb 6d1b6009e8 avm1: Use bitflags for ChannelOptions 2021-06-18 15:30:09 -07:00
Adrian Wielgosik 867b7ffcad
core: Preallocate bitmaps for remaining cases in decode_define_bits_lossless 2021-06-17 15:43:36 -07:00
Mike Welsh 09b86cda8b avm1: Implement ToggleHighQuality op
Wire up the op so that it affects the quality setting, although the
setting is still unused by Ruffle.

This op will remember whether the stage was in `High`/`Best` quality.
Split out the "bitmap downsampling" flag in `Stage` so that we can
persist this state.
2021-06-17 13:55:56 -07:00
Mike Welsh eb12a3af17 avm1: Wire up _highquality 2021-06-17 13:55:56 -07:00
Mike Welsh 9357fd7b4f avm2: Wire up Stage.quality 2021-06-17 13:55:56 -07:00
Mike Welsh 9370b84092 avm1: Wire up _quality 2021-06-17 13:55:56 -07:00
Mike Welsh ee8439e55c core: Add Stage::quality 2021-06-17 13:55:56 -07:00
Mike Welsh a1ceb07bec core: Fix PlaceObjectAction::Replace in gotos (fix #4545) 2021-06-16 20:57:43 -07:00
Mike Welsh 622f35eb71 core: Pump action queue after handling an event 2021-06-16 12:42:49 -07:00
Mike Welsh e2659e451c core: Fire button events after mouse move events 2021-06-16 12:42:49 -07:00
Mike Welsh 71024939e3 core: Remove self_node parameter from DisplayObject::mouse_pick 2021-06-16 12:42:49 -07:00
Mike Welsh 6894382e8e avm1: Implement _droptarget 2021-06-16 12:42:49 -07:00
Mike Welsh 495f8d90e6 avm1: Implement dragOver/dragOut button events 2021-06-16 12:42:49 -07:00
Mike Welsh 6de7ee1a8c core: Support drag events with magic button frame labels 2021-06-16 12:42:49 -07:00
Mike Welsh 90024a1266 core: Wire up dragOver/dragOut events for buttons 2021-06-16 12:42:49 -07:00
Mike Welsh b0143ff918 core: Add Player::mouse_pressed_object 2021-06-16 12:42:49 -07:00
Mike Welsh 2f25887080 avm1: SetTarget of a removed clip is invalid
A `SetTarget` call should ignore any clip that has been removed.
This can happen in cases such as `tellTarget("_root")` seeking
to a frame where the clip no longer exists.

Fixes this issue:
https://github.com/ruffle-rs/ruffle/pull/4452#issuecomment-860747028
2021-06-14 14:04:28 -07:00
Mike Welsh ed1bfd74fe core: keyPress events take precedence over text input 2021-06-14 14:04:28 -07:00
Mike Welsh 4687eb6d4e core: Ensure bitmaps run post_instantiate 2021-06-14 14:04:28 -07:00
Mike Welsh 1f96af6b64 core: Add Avm1::exec_list to manage global list of display objects 2021-06-14 14:04:28 -07:00
dependabot[bot] cf4a1136c5 chore: Bump env_logger from 0.8.3 to 0.8.4
Bumps [env_logger](https://github.com/env-logger-rs/env_logger) from 0.8.3 to 0.8.4.
- [Release notes](https://github.com/env-logger-rs/env_logger/releases)
- [Changelog](https://github.com/env-logger-rs/env_logger/blob/main/CHANGELOG.md)
- [Commits](https://github.com/env-logger-rs/env_logger/compare/v0.8.3...v0.8.4)

---
updated-dependencies:
- dependency-name: env_logger
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-14 00:47:57 -07:00
dependabot[bot] 1b6b4964c9 chore: Bump syn from 1.0.72 to 1.0.73
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.72 to 1.0.73.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.72...1.0.73)

---
updated-dependencies:
- dependency-name: syn
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-14 00:47:40 -07:00
Mike Welsh 83f842faf9 avm1: Implement MovieClip.beginBitmapFill 2021-06-13 20:03:53 -07:00
Mike Welsh 554aa7fd63 core: Add backend::render::BitmapSource trait
This interface handles returning a bitmap given an ID and is used
by the render backend to get the bitmap used for a bitmap fill.
This will allow for bitmap fills in the drawing API, as these will
manage their own list of bitmaps.
This also  removes the MovieLibrary dependency from render backends
and will allow for better decoupling in the future.
2021-06-13 20:03:53 -07:00
Chris Midgley b6a2738dab core: support magic button labels for avm1 2021-06-13 10:46:24 -07:00
Adrian Wielgosik 7d1bd57066 avm1: Call ContextMenu.onSelect before preparing context menu items 2021-06-13 10:37:38 -07:00
relrelb 9c5b9b7072 avm1: Rewrite TObject array methods 2021-06-13 10:37:15 -07:00
Mike Welsh 3b215d6c76 core: Use swf::ClipEventFlag in stored clip event handlers
* Rename movie_clip::ClipAction to movie_clip::ClipEventHandler.
 * Store the swf::ClipEventFlag event flags that trigger the event
   directly in the event handler. Previously we split up any event
   that had multiple event flags into separate events. Now these
   can be kept as a single event.
 * Remove `MovieClip::has_button_event`, and instead store the
   union of all event flags in `MovieClip::clip_event_flags`. This
   will be useful for other cases in the future.
2021-06-11 12:54:53 -07:00
relrelb ede9650899 chore: Avoid unused_variables annotations
Instead prefix the unused variables with an underscore.
2021-06-11 16:16:53 +03:00
Mike Welsh 5462b8a522 core: Allow MorphShapes and Texts to be replaced via PlaceObject
PR #4540 allowed shapes to replace their inner art handles via
replace PlaceObject tags. This can also happen for morph shapes and
static texts.

Add MorphShape::replace_with and Text::repalce_with. This fixes the
incorrect art in main menu buttons of Super Mario 63.
2021-06-09 23:37:38 -07:00
Mike Welsh 4fc9225e8f avm2: Only construct Shapes once
Shape objects were mistakenly being reconstructed each frame in
`Graphic::construct_frame`.
2021-06-08 19:47:16 -07:00
Mike Welsh b1318ecb01 core: PlaceObjectAction::Replace swaps out graphic handles
A `PlaceObjectAction::Replace` signals that a shape should
be swapped with a different shape. Previously we instantiated a
completely new `Graphic`, but this is incorrect; instead the
underlying shape handle should be swapped out, but the outer object
remains. This is visible in AVM2 where you can access `Shape` as
a normal display object.
2021-06-08 19:47:16 -07:00
Mike Welsh 93e83d7ad5 avm1: DefineFunction should respect case sensitivity 2021-06-08 16:51:59 -07:00
Mike Welsh 21c351fe5b swf: Change Twips::zero fn to Twips::ZERO const 2021-06-08 14:57:15 -07:00
Mike Welsh d23ea90459 swf: Change Matrix to use Fixed16 for a, b, c, d
Matrices in an SWF file store their scale/skew components in
in 16.16 format (fbits).

Split `ruffle_core::Matrix` and `swf::Matrix`. `swf::Matrix` now
stores its data as `Fixed16` instead of immediately converting to
`f32`.
2021-06-08 14:57:15 -07:00
relrelb 39decde5bc avm1: Refactor ScriptObject::get_local 2021-06-08 10:48:50 -07:00
relrelb 1c0007f34f avm1: Make TObject::get_local return Option 2021-06-08 10:48:50 -07:00
relrelb 15fa92a9fb avm1: Add TObject::set_local 2021-06-08 10:48:50 -07:00
relrelb c9d015d7c5 avm1: Cleanup some TObject methods 2021-06-08 10:48:50 -07:00
dependabot[bot] 2f1dc0cbb1 chore: Bump approx from 0.4.0 to 0.5.0
Bumps [approx](https://github.com/brendanzab/approx) from 0.4.0 to 0.5.0.
- [Release notes](https://github.com/brendanzab/approx/releases)
- [Commits](https://github.com/brendanzab/approx/compare/v0.4.0...v0.5.0)

---
updated-dependencies:
- dependency-name: approx
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-07 11:30:59 -07:00
relrelb b8eae51888 swf: Move num_colors into BitmapFormat::ColorMap8 2021-06-07 11:29:28 -07:00
relrelb ef2e581f09 core: Use casting instead of ToPrimitive 2021-06-07 11:29:28 -07:00
relrelb aee37276ec core: Replace num_enum with num_derive 2021-06-05 10:19:31 -07:00
relrelb f82faf9603 chore: Appease clippy 2021-06-05 10:16:00 -07:00
Adam Gashlin ba83f17ef7 core: Set init_object after first run_frame (fix #2084, #3414) 2021-06-02 23:28:24 -07:00
dependabot[bot] 83243acc37 chore: Bump regress from 0.2.0 to 0.3.0
Bumps [regress](https://github.com/ridiculousfish/regress) from 0.2.0 to 0.3.0.
- [Release notes](https://github.com/ridiculousfish/regress/releases)
- [Commits](https://github.com/ridiculousfish/regress/commits)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-31 10:06:11 -07:00
Mike Welsh f173b81e38 swf: Use bitflags for Function flags 2021-05-30 22:14:32 -07:00
Mike Welsh 2b98c878f0 swf: Use Fixed in more places 2021-05-30 21:24:03 -07:00
Adrian Wielgosik 34d54dbc05
avm1: Fix string methods handling of negative args (fix #4437)
* Improve string.substr handling of negative args
* Add tests for more substr() combinations
2021-05-30 12:04:17 -07:00
Mike Welsh 1304b2c55a avm2: Move Object properties to Object.prototype 2021-05-24 17:52:15 -07:00
Moulins af5694b642 [avm1] extend impl_custom_object! to reduce boilerplate
This add two knobs to the impl_custom_object! macro:
  - `set(...)`, for using a specific prototype in the `set`
method;
  - `bare_object(...)`, for objects that are convertible to a raw object
type.
2021-05-24 17:06:47 -07:00
Mike Welsh 3ddb97d2f6 core: Add SwfMovie::frame_rate and num_frames 2021-05-23 23:02:38 -07:00
Mike Welsh 172ad82aa5 core: Add SwfMovie::uncompressed_len 2021-05-23 23:02:38 -07:00
Mike Welsh 077c7f045e core: Add SwfMovie::stage_size
Change `SwfMovie::width` and `height` to return `Twips`.
2021-05-23 23:02:38 -07:00
Mike Welsh bec6eb9dd3 core: Use SwfMovie::avm_type instead of MovieLibrary::avm_type 2021-05-23 23:02:38 -07:00
Mike Welsh e1439f4105 swf: Add HeaderExt struct providing additional info
When reading an SWF, search for FileAttributes and
SetBackgroundColor and return this along with the header data
because it's useful (in particular, the AS3 flag).
2021-05-23 23:02:38 -07:00