2019-01-05 22:59:57 +00:00
|
|
|
#ifndef CITYMAPPIXMAPITEM_H
|
|
|
|
#define CITYMAPPIXMAPITEM_H
|
|
|
|
|
|
|
|
#include "tilemaptileselector.h"
|
2019-01-15 22:06:18 +00:00
|
|
|
|
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-04-06 23:11:56 +01:00
|
|
|
|
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();
|
2019-01-09 02:03:54 +00:00
|
|
|
int getIndexAt(int, int);
|
2019-01-15 22:06:18 +00:00
|
|
|
int width();
|
|
|
|
int height();
|
2019-01-09 02:03:54 +00:00
|
|
|
|
2019-01-22 20:06:49 +00:00
|
|
|
QVector<uint8_t> getTiles();
|
|
|
|
void setTiles(QVector<uint8_t>);
|
|
|
|
|
2019-01-15 22:06:18 +00:00
|
|
|
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
|