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