]> git.localhorst.tv Git - l2e.git/blobdiff - src/app/Application.h
made application state changes yet a bit safer
[l2e.git] / src / app / Application.h
index dcc5e006c0dc36d28b65859bcbb048761cfc96be..5e9e88838dfb05db9ae0dc4d11dc64dacd8b7275 100644 (file)
@@ -41,9 +41,19 @@ public:
        Input &Buttons() { return input; }
        const Input &Buttons() const { return input; }
 
+private:
+       struct StateCommand {
+               enum Type {
+                       PUSH, POP, CHANGE
+               } type;
+               State *state;
+       };
+
 private:
        State *CurrentState();
+       bool StateChangePending() const { return !stateChanges.empty(); }
        void UpdateState();
+       void RealChangeState(State *);
        void RealPushState(State *);
        void RealPopState();
        void PopAllStates();
@@ -56,10 +66,9 @@ private:
 private:
        sdl::InitScreen *screen;
        std::stack<State *> states;
-       std::queue<State *> toPush;
+       std::queue<StateCommand> stateChanges;
        Input input;
        Uint32 last;
-       int toPop;
 
 };