Add straight paths for map shifting
This commit is contained in:
parent
a59e695907
commit
713ded1754
2 changed files with 25 additions and 0 deletions
|
@ -1081,6 +1081,12 @@ void Editor::mouseEvent_map(QGraphicsSceneMouseEvent *event, MapPixmapItem *item
|
||||||
item->pick(event);
|
item->pick(event);
|
||||||
}
|
}
|
||||||
} else if (map_edit_mode == "shift") {
|
} else if (map_edit_mode == "shift") {
|
||||||
|
this->setStraightPathCursorMode(event);
|
||||||
|
if (this->cursorMapTileRect->getStraightPathMode()) {
|
||||||
|
item->lockNondominantAxis(event);
|
||||||
|
x = item->adjustCoord(x, MapPixmapItem::Axis::X);
|
||||||
|
y = item->adjustCoord(y, MapPixmapItem::Axis::Y);
|
||||||
|
}
|
||||||
item->shift(event);
|
item->shift(event);
|
||||||
}
|
}
|
||||||
} else if (item->paintingMode == MapPixmapItem::PaintMode::EventObjects) {
|
} else if (item->paintingMode == MapPixmapItem::PaintMode::EventObjects) {
|
||||||
|
@ -1183,6 +1189,12 @@ void Editor::mouseEvent_collision(QGraphicsSceneMouseEvent *event, CollisionPixm
|
||||||
} else if (map_edit_mode == "pick") {
|
} else if (map_edit_mode == "pick") {
|
||||||
item->pick(event);
|
item->pick(event);
|
||||||
} else if (map_edit_mode == "shift") {
|
} else if (map_edit_mode == "shift") {
|
||||||
|
this->setStraightPathCursorMode(event);
|
||||||
|
if (this->cursorMapTileRect->getStraightPathMode()) {
|
||||||
|
item->lockNondominantAxis(event);
|
||||||
|
x = item->adjustCoord(x, MapPixmapItem::Axis::X);
|
||||||
|
y = item->adjustCoord(y, MapPixmapItem::Axis::Y);
|
||||||
|
}
|
||||||
item->shift(event);
|
item->shift(event);
|
||||||
}
|
}
|
||||||
this->playerViewRect->updateLocation(x, y);
|
this->playerViewRect->updateLocation(x, y);
|
||||||
|
|
|
@ -56,6 +56,19 @@ void MapPixmapItem::shift(QGraphicsSceneMouseEvent *event) {
|
||||||
int x = static_cast<int>(pos.x()) / 16;
|
int x = static_cast<int>(pos.x()) / 16;
|
||||||
int y = static_cast<int>(pos.y()) / 16;
|
int y = static_cast<int>(pos.y()) / 16;
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
|
|
||||||
if (event->type() == QEvent::GraphicsSceneMousePress) {
|
if (event->type() == QEvent::GraphicsSceneMousePress) {
|
||||||
selection_origin = QPoint(x, y);
|
selection_origin = QPoint(x, y);
|
||||||
selection.clear();
|
selection.clear();
|
||||||
|
|
Loading…
Reference in a new issue