-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAnimationManager.cpp
85 lines (71 loc) · 1.71 KB
/
AnimationManager.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include "AnimationManager.h"
AnimationManager::AnimationManager() {
}
void AnimationManager::begin() {
//what do we have to do here?
}
int8_t AnimationManager::addAnimation(LampAnimation* anim) {
if(num_animations < max_animations) {
anims[num_animations] = anim;
int8_t ret = num_animations;
num_animations++;
return ret;
}
}
LampAnimation* AnimationManager::getAnimation(int8_t idx) {
if(idx < num_animations) {
return anims[idx];
}
}
LampAnimation* AnimationManager::getCurrentAnimation() {
if(cur_animation < num_animations) {
return anims[cur_animation];
}
}
void AnimationManager::switchAnimation(int8_t idx) {
if(idx < num_animations) {
cur_animation = idx;
}
}
int AnimationManager::switchAnimationByName(String name) {
for(int i = 0; i < num_animations; i++) {
if(anims[i]->getName() == name) {
cur_animation = i;
return i;
}
}
return -1;
}
int8_t AnimationManager::getNumAnimations() {
return num_animations;
}
//gets an array of animation names
String AnimationManager::getAnimationNames() {
String names;
for(int8_t i = 0; i < num_animations; i++) {
if(i > 0) {
names+=",";
}
names += (String) anims[i]->getName();
}
return names;
}
//itterates the current animation
int AnimationManager::itterate() {
return anims[cur_animation]->itterate();
}
//resets the current animation
void AnimationManager::reset() {
anims[cur_animation]->reset();
}
void AnimationManager::setSpeed(uint8_t percent) {
speed = percent;
anims[cur_animation]->setSpeed(percent);
}
Lamp* AnimationManager::getLamp() {
return anims[cur_animation]->getLamp();
}
void AnimationManager::loop() {
setSpeed(speed);
itterate();
}