X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fapp%2FState.cpp;h=fc6c8067acfb4782bb1fe9c41f5272fdbdaa0273;hb=7b3710c47f24e64e0d01378a4564730bcb2f6ef2;hp=50b5bf601bc52c7027ce7408cc9410f3e767815d;hpb=7252571fb926a187c4c40e8f4eec718f16d63ffa;p=l2e.git diff --git a/src/app/State.cpp b/src/app/State.cpp index 50b5bf6..fc6c806 100644 --- a/src/app/State.cpp +++ b/src/app/State.cpp @@ -1,37 +1,58 @@ -/* - * State.cpp - * - * Created on: Oct 17, 2012 - * Author: holy - */ - #include "State.h" +#include + +using std::domain_error; + namespace app { +State::State() +: ctrl(0) { + +} + State::~State() { } -void State::EnterState(Application &ctrl, SDL_Surface *screen) { - OnEnterState(ctrl, screen); +void State::EnterState(Application &c, SDL_Surface *screen) { + ctrl = &c; + OnEnterState(screen); } -void State::ExitState(Application &ctrl, SDL_Surface *screen) { - OnExitState(ctrl, screen); +void State::ExitState(Application &c, SDL_Surface *screen) { + OnExitState(screen); + ctrl = 0; } -void State::ResumeState(Application &ctrl, SDL_Surface *screen) { - OnResumeState(ctrl, screen); +void State::ResumeState(SDL_Surface *screen) { + OnResumeState(screen); } -void State::PauseState(Application &ctrl, SDL_Surface *screen) { - OnPauseState(ctrl, screen); +void State::PauseState(SDL_Surface *screen) { + OnPauseState(screen); } void State::Resize(int width, int height) { OnResize(width, height); } + +Application &State::Ctrl() { + if (ctrl) { + return *ctrl; + } else { + throw domain_error("call to app::State::Ctrl() without application context"); + } +} + +const Application &State::Ctrl() const { + if (ctrl) { + return *ctrl; + } else { + throw domain_error("call to app::State::Ctrl() without application context"); + } +} + }