Crossfire Server, Trunk
CREAnimationControl.cpp
Go to the documentation of this file.
1
#include <Qt>
2
3
#include "
CREAnimationControl.h
"
4
#include "
CREAnimationWidget.h
"
5
#include "
face.h
"
6
7
CREAnimationControl::CREAnimationControl
(QWidget* parent) : QWidget(parent)
8
{
9
myAnimation
= NULL;
10
myStep
= 0;
11
myLastStep
= 0;
12
13
CREAnimationWidget
* widget;
14
QGridLayout*
layout
=
new
QGridLayout(
this
);
15
16
for
(
int
dir = 1; dir <= 8; dir++)
17
{
18
widget =
new
CREAnimationWidget
(
this
);
19
widget->setVisible(
false
);
20
21
layout
->addWidget(widget, 2 +
freearr_y
[dir], 2 +
freearr_x
[dir]);
22
myWidgets
.append(widget);
23
}
24
25
myTimer
=
new
QTimer(
this
);
26
connect
(
myTimer
, SIGNAL(timeout()),
this
, SLOT(
step
()));
27
}
28
29
void
CREAnimationControl::setAnimation
(
const
Animations
* animation,
int
facings
)
30
{
31
myTimer
->stop();
32
myAnimation
= animation;
33
display
(animation,
facings
);
34
myTimer
->start(250);
35
}
36
37
void
CREAnimationControl::display
(
const
Animations
* animation,
int
facings
)
38
{
39
myFacings
=
facings
== -1 ? animation->
facings
:
facings
;
40
41
int
widget, widgetStep, faceCount, face, faceCurrent;
42
43
for
(widget = 0; widget < 8; widget++)
44
myWidgets
[widget]->setVisible(
false
);
45
46
widget = 0;
47
48
if
(
myFacings
== 1)
49
{
50
widgetStep = 8;
51
faceCount = animation->
num_animations
;
52
}
53
else
if
(
myFacings
== 2)
54
{
55
widgetStep = 4;
56
faceCount = animation->
num_animations
/ 2;
57
}
58
else
if
(
myFacings
== 4)
59
{
60
widgetStep = 2;
61
faceCount = animation->
num_animations
/ 4;
62
}
63
else
64
{
65
widgetStep = 1;
66
faceCount = animation->
num_animations
/ 8;
67
}
68
69
face =
facings
== -1 ? 0 : 1;
70
while
(widget < 8)
71
{
72
myWidgets
[widget]->setVisible(
true
);
73
QList<int>
faces
;
74
for
(faceCurrent = 0; faceCurrent < faceCount; faceCurrent++)
75
faces
.append(animation->
faces
[face++]->
number
);
76
myWidgets
[widget]->setAnimation(
faces
);
77
78
widget += widgetStep;
79
}
80
}
81
82
void
CREAnimationControl::step
()
83
{
84
if
(
myAnimation
== NULL)
85
return
;
86
87
for
(
int
w = 0; w <
myWidgets
.size(); w++)
88
myWidgets
[w]->
step
();
89
}
CREAnimationControl::step
void step()
Definition:
CREAnimationControl.cpp:82
layout
Definition:
main.c:85
face.h
CREAnimationControl::setAnimation
void setAnimation(const Animations *animation, int facings=-1)
Definition:
CREAnimationControl.cpp:29
make_face_from_files.facings
list facings
Definition:
make_face_from_files.py:38
CREAnimationControl::myAnimation
const Animations * myAnimation
Definition:
CREAnimationControl.h:29
freearr_x
short freearr_x[SIZEOFFREE]
Definition:
object.c:288
freearr_y
short freearr_y[SIZEOFFREE]
Definition:
object.c:294
CREAnimationControl::CREAnimationControl
CREAnimationControl(QWidget *parent)
Definition:
CREAnimationControl.cpp:7
Face::number
uint16_t number
Definition:
face.h:15
animations_struct::num_animations
uint8_t num_animations
Definition:
face.h:27
CREAnimationControl.h
CREAnimationControl::myWidgets
QList< CREAnimationWidget * > myWidgets
Definition:
CREAnimationControl.h:35
CREAnimationControl::display
void display(const Animations *animation, int facings=-1)
Definition:
CREAnimationControl.cpp:37
animations_struct
Definition:
face.h:25
animations_struct::facings
uint8_t facings
Definition:
face.h:28
animations_struct::faces
const Face ** faces
Definition:
face.h:30
CREAnimationControl::myTimer
QTimer * myTimer
Definition:
CREAnimationControl.h:36
CREAnimationWidget
Definition:
CREAnimationWidget.h:7
dragon_attune.faces
dictionary faces
Definition:
dragon_attune.py:31
CREAnimationControl::myLastStep
int myLastStep
Definition:
CREAnimationControl.h:31
CREAnimationWidget.h
connect
Definition:
connect.py:1
CREAnimationControl::myFacings
int myFacings
Definition:
CREAnimationControl.h:32
CREAnimationControl::myStep
int myStep
Definition:
CREAnimationControl.h:30
crossfire-crossfire-server
utils
cre
CREAnimationControl.cpp
Generated by
1.8.17