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