]> git.localhorst.tv Git - blobs.git/blob - src/app/MasterState.hpp
8290e86886b53d59c246ea36d076c34acadf4dfd
[blobs.git] / src / app / MasterState.hpp
1 #ifndef BLOBS_APP_MASTERSTATE_HPP_
2 #define BLOBS_APP_MASTERSTATE_HPP_
3
4 #include "State.hpp"
5
6 #include "Assets.hpp"
7 #include "../graphics/Camera.hpp"
8 #include "../ui/CreaturePanel.hpp"
9 #include "../ui/RecordsPanel.hpp"
10 #include "../ui/TimePanel.hpp"
11
12
13 namespace blobs {
14 namespace world {
15         class Body;
16         class Simulation;
17 }
18 namespace app {
19
20 class MasterState
21 : public State {
22
23 public:
24         MasterState(Assets &, world::Simulation &) noexcept;
25         ~MasterState() noexcept;
26
27         MasterState(const MasterState &) = delete;
28         MasterState &operator =(const MasterState &) = delete;
29
30         MasterState(MasterState &&) = delete;
31         MasterState &operator =(MasterState &&) = delete;
32
33 public:
34         graphics::Camera &GetCamera() noexcept { return cam; }
35         const graphics::Camera &GetCamera() const noexcept { return cam; }
36
37         ui::CreaturePanel &GetCreaturePanel() noexcept { return cp; }
38         const ui::CreaturePanel &GetCreaturePanel() const noexcept { return cp; }
39
40         ui::RecordsPanel &GetRecordsPanel() noexcept { return rp; }
41         const ui::RecordsPanel &GetRecordsPanel() const noexcept { return rp; }
42
43         ui::TimePanel &GetTimePanel() noexcept { return tp; }
44         const ui::TimePanel &GetTimePanel() const noexcept { return tp; }
45
46 private:
47         void OnResize(int w, int h) override;
48
49         void OnKeyDown(const SDL_KeyboardEvent &) override;
50         void OnMouseDown(const SDL_MouseButtonEvent &) override;
51         void OnMouseUp(const SDL_MouseButtonEvent &) override;
52         void OnMouseMotion(const SDL_MouseMotionEvent &) override;
53         void OnMouseWheel(const SDL_MouseWheelEvent &) override;
54
55         void OnUpdate(int dt) override;
56         void OnRender(graphics::Viewport &) override;
57
58         void Tick();
59         int FrameMS() const noexcept;
60
61 private:
62         Assets &assets;
63         world::Simulation ∼
64
65         graphics::Camera cam;
66         double cam_dist;
67         double cam_tgt_dist;
68         glm::dvec3 cam_orient;
69         bool cam_dragging;
70
71         ui::CreaturePanel cp;
72         ui::RecordsPanel rp;
73         ui::TimePanel tp;
74
75         int remain;
76         int thirds;
77         bool paused;
78
79 };
80
81 }
82 }
83
84 #endif