Fix selected collision space not updating during paint

This commit is contained in:
GriffinR 2022-01-11 09:25:05 -05:00 committed by huderlem
parent 611e787122
commit 2f6de2a285
3 changed files with 18 additions and 3 deletions

View file

@ -17,6 +17,7 @@ The **"Breaking Changes"** listed below are changes that have been made in the d
### Fixed
- Fix cursor tile outline not updating at the end of a dragged selection.
- Fix selected space not updating while painting in Collision view.
## [4.5.0] - 2021-12-26
### Added

View file

@ -27,6 +27,7 @@ public:
private:
unsigned actionId_ = 0;
QPoint previousPos;
signals:
void mouseEvent(QGraphicsSceneMouseEvent *, CollisionPixmapItem *);
@ -35,6 +36,7 @@ signals:
protected:
void hoverMoveEvent(QGraphicsSceneHoverEvent*);
void hoverEnterEvent(QGraphicsSceneHoverEvent*);
void hoverLeaveEvent(QGraphicsSceneHoverEvent*);
void mousePressEvent(QGraphicsSceneMouseEvent*);
void mouseMoveEvent(QGraphicsSceneMouseEvent*);

View file

@ -3,14 +3,21 @@
#include "metatile.h"
void CollisionPixmapItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) {
int x = static_cast<int>(event->pos().x()) / 16;
int y = static_cast<int>(event->pos().y()) / 16;
emit this->hoveredMapMovementPermissionChanged(x, y);
QPoint pos = Metatile::coordFromPixmapCoord(event->pos());
if (pos != this->previousPos) {
this->previousPos = pos;
emit this->hoveredMapMovementPermissionChanged(pos.x(), pos.y());
}
if (this->settings->betterCursors && this->paintingMode == MapPixmapItem::PaintMode::Metatiles) {
setCursor(this->settings->mapCursor);
}
}
void CollisionPixmapItem::hoverEnterEvent(QGraphicsSceneHoverEvent * event) {
QPoint pos = Metatile::coordFromPixmapCoord(event->pos());
emit this->hoveredMapMovementPermissionChanged(pos.x(), pos.y());
}
void CollisionPixmapItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *) {
emit this->hoveredMapMovementPermissionCleared();
if (this->settings->betterCursors && this->paintingMode == MapPixmapItem::PaintMode::Metatiles){
@ -26,6 +33,11 @@ void CollisionPixmapItem::mousePressEvent(QGraphicsSceneMouseEvent *event) {
}
void CollisionPixmapItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
QPoint pos = Metatile::coordFromPixmapCoord(event->pos());
if (pos != this->previousPos) {
this->previousPos = pos;
emit this->hoveredMapMovementPermissionChanged(pos.x(), pos.y());
}
emit mouseEvent(event, this);
}