Skip to main content

yog_event/
video.rs

1//! The videos a client plays (`docs/design/video.md`; the runtime answers,
2//! on a client): a player opened on a mod's video, played, paused, sought,
3//! closed — and, each frame it's drawn, its picture.
4
5/// Opens a player on video `id` (`mymod:intro`), paused at its start; its
6/// handle (none: no such video, or no client).
7#[derive(Debug, Clone, yog_data::Schema)]
8pub struct Open {
9    pub id: String,
10}
11
12/// Plays (`playing`) or pauses player `handle`.
13#[derive(Debug, Clone, yog_data::Schema)]
14pub struct Play {
15    pub handle: u32,
16    pub playing: bool,
17}
18
19/// Sends player `handle` to `seconds` from its video's start.
20#[derive(Debug, Clone, yog_data::Schema)]
21pub struct Seek {
22    pub handle: u32,
23    pub seconds: f64,
24}
25
26/// Lets player `handle` go: its picture, its sound.
27#[derive(Debug, Clone, yog_data::Schema)]
28pub struct Close {
29    pub handle: u32,
30}
31
32/// Player `handle`'s picture now (asked for each frame it's drawn).
33#[derive(Debug, Clone, yog_data::Schema)]
34pub struct Frame {
35    pub handle: u32,
36}
37
38/// Plays video `id` full screen over the game till its end; `skippable`:
39/// Esc ends it early. Whether it started.
40#[derive(Debug, Clone, yog_data::Schema)]
41pub struct Cutscene {
42    pub id: String,
43    pub skippable: bool,
44}
45
46/// A player's picture and where it is.
47#[derive(Debug, Clone, Default, PartialEq, yog_data::Schema)]
48pub struct Picture {
49    /// The texture it's in: an image source, drawn like any other.
50    pub texture: String,
51    /// Its size, pixels.
52    pub width: u32,
53    pub height: u32,
54    /// Seconds from its start, and its length.
55    pub seconds: f64,
56    pub length: f64,
57    pub playing: bool,
58}