#include "hud.h" #include #include #include #include #include #include #include #include "../typedefs.h" #include "../content/Content.h" #include "../util/stringutil.h" #include "../assets/Assets.h" #include "../graphics/Shader.h" #include "../graphics/Batch2D.h" #include "../graphics/Font.h" #include "../graphics/Atlas.h" #include "../graphics/Mesh.h" #include "../window/Camera.h" #include "../window/Window.h" #include "../window/Events.h" #include "../window/input.h" #include "../voxels/Chunks.h" #include "../voxels/Block.h" #include "../world/World.h" #include "../world/Level.h" #include "../objects/Player.h" #include "../physics/Hitbox.h" #include "../maths/voxmaths.h" #include "gui/controls.h" #include "gui/panels.h" #include "gui/UINode.h" #include "gui/GUI.h" #include "ContentGfxCache.h" #include "screens.h" #include "world_render.h" #include "../engine.h" #include "../core_defs.h" using std::wstring; using std::shared_ptr; using glm::vec2; using glm::vec3; using glm::vec4; using namespace gui; inline Label* create_label(gui::wstringsupplier supplier) { Label* label = new Label(L"-"); label->textSupplier(supplier); return label; } HudRenderer::HudRenderer(Engine* engine, Level* level, const ContentGfxCache* cache, WorldRenderer* renderer) : level(level), assets(engine->getAssets()), gui(engine->getGUI()), cache(cache), renderer(renderer) { auto menu = gui->getMenu(); batch = new Batch2D(1024); uicamera = new Camera(vec3(), 1); uicamera->perspective = false; uicamera->flipped = true; Panel* panel = new Panel(vec2(250, 200), vec4(5.0f), 1.0f); debugPanel = shared_ptr(panel); panel->listenInterval(1.0f, [this]() { fpsString = std::to_wstring(fpsMax)+L" / "+std::to_wstring(fpsMin); fpsMin = fps; fpsMax = fps; }); panel->setCoord(vec2(10, 10)); panel->add(shared_ptr