#ifndef METATILESELECTOR_H #define METATILESELECTOR_H #include #include "selectablepixmapitem.h" #include "map.h" #include "tileset.h" #include "maplayout.h" class MetatileSelector: public SelectablePixmapItem { Q_OBJECT public: MetatileSelector(int numMetatilesWide, Map *map): SelectablePixmapItem(16, 16) { this->externalSelection = false; this->numMetatilesWide = numMetatilesWide; this->map = map; this->primaryTileset = map->layout->tileset_primary; this->secondaryTileset = map->layout->tileset_secondary; this->selectedMetatiles = new QList(); this->selectedCollisions = new QList>(); this->externalSelectedMetatiles = new QList(); setAcceptHoverEvents(true); } QPoint getSelectionDimensions(); void draw(); bool select(uint16_t metatile); bool selectFromMap(uint16_t metatileId, uint16_t collision, uint16_t elevation); void setTilesets(Tileset*, Tileset*); QList* getSelectedMetatiles(); QList>* getSelectedCollisions(); void setExternalSelection(int, int, QList, QList>); QPoint getMetatileIdCoordsOnWidget(uint16_t); protected: void mousePressEvent(QGraphicsSceneMouseEvent*); void mouseMoveEvent(QGraphicsSceneMouseEvent*); void mouseReleaseEvent(QGraphicsSceneMouseEvent*); void hoverMoveEvent(QGraphicsSceneHoverEvent*); void hoverLeaveEvent(QGraphicsSceneHoverEvent*); private: bool externalSelection; int numMetatilesWide; Map *map; Tileset *primaryTileset; Tileset *secondaryTileset; QList *selectedMetatiles; QList> *selectedCollisions; int externalSelectionWidth; int externalSelectionHeight; QList *externalSelectedMetatiles; void updateSelectedMetatiles(); uint16_t getMetatileId(int x, int y); QPoint getMetatileIdCoords(uint16_t); bool shouldAcceptEvent(QGraphicsSceneMouseEvent*); bool selectionIsValid(); signals: void hoveredMetatileSelectionChanged(uint16_t); void hoveredMetatileSelectionCleared(); void selectedMetatilesChanged(); }; #endif // METATILESELECTOR_H