aboutsummaryrefslogtreecommitdiff
path: root/src/tool
diff options
context:
space:
mode:
Diffstat (limited to 'src/tool')
-rw-r--r--src/tool/room_tool.rs11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/tool/room_tool.rs b/src/tool/room_tool.rs
index 1bfb225..52748fc 100644
--- a/src/tool/room_tool.rs
+++ b/src/tool/room_tool.rs
@@ -1,6 +1,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::map_data::MapData;
use crate::math::{Rect, Vec2};
@@ -14,6 +15,7 @@ pub struct RoomTool {
/// The rectangle that is currently being drawn by the user. Once it is finished, it will be
/// pushed into the room_rects.
unfinished_rect: Option<(Vec2<f32>, Vec2<f32>)>,
+ dimension_indicator: DimensionIndicator,
}
impl RoomTool {
@@ -22,6 +24,7 @@ impl RoomTool {
Self {
keybindings,
unfinished_rect: None,
+ dimension_indicator: DimensionIndicator::new(),
}
}
}
@@ -29,9 +32,11 @@ impl RoomTool {
impl Tool for RoomTool {
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
- if let Some((_, ref mut pos2)) = &mut self.unfinished_rect {
+ // 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);
+
+ self.dimension_indicator.update_dimensions(&[*pos1, *pos2]);
}
// Start or finish drawing the currently unfinished rectangle
@@ -73,6 +78,8 @@ impl Tool for RoomTool {
a: 255,
},
);
+
+ self.dimension_indicator.draw(rld, transform);
}
}