wolfrpg_map_parser/command/picture_command/show/
delay.rs1use crate::command::picture_command::colors::Colors;
2use crate::command::picture_command::show::delay_fields::DelayFields;
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 Delay {
10 position_x: u32,
11 position_y: u32,
12 fields: DelayFields
13}
14
15impl Delay {
16 pub(crate) fn parse(bytes: &[u8]) -> (usize, Option<u32>, Self) {
17 let (offset, (position_x, position_y, filename_variable, fields))
18 : (usize, (u32, u32, Option<u32>, DelayFields))
19 = parse_fields(bytes);
20
21 (offset, filename_variable, Self {
22 position_x,
23 position_y,
24 fields
25 })
26 }
27
28 pub fn position_x(&self) -> u32 {
29 self.position_x
30 }
31
32 pub fn position_x_mut(&mut self) -> &mut u32 {
33 &mut self.position_x
34 }
35
36 pub fn position_y(&self) -> u32 {
37 self.position_y
38 }
39
40 pub fn position_y_mut(&mut self) -> &mut u32 {
41 &mut self.position_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}