#include "hud.h" #include #include #include #include #include #include #include #include "../typedefs.h" #include "../content/Content.h" #include "../util/stringutil.h" #include "../util/timeutil.h" #include "../assets/Assets.h" #include "../graphics/Shader.h" #include "../graphics/Batch2D.h" #include "../graphics/Batch3D.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 "WorldRenderer.h" #include "BlocksPreview.h" #include "InventoryView.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) : level(level), assets(engine->getAssets()), gui(engine->getGUI()), cache(cache) { auto menu = gui->getMenu(); blocksPreview = new BlocksPreview(assets->getShader("ui3d"), assets->getAtlas("blocks"), cache); auto content = level->content; auto indices = content->indices; std::vector blocks; for (blockid_t id = 1; id < indices->countBlockDefs(); id++) { const Block* def = indices->getBlockDef(id); if (def->hidden) continue; blocks.push_back(id); } contentAccess.reset(new InventoryView( 8, level->player, assets, indices, cache, blocks)); 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