2018-09-30 22:15:04 +01:00
|
|
|
#ifndef METATILELAYERSITEM_H
|
|
|
|
#define METATILELAYERSITEM_H
|
|
|
|
|
|
|
|
#include "tileset.h"
|
2018-10-06 21:49:26 +01:00
|
|
|
#include "selectablepixmapitem.h"
|
2018-09-30 22:15:04 +01:00
|
|
|
#include <QGraphicsPixmapItem>
|
|
|
|
#include <QGraphicsSceneMouseEvent>
|
|
|
|
|
2018-10-06 21:49:26 +01:00
|
|
|
class MetatileLayersItem: public SelectablePixmapItem {
|
2018-09-30 22:15:04 +01:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2020-07-14 23:54:56 +01:00
|
|
|
MetatileLayersItem(Metatile *metatile, Tileset *primaryTileset, Tileset *secondaryTileset): SelectablePixmapItem(16, 16, 6, 2) {
|
2018-09-30 22:15:04 +01:00
|
|
|
this->metatile = metatile;
|
|
|
|
this->primaryTileset = primaryTileset;
|
|
|
|
this->secondaryTileset = secondaryTileset;
|
2018-10-06 23:07:36 +01:00
|
|
|
this->clearLastModifiedCoords();
|
2024-01-05 07:47:23 +00:00
|
|
|
this->clearLastHoveredCoords();
|
|
|
|
setAcceptHoverEvents(true);
|
2018-09-30 22:15:04 +01:00
|
|
|
}
|
|
|
|
void draw();
|
|
|
|
void setTilesets(Tileset*, Tileset*);
|
|
|
|
void setMetatile(Metatile*);
|
2018-10-06 23:07:36 +01:00
|
|
|
void clearLastModifiedCoords();
|
2024-01-05 07:47:23 +00:00
|
|
|
void clearLastHoveredCoords();
|
2023-12-20 02:21:16 +00:00
|
|
|
bool showGrid;
|
2018-09-30 22:15:04 +01:00
|
|
|
private:
|
|
|
|
Metatile* metatile;
|
|
|
|
Tileset *primaryTileset;
|
|
|
|
Tileset *secondaryTileset;
|
2024-01-05 07:47:23 +00:00
|
|
|
QPoint prevChangedPos;
|
|
|
|
QPoint prevHoveredPos;
|
|
|
|
QPoint getBoundedPos(const QPointF &);
|
2018-09-30 22:15:04 +01:00
|
|
|
signals:
|
2018-10-03 01:01:27 +01:00
|
|
|
void tileChanged(int, int);
|
2018-10-06 21:49:26 +01:00
|
|
|
void selectedTilesChanged(QPoint, int, int);
|
2024-01-05 07:47:23 +00:00
|
|
|
void hoveredTileChanged(uint16_t);
|
|
|
|
void hoveredTileCleared();
|
2018-09-30 22:15:04 +01:00
|
|
|
protected:
|
|
|
|
void mousePressEvent(QGraphicsSceneMouseEvent*);
|
2018-10-06 21:49:26 +01:00
|
|
|
void mouseMoveEvent(QGraphicsSceneMouseEvent*);
|
|
|
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent*);
|
2024-01-05 07:47:23 +00:00
|
|
|
void hoverMoveEvent(QGraphicsSceneHoverEvent*);
|
|
|
|
void hoverLeaveEvent(QGraphicsSceneHoverEvent*);
|
2018-09-30 22:15:04 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // METATILELAYERSITEM_H
|