X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fui%2FHUD.hpp;h=b842da392d892340d9d6413cc45c76d85f531865;hb=ed3bdc028edc0ecb5835d1c0bf18dbc59b342daf;hp=245d886e795ffaccf35b658e7fde710457d46d9d;hpb=55dbd6b35a39888f245e247d2e140f141f918178;p=blank.git diff --git a/src/ui/HUD.hpp b/src/ui/HUD.hpp index 245d886..b842da3 100644 --- a/src/ui/HUD.hpp +++ b/src/ui/HUD.hpp @@ -1,58 +1,101 @@ #ifndef BLANK_UI_HUD_H_ #define BLANK_UI_HUD_H_ -#include "../graphics/Texture.hpp" -#include "../model/Model.hpp" -#include "../model/OutlineModel.hpp" -#include "../model/SpriteModel.hpp" +#include "FixedText.hpp" +#include "MessageBox.hpp" +#include "../graphics/EntityMesh.hpp" +#include "../graphics/PrimitiveMesh.hpp" #include namespace blank { -class BlendedSprite; class Block; class BlockTypeRegistry; -class DirectionalLighting; +class Config; +class CongestionControl; +class Environment; class Font; +class Player; +class Viewport; class HUD { public: - HUD(const BlockTypeRegistry &, const Font &); + explicit HUD(Environment &, Config &, const Player &); HUD(const HUD &) = delete; HUD &operator =(const HUD &) = delete; - void Viewport(float width, float height) noexcept; - void Viewport(float x, float y, float width, float height) noexcept; + // focus + void FocusBlock(const Chunk &, int); + void FocusEntity(const Entity &); + void FocusNone(); - void Display(const Block &); + // "inventory" + void DisplayNone(); + void Display(const BlockType &); - void Render(DirectionalLighting &, BlendedSprite &) noexcept; + // debug overlay + void UpdateDebug(); + void UpdateCounter(); + void UpdatePosition(); + void UpdateOrientation(); -private: - const BlockTypeRegistry &types; - const Font &font; + // net stats + void UpdateNetStats(const CongestionControl &); - Model block; - Model::Buffer block_buf; - glm::mat4 block_transform; + // message box + void PostMessage(const char *); + void PostMessage(const std::string &msg) { + PostMessage(msg.c_str()); + } + // whether to always render message box regardless of last post + void KeepMessages(bool k) { msg_keep = k; } - Texture block_label; - SpriteModel label_sprite; - glm::mat4 label_transform; - SDL_Color label_color; + void Update(int dt); + void Render(Viewport &) noexcept; +private: + Environment &env; + Config &config; + const Player &player; + + // block focus + PrimitiveMesh outline; + glm::mat4 outline_transform; + bool outline_visible; + + // "inventory" + EntityMesh block; + EntityMesh::Buffer block_buf; + glm::mat4 block_transform; + FixedText block_label; bool block_visible; - OutlineModel crosshair; - glm::mat4 crosshair_transform; - - float near, far; - glm::mat4 projection; - glm::mat4 view; + // debug overlay + FixedText counter_text; + FixedText position_text; + FixedText orientation_text; + FixedText block_text; + FixedText entity_text; + bool show_block; + bool show_entity; + + // net stats + FixedText bandwidth_text; + FixedText rtt_text; + FixedText packet_loss_text; + bool show_net; + + // message box + MessageBox messages; + CoarseTimer msg_timer; + bool msg_keep; + + // crosshair + PrimitiveMesh crosshair; };