Crossfire Server, Trunk
CREAnimationWidget.cpp
Go to the documentation of this file.
1 #include <Qt>
2 
3 #include "CREAnimationWidget.h"
4 #include "CREPixmap.h"
5 
6 CREAnimationWidget::CREAnimationWidget(QWidget* parent) : QWidget(parent)
7 {
8  myStep = 0;
9  setMinimumWidth(32);
10  setMinimumHeight(32);
11 }
12 
14 {
15  myFaces = faces;
16  myStep = 0;
17 }
18 
20 {
21  if (myFaces.size() == 0)
22  return;
23 
24  myStep++;
25  if (myStep == myFaces.size())
26  myStep = 0;
27 
28  repaint();
29 }
30 
31 void CREAnimationWidget::paintEvent(QPaintEvent* /*event*/)
32 {
33  if (myStep >= myFaces.size())
34  return;
35 
36  QPainter painter(this);
37  CREPixmap::getIcon(myFaces[myStep]).paint(&painter, 0, 0, 32, 32);
38 }
CREPixmap::getIcon
static QIcon getIcon(uint16_t faceNumber)
Definition: CREPixmap.cpp:55
CREAnimationWidget::step
void step()
Definition: CREAnimationWidget.cpp:19
CREAnimationWidget::setAnimation
void setAnimation(QList< int > faces)
Definition: CREAnimationWidget.cpp:13
CREAnimationWidget::CREAnimationWidget
CREAnimationWidget(QWidget *parent)
Definition: CREAnimationWidget.cpp:6
CREAnimationWidget::paintEvent
virtual void paintEvent(QPaintEvent *event)
Definition: CREAnimationWidget.cpp:31
dragon_attune.faces
dictionary faces
Definition: dragon_attune.py:31
CREAnimationWidget::myStep
int myStep
Definition: CREAnimationWidget.h:19
CREAnimationWidget::myFaces
QList< int > myFaces
Definition: CREAnimationWidget.h:20
CREAnimationWidget.h
CREPixmap.h