1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
use crate::{dialogue::Dialogue, Color, Position, Scale};
#[cfg(feature = "script-flow")]
use core::prefab::PrefabValue;
use core::{prefab::Prefab, Ignite, Scalar};
use serde::{Deserialize, Serialize};

#[derive(Debug, Copy, Clone, Serialize, Deserialize)]
pub enum LogType {
    Info,
    Warning,
    Error,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum Action {
    None,
    // (log type, message)
    Log(LogType, String),
    Label(String),
    Wait(Scalar),
    GoToScene(String),
    EndScene,
    ChangeSceneBackground(String),
    ShowCharacter(String),
    HideCharacter(String),
    /// (character name, visibility percentage)
    ChangeCharacterVisibility(String, Scalar),
    /// (character name, color)
    ChangeCharacterNameColor(String, Color),
    /// (character name, position percentage)
    ChangeCharacterPosition(String, Position),
    /// (character name, alignment percentage)
    ChangeCharacterAlignment(String, Position),
    /// (character name, rotation percentage)
    ChangeCharacterRotation(String, Scalar),
    /// (character name, scale percentage)
    ChangeCharacterScale(String, Scale),
    /// (character name, style name)
    ChangeCharacterStyle(String, String),
    ChangeCameraPosition(Position),
    ChangeCameraRotation(Scalar),
    GoToLabel(String),
    GoToChapter(String),
    Parallel(Vec<Action>),
    ShowDialogue(Dialogue),
    HideDialogue,
    /// (VM name, event name, [parameter])
    #[cfg(feature = "script-flow")]
    CallScriptFlow(String, String, Vec<PrefabValue>),
}

impl Default for Action {
    fn default() -> Self {
        Self::None
    }
}

impl Prefab for Action {}

#[derive(Ignite, Debug, Default, Clone, Serialize, Deserialize)]
pub struct Chapter {
    pub name: String,
    pub actions: Vec<Action>,
}

impl Prefab for Chapter {}