]> git.localhorst.tv Git - blank.git/blob - src/ui/HUD.hpp
glm backwards compatibility
[blank.git] / src / ui / HUD.hpp
1 #ifndef BLANK_UI_HUD_H_
2 #define BLANK_UI_HUD_H_
3
4 #include "FixedText.hpp"
5 #include "MessageBox.hpp"
6 #include "../graphics/EntityMesh.hpp"
7 #include "../graphics/glm.hpp"
8 #include "../graphics/PrimitiveMesh.hpp"
9
10
11 namespace blank {
12
13 class Block;
14 class BlockTypeRegistry;
15 class Config;
16 class CongestionControl;
17 class Environment;
18 class Font;
19 class Player;
20 class Viewport;
21
22 class HUD {
23
24 public:
25         explicit HUD(Environment &, Config &, const Player &);
26
27         HUD(const HUD &) = delete;
28         HUD &operator =(const HUD &) = delete;
29
30         // focus
31         void FocusBlock(const Chunk &, int);
32         void FocusEntity(const Entity &);
33         void FocusNone();
34
35         // "inventory"
36         void DisplayNone();
37         void Display(const BlockType &);
38
39         // debug overlay
40         void UpdateDebug();
41         void UpdateCounter();
42         void UpdatePosition();
43         void UpdateOrientation();
44
45         // net stats
46         void UpdateNetStats(const CongestionControl &);
47
48         // message box
49         void PostMessage(const char *);
50         void PostMessage(const std::string &msg) {
51                 PostMessage(msg.c_str());
52         }
53         // whether to always render message box regardless of last post
54         void KeepMessages(bool k) { msg_keep = k; }
55
56         void Update(int dt);
57         void Render(Viewport &) noexcept;
58
59 private:
60         Environment &env;
61         Config &config;
62         const Player &player;
63
64         // block focus
65         PrimitiveMesh outline;
66         glm::mat4 outline_transform;
67         bool outline_visible;
68
69         // "inventory"
70         EntityMesh block;
71         EntityMesh::Buffer block_buf;
72         glm::mat4 block_transform;
73         FixedText block_label;
74         bool block_visible;
75
76         // debug overlay
77         FixedText counter_text;
78         FixedText position_text;
79         FixedText orientation_text;
80         FixedText block_text;
81         FixedText entity_text;
82         bool show_block;
83         bool show_entity;
84
85         // net stats
86         FixedText bandwidth_text;
87         FixedText rtt_text;
88         FixedText packet_loss_text;
89         bool show_net;
90
91         // message box
92         MessageBox messages;
93         CoarseTimer msg_timer;
94         bool msg_keep;
95
96         // crosshair
97         PrimitiveMesh crosshair;
98
99 };
100
101 }
102
103 #endif