00001 #ifndef CARD_SPRITE_H
00002 #define CARD_SPRITE_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <QGraphicsPixmapItem>
00025 #include <QList>
00026 #include <QPoint>
00027 #include <QPointF>
00028 #include <QPixmap>
00029
00030
00031 #include "thememanager.h"
00032 #include "deck.h"
00033
00034
00038 class CardSprite : public QGraphicsPixmapItem, public virtual Themable
00039 {
00040
00041 public:
00049 CardSprite(const Suite suite, const CardType type, ThemeManager* theme, int advancePeriod, QGraphicsScene* scene);
00050
00052 enum AnimationState {Idle, Turning, Moving, Removing,
00053 ShuffleMove};
00054
00059 virtual void changeTheme();
00060
00063 void setFrontside();
00064
00067 void setBackside();
00068
00072 virtual void advance(int phase);
00073
00076 void stop();
00077
00081 void setTurning(bool front);
00082
00088 void setMove(QPointF pos, double time);
00089
00093 void setPosition(QPointF pos);
00094
00100 void setRemove(QPointF pos, double time);
00101
00109 void setShuffleMove(QPointF pos, double delay, bool front);
00110
00115 void setFrame(int no, bool force=false);
00116
00120 int count();
00121
00125 int cardid() {return mCardType*4+mSuite;}
00126
00130 int frame() {return mCurrentFrame;}
00131
00132 protected:
00137 void calcFrame(int no);
00138
00146 QPixmap createCard(const QPixmap front, const QPixmap back, int curNo, int count);
00147
00152 void calcTargetAndSpeed(QPointF pos, double time);
00153
00157 bool deltaMove();
00158
00159
00160 private:
00161
00162 AnimationState mAnimationState;
00163
00164 double mTime;
00165
00166 QPointF mMoveTarget;
00167
00168 double mMoveSpeedX;
00169
00170 double mMoveSpeedY;
00171
00172 bool mFrontFlag;
00173
00174 QList<QPixmap> mFrames;
00175
00176 QList<QPointF> mHotspots;
00177
00178 int mCurrentFrame;
00179
00180
00181 int mAdvancePeriod;
00182
00183 double mWidth;
00184
00185 Suite mSuite;
00186
00187 CardType mCardType;
00188
00189
00190 QPointF mStart;
00191
00192 };
00193
00194 #endif