diff options
Diffstat (limited to 'src/tool')
| -rw-r--r-- | src/tool/icon_tool.rs | 8 | ||||
| -rw-r--r-- | src/tool/room_tool.rs | 6 | ||||
| -rw-r--r-- | src/tool/wall_tool.rs | 6 |
3 files changed, 11 insertions, 9 deletions
diff --git a/src/tool/icon_tool.rs b/src/tool/icon_tool.rs index 702c30e..bd16de8 100644 --- a/src/tool/icon_tool.rs +++ b/src/tool/icon_tool.rs @@ -1,6 +1,6 @@ use crate::button::Button; use crate::config::{IconToolKeybindings, ToolKeybindings}; -use crate::grid::snap_to_grid; +use crate::grid::{snap_to_grid, SNAP_SIZE}; use crate::map_data::MapData; use crate::math::Vec2; use crate::tool::Tool; @@ -125,8 +125,10 @@ impl Tool for IconTool { fn active_update(&mut self, map: &mut MapData, rl: &RaylibHandle, transform: &Transform) { // Update the position of the icon that should be drawn to the current mouse position. - let snapped_mouse_pos_m = - snap_to_grid(transform.point_px_to_m(rl.get_mouse_position().into()), 0.5); + let snapped_mouse_pos_m = snap_to_grid( + transform.point_px_to_m(rl.get_mouse_position().into()), + SNAP_SIZE, + ); self.current_icon.position = snapped_mouse_pos_m; // Unwrap the current icon, since it is now definitely set, as we are in the active update. diff --git a/src/tool/room_tool.rs b/src/tool/room_tool.rs index bb719e0..0ac74b5 100644 --- a/src/tool/room_tool.rs +++ b/src/tool/room_tool.rs @@ -2,7 +2,7 @@ use super::Tool; use crate::button::Button; use crate::config::{RoomToolKeybindings, ToolKeybindings}; use crate::dimension_indicator::DimensionIndicator; -use crate::grid::snap_to_grid; +use crate::grid::{snap_to_grid, SNAP_SIZE}; use crate::map_data::MapData; use crate::math::{Rect, Vec2}; use crate::transform::Transform; @@ -34,7 +34,7 @@ impl Tool for RoomTool { let mouse_pos_m = transform.point_px_to_m(rl.get_mouse_position().into()); // Update the currently drawn rectangle, if it exists, and also its dimension indicator. if let Some((ref pos1, ref mut pos2)) = &mut self.unfinished_rect { - *pos2 = snap_to_grid(mouse_pos_m, 0.5); + *pos2 = snap_to_grid(mouse_pos_m, SNAP_SIZE); self.dimension_indicator.update_dimensions(&[*pos1, *pos2]); } @@ -44,7 +44,7 @@ impl Tool for RoomTool { let (pos1, pos2) = self.unfinished_rect.take().unwrap(); map_data.rooms_mut().push(Rect::bounding_rect(pos1, pos2)); } else if self.keybindings.start_draw.is_pressed(rl) { - let snapped_mouse_pos = snap_to_grid(mouse_pos_m, 0.5); + let snapped_mouse_pos = snap_to_grid(mouse_pos_m, SNAP_SIZE); self.unfinished_rect = Some((snapped_mouse_pos, snapped_mouse_pos)) } diff --git a/src/tool/wall_tool.rs b/src/tool/wall_tool.rs index e815484..157f626 100644 --- a/src/tool/wall_tool.rs +++ b/src/tool/wall_tool.rs @@ -1,7 +1,7 @@ use super::Tool; use crate::button::Button; use crate::config::{ToolKeybindings, WallToolKeybindings}; -use crate::grid::snap_to_grid; +use crate::grid::{snap_to_grid, SNAP_SIZE}; use crate::map_data::MapData; use crate::math::Vec2; use crate::transform::Transform; @@ -27,7 +27,7 @@ impl Tool for WallTool { fn active_update(&mut self, map_data: &mut MapData, rl: &RaylibHandle, transform: &Transform) { let mouse_pos_m = transform.point_px_to_m(rl.get_mouse_position().into()); if let Some((_, ref mut pos2)) = &mut self.unfinished_wall { - *pos2 = snap_to_grid(mouse_pos_m, 0.5); + *pos2 = snap_to_grid(mouse_pos_m, SNAP_SIZE); } if self.keybindings.finish_segment.is_pressed(rl) && self.unfinished_wall.is_some() { @@ -35,7 +35,7 @@ impl Tool for WallTool { map_data.walls_mut().push((pos1, pos2)); self.unfinished_wall = Some((pos2, pos2)); } else if self.keybindings.start_wall.is_pressed(rl) { - let snapped_mouse_pos = snap_to_grid(mouse_pos_m, 0.5); + let snapped_mouse_pos = snap_to_grid(mouse_pos_m, SNAP_SIZE); self.unfinished_wall = Some((snapped_mouse_pos, snapped_mouse_pos)) } |
