yog_formats/yres.rs
1//! `.yres` — a mod's texts, images, sounds, files, colors, numbers, flags.
2
3use yog_data::Schema;
4
5/// An entry's type.
6#[derive(Debug, Clone, Copy, PartialEq, Eq, Schema)]
7pub enum Kind {
8 String,
9 Image,
10 File,
11 Sound,
12 Color,
13 Number,
14 Bool,
15}
16
17impl Kind {
18 pub fn name(self) -> &'static str {
19 match self {
20 Kind::String => "string",
21 Kind::Image => "image",
22 Kind::File => "file",
23 Kind::Sound => "sound",
24 Kind::Color => "color",
25 Kind::Number => "number",
26 Kind::Bool => "bool",
27 }
28 }
29}
30
31/// An entry's object form: `{ "type": ..., "value": ..., "comment": ..., ... }`.
32#[derive(Schema)]
33pub struct EntryObject {
34 /// What the entry is; by default what its value is (string, number, bool).
35 #[data(rename = "type")]
36 pub kind: Option<Kind>,
37 /// The text, path, color, number or flag.
38 pub value: yog_data::Value,
39 /// A note for whoever edits the file — never shipped.
40 pub comment: Option<String>,
41 /// Texts: the translation key instead of the default one.
42 pub key: Option<String>,
43 /// Images: the texture path under `assets/<mod id>/textures/`.
44 pub texture: Option<String>,
45 /// Sounds: the sound event name.
46 pub event: Option<String>,
47 /// Sounds: the subtitle's translation key.
48 pub subtitle: Option<String>,
49}