wolfrpg_map_parser/command/effect_command/scroll_screen/
options.rs1#[cfg(feature = "serde")]
2use serde::{Serialize, Deserialize};
3use crate::command::effect_command::scroll_screen::scroll_operation::ScrollOperation;
4use crate::command::effect_command::scroll_screen::scroll_speed::ScrollSpeed;
5
6#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
7#[derive(PartialEq, Clone)]
8pub struct Options {
9 scroll_operation: ScrollOperation,
10 scroll_speed: ScrollSpeed,
11 wait_until_done: bool,
12 pixel_units: bool
13}
14
15impl Options {
16 pub fn new(options: u32) -> Self {
17 Self {
18 scroll_operation: ScrollOperation::new((options & 0x0f) as u8),
19 scroll_speed: ScrollSpeed::new(((options & 0xf0) >> 4) as u8),
20 wait_until_done: (options >> 8) & 0b00000001 != 0,
21 pixel_units: (options >> 8) & 0b00000010 != 0,
22 }
23 }
24
25 pub fn scroll_operation(&self) -> &ScrollOperation {
26 &self.scroll_operation
27 }
28
29 pub fn scroll_operation_mut(&mut self) -> &mut ScrollOperation {
30 &mut self.scroll_operation
31 }
32
33 pub fn scroll_speed(&self) -> &ScrollSpeed {
34 &self.scroll_speed
35 }
36
37 pub fn scroll_speed_mut(&mut self) -> &mut ScrollSpeed {
38 &mut self.scroll_speed
39 }
40
41 pub fn wait_until_done(&self) -> bool {
42 self.wait_until_done
43 }
44
45 pub fn wait_until_done_mut(&mut self) -> &mut bool {
46 &mut self.wait_until_done
47 }
48
49 pub fn pixel_units(&self) -> bool {
50 self.pixel_units
51 }
52
53 pub fn pixel_units_mut(&mut self) -> &mut bool {
54 &mut self.pixel_units
55 }
56}