]> git.localhorst.tv Git - l2e.git/blob - src/graphics/ColorFade.h
renamed app::State's Resize -> OnResize
[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 OnEnterState(app::Application &ctrl, SDL_Surface *screen);
31         virtual void OnExitState(app::Application &ctrl, SDL_Surface *screen);
32         virtual void OnResumeState(app::Application &ctrl, SDL_Surface *screen);
33         virtual void OnPauseState(app::Application &ctrl, SDL_Surface *screen);
34
35         virtual void OnResize(int width, int height);
36
37         virtual void HandleEvents(const app::Input &);
38         virtual void UpdateWorld(float deltaT);
39         virtual void Render(SDL_Surface *);
40
41 private:
42         void UpdateBlinds(int width, int height);
43         Uint8 GetAlpha() const;
44
45 private:
46         app::Timer<Uint32> timer;
47         app::Application *ctrl;
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_ */