wolfrpg_map_parser/command/input_key_command/input_key/
direction_keys.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
#[cfg(feature = "serde")]
use serde::{Serialize, Deserialize};

#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(PartialEq)]
pub enum DirectionKeys {
    No          = 0x00,
    Dir4        = 0x01,
    Dir8        = 0x02,
    Up          = 0x03,
    Down        = 0x04,
    Left        = 0x05,
    Right       = 0x06,
    UpDown      = 0x07,
    LeftRight   = 0x08,
    Unknown
}

impl DirectionKeys {
    pub const fn new(direction: u8) -> Self {
        match direction {
            0x00 => Self::No,
            0x01 => Self::Dir4,
            0x02 => Self::Dir8,
            0x03 => Self::Up,
            0x04 => Self::Down,
            0x05 => Self::Left,
            0x06 => Self::Right,
            0x07 => Self::UpDown,
            0x08 => Self::LeftRight,
            _ => Self::Unknown,
        }
    }
}