Simplify some straight paths logic

This commit is contained in:
BigBahss 2020-08-23 09:25:03 -04:00 committed by garak
parent 5f5087df05
commit de2246e2fd
2 changed files with 6 additions and 13 deletions

View file

@ -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;

View file

@ -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) {