wolfrpg_map_parser/command/picture_command/show/
range.rs

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
use crate::command::picture_command::colors::Colors;
use crate::command::picture_command::show::parser::parse_fields;
use crate::command::picture_command::show::range_fields::RangeFields;
#[cfg(feature = "serde")]
use serde::Serialize;

#[cfg_attr(feature = "serde", derive(Serialize))]
pub struct Range {
    position_x: u32,
    position_y: u32,
    fields: RangeFields
}

impl Range {
    pub fn parse(bytes: &[u8]) -> (usize, Option<u32>, Self) {
        let (offset, (position_x, position_y, filename_variable, fields))
            : (usize, (u32, u32, Option<u32>, RangeFields))
            = parse_fields(bytes);

        (offset, filename_variable, Self {
            position_x,
            position_y,
            fields
        })
    }

    pub fn position_x(&self) -> u32 {
        self.position_x
    }

    pub fn position_x_mut(&mut self) -> &mut u32 {
        &mut self.position_x
    }

    pub fn position_y(&self) -> u32 {
        self.position_y
    }

    pub fn position_y_mut(&mut self) -> &mut u32 {
        &mut self.position_y
    }

    pub fn colors(&self) -> &Colors {
        self.fields.colors()
    }

    pub fn colors_mut(&mut self) -> &mut Colors {
        self.fields.colors_mut()
    }

    pub fn delay(&self) -> u32 {
        self.fields.delay()
    }

    pub fn delay_mut(&mut self) -> &mut u32 {
        self.fields.delay_mut()
    }

    pub fn range_count(&self) -> u32 {
        self.fields.range_count()
    }

    pub fn range_count_mut(&mut self) -> &mut u32 {
        self.fields.range_count_mut()
    }
}