use std::fmt;
use std::ops::Range;
use super::style::Style;
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive]
pub enum TextEvent {
Voice(String),
Se(String),
Custom {
name: String,
args: Vec<String>,
},
WaitInput,
WaitClick,
Finished,
Blip(String),
}
impl fmt::Display for TextEvent {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
TextEvent::Voice(id) => write!(f, "voice {id}"),
TextEvent::Se(id) => write!(f, "se {id}"),
TextEvent::Custom { name, args } => {
write!(f, "event {name}")?;
for a in args {
write!(f, " {a}")?;
}
Ok(())
}
TextEvent::WaitInput => write!(f, "入力待ち"),
TextEvent::WaitClick => write!(f, "クリック待ち"),
TextEvent::Blip(id) => write!(f, "blip {id}"),
TextEvent::Finished => write!(f, "終了"),
}
}
}
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive]
pub enum Item {
Text {
text: String,
style: usize,
source: Vec<Range<usize>>,
},
Ruby {
base: String,
reading: String,
style: usize,
source: Vec<Range<usize>>,
},
Tcy {
text: String,
style: usize,
source: Vec<Range<usize>>,
},
Var {
name: String,
style: usize,
source: Range<usize>,
},
Icon {
id: String,
width: f32,
style: usize,
source: Range<usize>,
},
Wait(f32),
Click,
Break,
Page,
Event(TextEvent),
}
#[derive(Debug, Clone, PartialEq, Default)]
#[non_exhaustive]
pub struct Script {
pub items: Vec<Item>,
pub styles: Vec<Style>,
}