From 8594c2ce36619765b9565afac8e635b1d17289f1 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Mon, 28 Nov 2022 16:01:29 -0500 Subject: [PATCH] Display message when hovering on border metatiles --- CHANGELOG.md | 3 +++ include/ui/bordermetatilespixmapitem.h | 9 +++++++++ src/editor.cpp | 4 ++++ src/ui/bordermetatilespixmapitem.cpp | 18 ++++++++++++++++++ 4 files changed, 34 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index eed6c36a..75cd1932 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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). diff --git a/include/ui/bordermetatilespixmapitem.h b/include/ui/bordermetatilespixmapitem.h index 870c975e..f4af8bfe 100644 --- a/include/ui/bordermetatilespixmapitem.h +++ b/include/ui/bordermetatilespixmapitem.h @@ -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 diff --git a/src/editor.cpp b/src/editor.cpp index 21873fd7..7bb4b26f 100644 --- a/src/editor.cpp +++ b/src/editor.cpp @@ -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); } diff --git a/src/ui/bordermetatilespixmapitem.cpp b/src/ui/bordermetatilespixmapitem.cpp index 9aa6548e..8f8bc134 100644 --- a/src/ui/bordermetatilespixmapitem.cpp +++ b/src/ui/bordermetatilespixmapitem.cpp @@ -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(); +}