wolfrpg_map_parser/command/input_key_command/automatic_input/
basic_options.rs1#[cfg(feature = "serde")]
2use serde::{Serialize, Deserialize};
3
4#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
5#[derive(PartialEq, Clone)]
6pub struct BasicOptions {
7 input_ok: bool,
8 input_cancel: bool,
9 input_subkey: bool,
10 down: bool,
11 left: bool,
12 right: bool,
13 up: bool,
14}
15
16impl BasicOptions {
17 pub fn new(options: u8) -> Self {
18 Self {
19 input_ok: options & 0b00000001 != 0,
20 input_cancel: options & 0b00000010 != 0,
21 input_subkey: options & 0b00000100 != 0,
22 down: options & 0b00010000 != 0,
23 left: options & 0b00100000 != 0,
24 right: options & 0b01000000 != 0,
25 up: options & 0b10000000 != 0,
26 }
27 }
28
29 pub fn input_ok(&self) -> bool {
30 self.input_ok
31 }
32
33 pub fn input_ok_mut(&mut self) -> &mut bool {
34 &mut self.input_ok
35 }
36
37 pub fn input_cancel(&self) -> bool {
38 self.input_cancel
39 }
40
41 pub fn input_cancel_mut(&mut self) -> &mut bool {
42 &mut self.input_cancel
43 }
44
45 pub fn input_subkey(&self) -> bool {
46 self.input_subkey
47 }
48
49 pub fn input_subkey_mut(&mut self) -> &mut bool {
50 &mut self.input_subkey
51 }
52
53 pub fn down(&self) -> bool {
54 self.down
55 }
56
57 pub fn down_mut(&mut self) -> &mut bool {
58 &mut self.down
59 }
60
61 pub fn left(&self) -> bool {
62 self.left
63 }
64
65 pub fn left_mut(&mut self) -> &mut bool {
66 &mut self.left
67 }
68
69 pub fn right(&self) -> bool {
70 self.right
71 }
72
73 pub fn right_mut(&mut self) -> &mut bool {
74 &mut self.right
75 }
76
77 pub fn up(&self) -> bool {
78 self.up
79 }
80
81 pub fn up_mut(&mut self) -> &mut bool {
82 &mut self.up
83 }
84}