porymap/include/ui/citymappixmapitem.h

57 lines
1.3 KiB
C
Raw Permalink Normal View History

2019-01-05 22:59:57 +00:00
#ifndef CITYMAPPIXMAPITEM_H
#define CITYMAPPIXMAPITEM_H
#include "tilemaptileselector.h"
2019-01-05 22:59:57 +00:00
#include <QGraphicsPixmapItem>
#include <QByteArray>
2019-01-22 20:06:49 +00:00
#include <QVector>
2019-01-05 22:59:57 +00:00
class CityMapPixmapItem : public QObject, public QGraphicsPixmapItem {
Q_OBJECT
2019-08-07 04:35:02 +01:00
private:
using QGraphicsPixmapItem::paint;
2019-01-05 22:59:57 +00:00
public:
CityMapPixmapItem(QString fname, TilemapTileSelector *tile_selector) {
this->file = fname;
this->tile_selector = tile_selector;
setAcceptHoverEvents(true);
init();
}
TilemapTileSelector *tile_selector;
QString file;
QByteArray data;
2019-01-05 22:59:57 +00:00
void init();
void save();
void create(QString);
2019-08-07 04:35:02 +01:00
virtual void paint(QGraphicsSceneMouseEvent *);
2019-01-05 22:59:57 +00:00
virtual void draw();
int getIndexAt(int, int);
int width();
int height();
2019-01-22 20:06:49 +00:00
QVector<uint8_t> getTiles();
void setTiles(QVector<uint8_t>);
private:
int width_;
int height_;
2019-01-05 22:59:57 +00:00
signals:
void mouseEvent(QGraphicsSceneMouseEvent *, CityMapPixmapItem *);
void hoveredRegionMapTileChanged(int x, int y);
void hoveredRegionMapTileCleared();
protected:
void mousePressEvent(QGraphicsSceneMouseEvent*);
2019-01-22 20:06:49 +00:00
void mouseMoveEvent(QGraphicsSceneMouseEvent*);
void mouseReleaseEvent(QGraphicsSceneMouseEvent*);
2019-01-05 22:59:57 +00:00
};
#endif // CITYMAPPIXMAPITEM_H