62 lines
1.7 KiB
C++
62 lines
1.7 KiB
C++
#ifndef AD_GRAPHICS_H
|
|
#define AD_GRAPHICS_H
|
|
#include <QGraphicsView>
|
|
#include <QGraphicsWidget>
|
|
#include <QPushButton>
|
|
#include <QMouseEvent>
|
|
#include <QEasingCurve>
|
|
|
|
#include "adcore.h"
|
|
#include "moneyitem.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, bool missed);
|
|
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);
|
|
void resizeEvent(QResizeEvent *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;
|
|
// QList<MoneyItem*> moneyitems;
|
|
|
|
QTransform m_scale;
|
|
bool m_building;
|
|
|
|
protected:
|
|
void timerEvent(QTimerEvent * );
|
|
|
|
signals:
|
|
void cancel();
|
|
void add_tow(QPoint pnt, bool shift);
|
|
void selected_tower_changed(QPoint id);
|
|
};
|
|
|
|
#endif // AD_GRAPHICS_H
|