wolfrpg_map_parser/command/picture_command/show/
free_transform.rs

1use crate::command::picture_command::colors::Colors;
2use crate::command::picture_command::show::free_transform_fields::FreeTransformFields;
3use crate::command::picture_command::show::parser::parse_fields;
4#[cfg(feature = "serde")]
5use serde::{Serialize, Deserialize};
6
7#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
8#[derive(PartialEq, Clone)]
9pub struct FreeTransform {
10    top_left_x: u32,
11    top_left_y: u32,
12    fields: FreeTransformFields
13}
14
15impl FreeTransform {
16    pub(crate) fn parse(bytes: &[u8]) -> (usize, Option<u32>, Self) {
17        let (offset, (top_left_x, top_left_y, filename_variable, fields))
18            : (usize, (u32, u32, Option<u32>, FreeTransformFields))
19            = parse_fields(bytes);
20
21        (offset, filename_variable, Self {
22            top_left_x,
23            top_left_y,
24            fields
25        })
26    }
27
28    pub fn top_left_x(&self) -> u32 {
29        self.top_left_x
30    }
31
32    pub fn top_left_x_mut(&mut self) -> &mut u32 {
33        &mut self.top_left_x
34    }
35
36    pub fn top_left_y(&self) -> u32 {
37        self.top_left_y
38    }
39
40    pub fn top_left_y_mut(&mut self) -> &mut u32 {
41        &mut self.top_left_y
42    }
43
44    pub fn colors(&self) -> &Colors {
45        self.fields.colors()
46    }
47
48    pub fn colors_mut(&mut self) -> &mut Colors {
49        self.fields.colors_mut()
50    }
51
52    pub fn delay(&self) -> u32 {
53        self.fields.delay()
54    }
55
56    pub fn delay_mut(&mut self) -> &mut u32 {
57        self.fields.delay_mut()
58    }
59
60    pub fn range_count(&self) -> u32 {
61        self.fields.range_count()
62    }
63
64    pub fn range_count_mut(&mut self) -> &mut u32 {
65        self.fields.range_count_mut()
66    }
67
68    pub fn color_values(&self) -> &[u32; 3] {
69        self.fields.color_values()
70    }
71
72    pub fn color_values_mut(&mut self) -> &mut [u32; 3] {
73        self.fields.color_values_mut()
74    }
75
76    pub fn zoom_height(&self) -> u32 {
77        self.fields.zoom_height()
78    }
79
80    pub fn zoom_height_mut(&mut self) -> &mut u32 {
81        self.fields.zoom_height_mut()
82    }
83
84    pub fn top_right_x(&self) -> u32 {
85        self.fields.top_right_x()
86    }
87
88    pub fn top_right_x_mut(&mut self) -> &mut u32 {
89        self.fields.top_right_x_mut()
90    }
91
92    pub fn top_right_y(&self) -> u32 {
93        self.fields.top_right_y()
94    }
95
96    pub fn top_right_y_mut(&mut self) -> &mut u32 {
97        self.fields.top_right_y_mut()
98    }
99
100    pub fn bottom_left_x(&self) -> u32 {
101        self.fields.bottom_left_x()
102    }
103
104    pub fn bottom_left_x_mut(&mut self) -> &mut u32 {
105        self.fields.bottom_left_x_mut()
106    }
107
108    pub fn bottom_left_y(&self) -> u32 {
109        self.fields.bottom_left_y()
110    }
111
112    pub fn bottom_left_y_mut(&mut self) -> &mut u32 {
113        self.fields.bottom_left_y_mut()
114    }
115
116    pub fn bottom_right_x(&self) -> u32 {
117        self.fields.bottom_right_x()
118    }
119
120    pub fn bottom_right_x_mut(&mut self) -> &mut u32 {
121        self.fields.bottom_right_x_mut()
122    }
123
124    pub fn bottom_right_y(&self) -> u32 {
125        self.fields.bottom_right_y()
126    }
127
128    pub fn bottom_right_y_mut(&mut self) -> &mut u32 {
129        self.fields.bottom_right_y_mut()
130    }
131}