1use tinystr::TinyStr8;
2
3pub type SoundId = TinyStr8;
4
5#[derive(Debug, Clone, PartialEq, Eq, Hash, serde::Deserialize, serde::Serialize)]
6pub struct Sound {
7 pub name: SoundId,
8 pub variant: Option<u16>,
9}
10
11impl Sound {
12 pub fn named(name: TinyStr8) -> Self {
13 Self {
14 name,
15 variant: None,
16 }
17 }
18
19 pub fn variant(name: TinyStr8, variant: Option<u16>) -> Self {
20 Self { name, variant }
21 }
22}
23
24impl core::fmt::Display for Sound {
25 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
26 match &self.variant {
27 Some(variant) => write!(f, "{} #{}", self.name, variant),
28 None => core::fmt::Display::fmt(&self.name, f),
29 }
30 }
31}