]> git.localhorst.tv Git - blank.git/blob - src/ui/Interface.hpp
1e2e8834ba7a507f369661e4f68ca84eba583749
[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 <glm/glm.hpp>
13
14
15 namespace blank {
16
17 class Assets;
18 class Chunk;
19 class FrameCounter;
20 class Viewport;
21 class World;
22
23 class Interface {
24
25 public:
26         struct Config {
27                 float move_velocity = 0.005f;
28                 float pitch_sensitivity = -0.0025f;
29                 float yaw_sensitivity = -0.001f;
30
31                 bool keyboard_disabled = false;
32                 bool mouse_disabled = false;
33                 bool visual_disabled = false;
34         };
35
36         Interface(const Config &, const Assets &, const FrameCounter &, World &);
37
38         void HandlePress(const SDL_KeyboardEvent &);
39         void HandleRelease(const SDL_KeyboardEvent &);
40         void Handle(const SDL_MouseMotionEvent &);
41         void HandlePress(const SDL_MouseButtonEvent &);
42         void HandleRelease(const SDL_MouseButtonEvent &);
43         void Handle(const SDL_MouseWheelEvent &);
44
45         void Resize(const Viewport &);
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 ToggleCounter();
66         void UpdateCounter();
67
68         void Update(int dt);
69
70         void Render(Viewport &) noexcept;
71
72 private:
73         void CheckAim();
74
75 private:
76         const FrameCounter &counter;
77         World &world;
78         FPSController ctrl;
79         Font font;
80         HUD hud;
81
82         Ray aim;
83         Chunk *aim_chunk;
84         int aim_block;
85         glm::vec3 aim_normal;
86
87         OutlineModel outline;
88         glm::mat4 outline_transform;
89
90         bool show_counter;
91         Texture counter_tex;
92         SpriteModel counter_sprite;
93         glm::mat4 counter_transform;
94         float counter_x;
95
96         Config config;
97
98         IntervalTimer place_timer;
99         IntervalTimer remove_timer;
100
101         Block remove;
102         Block selection;
103
104         glm::tvec3<int> fwd, rev;
105
106 };
107
108 }
109
110 #endif