]> git.localhorst.tv Git - l2e.git/blob - State.cpp
fc6c8067acfb4782bb1fe9c41f5272fdbdaa0273
[l2e.git] / State.cpp
1 #include "State.h"
2
3 #include <stdexcept>
4
5 using std::domain_error;
6
7 namespace app {
8
9 State::State()
10 : ctrl(0) {
11
12 }
13
14 State::~State() {
15
16 }
17
18
19 void State::EnterState(Application &c, SDL_Surface *screen) {
20         ctrl = &c;
21         OnEnterState(screen);
22 }
23
24 void State::ExitState(Application &c, SDL_Surface *screen) {
25         OnExitState(screen);
26         ctrl = 0;
27 }
28
29 void State::ResumeState(SDL_Surface *screen) {
30         OnResumeState(screen);
31 }
32
33 void State::PauseState(SDL_Surface *screen) {
34         OnPauseState(screen);
35 }
36
37 void State::Resize(int width, int height) {
38         OnResize(width, height);
39 }
40
41
42 Application &State::Ctrl() {
43         if (ctrl) {
44                 return *ctrl;
45         } else {
46                 throw domain_error("call to app::State::Ctrl() without application context");
47         }
48 }
49
50 const Application &State::Ctrl() const {
51         if (ctrl) {
52                 return *ctrl;
53         } else {
54                 throw domain_error("call to app::State::Ctrl() without application context");
55         }
56 }
57
58 }