#ifndef ADITEM_H
#define ADITEM_H

#include <QGraphicsItem>
#include <QPainter>

class ADItem : public QGraphicsItem
{
public:
    enum adType {Alien, Tower, Splash, Other};
    explicit ADItem(int id, adType type, QList<QImage *> *images, QRectF geometry = QRectF(), QGraphicsItem *parent = 0);
    explicit ADItem(QPoint id, QImage * image, QRectF geometry = QRectF(), QGraphicsItem *parent = 0);
    void setBarValue(float val) {barValue = val;}
    void setBarVisible(bool visible = true) {hasBar = visible;}
    void setCompositionMode(QPainter::CompositionMode mode) {cmode = mode;}
    void hideBar() {hasBar = false; setCacheMode(QGraphicsItem::ItemCoordinateCache);}
    float value() {return barValue;}
    bool isBarVisible() {return hasBar;}
    void next(float step = 1.f);
    QPoint tid() {return m_tid;}
    int id() {return m_id;}
    adType itemType() {return m_type;}
    QRectF boundingRect() const;

private:
    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
    QList<QImage *> * images;
    QImage * img;
    float anim;
    adType m_type;
    int m_id;
    QPoint m_tid;
    int animcount;
    bool staticImage;
    bool hasBar;
    float barValue;
    QRectF br;
    QPainter::CompositionMode cmode;
};

#endif // ADITEM_H
