Display message when hovering on border metatiles

This commit is contained in:
GriffinR 2022-11-28 16:01:29 -05:00
parent 3a4ce68232
commit 8594c2ce36
4 changed files with 34 additions and 0 deletions

View file

@ -10,6 +10,9 @@ The **"Breaking Changes"** listed below are changes that have been made in the d
### Added
- Add `setScale` to the scripting API.
### Changed
- Hovering on border metatiles with the mouse will now display their information in the bottom bar.
## [5.0.0] - 2022-10-30
### Breaking Changes
- Proper support for pokefirered's clone objects was added, which requires the changes made in [pokefirered/#484](https://github.com/pret/pokefirered/pull/484).

View file

@ -18,9 +18,18 @@ public:
Map *map;
void draw();
signals:
void hoveredBorderMetatileSelectionChanged(uint16_t);
void hoveredBorderMetatileSelectionCleared();
void borderMetatilesChanged();
private:
void hoverUpdate(const QPointF &);
protected:
void mousePressEvent(QGraphicsSceneMouseEvent*);
void mouseMoveEvent(QGraphicsSceneMouseEvent*);
void hoverMoveEvent(QGraphicsSceneHoverEvent*);
void hoverLeaveEvent(QGraphicsSceneHoverEvent*);
};
#endif // BORDERMETATILESPIXMAPITEM_H

View file

@ -1443,6 +1443,10 @@ void Editor::displayBorderMetatiles() {
selected_border_metatiles_item->draw();
scene_selected_border_metatiles->addItem(selected_border_metatiles_item);
connect(selected_border_metatiles_item, &BorderMetatilesPixmapItem::hoveredBorderMetatileSelectionChanged,
this, &Editor::onHoveredMetatileSelectionChanged);
connect(selected_border_metatiles_item, &BorderMetatilesPixmapItem::hoveredBorderMetatileSelectionCleared,
this, &Editor::onHoveredMetatileSelectionCleared);
connect(selected_border_metatiles_item, &BorderMetatilesPixmapItem::borderMetatilesChanged,
this, &Editor::onBorderMetatilesChanged);
}

View file

@ -54,3 +54,21 @@ void BorderMetatilesPixmapItem::draw() {
emit borderMetatilesChanged();
}
void BorderMetatilesPixmapItem::hoverUpdate(const QPointF &pixmapPos) {
QPoint pos = Metatile::coordFromPixmapCoord(pixmapPos);
uint16_t metatileId = this->map->getBorderMetatileId(pos.x(), pos.y());
emit this->hoveredBorderMetatileSelectionChanged(metatileId);
}
void BorderMetatilesPixmapItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
this->hoverUpdate(event->pos());
}
void BorderMetatilesPixmapItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) {
this->hoverUpdate(event->pos());
}
void BorderMetatilesPixmapItem::hoverLeaveEvent(QGraphicsSceneHoverEvent*) {
emit this->hoveredBorderMetatileSelectionCleared();
}