-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTransition.cpp
More file actions
114 lines (101 loc) · 2.39 KB
/
Transition.cpp
File metadata and controls
114 lines (101 loc) · 2.39 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/** @file Transition.cpp */
#include "Transition.h"
#include "TransitionFade.h"
#include "System.h"
#include <iostream>
/**
* @brief Creates a transition effect.
* @param direction direction of the transition effect (in or out)
*/
Transition::Transition(Transition::Direction direction):
game(NULL),
direction(direction),
previous_surface(NULL),
suspended(false),
when_suspended(0)
{
}
Transition::~Transition()
{
}
/**
* @brief Returns the current game.
*
* Some transition effects need a game to run.
*
* @return The current game or NULL.
*/
Game* Transition::get_game() const
{
return game;
}
/**
* @brief Returns the direction of this transition effect.
* @returns the direction of this transition effect: Transition::IN or Transition::OUT
*/
Transition::Direction Transition::get_direction() const
{
return direction;
}
/**
* @brief Returns the surface to show during the OUT transition
* that was played before this IN transition.
* @return The previous surface or NULL.
*/
Surface* Transition::get_previous_surface() const
{
return previous_surface;
}
/**
* @brief Indicates the surface that was shown during the OUT transition
* that was played before this IN transition.
* @param previous_surface The previous surface or NULL.
*/
void Transition::set_previous_surface(Surface* previous_surface)
{
if(!(previous_surface == NULL || get_direction() != OUT))
{
std::cerr << "Cannot show a previous surface with an OUT transition effect\n";
}
this->previous_surface = previous_surface;
}
/**
* @brief Returns whether this transition effect needs the previous surface.
* @return false
*/
bool Transition::needs_previous_surface() const
{
return false;
}
/**
* @brief Returns whether this transition is currently suspended.
* @return true if this transition is suspended.
*/
bool Transition::is_suspended() const
{
return suspended;
}
/**
* @brief Suspends or resumes this transition.
* @param suspended true to suspend it, false to resume it.
*/
void Transition::set_suspended(bool suspended)
{
if (suspended != this->suspended)
{
this->suspended = suspended;
if (suspended)
{
when_suspended = System::now();
}
notify_suspended(suspended);
}
}
/**
* @brief Returns the date when this transition was suspended if it is.
* @return The date when this transition was suspended or 0.
*/
uint32_t Transition::get_when_suspended() const
{
return when_suspended;
}