]> git.localhorst.tv Git - blank.git/blob - src/ui/HUD.hpp
centralize entity controllers
[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 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         // message box
46         void PostMessage(const char *);
47         void PostMessage(const std::string &msg) {
48                 PostMessage(msg.c_str());
49         }
50         // whether to always render message box regardless of last post
51         void KeepMessages(bool k) { msg_keep = k; }
52
53         void Update(int dt);
54         void Render(Viewport &) noexcept;
55
56 private:
57         Environment &env;
58         Config &config;
59         const Player &player;
60
61         // block focus
62         PrimitiveMesh outline;
63         glm::mat4 outline_transform;
64         bool outline_visible;
65
66         // "inventory"
67         EntityMesh block;
68         EntityMesh::Buffer block_buf;
69         glm::mat4 block_transform;
70         FixedText block_label;
71         bool block_visible;
72
73         // debug overlay
74         FixedText counter_text;
75         FixedText position_text;
76         FixedText orientation_text;
77         FixedText block_text;
78         FixedText entity_text;
79         bool show_block;
80         bool show_entity;
81
82         // message box
83         MessageBox messages;
84         CoarseTimer msg_timer;
85         bool msg_keep;
86
87         // crosshair
88         PrimitiveMesh crosshair;
89
90 };
91
92 }
93
94 #endif