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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
use nanoserde::DeJson;
use std::collections::HashMap;
#[derive(Clone, Debug, Default, DeJson)]
#[nserde(default)]
pub struct Chunk {
pub data: Vec<u32>,
pub height: usize,
pub width: usize,
pub x: i32,
pub y: i32,
}
#[derive(Clone, Debug, Default, DeJson)]
#[nserde(default)]
pub struct Layer {
pub chunks: Option<Vec<Chunk>>,
pub name: String,
pub opacity: f32,
pub properties: Option<HashMap<String, String>>,
pub visible: bool,
pub width: u32,
pub height: u32,
#[nserde(rename = "type")]
pub ty: String,
pub data: Vec<u32>,
pub draworder: Option<String>,
#[nserde(default)]
pub objects: Vec<Object>,
pub offsetx: Option<i32>,
pub offsety: Option<i32>,
pub x: Option<f32>,
pub y: Option<f32>,
}
#[derive(Clone, Debug, Default, DeJson)]
#[nserde(default)]
pub struct Property {
pub name: String,
#[nserde(rename = "type")]
pub ty: String,
pub value: String,
}
#[derive(Clone, Debug, Default, DeJson)]
#[nserde(default)]
pub struct Object {
pub id: u32,
pub name: String,
#[nserde(rename = "type")]
pub ty: String,
pub gid: Option<u32>,
pub ellipse: Option<bool>,
pub polygon: Option<Vec<PolyPoint>>,
pub properties: Vec<Property>,
pub rotation: f32,
pub visible: bool,
pub height: f32,
pub width: f32,
pub x: f32,
pub y: f32,
}
#[derive(Copy, Clone, Debug, DeJson)]
pub struct PolyPoint {
pub x: f32,
pub y: f32,
}