porymap/include/ui/tileseteditortileselector.h

74 lines
2.2 KiB
C
Raw Normal View History

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