]> git.localhorst.tv Git - l2e.git/blob - src/app/State.h
commented headers in app/ directory
[l2e.git] / src / app / State.h
1 /*
2  * State.h
3  *
4  *  Created on: Apr 8, 2012
5  *      Author: holy
6  */
7
8 #ifndef APP_APPLICATIONSTATE_H_
9 #define APP_APPLICATIONSTATE_H_
10
11 #include "fwd.h"
12 #include "Timer.h"
13
14 #include <SDL.h>
15
16 namespace app {
17
18 /// Application state base class for use with app::Application.
19 class State {
20
21 public:
22         virtual ~State() { };
23
24 public:
25         /// Do some setup that needs an application and/or screen handle and thus
26         /// can not be done by the constructor.
27         /// Called when the state first enters the stack.
28         /// @param ctrl the Application running the state
29         virtual void EnterState(Application &ctrl, SDL_Surface *screen) = 0;
30         /// Do some cleanup.
31         /// Called when the state is popped from the stack.
32         virtual void ExitState(Application &ctrl, SDL_Surface *screen) = 0;
33         /// Called when the state becomes the active one.
34         virtual void ResumeState(Application &ctrl, SDL_Surface *screen) = 0;
35         /// Called when the state becomes inactive.
36         virtual void PauseState(Application &ctrl, SDL_Surface *screen) = 0;
37
38         /// Adapt the state's graphics to given dimensions.
39         /// NOTE: currently, this is only called for the stack top and not
40         ///       propagated on stack changes.
41         ///       Will be fixed soom ;).
42         virtual void Resize(int width, int height) = 0;
43
44         /// Handle interactive events such as input and timers.
45         virtual void HandleEvents(const Input &) = 0;
46         /// Update the time-dependant world representation.
47         virtual void UpdateWorld(float deltaT) = 0;
48         /// Draw a picture of the world.
49         virtual void Render(SDL_Surface *) = 0;
50
51 public:
52         /// Timers handle intended for graphics, sync'ed with render time.
53         /// These timers are only updated for the stack top and thus appear paused
54         /// when the state is visible (roughly).
55         Timers<Uint32> &GraphicsTimers() { return graphicsTimers; }
56         /// Timers handle intended for graphics, sync'ed with world time.
57         /// These timers are only updated for the stack top and thus appear paused
58         /// when the state is visible (roughly).
59         Timers<float> &PhysicsTimers() { return physicsTimers; }
60
61 private:
62         Timers<Uint32> graphicsTimers;
63         Timers<float> physicsTimers;
64
65 };
66
67 }
68
69 #endif /* APP_STATE_H_ */