aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/dimension_indicator.rs4
-rw-r--r--src/tool/deletion_tool.rs4
-rw-r--r--src/tool/room_tool.rs6
-rw-r--r--src/tool/wall_tool.rs4
4 files changed, 18 insertions, 0 deletions
diff --git a/src/dimension_indicator.rs b/src/dimension_indicator.rs
index 0ea96d3..2eb3eee 100644
--- a/src/dimension_indicator.rs
+++ b/src/dimension_indicator.rs
@@ -24,6 +24,10 @@ impl DimensionIndicator {
this
}
+ pub fn clear_dimensions(&mut self) {
+ self.length_lines.clear();
+ }
+
/// Update the dimensions by analysing a given set of points and adjusting the internal
/// (measured) dimensions.
pub fn update_dimensions(&mut self, corner_points: &[Vec2<f32>]) {
diff --git a/src/tool/deletion_tool.rs b/src/tool/deletion_tool.rs
index 6f5ac24..bd80809 100644
--- a/src/tool/deletion_tool.rs
+++ b/src/tool/deletion_tool.rs
@@ -36,6 +36,10 @@ impl DeletionTool {
}
impl Tool for DeletionTool {
+ fn deactivate(&mut self) {
+ self.deletion_rect = None;
+ }
+
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.deletion_rect {
diff --git a/src/tool/room_tool.rs b/src/tool/room_tool.rs
index 0ac74b5..3416596 100644
--- a/src/tool/room_tool.rs
+++ b/src/tool/room_tool.rs
@@ -30,6 +30,11 @@ impl RoomTool {
}
impl Tool for RoomTool {
+ fn deactivate(&mut self) {
+ self.unfinished_rect = None;
+ self.dimension_indicator.clear_dimensions();
+ }
+
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());
// Update the currently drawn rectangle, if it exists, and also its dimension indicator.
@@ -42,6 +47,7 @@ impl Tool for RoomTool {
// Start or finish drawing the currently unfinished rectangle
if self.keybindings.finish_draw.is_pressed(rl) && self.unfinished_rect.is_some() {
let (pos1, pos2) = self.unfinished_rect.take().unwrap();
+ self.dimension_indicator.clear_dimensions();
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, SNAP_SIZE);
diff --git a/src/tool/wall_tool.rs b/src/tool/wall_tool.rs
index 157f626..85079b0 100644
--- a/src/tool/wall_tool.rs
+++ b/src/tool/wall_tool.rs
@@ -24,6 +24,10 @@ impl WallTool {
}
impl Tool for WallTool {
+ fn deactivate(&mut self) {
+ self.unfinished_wall = None;
+ }
+
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 {