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