]> git.localhorst.tv Git - blobs.git/blob - src/app/MasterState.hpp
test basic interaction
[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::BodyPanel &GetBodyPanel() noexcept { return bp; }
45         const ui::BodyPanel &GetBodyPanel() const noexcept { return bp; }
46
47         ui::CreaturePanel &GetCreaturePanel() noexcept { return cp; }
48         const ui::CreaturePanel &GetCreaturePanel() const noexcept { return cp; }
49
50         ui::RecordsPanel &GetRecordsPanel() noexcept { return rp; }
51         const ui::RecordsPanel &GetRecordsPanel() const noexcept { return rp; }
52
53         ui::TimePanel &GetTimePanel() noexcept { return tp; }
54         const ui::TimePanel &GetTimePanel() const noexcept { return tp; }
55
56 private:
57         void OnResize(int w, int h) override;
58
59         void OnKeyDown(const SDL_KeyboardEvent &) override;
60         void OnMouseDown(const SDL_MouseButtonEvent &) override;
61         void OnMouseUp(const SDL_MouseButtonEvent &) override;
62         void OnMouseMotion(const SDL_MouseMotionEvent &) override;
63         void OnMouseWheel(const SDL_MouseWheelEvent &) override;
64
65         void OnUpdate(int dt) override;
66         void OnRender(graphics::Viewport &) override;
67
68         void Tick();
69         int FrameMS() const noexcept;
70
71 private:
72         Assets &assets;
73         world::Simulation ∼
74
75         graphics::Camera cam;
76         glm::dvec3 cam_pos;
77         glm::dvec3 cam_tgt_pos;
78         glm::dvec3 cam_focus;
79         glm::dvec3 cam_tgt_focus;
80         glm::dvec3 cam_up;
81         glm::dvec3 cam_tgt_up;
82         double cam_dist;
83         glm::dvec3 cam_orient;
84         bool cam_dragging;
85
86         creature::Creature *shown_creature;
87         world::Body *shown_body;
88
89         ui::BodyPanel bp;
90         ui::CreaturePanel cp;
91         ui::RecordsPanel rp;
92         ui::TimePanel tp;
93
94         int remain;
95         int thirds;
96         bool paused;
97
98 };
99
100 }
101 }
102
103 #endif