From 12f7283b34b9504cafe9448ede110b1fc2a3ae41 Mon Sep 17 00:00:00 2001 From: HampusM Date: Tue, 1 Sep 2026 18:24:39 +0200 Subject: refactor(engine): replace MapVec with intmap crate --- engine/src/windowing/mouse.rs | 19 +++++++++++++++++++ engine/src/windowing/window.rs | 12 ++++++++++++ 2 files changed, 31 insertions(+) (limited to 'engine/src/windowing') diff --git a/engine/src/windowing/mouse.rs b/engine/src/windowing/mouse.rs index f6087f4..3a43e79 100644 --- a/engine/src/windowing/mouse.rs +++ b/engine/src/windowing/mouse.rs @@ -106,6 +106,25 @@ pub enum Button Other(u16), } +impl intmap::IntKey for Button +{ + type Int = u32; + + const PRIME: Self::Int = ::PRIME; + + fn into_int(self) -> Self::Int + { + match &self { + Self::Left => 0, + Self::Right => 1, + Self::Middle => 2, + Self::Back => 3, + Self::Forward => 4, + Self::Other(other) => 5 + *other as u32, + } + } +} + impl From for Button { fn from(mouse_button: winit::event::MouseButton) -> Self diff --git a/engine/src/windowing/window.rs b/engine/src/windowing/window.rs index 54c24ac..6d7a464 100644 --- a/engine/src/windowing/window.rs +++ b/engine/src/windowing/window.rs @@ -13,6 +13,18 @@ pub struct Id inner: winit::window::WindowId, } +impl intmap::IntKey for Id +{ + type Int = u64; + + const PRIME: Self::Int = ::PRIME; + + fn into_int(self) -> Self::Int + { + self.inner.into() + } +} + impl Id { pub(crate) fn from_inner(inner: winit::window::WindowId) -> Self -- cgit v1.2.3-18-g5258