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