Commit Graph

410 Commits

Author SHA1 Message Date
Moulins 47030b4f5b core: remove UpdateContext's unused lifetime and reborrow method 2024-08-10 22:53:27 +02:00
Kamil Jarosz 53d2d16162 core: Add UiBackend::close_virtual_keyboard
This method may be used by backends that require explicit virtual
keyboard closing.
2024-07-27 21:32:35 +02:00
Aaron Hill 6e93927f63 web: Check for locked 'Player' mutex and reschedule with setTimeout
We use 'wasm-bindgen-futures' as our futures executor on web, which
in turn uses 'queueMicroTask'. This can result in the browser executing
one of our futures while we're still inside our `requestAnimationFrame`
callback (in particular, while we still have the `Player` mutex locked).

We now detect this condition by attempting the lock the Player mutex
inside of our `spawn_local` future. If this fails, we `await`
a `setTimeout`-based promise, which ensures that our code runs in
a new top-level `setTimeout` javascript 'task' (outside of our
`requestAnimationFrame` callback).
2024-07-15 22:46:22 +02:00
Kamil Jarosz 392101611e core: Add support for pressing multiple mouse buttons 2024-07-12 15:41:08 +02:00
Kamil Jarosz 368a95cf3b core: Add button parameter to is_mouse_down() 2024-07-12 15:41:08 +02:00
Nathan Adams dd7692b211 core: Document audio+DO methods slightly 2024-07-07 23:57:24 +02:00
Nathan Adams 229697fbbd core: Correctly handle sound events attached to buttons. Fixes #2473 2024-07-07 23:57:24 +02:00
Nathan Adams 84df034f84 core: When stopping sounds associated with movieclips, go by path instead of pointer - fixes #9795 2024-07-07 23:57:24 +02:00
Kamil Jarosz d770422724 core: Calculate click index when not supplied 2024-07-06 18:32:10 +02:00
Kornelius Rohrschneider 0b30b7fdda core: Use HTTP response encoding if existing
If System#useCodepage has been set to true, the form loader now uses the
encoding specified in the HTTP response content type field, if existing,
to decode remote text files. chardetng is now (only) used if the HTTP
response doesn't specify any encoding or if the file is local.
2024-06-26 02:37:44 +02:00
Nathan Adams c9b111996f web: Make serde (more-)optional in core 2024-06-13 00:22:33 +02:00
Kamil Jarosz c23ec0782a core: Prevent pasting empty string when the clipboard is empty 2024-06-09 15:38:35 +02:00
Nathan Adams 618e061564 core: Expand on audio related error messages 2024-06-01 14:08:54 +02:00
Kamil Jarosz 8e6e71b2f7 web: Download the file on FileReference.save
This patch adds support for saving files on web using FileReference.
When writing data, a download is triggered with the default file name.
Currently, there's no dialog that lets the user select save destination.

This patch also ensures that all implementations of FileDialogResult
behave the same way: desktop, web, and tests.
The methods `write` and `refresh` have been merged into one:
`write_and_refresh`, which allows the tests and web implementations
behave the same way as desktop.
2024-05-07 22:26:30 +02:00
TÖRÖK Attila b8ec3a8089 nit: Silence nightly `clippy::legacy_numeric_constants` lint 2024-04-20 17:39:54 +02:00
Kamil Jarosz c260a45603 core: Close sockets and timers when replacing the root movie
Turns out that the comment from `set_root_movie` was right all along!
`set_root_movie` should not be used when replacing the root movie,
because it will leave out unclosed resources.
This patch introduces `replace_root_movie`, which is dedicated to be
used when replacing (instead of just setting) the root movie.

The best solution would be to use RAII, e.g. destroy and recreate
the whole Player instance, but this patch is a first step towards
proper resource control.
2024-03-05 23:14:08 +01:00
Nathan Adams 09dfa6427e desktop: Allow changing the language in Preferences 2024-03-05 00:02:27 +01:00
TÖRÖK Attila 85dd258168 cleanup: Remove a stale workaround for a `generational-arena` bug 2024-03-03 21:18:39 +01:00
TÖRÖK Attila 8764c08b01 cleanup: Define distinct key types for different kinds of slotmaps 2024-03-03 21:18:39 +01:00
TÖRÖK Attila 55773f0205 chore: Replace `generational-arena` with `slotmap` 2024-03-02 19:42:11 +01:00
Kamil Jarosz cc8b0aa5dd core: Use async channels in NavigatorBackend
This has several advantages:
1. it allows using async variants of send and recv,
2. it adds consistency as until now Receiver was async,
   and Sender was not.
