2018-09-29 21:24:35 +01:00
|
|
|
#ifndef TILESETEDITORMETATILESELECTOR_H
|
|
|
|
#define TILESETEDITORMETATILESELECTOR_H
|
|
|
|
|
|
|
|
#include "selectablepixmapitem.h"
|
|
|
|
#include "tileset.h"
|
2020-07-02 02:19:08 +01:00
|
|
|
#include "map.h"
|
2018-09-29 21:24:35 +01:00
|
|
|
|
|
|
|
class TilesetEditorMetatileSelector: public SelectablePixmapItem {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2021-07-20 03:02:31 +01:00
|
|
|
TilesetEditorMetatileSelector(Tileset *primaryTileset, Tileset *secondaryTileset, Map *map);
|
2020-07-02 02:19:08 +01:00
|
|
|
Map *map = nullptr;
|
2018-09-29 21:24:35 +01:00
|
|
|
void draw();
|
2020-07-08 08:56:27 +01:00
|
|
|
bool select(uint16_t metatileId);
|
2021-07-20 03:02:31 +01:00
|
|
|
void setTilesets(Tileset*, Tileset*, bool draw = true);
|
2022-03-30 23:03:13 +01:00
|
|
|
uint16_t getSelectedMetatileId();
|
2020-06-30 08:34:14 +01:00
|
|
|
void updateSelectedMetatile();
|
2020-07-01 19:01:18 +01:00
|
|
|
QPoint getMetatileIdCoordsOnWidget(uint16_t metatileId);
|
2022-10-05 13:54:04 +01:00
|
|
|
QImage buildPrimaryMetatilesImage();
|
|
|
|
QImage buildSecondaryMetatilesImage();
|
2018-09-29 21:24:35 +01:00
|
|
|
|
2021-07-20 03:02:31 +01:00
|
|
|
QVector<uint16_t> usedMetatiles;
|
|
|
|
bool selectorShowUnused = false;
|
|
|
|
bool selectorShowCounts = false;
|
2023-12-20 02:21:16 +00:00
|
|
|
bool showGrid;
|
2021-07-20 03:02:31 +01:00
|
|
|
|
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;
|
2023-12-20 02:21:16 +00:00
|
|
|
int numMetatilesHigh;
|
2018-09-29 21:24:35 +01:00
|
|
|
uint16_t getMetatileId(int x, int y);
|
|
|
|
QPoint getMetatileIdCoords(uint16_t);
|
2020-06-29 23:07:26 +01:00
|
|
|
bool shouldAcceptEvent(QGraphicsSceneMouseEvent*);
|
2023-12-20 02:21:16 +00:00
|
|
|
int numRows(int numMetatiles);
|
|
|
|
int numRows();
|
2023-12-31 19:06:47 +00:00
|
|
|
void drawGrid();
|
2021-07-20 03:02:31 +01:00
|
|
|
void drawFilters();
|
|
|
|
void drawUnused();
|
|
|
|
void drawCounts();
|
2022-10-05 13:54:04 +01:00
|
|
|
QImage buildAllMetatilesImage();
|
2022-10-05 15:53:22 +01:00
|
|
|
QImage buildImage(int metatileIdStart, int numMetatiles);
|
2021-07-20 03:02:31 +01:00
|
|
|
|
2018-09-29 21:24:35 +01:00
|
|
|
signals:
|
|
|
|
void hoveredMetatileChanged(uint16_t);
|
|
|
|
void hoveredMetatileCleared();
|
|
|
|
void selectedMetatileChanged(uint16_t);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // TILESETEDITORMETATILESELECTOR_H
|