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 ### Fixed
- Fix cursor tile outline not updating at the end of a dragged selection. - 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 ## [4.5.0] - 2021-12-26
### Added ### Added

View file

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

View file

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