Crossfire Server, Branch 1.12
R12190
|
00001 #include <Qt> 00002 00003 #include "CREAnimationWidget.h" 00004 #include "CREPixmap.h" 00005 00006 CREAnimationWidget::CREAnimationWidget(QWidget* parent) : QWidget(parent) 00007 { 00008 myStep = 0; 00009 setMinimumWidth(32); 00010 setMinimumHeight(32); 00011 } 00012 00013 void CREAnimationWidget::setAnimation(QList<int> faces) 00014 { 00015 myFaces = faces; 00016 myStep = 0; 00017 } 00018 00019 void CREAnimationWidget::step() 00020 { 00021 if (myFaces.size() == 0) 00022 return; 00023 00024 myStep++; 00025 if (myStep == myFaces.size()) 00026 myStep = 0; 00027 00028 repaint(); 00029 } 00030 00031 void CREAnimationWidget::paintEvent(QPaintEvent* /*event*/) 00032 { 00033 if (myStep >= myFaces.size()) 00034 return; 00035 00036 QPainter painter(this); 00037 CREPixmap::getIcon(myFaces[myStep]).paint(&painter, 0, 0, 32, 32); 00038 }