From de2246e2fd4db5bed21bb73cb08be8d2f95dfd0c Mon Sep 17 00:00:00 2001 From: BigBahss Date: Sun, 23 Aug 2020 09:25:03 -0400 Subject: [PATCH] Simplify some straight paths logic --- include/ui/mappixmapitem.h | 1 - src/ui/mappixmapitem.cpp | 18 ++++++------------ 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/include/ui/mappixmapitem.h b/include/ui/mappixmapitem.h index b54de69d..554e6f77 100644 --- a/include/ui/mappixmapitem.h +++ b/include/ui/mappixmapitem.h @@ -36,7 +36,6 @@ public: bool right_click; int paint_tile_initial_x; int paint_tile_initial_y; - bool straightPathMode; bool prevStraightPathState; int straight_path_initial_x; int straight_path_initial_y; diff --git a/src/ui/mappixmapitem.cpp b/src/ui/mappixmapitem.cpp index ae0caca0..b45cddac 100644 --- a/src/ui/mappixmapitem.cpp +++ b/src/ui/mappixmapitem.cpp @@ -17,16 +17,12 @@ void MapPixmapItem::paint(QGraphicsSceneMouseEvent *event) { // Set straight paths on/off and snap to the dominant axis when on bool straightPathsEnabled = event->modifiers() & Qt::ControlModifier; if (this->settings->straightPathsEnabled || straightPathsEnabled) { - this->straightPathMode = true; - } else { - this->straightPathMode = false; - this->prevStraightPathState = false; - this->lockedAxis = MapPixmapItem::Axis::None; - } - if (this->straightPathMode) { this->lockNondominantAxis(event); x = this->adjustCoord(x, MapPixmapItem::Axis::X); y = this->adjustCoord(y, MapPixmapItem::Axis::Y); + } else { + this->prevStraightPathState = false; + this->lockedAxis = MapPixmapItem::Axis::None; } // Paint onto the map. @@ -61,14 +57,12 @@ void MapPixmapItem::shift(QGraphicsSceneMouseEvent *event) { // Set straight paths on/off and snap to the dominant axis when on bool straightPathsEnabled = event->modifiers() & Qt::ControlModifier; if (this->settings->straightPathsEnabled || straightPathsEnabled) { - this->straightPathMode = true; - } else { - this->straightPathMode = false; - } - if (this->straightPathMode) { this->lockNondominantAxis(event); x = this->adjustCoord(x, MapPixmapItem::Axis::X); y = this->adjustCoord(y, MapPixmapItem::Axis::Y); + } else { + this->prevStraightPathState = false; + this->lockedAxis = MapPixmapItem::Axis::None; } if (event->type() == QEvent::GraphicsSceneMousePress) {