porymap/include/ui/tileseteditormetatileselector.h

55 lines
1.7 KiB
C
Raw Normal View History

#ifndef TILESETEDITORMETATILESELECTOR_H
#define TILESETEDITORMETATILESELECTOR_H
#include "selectablepixmapitem.h"
#include "tileset.h"
#include "map.h"
class TilesetEditorMetatileSelector: public SelectablePixmapItem {
Q_OBJECT
public:
TilesetEditorMetatileSelector(Tileset *primaryTileset, Tileset *secondaryTileset, Map *map);
Map *map = nullptr;
void draw();
bool select(uint16_t metatileId);
void setTilesets(Tileset*, Tileset*, bool draw = true);
2022-03-30 23:03:13 +01:00
uint16_t getSelectedMetatileId();
void updateSelectedMetatile();
QPoint getMetatileIdCoordsOnWidget(uint16_t metatileId);
2022-10-05 13:54:04 +01:00
QImage buildPrimaryMetatilesImage();
QImage buildSecondaryMetatilesImage();
QVector<uint16_t> usedMetatiles;
bool selectorShowUnused = false;
bool selectorShowCounts = false;
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;
uint16_t selectedMetatile;
int numMetatilesWide;
uint16_t getMetatileId(int x, int y);
QPoint getMetatileIdCoords(uint16_t);
bool shouldAcceptEvent(QGraphicsSceneMouseEvent*);
void drawFilters();
void drawUnused();
void drawCounts();
2022-10-05 13:54:04 +01:00
QImage buildAllMetatilesImage();
QImage buildImage(int metatileIdStart, int numMetatiles);
signals:
void hoveredMetatileChanged(uint16_t);
void hoveredMetatileCleared();
void selectedMetatileChanged(uint16_t);
};
#endif // TILESETEDITORMETATILESELECTOR_H