]> git.localhorst.tv Git - blank.git/blob - src/ui/Interface.hpp
display focused entity in debug overlay
[blank.git] / src / ui / Interface.hpp
1 #ifndef BLANK_UI_INTERFACE_HPP_
2 #define BLANK_UI_INTERFACE_HPP_
3
4 #include "FixedText.hpp"
5 #include "HUD.hpp"
6 #include "MessageBox.hpp"
7 #include "../app/FPSController.hpp"
8 #include "../app/IntervalTimer.hpp"
9 #include "../audio/Sound.hpp"
10 #include "../model/geometry.hpp"
11 #include "../model/OutlineModel.hpp"
12 #include "../world/Block.hpp"
13 #include "../world/EntityCollision.hpp"
14 #include "../world/WorldCollision.hpp"
15
16 #include <string>
17 #include <glm/glm.hpp>
18 #include <SDL.h>
19
20
21 namespace blank {
22
23 class Environment;
24 class Viewport;
25 class World;
26
27 class Interface {
28
29 public:
30         struct Config {
31                 float move_velocity = 0.005f;
32                 float pitch_sensitivity = -0.0025f;
33                 float yaw_sensitivity = -0.001f;
34
35                 bool keyboard_disabled = false;
36                 bool mouse_disabled = false;
37                 bool audio_disabled = false;
38                 bool visual_disabled = false;
39         };
40
41         Interface(const Config &, Environment &, World &);
42
43         void HandlePress(const SDL_KeyboardEvent &);
44         void HandleRelease(const SDL_KeyboardEvent &);
45         void Handle(const SDL_MouseMotionEvent &);
46         void HandlePress(const SDL_MouseButtonEvent &);
47         void HandleRelease(const SDL_MouseButtonEvent &);
48         void Handle(const SDL_MouseWheelEvent &);
49
50         void FaceBlock();
51         void TurnBlock();
52
53         void ToggleCollision();
54
55         void PickBlock();
56         void PlaceBlock();
57         void RemoveBlock() noexcept;
58
59         void PrintBlockInfo();
60         void PrintChunkInfo();
61         void PrintLightInfo();
62         void PrintSelectionInfo();
63         void Print(const Block &);
64
65         void SelectNext();
66         void SelectPrevious();
67
68         void ToggleAudio();
69         void ToggleVisual();
70
71         void ToggleDebug();
72         void UpdateCounter();
73         void UpdatePosition();
74         void UpdateOrientation();
75         void UpdateBlockInfo();
76         void UpdateEntityInfo();
77
78         void PostMessage(const char *);
79         void PostMessage(const std::string &msg) {
80                 PostMessage(msg.c_str());
81         }
82
83         void Update(int dt);
84
85         void Render(Viewport &) noexcept;
86
87 private:
88         void CheckAim();
89         void UpdateOutline();
90
91 private:
92         Environment &env;
93         World &world;
94         FPSController ctrl;
95         HUD hud;
96
97         Ray aim;
98         WorldCollision aim_world;
99         EntityCollision aim_entity;
100
101         OutlineModel outline;
102         glm::mat4 outline_transform;
103
104         FixedText counter_text;
105         FixedText position_text;
106         FixedText orientation_text;
107         FixedText block_text;
108         FixedText entity_text;
109         Block last_block;
110         Entity *last_entity;
111         MessageBox messages;
112         IntervalTimer msg_timer;
113
114         Config config;
115
116         IntervalTimer place_timer;
117         IntervalTimer remove_timer;
118
119         Block remove;
120         Block selection;
121
122         Sound place_sound;
123         Sound remove_sound;
124
125         glm::ivec3 fwd, rev;
126
127         bool debug;
128
129 };
130
131 }
132
133 #endif