From 0b2a6940ad9e60a4485445e86db7782a2fc36665 Mon Sep 17 00:00:00 2001 From: ZeWaka Date: Sat, 23 Dec 2023 17:44:26 -0800 Subject: [PATCH 1/3] dir stuff --- Cargo.toml | 5 +++-- src/dirs.rs | 37 +++++++++++++++++++++++++++++++++++++ src/lib.rs | 1 + 3 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 src/dirs.rs diff --git a/Cargo.toml b/Cargo.toml index 81c737c..a481fb8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,8 @@ exclude = ["src/tests.rs", "tests/*"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -thiserror = "1.0" -image = { version = "0.24.7", default-features = false, features = ["png"] } +bitflags = "2.4.1" deflate = "1.0" +image = { version = "0.24.7", default-features = false, features = ["png"] } inflate = "0.4.5" +thiserror = "1.0" diff --git a/src/dirs.rs b/src/dirs.rs new file mode 100644 index 0000000..0809344 --- /dev/null +++ b/src/dirs.rs @@ -0,0 +1,37 @@ +use bitflags::bitflags; + +bitflags! { + pub struct Dirs: u8 { + const NORTH = 1 << 1; + const SOUTH = 1 << 2; + const EAST = 1 << 3; + const WEST = 1 << 4; + const SOUTHEAST = Self::SOUTH.bits() | Self::EAST.bits(); + const SOUTHWEST = Self::SOUTH.bits() | Self::WEST.bits(); + const NORTHEAST = Self::NORTH.bits() | Self::EAST.bits(); + const NORTHWEST = Self::NORTH.bits() | Self::WEST.bits(); + } +} + +/// A list of every cardinal direction. +pub const CARDINAL_DIRS: [Dirs; 4] = [Dirs::NORTH, Dirs::SOUTH, Dirs::EAST, Dirs::WEST]; + +/// A list of every ordinal direction. +pub const ORDINAL_DIRS: [Dirs; 4] = [ + Dirs::NORTHEAST, + Dirs::NORTHWEST, + Dirs::SOUTHEAST, + Dirs::SOUTHWEST, +]; + +/// A list of every direction, cardinals and ordinals. +pub const ALL_DIRS: [Dirs; 8] = [ + Dirs::NORTH, + Dirs::SOUTH, + Dirs::EAST, + Dirs::WEST, + Dirs::NORTHEAST, + Dirs::NORTHWEST, + Dirs::SOUTHEAST, + Dirs::SOUTHWEST, +]; diff --git a/src/lib.rs b/src/lib.rs index 22c4842..68f5ed0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,6 @@ pub mod chunk; pub(crate) mod crc; +pub mod dirs; pub mod error; pub mod icon; pub mod iend; From d87b6a0d1e069321a0686839e652464b0722677b Mon Sep 17 00:00:00 2001 From: ZeWaka Date: Sat, 23 Dec 2023 17:47:13 -0800 Subject: [PATCH 2/3] fixx --- src/dirs.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/dirs.rs b/src/dirs.rs index 0809344..72f2c50 100644 --- a/src/dirs.rs +++ b/src/dirs.rs @@ -2,10 +2,10 @@ use bitflags::bitflags; bitflags! { pub struct Dirs: u8 { - const NORTH = 1 << 1; - const SOUTH = 1 << 2; - const EAST = 1 << 3; - const WEST = 1 << 4; + const NORTH = 1 << 0; + const SOUTH = 1 << 1; + const EAST = 1 << 2; + const WEST = 1 << 3; const SOUTHEAST = Self::SOUTH.bits() | Self::EAST.bits(); const SOUTHWEST = Self::SOUTH.bits() | Self::WEST.bits(); const NORTHEAST = Self::NORTH.bits() | Self::EAST.bits(); From 0d650be9322264f411102dacb466ad9dfaea3915 Mon Sep 17 00:00:00 2001 From: ZeWaka Date: Sat, 23 Dec 2023 17:48:20 -0800 Subject: [PATCH 3/3] comment --- src/dirs.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/dirs.rs b/src/dirs.rs index 72f2c50..9146b9d 100644 --- a/src/dirs.rs +++ b/src/dirs.rs @@ -1,6 +1,7 @@ use bitflags::bitflags; bitflags! { + /// The possible values for a direction in DM. pub struct Dirs: u8 { const NORTH = 1 << 0; const SOUTH = 1 << 1;