2018-09-29 21:24:35 +01:00
|
|
|
#ifndef TILESETEDITORMETATILESELECTOR_H
|
|
|
|
#define TILESETEDITORMETATILESELECTOR_H
|
|
|
|
|
|
|
|
#include "selectablepixmapitem.h"
|
|
|
|
#include "tileset.h"
|
|
|
|
|
|
|
|
class TilesetEditorMetatileSelector: public SelectablePixmapItem {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
TilesetEditorMetatileSelector(Tileset *primaryTileset, Tileset *secondaryTileset): SelectablePixmapItem(32, 32, 1, 1) {
|
|
|
|
this->primaryTileset = primaryTileset;
|
|
|
|
this->secondaryTileset = secondaryTileset;
|
|
|
|
this->numMetatilesWide = 8;
|
|
|
|
setAcceptHoverEvents(true);
|
|
|
|
}
|
|
|
|
void draw();
|
|
|
|
void select(uint16_t metatileId);
|
|
|
|
void setTilesets(Tileset*, Tileset*);
|
|
|
|
uint16_t getSelectedMetatile();
|
2020-06-30 08:34:14 +01:00
|
|
|
void updateSelectedMetatile();
|
2020-07-01 19:01:18 +01:00
|
|
|
QPoint getMetatileIdCoordsOnWidget(uint16_t metatileId);
|
2018-09-29 21:24:35 +01:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void mousePressEvent(QGraphicsSceneMouseEvent*);
|
|
|
|
void mouseMoveEvent(QGraphicsSceneMouseEvent*);
|
|
|
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent*);
|
|
|
|
void hoverMoveEvent(QGraphicsSceneHoverEvent*);
|
|
|
|
void hoverLeaveEvent(QGraphicsSceneHoverEvent*);
|
|
|
|
|
|
|
|
private:
|
2018-10-03 01:01:15 +01:00
|
|
|
Tileset *primaryTileset = nullptr;
|
|
|
|
Tileset *secondaryTileset = nullptr;
|
2018-09-29 21:24:35 +01:00
|
|
|
uint16_t selectedMetatile;
|
|
|
|
int numMetatilesWide;
|
|
|
|
uint16_t getMetatileId(int x, int y);
|
|
|
|
QPoint getMetatileIdCoords(uint16_t);
|
2020-06-29 23:07:26 +01:00
|
|
|
bool shouldAcceptEvent(QGraphicsSceneMouseEvent*);
|
2018-09-29 21:24:35 +01:00
|
|
|
|
|
|
|
signals:
|
|
|
|
void hoveredMetatileChanged(uint16_t);
|
|
|
|
void hoveredMetatileCleared();
|
|
|
|
void selectedMetatileChanged(uint16_t);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // TILESETEDITORMETATILESELECTOR_H
|