]> git.localhorst.tv Git - blank.git/blob - src/interface.hpp
9f43f4f6f662b6ba10b71d0706ebf5b202e9887b
[blank.git] / src / interface.hpp
1 #ifndef BLANK_INTERFACE_HPP_
2 #define BLANK_INTERFACE_HPP_
3
4 #include "block.hpp"
5 #include "controller.hpp"
6 #include "geometry.hpp"
7 #include "hud.hpp"
8 #include "model.hpp"
9 #include "shader.hpp"
10 #include "timer.hpp"
11
12 #include <SDL.h>
13 #include <glm/glm.hpp>
14
15
16 namespace blank {
17
18 class Chunk;
19 class World;
20
21 class Interface {
22
23 public:
24         struct Config {
25                 float move_velocity = 0.005f;
26                 float pitch_sensitivity = -0.0025f;
27                 float yaw_sensitivity = -0.001f;
28
29                 bool keyboard_disabled = false;
30                 bool mouse_disabled = false;
31                 bool visual_disabled = false;
32         };
33
34         Interface(const Config &, World &);
35
36         void HandlePress(const SDL_KeyboardEvent &);
37         void HandleRelease(const SDL_KeyboardEvent &);
38         void Handle(const SDL_MouseMotionEvent &);
39         void HandlePress(const SDL_MouseButtonEvent &);
40         void HandleRelease(const SDL_MouseButtonEvent &);
41         void Handle(const SDL_MouseWheelEvent &);
42         void Handle(const SDL_WindowEvent &) noexcept;
43
44         void FaceBlock();
45         void TurnBlock();
46
47         void PickBlock();
48         void PlaceBlock();
49         void RemoveBlock() noexcept;
50
51         void PrintBlockInfo();
52         void PrintChunkInfo();
53         void PrintLightInfo();
54         void PrintSelectionInfo();
55         void Print(const Block &);
56
57         void SelectNext();
58         void SelectPrevious();
59
60         void Update(int dt);
61
62         void Render(DirectionalLighting &) noexcept;
63
64 private:
65         void CheckAim();
66
67 private:
68         World &world;
69         FPSController ctrl;
70         HUD hud;
71
72         Ray aim;
73         Chunk *aim_chunk;
74         int aim_block;
75         glm::vec3 aim_normal;
76
77         OutlineModel outline;
78         glm::mat4 outline_transform;
79
80         Config config;
81
82         IntervalTimer place_timer;
83         IntervalTimer remove_timer;
84
85         Block remove;
86         Block selection;
87
88         glm::tvec3<int> fwd, rev;
89
90 };
91
92 }
93
94 #endif