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