]> git.localhorst.tv Git - blank.git/blob - src/ui/Interface.hpp
set and display block type labels
[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 "../model/geometry.hpp"
9 #include "../model/OutlineModel.hpp"
10 #include "../world/Block.hpp"
11
12 #include <SDL.h>
13 #include <glm/glm.hpp>
14
15
16 namespace blank {
17
18 class Chunk;
19 class BlendedSprite;
20 class DirectionalLighting;
21 class Assets;
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 &, 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         void Handle(const SDL_WindowEvent &) noexcept;
46
47         void FaceBlock();
48         void TurnBlock();
49
50         void ToggleCollision();
51
52         void PickBlock();
53         void PlaceBlock();
54         void RemoveBlock() noexcept;
55
56         void PrintBlockInfo();
57         void PrintChunkInfo();
58         void PrintLightInfo();
59         void PrintSelectionInfo();
60         void Print(const Block &);
61
62         void SelectNext();
63         void SelectPrevious();
64
65         void Update(int dt);
66
67         void Render(DirectionalLighting &, BlendedSprite &) noexcept;
68
69 private:
70         void CheckAim();
71
72 private:
73         World &world;
74         FPSController ctrl;
75         Font font;
76         HUD hud;
77
78         Ray aim;
79         Chunk *aim_chunk;
80         int aim_block;
81         glm::vec3 aim_normal;
82
83         OutlineModel outline;
84         glm::mat4 outline_transform;
85
86         Config config;
87
88         IntervalTimer place_timer;
89         IntervalTimer remove_timer;
90
91         Block remove;
92         Block selection;
93
94         glm::tvec3<int> fwd, rev;
95
96 };
97
98 }
99
100 #endif