]> git.localhorst.tv Git - blank.git/blob - src/ui/Interface.hpp
combine text handling stuff into a class
[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 "../graphics/Font.hpp"
8 #include "../graphics/Text.hpp"
9 #include "../model/geometry.hpp"
10 #include "../model/OutlineModel.hpp"
11 #include "../world/Block.hpp"
12
13 #include <glm/glm.hpp>
14
15
16 namespace blank {
17
18 class Assets;
19 class Chunk;
20 class FrameCounter;
21 class Viewport;
22 class World;
23
24 class Interface {
25
26 public:
27         struct Config {
28                 float move_velocity = 0.005f;
29                 float pitch_sensitivity = -0.0025f;
30                 float yaw_sensitivity = -0.001f;
31
32                 bool keyboard_disabled = false;
33                 bool mouse_disabled = false;
34                 bool visual_disabled = false;
35         };
36
37         Interface(const Config &, const Assets &, const FrameCounter &, World &);
38
39         void HandlePress(const SDL_KeyboardEvent &);
40         void HandleRelease(const SDL_KeyboardEvent &);
41         void Handle(const SDL_MouseMotionEvent &);
42         void HandlePress(const SDL_MouseButtonEvent &);
43         void HandleRelease(const SDL_MouseButtonEvent &);
44         void Handle(const SDL_MouseWheelEvent &);
45
46         void FaceBlock();
47         void TurnBlock();
48
49         void ToggleCollision();
50
51         void PickBlock();
52         void PlaceBlock();
53         void RemoveBlock() noexcept;
54
55         void PrintBlockInfo();
56         void PrintChunkInfo();
57         void PrintLightInfo();
58         void PrintSelectionInfo();
59         void Print(const Block &);
60
61         void SelectNext();
62         void SelectPrevious();
63
64         void ToggleCounter();
65         void UpdateCounter();
66
67         void Update(int dt);
68
69         void Render(Viewport &) noexcept;
70
71 private:
72         void CheckAim();
73
74 private:
75         const FrameCounter &counter;
76         World &world;
77         FPSController ctrl;
78         Font font;
79         HUD hud;
80
81         Ray aim;
82         Chunk *aim_chunk;
83         int aim_block;
84         glm::vec3 aim_normal;
85
86         OutlineModel outline;
87         glm::mat4 outline_transform;
88
89         Text counter_text;
90
91         Config config;
92
93         IntervalTimer place_timer;
94         IntervalTimer remove_timer;
95
96         Block remove;
97         Block selection;
98
99         glm::tvec3<int> fwd, rev;
100
101 };
102
103 }
104
105 #endif