]> git.localhorst.tv Git - l2e.git/blob - src/graphics/ColorFade.h
079d30ea74a44a49f53c0707d6136fc9f97c8a96
[l2e.git] / src / graphics / ColorFade.h
1 /*
2  * ColorFade.h
3  *
4  *  Created on: Oct 7, 2012
5  *      Author: holy
6  */
7
8 #ifndef GRAPHICS_COLORFADE_H_
9 #define GRAPHICS_COLORFADE_H_
10
11 #include "../app/State.h"
12 #include "../app/Timer.h"
13
14 #include <SDL.h>
15
16 namespace graphics {
17
18 class ColorFade
19 : public app::State {
20
21 public:
22         ColorFade(app::State *slave, Uint32 color, int duration, bool in = false, bool interactive = false);
23         virtual ~ColorFade() { }
24
25 public:
26         void SetLeadInTime(int ms) { leadIn = ms; if (ms > 0) leadInDone = false; }
27         void SetLeadOutTime(int ms) { leadOut = ms; }
28
29 public:
30         virtual void HandleEvents(const app::Input &);
31         virtual void UpdateWorld(float deltaT);
32         virtual void Render(SDL_Surface *);
33
34 private:
35         virtual void OnEnterState(SDL_Surface *screen);
36         virtual void OnExitState(SDL_Surface *screen);
37         virtual void OnResumeState(SDL_Surface *screen);
38         virtual void OnPauseState(SDL_Surface *screen);
39
40         virtual void OnResize(int width, int height);
41
42 private:
43         void UpdateBlinds(int width, int height);
44         Uint8 GetAlpha() const;
45
46 private:
47         app::Timer<Uint32> timer;
48         app::State *slave;
49         SDL_Surface *blinds;
50         Uint32 color;
51         int duration;
52         int leadIn;
53         int leadOut;
54         bool leadInDone;
55         bool fadeDone;
56         bool in;
57         bool interactive;
58
59 };
60
61 }
62
63 #endif /* GRAPHICS_COLORFADE_H_ */