wolfrpg_map_parser/command/input_key_command/automatic_input/
mouse_options.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
#[cfg(feature = "serde")]
use serde::Serialize;
use crate::command::input_key_command::automatic_input::mouse_type::MouseType;

#[cfg_attr(feature = "serde", derive(Serialize))]
pub struct MouseOptions {
    left_click: bool,
    right_click: bool,
    middle_click: bool,
    mouse_type: MouseType
}

impl MouseOptions {
    pub fn new(options: u8) -> Self {
        Self {
            left_click:     options & 0b00000001 != 0,
            right_click:    options & 0b00000010 != 0,
            middle_click:   options & 0b00000100 != 0,
            mouse_type: MouseType::new(options >> 3)
        }
    }

    pub fn left_click(&self) -> bool {
        self.left_click
    }

    pub fn left_click_mut(&mut self) -> &mut bool {
        &mut self.left_click
    }

    pub fn right_click(&self) -> bool {
        self.right_click
    }

    pub fn right_click_mut(&mut self) -> &mut bool {
        &mut self.right_click
    }

    pub fn middle_click(&self) -> bool {
        self.middle_click
    }

    pub fn middle_click_mut(&mut self) -> &mut bool {
        &mut self.middle_click
    }

    pub fn mouse_type(&self) -> &MouseType {
        &self.mouse_type
    }

    pub fn mouse_type_mut(&mut self) -> &mut MouseType {
        &mut self.mouse_type
    }
}