2018-09-30 18:33:58 +01:00
|
|
|
#ifndef TILESETEDITORTILESELECTOR_H
|
|
|
|
#define TILESETEDITORTILESELECTOR_H
|
|
|
|
|
|
|
|
#include "selectablepixmapitem.h"
|
|
|
|
#include "tileset.h"
|
|
|
|
|
|
|
|
class TilesetEditorTileSelector: public SelectablePixmapItem {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2022-10-04 02:28:16 +01:00
|
|
|
TilesetEditorTileSelector(Tileset *primaryTileset, Tileset *secondaryTileset, int numLayers)
|
|
|
|
: SelectablePixmapItem(16, 16, numLayers * 2, 2) {
|
2018-09-30 18:33:58 +01:00
|
|
|
this->primaryTileset = primaryTileset;
|
|
|
|
this->secondaryTileset = secondaryTileset;
|
|
|
|
this->numTilesWide = 16;
|
2018-09-30 20:54:38 +01:00
|
|
|
this->paletteId = 0;
|
2018-10-03 01:01:37 +01:00
|
|
|
this->xFlip = false;
|
|
|
|
this->yFlip = false;
|
2020-07-14 08:02:01 +01:00
|
|
|
this->paletteChanged = false;
|
2018-09-30 18:33:58 +01:00
|
|
|
setAcceptHoverEvents(true);
|
|
|
|
}
|
2018-10-06 21:49:26 +01:00
|
|
|
QPoint getSelectionDimensions();
|
2018-09-30 18:33:58 +01:00
|
|
|
void draw();
|
|
|
|
void select(uint16_t metatileId);
|
2020-07-20 16:11:38 +01:00
|
|
|
void highlight(uint16_t metatileId);
|
2018-09-30 18:33:58 +01:00
|
|
|
void setTilesets(Tileset*, Tileset*);
|
2018-09-30 20:54:38 +01:00
|
|
|
void setPaletteId(int);
|
2018-10-03 01:01:27 +01:00
|
|
|
void setTileFlips(bool, bool);
|
2018-10-06 21:49:26 +01:00
|
|
|
QList<Tile> getSelectedTiles();
|
2020-07-14 21:27:10 +01:00
|
|
|
void setExternalSelection(int, int, QList<Tile>, QList<int>);
|
2018-10-08 20:42:51 +01:00
|
|
|
QPoint getTileCoordsOnWidget(uint16_t);
|
2019-01-05 21:52:55 +00:00
|
|
|
QImage buildPrimaryTilesIndexedImage();
|
|
|
|
QImage buildSecondaryTilesIndexedImage();
|
2018-09-30 18:33:58 +01:00
|
|
|
|
2021-07-21 23:55:33 +01:00
|
|
|
QVector<uint16_t> usedTiles;
|
|
|
|
bool showUnused = false;
|
|
|
|
|
2018-09-30 18:33:58 +01:00
|
|
|
protected:
|
|
|
|
void mousePressEvent(QGraphicsSceneMouseEvent*);
|
|
|
|
void mouseMoveEvent(QGraphicsSceneMouseEvent*);
|
|
|
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent*);
|
|
|
|
void hoverMoveEvent(QGraphicsSceneHoverEvent*);
|
|
|
|
void hoverLeaveEvent(QGraphicsSceneHoverEvent*);
|
|
|
|
|
|
|
|
private:
|
2018-10-06 21:49:26 +01:00
|
|
|
bool externalSelection;
|
|
|
|
int externalSelectionWidth;
|
|
|
|
int externalSelectionHeight;
|
2020-07-13 18:08:57 +01:00
|
|
|
QList<Tile> externalSelectedTiles;
|
2020-07-14 21:27:10 +01:00
|
|
|
QList<int> externalSelectedPos;
|
2018-10-06 21:49:26 +01:00
|
|
|
|
2018-09-30 18:33:58 +01:00
|
|
|
Tileset *primaryTileset;
|
|
|
|
Tileset *secondaryTileset;
|
2018-10-03 01:01:27 +01:00
|
|
|
QList<uint16_t> selectedTiles;
|
2018-09-30 18:33:58 +01:00
|
|
|
int numTilesWide;
|
2018-09-30 20:54:38 +01:00
|
|
|
int paletteId;
|
2018-10-03 01:01:27 +01:00
|
|
|
bool xFlip;
|
|
|
|
bool yFlip;
|
2020-07-14 08:02:01 +01:00
|
|
|
bool paletteChanged;
|
2018-10-03 01:01:27 +01:00
|
|
|
void updateSelectedTiles();
|
2018-09-30 18:33:58 +01:00
|
|
|
uint16_t getTileId(int x, int y);
|
|
|
|
QPoint getTileCoords(uint16_t);
|
|
|
|
QList<QRgb> getCurPaletteTable();
|
2020-07-13 18:08:57 +01:00
|
|
|
QList<Tile> buildSelectedTiles(int, int, QList<Tile>);
|
2018-09-30 18:33:58 +01:00
|
|
|
|
2021-07-21 23:55:33 +01:00
|
|
|
void drawUnused();
|
|
|
|
|
2018-09-30 18:33:58 +01:00
|
|
|
signals:
|
|
|
|
void hoveredTileChanged(uint16_t);
|
|
|
|
void hoveredTileCleared();
|
2018-10-03 01:01:27 +01:00
|
|
|
void selectedTilesChanged();
|
2018-09-30 18:33:58 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // TILESETEDITORTILESELECTOR_H
|