#ifndef AD_GRAPHICS_H #define AD_GRAPHICS_H #include #include #include #include #include #include "adcore.h" class AD_Graphics: public QGraphicsView { Q_OBJECT Q_PROPERTY(bool building READ building WRITE setBuilding) public: explicit AD_Graphics(AD_Core * core, QWidget * parent = 0); QPoint selectedTower() {if (select_tow != 0) return select_tow->tid(); else return QPoint();} int selectedAlien() {if (select_al != 0) return select_al->id(); else return -1;} ~AD_Graphics(); bool building() const {return m_building;} public slots: void selectTower(ADItem * item) {select_tow = item;} void setBuilding(bool arg) {m_building = arg;} void alienKilled(int id); void towerKilled(QPoint id) {focus_item = 0; if (select_tow != 0) if (select_tow->tid() == id) {select_tow = 0; emit selected_tower_changed(QPoint());}} private: void drawBackground(QPainter * p, const QRectF &); void drawForeground(QPainter *painter, const QRectF &rect); void mousePressEvent(QMouseEvent *event); void mouseMoveEvent(QMouseEvent *event); QGraphicsScene * scene; AD_Core * core; QImage * mapimg; Game_Data * data; ADItem * focus_item; ADItem * select_al; ADItem * select_tow; ADItem * selection_tow; ADItem * selection_al; QEasingCurve color_curve; bool m_building; protected: void timerEvent(QTimerEvent * ); signals: void cancel(); void add_tow(QPoint pnt); void selected_tower_changed(QPoint id); }; #endif // AD_GRAPHICS_H