]> git.localhorst.tv Git - blank.git/blob - src/ui/Interface.hpp
"streamlined" model/VAO handling
[blank.git] / src / ui / Interface.hpp
1 #ifndef BLANK_UI_INTERFACE_HPP_
2 #define BLANK_UI_INTERFACE_HPP_
3
4 #include "HUD.hpp"
5 #include "../app/FPSController.hpp"
6 #include "../app/IntervalTimer.hpp"
7 #include "../audio/Sound.hpp"
8 #include "../graphics/FixedText.hpp"
9 #include "../graphics/Font.hpp"
10 #include "../graphics/MessageBox.hpp"
11 #include "../model/geometry.hpp"
12 #include "../model/OutlineModel.hpp"
13 #include "../world/Block.hpp"
14
15 #include <string>
16 #include <glm/glm.hpp>
17
18
19 namespace blank {
20
21 class Assets;
22 class Audio;
23 class Chunk;
24 class FrameCounter;
25 class Viewport;
26 class World;
27
28 class Interface {
29
30 public:
31         struct Config {
32                 float move_velocity = 0.005f;
33                 float pitch_sensitivity = -0.0025f;
34                 float yaw_sensitivity = -0.001f;
35
36                 bool keyboard_disabled = false;
37                 bool mouse_disabled = false;
38                 bool audio_disabled = false;
39                 bool visual_disabled = false;
40         };
41
42         Interface(const Config &, const Assets &, Audio &, const FrameCounter &, World &);
43
44         void HandlePress(const SDL_KeyboardEvent &);
45         void HandleRelease(const SDL_KeyboardEvent &);
46         void Handle(const SDL_MouseMotionEvent &);
47         void HandlePress(const SDL_MouseButtonEvent &);
48         void HandleRelease(const SDL_MouseButtonEvent &);
49         void Handle(const SDL_MouseWheelEvent &);
50
51         void FaceBlock();
52         void TurnBlock();
53
54         void ToggleCollision();
55
56         void PickBlock();
57         void PlaceBlock();
58         void RemoveBlock() noexcept;
59
60         void PrintBlockInfo();
61         void PrintChunkInfo();
62         void PrintLightInfo();
63         void PrintSelectionInfo();
64         void Print(const Block &);
65
66         void SelectNext();
67         void SelectPrevious();
68
69         void ToggleAudio();
70         void ToggleVisual();
71
72         void ToggleCounter();
73         void UpdateCounter();
74
75         void PostMessage(const char *);
76         void PostMessage(const std::string &msg) {
77                 PostMessage(msg.c_str());
78         }
79
80         void Update(int dt);
81
82         void Render(Viewport &) noexcept;
83
84 private:
85         void CheckAim();
86
87 private:
88         Audio &audio;
89         const FrameCounter &counter;
90         World &world;
91         FPSController ctrl;
92         Font font;
93         HUD hud;
94
95         Ray aim;
96         Chunk *aim_chunk;
97         int aim_block;
98         glm::vec3 aim_normal;
99
100         OutlineModel outline;
101         glm::mat4 outline_transform;
102
103         FixedText counter_text;
104         MessageBox messages;
105         IntervalTimer msg_timer;
106
107         Config config;
108
109         IntervalTimer place_timer;
110         IntervalTimer remove_timer;
111
112         Block remove;
113         Block selection;
114
115         Sound place_sound;
116         Sound remove_sound;
117
118         glm::tvec3<int> fwd, rev;
119
120 };
121
122 }
123
124 #endif