summaryrefslogtreecommitdiffstats
path: root/include/game.hpp
diff options
context:
space:
mode:
authorJon Santmyer <jon@jonsantmyer.com>2022-06-22 17:41:59 -0400
committerJon Santmyer <jon@jonsantmyer.com>2022-06-22 17:41:59 -0400
commit5e3a2492c7bb73daa4e27398daaf490d09980ff3 (patch)
tree75178d823d596b6a898002c3f1d45b9ceede0e1e /include/game.hpp
downloadsystemviewer-5e3a2492c7bb73daa4e27398daaf490d09980ff3.tar.gz
systemviewer-5e3a2492c7bb73daa4e27398daaf490d09980ff3.tar.bz2
systemviewer-5e3a2492c7bb73daa4e27398daaf490d09980ff3.zip
Base system viewer with data loaded from csv files
Diffstat (limited to 'include/game.hpp')
-rw-r--r--include/game.hpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/include/game.hpp b/include/game.hpp
new file mode 100644
index 0000000..9454318
--- /dev/null
+++ b/include/game.hpp
@@ -0,0 +1,52 @@
+#ifndef GAME_HPP
+#define GAME_HPP 1
+
+#include "window.hpp"
+#include "camera.hpp"
+#include "ecs.hpp"
+#include "system.hpp"
+#include "timeman.hpp"
+#include "input.hpp"
+
+#include <memory>
+
+#define WINCTX_GAME "Game"
+
+class Game
+{
+public:
+ enum class State {
+ STOPPED, RUNNING, RUNNING_INPUT, PAUSED, PAUSED_INPUT
+ };
+
+ static void setup(unsigned w, unsigned h);
+ static void cleanup();
+
+ static void turn();
+ static void setState(State state) { m_state = state; }
+ static void setContext(const std::string &id) { m_currentContext = id; }
+
+ static bool running() { return m_state != State::STOPPED; }
+ static bool paused() { return m_state == State::PAUSED || m_state == State::PAUSED_INPUT; }
+ static bool inputMode() { return m_state == State::RUNNING_INPUT || m_state == State::PAUSED_INPUT; }
+
+ struct WindowContexts {
+ WindowContext &operator[](const std::string &id) { return Game::m_contexts.at(id); }
+ WindowContext &operator()() { return Game::m_contexts.at(Game::m_currentContext); }
+ };
+ static WindowContexts contexts;
+private:
+ static std::unordered_map<std::string, WindowContext> m_contexts;
+ static std::string m_currentContext;
+
+ static std::unique_ptr<Camera> m_camera;
+ static std::unique_ptr<System> m_system;
+ static SystemView m_systemView;
+
+ static input::Context m_inputContext;
+
+ static double m_delta;
+ static State m_state;
+};
+
+#endif