1use serde::{Deserialize, Serialize};
2
3use crate::{
4 common::{is_zero, Point},
5 image::ImageData,
6};
7
8#[derive(Clone, Debug, Deserialize, Serialize)]
10pub struct Doll {
11 id: u32,
12
13 #[serde(default, skip_serializing_if = "String::is_empty")]
15 pub desc: String,
16
17 #[serde(default, skip_serializing_if = "is_zero")]
19 pub width: u32,
20
21 #[serde(default, skip_serializing_if = "is_zero")]
23 pub height: u32,
24
25 #[serde(default, skip_serializing_if = "Point::is_zero")]
27 pub offset: Point,
28
29 pub slots: Vec<u32>,
31
32 pub path: String,
36
37 #[serde(skip)]
39 pub image: ImageData,
40}
41
42impl Doll {
43 pub(crate) fn new(id: u32) -> Self {
44 Self {
45 id,
46 desc: String::default(),
47 width: 0,
48 height: 0,
49 offset: Point::default(),
50 slots: vec![],
51 path: String::default(),
52 image: ImageData::default(),
53 }
54 }
55
56 pub fn id(&self) -> u32 {
57 self.id
58 }
59}