Use Metatile::coordFromPixmapCoord() in all remaining cases

This commit is contained in:
BigBahss 2020-10-02 15:32:22 -04:00
parent e2dd4fb76b
commit fb5e35bd5f
5 changed files with 96 additions and 141 deletions

View file

@ -77,7 +77,7 @@ public:
void updateMetatileSelection(QGraphicsSceneMouseEvent *event);
void paintNormal(int x, int y, bool fromScriptCall = false);
void lockNondominantAxis(QGraphicsSceneMouseEvent *event);
int adjustCoord(int coord, MapPixmapItem::Axis axis);
QPoint adjustCoords(QPoint pos);
private:
void paintSmartPath(int x, int y, bool fromScriptCall = false);

View file

@ -6,6 +6,7 @@
#include "mapconnection.h"
#include "currentselectedmetatilespixmapitem.h"
#include "mapsceneeventfilter.h"
#include "metatile.h"
#include "montabwidget.h"
#include "editcommands.h"
#include <QCheckBox>
@ -1002,17 +1003,15 @@ bool Editor::setMap(QString map_name) {
}
void Editor::onMapStartPaint(QGraphicsSceneMouseEvent *event, MapPixmapItem *item) {
if (!(item->paintingMode == MapPixmapItem::PaintMode::Metatiles)) {
if (item->paintingMode != MapPixmapItem::PaintMode::Metatiles) {
return;
}
QPointF pos = event->pos();
int x = static_cast<int>(pos.x()) / 16;
int y = static_cast<int>(pos.y()) / 16;
QPoint pos = Metatile::coordFromPixmapCoord(event->pos());
if (event->buttons() & Qt::RightButton && (map_edit_mode == "paint" || map_edit_mode == "fill")) {
this->cursorMapTileRect->initRightClickSelectionAnchor(x, y);
this->cursorMapTileRect->initRightClickSelectionAnchor(pos.x(), pos.y());
} else {
this->cursorMapTileRect->initAnchor(x, y);
this->cursorMapTileRect->initAnchor(pos.x(), pos.y());
}
}
@ -1056,9 +1055,7 @@ void Editor::mouseEvent_map(QGraphicsSceneMouseEvent *event, MapPixmapItem *item
return;
}
QPointF pos = event->pos();
int x = static_cast<int>(pos.x()) / 16;
int y = static_cast<int>(pos.y()) / 16;
QPoint pos = Metatile::coordFromPixmapCoord(event->pos());
if (item->paintingMode == MapPixmapItem::PaintMode::Metatiles) {
if (map_edit_mode == "paint") {
@ -1075,8 +1072,7 @@ void Editor::mouseEvent_map(QGraphicsSceneMouseEvent *event, MapPixmapItem *item
this->setStraightPathCursorMode(event);
if (this->cursorMapTileRect->getStraightPathMode()) {
item->lockNondominantAxis(event);
x = item->adjustCoord(x, MapPixmapItem::Axis::X);
y = item->adjustCoord(y, MapPixmapItem::Axis::Y);
pos = item->adjustCoords(pos);
}
item->paint(event);
}
@ -1100,8 +1096,7 @@ void Editor::mouseEvent_map(QGraphicsSceneMouseEvent *event, MapPixmapItem *item
this->setStraightPathCursorMode(event);
if (this->cursorMapTileRect->getStraightPathMode()) {
item->lockNondominantAxis(event);
x = item->adjustCoord(x, MapPixmapItem::Axis::X);
y = item->adjustCoord(y, MapPixmapItem::Axis::Y);
pos = item->adjustCoords(pos);
}
item->shift(event);
}
@ -1125,7 +1120,7 @@ void Editor::mouseEvent_map(QGraphicsSceneMouseEvent *event, MapPixmapItem *item
if (eventType != EventType::HealLocation) {
DraggablePixmapItem * newEvent = addNewEvent(eventType);
if (newEvent) {
newEvent->move(x, y);
newEvent->move(pos.x(), pos.y());
emit objectsChanged();
selectMapEvent(newEvent, false);
}
@ -1151,18 +1146,18 @@ void Editor::mouseEvent_map(QGraphicsSceneMouseEvent *event, MapPixmapItem *item
actionId++;
} else {
if (event->type() == QEvent::GraphicsSceneMousePress) {
selection_origin = QPoint(x, y);
selection_origin = QPoint(pos.x(), pos.y());
} else if (event->type() == QEvent::GraphicsSceneMouseMove) {
if (x != selection_origin.x() || y != selection_origin.y()) {
int xDelta = x - selection_origin.x();
int yDelta = y - selection_origin.y();
if (pos.x() != selection_origin.x() || pos.y() != selection_origin.y()) {
int xDelta = pos.x() - selection_origin.x();
int yDelta = pos.y() - selection_origin.y();
QList<Event *> selectedEvents;
for (DraggablePixmapItem *item : getObjects()) {
selectedEvents.append(item->event);
}
selection_origin = QPoint(x, y);
selection_origin = QPoint(pos.x(), pos.y());
map->editHistory.push(new EventShift(selectedEvents, xDelta, yDelta, actionId));
}
@ -1170,8 +1165,8 @@ void Editor::mouseEvent_map(QGraphicsSceneMouseEvent *event, MapPixmapItem *item
}
}
}
this->playerViewRect->updateLocation(x, y);
this->cursorMapTileRect->updateLocation(x, y);
this->playerViewRect->updateLocation(pos.x(), pos.y());
this->cursorMapTileRect->updateLocation(pos.x(), pos.y());
}
void Editor::mouseEvent_collision(QGraphicsSceneMouseEvent *event, CollisionPixmapItem *item) {
@ -1179,9 +1174,7 @@ void Editor::mouseEvent_collision(QGraphicsSceneMouseEvent *event, CollisionPixm
return;
}
QPointF pos = event->pos();
int x = static_cast<int>(pos.x()) / 16;
int y = static_cast<int>(pos.y()) / 16;
QPoint pos = Metatile::coordFromPixmapCoord(event->pos());
if (map_edit_mode == "paint") {
if (event->buttons() & Qt::RightButton) {
@ -1196,8 +1189,7 @@ void Editor::mouseEvent_collision(QGraphicsSceneMouseEvent *event, CollisionPixm
this->setStraightPathCursorMode(event);
if (this->cursorMapTileRect->getStraightPathMode()) {
item->lockNondominantAxis(event);
x = item->adjustCoord(x, MapPixmapItem::Axis::X);
y = item->adjustCoord(y, MapPixmapItem::Axis::Y);
pos = item->adjustCoords(pos);
}
item->paint(event);
}
@ -1217,13 +1209,12 @@ void Editor::mouseEvent_collision(QGraphicsSceneMouseEvent *event, CollisionPixm
this->setStraightPathCursorMode(event);
if (this->cursorMapTileRect->getStraightPathMode()) {
item->lockNondominantAxis(event);
x = item->adjustCoord(x, MapPixmapItem::Axis::X);
y = item->adjustCoord(y, MapPixmapItem::Axis::Y);
pos = item->adjustCoords(pos);
}
item->shift(event);
}
this->playerViewRect->updateLocation(x, y);
this->cursorMapTileRect->updateLocation(x, y);
this->playerViewRect->updateLocation(pos.x(), pos.y());
this->cursorMapTileRect->updateLocation(pos.x(), pos.y());
}
bool Editor::displayMap() {

View file

@ -1,22 +1,21 @@
#include "bordermetatilespixmapitem.h"
#include "imageproviders.h"
#include "metatile.h"
#include "editcommands.h"
#include <QPainter>
void BorderMetatilesPixmapItem::mousePressEvent(QGraphicsSceneMouseEvent *event) {
QList<uint16_t> *selectedMetatiles = this->metatileSelector->getSelectedMetatiles();
QPoint selectionDimensions = this->metatileSelector->getSelectionDimensions();
QPointF pos = event->pos();
int x = static_cast<int>(pos.x()) / 16;
int y = static_cast<int>(pos.y()) / 16;
QPoint pos = Metatile::coordFromPixmapCoord(event->pos());
int width = map->getBorderWidth();
int height = map->getBorderHeight();
Blockdata *oldBorder = map->layout->border->copy();
for (int i = 0; i < selectionDimensions.x() && (i + x) < width; i++) {
for (int j = 0; j < selectionDimensions.y() && (j + y) < height; j++) {
int blockIndex = (j + y) * width + (i + x);
for (int i = 0; i < selectionDimensions.x() && (i + pos.x()) < width; i++) {
for (int j = 0; j < selectionDimensions.y() && (j + pos.y()) < height; j++) {
int blockIndex = (j + pos.y()) * width + (i + pos.x());
uint16_t tile = selectedMetatiles->at(j * selectionDimensions.x() + i);
(*map->layout->border->blocks)[blockIndex].tile = tile;
}

View file

@ -1,5 +1,6 @@
#include "collisionpixmapitem.h"
#include "editcommands.h"
#include "metatile.h"
void CollisionPixmapItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) {
int x = static_cast<int>(event->pos().x()) / 16;
@ -18,11 +19,9 @@ void CollisionPixmapItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *) {
}
void CollisionPixmapItem::mousePressEvent(QGraphicsSceneMouseEvent *event) {
QPointF pos = event->pos();
int x = static_cast<int>(pos.x()) / 16;
int y = static_cast<int>(pos.y()) / 16;
this->paint_tile_initial_x = this->straight_path_initial_x = x;
this->paint_tile_initial_y = this->straight_path_initial_y = y;
QPoint pos = Metatile::coordFromPixmapCoord(event->pos());
this->paint_tile_initial_x = this->straight_path_initial_x = pos.x();
this->paint_tile_initial_y = this->straight_path_initial_y = pos.y();
emit mouseEvent(event, this);
}
@ -48,25 +47,22 @@ void CollisionPixmapItem::paint(QGraphicsSceneMouseEvent *event) {
} else if (map) {
Blockdata *oldCollision = map->layout->blockdata->copy();
QPointF pos = event->pos();
int x = static_cast<int>(pos.x()) / 16;
int y = static_cast<int>(pos.y()) / 16;
QPoint pos = Metatile::coordFromPixmapCoord(event->pos());
// Set straight paths on/off and snap to the dominant axis when on
if (event->modifiers() & Qt::ControlModifier) {
this->lockNondominantAxis(event);
x = this->adjustCoord(x, MapPixmapItem::Axis::X);
y = this->adjustCoord(y, MapPixmapItem::Axis::Y);
pos = this->adjustCoords(pos);
} else {
this->prevStraightPathState = false;
this->lockedAxis = MapPixmapItem::Axis::None;
}
Block *block = map->getBlock(x, y);
Block *block = map->getBlock(pos.x(), pos.y());
if (block) {
block->collision = this->movementPermissionsSelector->getSelectedCollision();
block->elevation = this->movementPermissionsSelector->getSelectedElevation();
map->setBlock(x, y, *block, true);
map->setBlock(pos.x(), pos.y(), *block, true);
}
Blockdata *newCollision = map->layout->blockdata->copy();
@ -85,12 +81,10 @@ void CollisionPixmapItem::floodFill(QGraphicsSceneMouseEvent *event) {
} else if (map) {
Blockdata *oldCollision = map->layout->blockdata->copy();
QPointF pos = event->pos();
int x = static_cast<int>(pos.x()) / 16;
int y = static_cast<int>(pos.y()) / 16;
QPoint pos = Metatile::coordFromPixmapCoord(event->pos());
uint16_t collision = this->movementPermissionsSelector->getSelectedCollision();
uint16_t elevation = this->movementPermissionsSelector->getSelectedElevation();
map->floodFillCollisionElevation(x, y, collision, elevation);
map->floodFillCollisionElevation(pos.x(), pos.y(), collision, elevation);
Blockdata *newCollision = map->layout->blockdata->copy();
if (newCollision->equals(oldCollision)) {
@ -107,12 +101,10 @@ void CollisionPixmapItem::magicFill(QGraphicsSceneMouseEvent *event) {
this->actionId_++;
} else if (map) {
Blockdata *oldCollision = map->layout->blockdata->copy();
QPointF pos = event->pos();
int x = static_cast<int>(pos.x()) / 16;
int y = static_cast<int>(pos.y()) / 16;
QPoint pos = Metatile::coordFromPixmapCoord(event->pos());
uint16_t collision = this->movementPermissionsSelector->getSelectedCollision();
uint16_t elevation = this->movementPermissionsSelector->getSelectedElevation();
map->magicFillCollisionElevation(x, y, collision, elevation);
map->magicFillCollisionElevation(pos.x(), pos.y(), collision, elevation);
Blockdata *newCollision = map->layout->blockdata->copy();
if (newCollision->equals(oldCollision)) {
@ -125,26 +117,22 @@ void CollisionPixmapItem::magicFill(QGraphicsSceneMouseEvent *event) {
}
void CollisionPixmapItem::pick(QGraphicsSceneMouseEvent *event) {
QPointF pos = event->pos();
int x = static_cast<int>(pos.x()) / 16;
int y = static_cast<int>(pos.y()) / 16;
Block *block = map->getBlock(x, y);
QPoint pos = Metatile::coordFromPixmapCoord(event->pos());
Block *block = map->getBlock(pos.x(), pos.y());
if (block) {
this->movementPermissionsSelector->select(block->collision, block->elevation);
}
}
void CollisionPixmapItem::updateMovementPermissionSelection(QGraphicsSceneMouseEvent *event) {
QPointF pos = event->pos();
int x = static_cast<int>(pos.x()) / 16;
int y = static_cast<int>(pos.y()) / 16;
QPoint pos = Metatile::coordFromPixmapCoord(event->pos());
// Snap point to within map bounds.
if (x < 0) x = 0;
if (x >= map->getWidth()) x = map->getWidth() - 1;
if (y < 0) y = 0;
if (y >= map->getHeight()) y = map->getHeight() - 1;
if (pos.x() < 0) pos.setX(0);
if (pos.x() >= map->getWidth()) pos.setX(map->getWidth() - 1);
if (pos.y() < 0) pos.setY(0);
if (pos.y() >= map->getHeight()) pos.setY(map->getHeight() - 1);
Block *block = map->getBlock(x, y);
Block *block = map->getBlock(pos.x(), pos.y());
this->movementPermissionsSelector->select(block->collision, block->elevation);
}

View file

@ -1,4 +1,5 @@
#include "mappixmapitem.h"
#include "metatile.h"
#include "log.h"
#include "editcommands.h"
@ -10,15 +11,12 @@ void MapPixmapItem::paint(QGraphicsSceneMouseEvent *event) {
if (event->type() == QEvent::GraphicsSceneMouseRelease) {
actionId_++;
} else {
QPointF pos = event->pos();
int x = static_cast<int>(pos.x()) / 16;
int y = static_cast<int>(pos.y()) / 16;
QPoint pos = Metatile::coordFromPixmapCoord(event->pos());
// Set straight paths on/off and snap to the dominant axis when on
if (event->modifiers() & Qt::ControlModifier) {
this->lockNondominantAxis(event);
x = this->adjustCoord(x, MapPixmapItem::Axis::X);
y = this->adjustCoord(y, MapPixmapItem::Axis::Y);
pos = this->adjustCoords(pos);
} else {
this->prevStraightPathState = false;
this->lockedAxis = MapPixmapItem::Axis::None;
@ -29,15 +27,15 @@ void MapPixmapItem::paint(QGraphicsSceneMouseEvent *event) {
QPoint selectionDimensions = this->metatileSelector->getSelectionDimensions();
if (settings->smartPathsEnabled) {
if (!shiftPressed && selectionDimensions.x() == 3 && selectionDimensions.y() == 3) {
paintSmartPath(x, y);
paintSmartPath(pos.x(), pos.y());
} else {
paintNormal(x, y);
paintNormal(pos.x(), pos.y());
}
} else {
if (shiftPressed && selectionDimensions.x() == 3 && selectionDimensions.y() == 3) {
paintSmartPath(x, y);
paintSmartPath(pos.x(), pos.y());
} else {
paintNormal(x, y);
paintNormal(pos.x(), pos.y());
}
}
}
@ -49,29 +47,26 @@ void MapPixmapItem::shift(QGraphicsSceneMouseEvent *event) {
if (event->type() == QEvent::GraphicsSceneMouseRelease) {
actionId_++;
} else {
QPointF pos = event->pos();
int x = static_cast<int>(pos.x()) / 16;
int y = static_cast<int>(pos.y()) / 16;
QPoint pos = Metatile::coordFromPixmapCoord(event->pos());
// Set straight paths on/off and snap to the dominant axis when on
if (event->modifiers() & Qt::ControlModifier) {
this->lockNondominantAxis(event);
x = this->adjustCoord(x, MapPixmapItem::Axis::X);
y = this->adjustCoord(y, MapPixmapItem::Axis::Y);
pos = this->adjustCoords(pos);
} else {
this->prevStraightPathState = false;
this->lockedAxis = MapPixmapItem::Axis::None;
}
if (event->type() == QEvent::GraphicsSceneMousePress) {
selection_origin = QPoint(x, y);
selection_origin = QPoint(pos.x(), pos.y());
selection.clear();
} else if (event->type() == QEvent::GraphicsSceneMouseMove) {
if (x != selection_origin.x() || y != selection_origin.y()) {
int xDelta = x - selection_origin.x();
int yDelta = y - selection_origin.y();
if (pos.x() != selection_origin.x() || pos.y() != selection_origin.y()) {
int xDelta = pos.x() - selection_origin.x();
int yDelta = pos.y() - selection_origin.y();
this->shift(xDelta, yDelta);
selection_origin = QPoint(x, y);
selection_origin = QPoint(pos.x(), pos.y());
selection.clear();
draw();
}
@ -286,18 +281,16 @@ void MapPixmapItem::lockNondominantAxis(QGraphicsSceneMouseEvent *event) {
if (this->lockedAxis != MapPixmapItem::Axis::None || event->type() == QEvent::GraphicsSceneMouseRelease)
return;
QPointF pos = event->pos();
int x = static_cast<int>(pos.x()) / 16;
int y = static_cast<int>(pos.y()) / 16;
QPoint pos = Metatile::coordFromPixmapCoord(event->pos());
if (!this->prevStraightPathState) {
this->prevStraightPathState = true;
this->straight_path_initial_x = x;
this->straight_path_initial_y = y;
this->straight_path_initial_x = pos.x();
this->straight_path_initial_y = pos.y();
}
// Only lock an axis when the current position != initial
int xDiff = x - this->straight_path_initial_x;
int yDiff = y - this->straight_path_initial_y;
int xDiff = pos.x() - this->straight_path_initial_x;
int yDiff = pos.y() - this->straight_path_initial_y;
if (xDiff || yDiff) {
if (abs(xDiff) < abs(yDiff)) {
this->lockedAxis = MapPixmapItem::Axis::X;
@ -308,38 +301,36 @@ void MapPixmapItem::lockNondominantAxis(QGraphicsSceneMouseEvent *event) {
}
// Adjust the cooresponding coordinate when it is locked
int MapPixmapItem::adjustCoord(int coord, MapPixmapItem::Axis axis) {
if (axis == MapPixmapItem::Axis::X && this->lockedAxis == MapPixmapItem::Axis::X) {
coord = this->straight_path_initial_x;
} else if (axis == MapPixmapItem::Axis::Y && this->lockedAxis == MapPixmapItem::Axis::Y) {
coord = this->straight_path_initial_y;
QPoint MapPixmapItem::adjustCoords(QPoint pos) {
if (this->lockedAxis == MapPixmapItem::Axis::X) {
pos.setX(this->straight_path_initial_x);
} else if (this->lockedAxis == MapPixmapItem::Axis::Y) {
pos.setY(this->straight_path_initial_y);
}
return coord;
return pos;
}
void MapPixmapItem::updateMetatileSelection(QGraphicsSceneMouseEvent *event) {
QPointF pos = event->pos();
int x = static_cast<int>(pos.x()) / 16;
int y = static_cast<int>(pos.y()) / 16;
QPoint pos = Metatile::coordFromPixmapCoord(event->pos());
// Snap point to within map bounds.
if (x < 0) x = 0;
if (x >= map->getWidth()) x = map->getWidth() - 1;
if (y < 0) y = 0;
if (y >= map->getHeight()) y = map->getHeight() - 1;
if (pos.x() < 0) pos.setX(0);
if (pos.x() >= map->getWidth()) pos.setX(map->getWidth() - 1);
if (pos.y() < 0) pos.setY(0);
if (pos.y() >= map->getHeight()) pos.setY(map->getHeight() - 1);
// Update/apply copied metatiles.
if (event->type() == QEvent::GraphicsSceneMousePress) {
selection_origin = QPoint(x, y);
selection_origin = QPoint(pos.x(), pos.y());
selection.clear();
selection.append(QPoint(x, y));
Block *block = map->getBlock(x, y);
selection.append(QPoint(pos.x(), pos.y()));
Block *block = map->getBlock(pos.x(), pos.y());
this->metatileSelector->selectFromMap(block->tile, block->collision, block->elevation);
} else if (event->type() == QEvent::GraphicsSceneMouseMove) {
int x1 = selection_origin.x();
int y1 = selection_origin.y();
int x2 = x;
int y2 = y;
int x2 = pos.x();
int y2 = pos.y();
if (x1 > x2) SWAP(x1, x2);
if (y1 > y2) SWAP(y1, y2);
selection.clear();
@ -369,19 +360,17 @@ void MapPixmapItem::floodFill(QGraphicsSceneMouseEvent *event) {
if (event->type() == QEvent::GraphicsSceneMouseRelease) {
actionId_++;
} else {
QPointF pos = event->pos();
int x = static_cast<int>(pos.x()) / 16;
int y = static_cast<int>(pos.y()) / 16;
Block *block = map->getBlock(x, y);
QPoint pos = Metatile::coordFromPixmapCoord(event->pos());
Block *block = map->getBlock(pos.x(), pos.y());
QList<uint16_t> *selectedMetatiles = this->metatileSelector->getSelectedMetatiles();
QPoint selectionDimensions = this->metatileSelector->getSelectionDimensions();
int tile = selectedMetatiles->first();
if (selectedMetatiles->count() > 1 || (block && block->tile != tile)) {
bool smartPathsEnabled = event->modifiers() & Qt::ShiftModifier;
if ((this->settings->smartPathsEnabled || smartPathsEnabled) && selectionDimensions.x() == 3 && selectionDimensions.y() == 3)
this->floodFillSmartPath(x, y);
this->floodFillSmartPath(pos.x(), pos.y());
else
this->floodFill(x, y);
this->floodFill(pos.x(), pos.y());
}
}
}
@ -392,10 +381,8 @@ void MapPixmapItem::magicFill(QGraphicsSceneMouseEvent *event) {
if (event->type() == QEvent::GraphicsSceneMouseRelease) {
actionId_++;
} else {
QPointF pos = event->pos();
int initialX = static_cast<int>(pos.x()) / 16;
int initialY = static_cast<int>(pos.y()) / 16;
this->magicFill(initialX, initialY);
QPoint initialPos = Metatile::coordFromPixmapCoord(event->pos());
this->magicFill(initialPos.x(), initialPos.y());
}
}
}
@ -691,26 +678,22 @@ void MapPixmapItem::floodFillSmartPath(int initialX, int initialY, bool fromScri
}
void MapPixmapItem::pick(QGraphicsSceneMouseEvent *event) {
QPointF pos = event->pos();
int x = static_cast<int>(pos.x()) / 16;
int y = static_cast<int>(pos.y()) / 16;
Block *block = map->getBlock(x, y);
QPoint pos = Metatile::coordFromPixmapCoord(event->pos());
Block *block = map->getBlock(pos.x(), pos.y());
if (block) {
this->metatileSelector->selectFromMap(block->tile, block->collision, block->elevation);
}
}
void MapPixmapItem::select(QGraphicsSceneMouseEvent *event) {
QPointF pos = event->pos();
int x = static_cast<int>(pos.x()) / 16;
int y = static_cast<int>(pos.y()) / 16;
QPoint pos = Metatile::coordFromPixmapCoord(event->pos());
if (event->type() == QEvent::GraphicsSceneMousePress) {
selection_origin = QPoint(x, y);
selection_origin = QPoint(pos.x(), pos.y());
selection.clear();
} else if (event->type() == QEvent::GraphicsSceneMouseMove) {
if (event->buttons() & Qt::LeftButton) {
selection.clear();
selection.append(QPoint(x, y));
selection.append(QPoint(pos.x(), pos.y()));
}
} else if (event->type() == QEvent::GraphicsSceneMouseRelease) {
if (!selection.isEmpty()) {
@ -740,8 +723,6 @@ void MapPixmapItem::draw(bool ignoreCache) {
}
void MapPixmapItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) {
int x = static_cast<int>(event->pos().x()) / 16;
int y = static_cast<int>(event->pos().y()) / 16;
emit this->hoveredMapMetatileChanged(event->scenePos(), event->screenPos());
if (this->settings->betterCursors && this->paintingMode != MapPixmapItem::PaintMode::Disabled) {
setCursor(this->settings->mapCursor);
@ -758,17 +739,13 @@ void MapPixmapItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *) {
this->has_mouse = false;
}
void MapPixmapItem::mousePressEvent(QGraphicsSceneMouseEvent *event) {
QPointF pos = event->pos();
int x = static_cast<int>(pos.x()) / 16;
int y = static_cast<int>(pos.y()) / 16;
this->paint_tile_initial_x = this->straight_path_initial_x = x;
this->paint_tile_initial_y = this->straight_path_initial_y = y;
QPoint pos = Metatile::coordFromPixmapCoord(event->pos());
this->paint_tile_initial_x = this->straight_path_initial_x = pos.x();
this->paint_tile_initial_y = this->straight_path_initial_y = pos.y();
emit startPaint(event, this);
emit mouseEvent(event, this);
}
void MapPixmapItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
int x = static_cast<int>(event->pos().x()) / 16;
int y = static_cast<int>(event->pos().y()) / 16;
emit this->hoveredMapMetatileChanged(event->scenePos(), event->screenPos());
emit mouseEvent(event, this);
}