wolfrpg_map_parser/command/input_key_command/input_key/
basic_options.rs1#[cfg(feature = "serde")]
2use serde::{Serialize, Deserialize};
3use crate::command::input_key_command::input_key::direction_keys::DirectionKeys;
4
5#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
6#[derive(PartialEq, Clone)]
7pub struct BasicOptions {
8 direction_keys: DirectionKeys,
9 input_ok: bool,
10 input_cancel: bool,
11 input_subkey: bool,
12 wait_for_input: bool
13}
14
15impl BasicOptions {
16 pub fn new(options: u8) -> Self {
17 Self {
18 direction_keys: DirectionKeys::new(options & 0x0f),
19 input_ok: options & 0b00010000 != 0,
20 input_cancel: options & 0b00100000 != 0,
21 input_subkey: options & 0b01000000 != 0,
22 wait_for_input: options & 0b10000000 != 0,
23 }
24 }
25
26 pub fn direction_keys(&self) -> &DirectionKeys {
27 &self.direction_keys
28 }
29
30 pub fn direction_keys_mut(&mut self) -> &mut DirectionKeys {
31 &mut self.direction_keys
32 }
33
34 pub fn input_ok(&self) -> bool {
35 self.input_ok
36 }
37
38 pub fn input_ok_mut(&mut self) -> &mut bool {
39 &mut self.input_ok
40 }
41
42 pub fn input_cancel(&self) -> bool {
43 self.input_cancel
44 }
45
46 pub fn input_cancel_mut(&mut self) -> &mut bool {
47 &mut self.input_cancel
48 }
49
50 pub fn input_subkey(&self) -> bool {
51 self.input_subkey
52 }
53
54 pub fn input_subkey_mut(&mut self) -> &mut bool {
55 &mut self.input_subkey
56 }
57
58 pub fn wait_for_input(&self) -> bool {
59 self.wait_for_input
60 }
61
62 pub fn wait_for_input_mut(&mut self) -> &mut bool {
63 &mut self.wait_for_input
64 }
65}