2024-02-28 19:42:54 +01:00
David Wendt 006c3af4b8 core: Add backend method for getting the expected length of a response. 2024-01-25 23:24:09 -07:00
David Wendt 91dd9563bb core: Add method to read downloads in chunks instead of all-at-once. 2024-01-25 23:24:09 -07:00
David Wendt 06eb2e1ee8 core: `Request` is now a trait. Body download is deferred to a second async method. 2024-01-25 23:24:09 -07:00
Tom Schuster e0f5b8906d desktop: Support device font with a non-zero index 2024-01-19 19:21:48 +01:00
TÖRÖK Attila d153290fd6 nits: Fix a whole bunch of typos all over the place 2024-01-17 23:59:19 +01:00
Daniel Jacobs 8f2292c2c7 core: Add error for loading invalid SWF files and display as appropriate 2024-01-17 17:38:47 -05:00
Nathan Adams 7e4ac986f2 core: Add FontFace struct, for loading a Font from a file binary 2024-01-08 23:00:18 +01:00
Tom Schuster e3d8a279ad core: load_device_font register function must be &mut 2023-12-22 13:47:48 +01:00
TÖRÖK Attila 941f87ca8e core/audio: Remove the now unused clip_frame parameter of start_stream 2023-11-26 03:51:28 +01:00
TÖRÖK Attila 8ce95d76fe core/audio: Remove the now unused stream_handle parameter of start_stream 2023-11-26 03:51:28 +01:00
TÖRÖK Attila 23960883f8 core/audio: Remove the now dummy is_loading_complete 2023-11-26 03:51:28 +01:00
MrCheeze 5920a6426e core: Allow Regular/Bold/Italic device fonts to be registered separately 2023-11-24 17:08:35 +01:00
Nathan Adams d6f16b0be5 tests: Make tests use a virtual filesystem, which currently maps to the regular physical FS rooted in a test directory 2023-11-13 22:28:10 +01:00
Nathan Adams e6b5ac9a2b tests: Allow tests to request http://example.org/foo/bar by loading ./example.org/foo/bar 2023-11-09 12:39:22 +01:00
CUB3D b0d88645bc avm1: Implement FileReference 2023-11-03 19:32:24 +01:00
TÖRÖK Attila 0c0b86c008 core,web: Replace `instant` with `web-time` 2023-10-28 03:01:45 +02:00
michiel2005 333009b79f avm1: Implement key.isToggled() 2023-10-26 17:39:14 -04:00
Nathan Adams 74a7ab5afe core: Implement device font lookup, and multiple default device fonts 2023-10-15 14:09:21 +02:00
Kornelius Rohrschneider 53ba75d587 Move logarithmic volume transformation to AudioMixer
Previously, the volume transformation to adapt the volume for
logarithmic hearing has been performed in the VolumeControls Rust struct
and TypeScript class each.
Since this calculation is the same on desktop and web and should be
implemented in the audio backend, it has been moved into the
AudioMixer::mix_audio method.
The VolumeControls struct and class now only calculate the linear volume
out of the checkbox and the slider.
Player::set_volume and Player::volume now don't take and return the
adapted volume, but use the linear volume (which gets saved internally).
2023-09-07 00:51:58 +02:00
David Wendt 6e3c468592 core: When reading part of a `Substream` slice for the tag reader, don't throw out the rest of it 2023-08-23 15:36:20 -06:00
David Wendt 2d0815c013 tests: Add test cases for `SliceCursor` 2023-08-23 15:36:20 -06:00
David Wendt 304f04952d core: `get_sound_duration` does not accept `SoundInstanceHandles` and I don't know why the compiler didn't flag this 2023-08-23 15:36:20 -06:00
David Wendt 782181557b core: Fix `SubstreamTagReader`'s chunk resizing 2023-08-23 15:36:20 -06:00
David Wendt 7158039135 audio: Audio streamed from FLVs do not have the SWF MP3 header 2023-08-23 15:36:20 -06:00
David Wendt 438f53a936 core: Explicitly report a `TooManySounds` error instead of coercing all failure modes into returning `None` in `AudioManager` 2023-08-23 15:36:20 -06:00
David Wendt f5d6bf9fb9 audio: Add support for playing substream sounds through the audio manager 2023-08-23 15:36:20 -06:00
David Wendt 4b5398e122 audio: Implement `start_substream`.
This also removes `append_substream` since `Substream` now handles that internally.

This requires duplicating a huge chunk of the decoder code to work with `Buffer` types instead of `SwfMovie` types. Eventually we'll want to wipe out all the SWF-specific stuff and use `Buffer` exclusively.
2023-08-23 15:36:20 -06:00
David Wendt b46ef355fd core: Add two new methods for managing streaming audio:
* `start_substream` plays audio data from a `Substream`, giving back a `SoundInstanceHandle` that can be manipulated the same way as the one from `start_stream`

 * `append_substream` adds more data to an already playing `Substream` backed `SoundInstance`. In the event that a sound has finished playing, `append_substream` will fail, and you have to start a new sound stream.

This is ultimately intended to replace the current streaming audio setup, which is SWF-specific and has a number of unused parameters. It is also designed to support progressive download in the future.

We also include stub impls for `NullAudioBackend`.
2023-08-23 15:36:20 -06:00
Daniel Jacobs dbb5e381f2 core/desktop/web: Play unsupported videos with browser 2023-08-07 14:31:33 -06:00