X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fapp%2FApplication.hpp;h=359599ef73750de04c0ee3de16c489690114a005;hb=d2f4c8720ae2326fac4203fa4984d835e875b355;hp=9644794c1e7d54a9ff5bade9b0c9a0f9c155a5d5;hpb=745729c1935276e6f49d108a0a465214aa93c3cb;p=blank.git diff --git a/src/app/Application.hpp b/src/app/Application.hpp index 9644794..359599e 100644 --- a/src/app/Application.hpp +++ b/src/app/Application.hpp @@ -1,43 +1,34 @@ #ifndef BLANK_APP_APPLICATION_HPP_ #define BLANK_APP_APPLICATION_HPP_ -#include "Assets.hpp" -#include "FrameCounter.hpp" -#include "../ai/RandomWalk.hpp" -#include "../audio/Audio.hpp" -#include "../graphics/Viewport.hpp" -#include "../ui/Interface.hpp" -#include "../world/World.hpp" - #include +#include namespace blank { +class Environment; +class HeadlessEnvironment; +class State; class Window; -class Application { +class HeadlessApplication { public: - struct Config { - bool vsync = true; - bool doublebuf = true; - int multisampling = 1; - - Interface::Config interface = Interface::Config(); - World::Config world = World::Config(); - }; + explicit HeadlessApplication(HeadlessEnvironment &); + ~HeadlessApplication(); - Application(Window &, const Config &); - ~Application(); + void PushState(State *); + State *PopState(); + State *SwitchState(State *); + State &GetState(); + void CommitStates(); + bool HasState() const noexcept; - Application(const Application &) = delete; - Application &operator =(const Application &) = delete; - - /// 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); @@ -48,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: - Window &window; - Viewport viewport; - Assets assets; - Audio audio; - FrameCounter counter; + HeadlessEnvironment &env; + std::stack states; + +}; + + +class Application +: public HeadlessApplication { - World world; - Interface interface; +public: + explicit Application(Environment &); + ~Application(); - RandomWalk test_controller; + 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(); - bool running; +private: + Environment &env; };