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