diff options
Diffstat (limited to 'src/editor.rs')
| -rw-r--r-- | src/editor.rs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/editor.rs b/src/editor.rs index d541fb6..8e025dc 100644 --- a/src/editor.rs +++ b/src/editor.rs @@ -7,8 +7,8 @@ use crate::button::{Button, MouseButton}; use crate::config::Config; -use crate::grid::{snap_to_grid, SNAP_SIZE}; use crate::map::Map; +use crate::snapping::Snapper; use crate::tool::*; use crate::transform::Transform; use raylib::core::drawing::RaylibDrawHandle; @@ -106,7 +106,13 @@ impl Editor { /// Update the internal editor data where necessary and handle selecting different tools, aswell /// as updating the currently active tool. Should be called once every frame. - pub fn update(&mut self, rl: &mut RaylibHandle, transform: &Transform, mouse_blocked: bool) { + pub fn update( + &mut self, + rl: &mut RaylibHandle, + transform: &Transform, + snapper: &Snapper, + mouse_blocked: bool, + ) { // Handle keybindings for tool change for (&tool_type, (_, activation_key)) in self.tools.iter() { if activation_key.is_pressed(rl, false) { @@ -136,7 +142,7 @@ impl Editor { */ let mouse_pos_m = transform.point_px_to_m(&rl.get_mouse_position().into()); - let snapped_mouse_pos = snap_to_grid(mouse_pos_m, SNAP_SIZE); + let snapped_mouse_pos = snapper.snap(mouse_pos_m); // Update the currently active tool let active_tool = &mut self.tools.get_mut(&self.active).unwrap().0; |
