Crossfire Server, Trunk
AnimationWidget.cpp
Go to the documentation of this file.
1
/*
2
* Crossfire -- cooperative multi-player graphical RPG and adventure game
3
*
4
* Copyright (c) 2022 the Crossfire Development Team
5
*
6
* Crossfire is free software and comes with ABSOLUTELY NO WARRANTY. You are
7
* welcome to redistribute it under certain conditions. For details, please
8
* see COPYING and LICENSE.
9
*
10
* The authors can be reached via e-mail at <crossfire@metalforge.org>.
11
*/
12
13
#include <Qt>
14
15
#include "
AnimationWidget.h
"
16
#include "
CREPixmap.h
"
17
18
AnimationWidget::AnimationWidget
(QWidget* parent) : QWidget(parent)
19
{
20
myStep
= 0;
21
setMinimumWidth(32);
22
setMinimumHeight(32);
23
}
24
25
void
AnimationWidget::setAnimation
(QList<int>
faces
)
26
{
27
myFaces
=
faces
;
28
myStep
= 0;
29
}
30
31
void
AnimationWidget::step
()
32
{
33
if
(
myFaces
.size() == 0)
34
return
;
35
36
myStep
++;
37
if
(
myStep
==
myFaces
.size())
38
myStep
= 0;
39
40
repaint();
41
}
42
43
void
AnimationWidget::paintEvent
(QPaintEvent*
/*event*/
)
44
{
45
if
(
myStep
>=
myFaces
.size())
46
return
;
47
48
QPainter painter(
this
);
49
int
face =
myFaces
[
myStep
];
50
if
(face == 0)
51
painter.eraseRect(0, 0, 32, 32);
52
else
53
CREPixmap::getIcon
(face).paint(&painter, 0, 0, 32, 32);
54
}
AnimationWidget.h
CREPixmap::getIcon
static QIcon getIcon(uint16_t faceNumber)
Definition:
CREPixmap.cpp:65
AnimationWidget::setAnimation
void setAnimation(QList< int > faces)
Definition:
AnimationWidget.cpp:25
AnimationWidget::myStep
int myStep
Definition:
AnimationWidget.h:33
AnimationWidget::myFaces
QList< int > myFaces
Definition:
AnimationWidget.h:34
AnimationWidget::step
void step()
Definition:
AnimationWidget.cpp:31
dragon_attune.faces
dictionary faces
Definition:
dragon_attune.py:31
AnimationWidget::paintEvent
virtual void paintEvent(QPaintEvent *event)
Definition:
AnimationWidget.cpp:43
CREPixmap.h
AnimationWidget::AnimationWidget
AnimationWidget(QWidget *parent)
Definition:
AnimationWidget.cpp:18
crossfire-crossfire-server
utils
cre
animations
AnimationWidget.cpp
Generated by
1.8.17