From 53d376eaeef991850d35318b147f75c8f103319d Mon Sep 17 00:00:00 2001 From: Arne Dußin Date: Sun, 27 Dec 2020 21:54:31 +0100 Subject: Change to polygongraph instead of polygon in roomtool The polygon room tool used a convoluted process for determining what the user actually wants to draw. I have changed to the polygon graph instead, which makes the checks easier and restricts the user a bit less. In the process however I found a serious problem with my handling float, so everything needed to change to margin compares (which I of course should have done in the beginning. Guys, take the warning seriously and don't ignore it for ten years like I did. It will come back to haunt you.. apparently) instead of direct equality. --- src/gui/dimension_indicator.rs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'src/gui/dimension_indicator.rs') diff --git a/src/gui/dimension_indicator.rs b/src/gui/dimension_indicator.rs index e8848fe..57f5bcc 100644 --- a/src/gui/dimension_indicator.rs +++ b/src/gui/dimension_indicator.rs @@ -41,22 +41,28 @@ impl Default for State { } } +impl Default for DimensionIndicator { + fn default() -> Self { + Self { + state: State::default(), + bounds: Rect::new(0., 0., 0., 0.), + } + } +} + impl DimensionIndicator { /// Create a new dimension indicator. While it is possible to have multiple instances, this is /// not generally recommended, since they will need to be managed carefully or otherwise steal /// keystrokes from each other. pub fn new() -> Self { - Self { - state: State::default(), - bounds: Rect::new(0., 0., 0., 0.), - } + Self::default() } /// Update whatever is selected on the map according to the dimension indicator rules and rulers. pub fn update(&mut self, map: &mut Map, rl: &mut RaylibHandle) { - match &self.state { - &State::Watching => self.update_watching(map, rl), - &State::Ruling { .. } => self.update_ruling(map, rl), + match self.state { + State::Watching => self.update_watching(map, rl), + State::Ruling { .. } => self.update_ruling(map, rl), }; } -- cgit v1.2.3-70-g09d2