]> git.localhorst.tv Git - blank.git/blobdiff - src/app/Application.hpp
cleanup
[blank.git] / src / app / Application.hpp
index 636b82e85899c389a7f69437a001495b638ec428..359599ef73750de04c0ee3de16c489690114a005 100644 (file)
@@ -1,42 +1,34 @@
 #ifndef BLANK_APP_APPLICATION_HPP_
 #define BLANK_APP_APPLICATION_HPP_
 
-#include "Assets.hpp"
-#include "FrameCounter.hpp"
-#include "init.hpp"
-#include "RandomWalk.hpp"
-#include "../audio/Audio.hpp"
-#include "../graphics/Viewport.hpp"
-#include "../ui/Interface.hpp"
-#include "../world/World.hpp"
-
 #include <SDL.h>
+#include <stack>
 
 
 namespace blank {
 
-class Application {
-
-public:
-       struct Config {
-               bool vsync = true;
-               bool doublebuf = true;
-               int multisampling = 1;
+class Environment;
+class HeadlessEnvironment;
+class State;
+class Window;
 
-               Interface::Config interface = Interface::Config();
-               World::Config world = World::Config();
-       };
+class HeadlessApplication {
 
-       explicit Application(const Config &);
-       ~Application();
+public:
+       explicit HeadlessApplication(HeadlessEnvironment &);
+       ~HeadlessApplication();
 
-       Application(const Application &) = delete;
-       Application &operator =(const Application &) = delete;
+       void PushState(State *);
+       State *PopState();
+       State *SwitchState(State *);
+       State &GetState();
+       void CommitStates();
+       bool HasState() const noexcept;
 
-       /// run until user quits
+       /// run until out of states
        void Run();
        /// evaluate a single frame of dt milliseconds
-       void Loop(int dt);
+       virtual void Loop(int dt);
 
        /// run for n frames
        void RunN(size_t n);
@@ -47,27 +39,40 @@ public:
 
        /// process all events in SDL's queue
        void HandleEvents();
-       void Handle(const SDL_WindowEvent &);
+       void Handle(const SDL_Event &);
        /// integrate to the next step with dt milliseconds passed
        void Update(int dt);
-       /// push the current state to display
-       void Render();
-
-       static Entity &MakeTestEntity(World &);
 
 private:
-       Init init;
-       Viewport viewport;
-       Assets assets;
-       Audio audio;
-       FrameCounter counter;
+       HeadlessEnvironment &env;
+       std::stack<State *> states;
 
-       World world;
-       Interface interface;
+};
 
-       RandomWalk test_controller;
 
-       bool running;
+class Application
+: public HeadlessApplication {
+
+public:
+       explicit Application(Environment &);
+       ~Application();
+
+       Application(const Application &) = delete;
+       Application &operator =(const Application &) = delete;
+
+       void Loop(int dt) override;
+
+       /// process all events in SDL's queue
+       void HandleEvents();
+       void Handle(const SDL_Event &);
+       void Handle(const SDL_WindowEvent &);
+       /// integrate to the next step with dt milliseconds passed
+       void Update(int dt);
+       /// push the current state to display
+       void Render();
+
+private:
+       Environment &env;
 
 };