]> git.localhorst.tv Git - blank.git/blob - src/ui/Interface.hpp
some code reorganization
[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 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