debug panel moved to new translation unit
This commit is contained in:
parent
ab1cfc8a4b
commit
e16b24f4af
148
src/frontend/debug_panel.cpp
Normal file
148
src/frontend/debug_panel.cpp
Normal file
@ -0,0 +1,148 @@
|
|||||||
|
#include <string>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#include "gui/controls.h"
|
||||||
|
#include "../graphics/Mesh.h"
|
||||||
|
#include "../objects/Player.h"
|
||||||
|
#include "../physics/Hitbox.h"
|
||||||
|
#include "../world/Level.h"
|
||||||
|
#include "../world/World.h"
|
||||||
|
#include "../voxels/Chunks.h"
|
||||||
|
#include "../voxels/Block.h"
|
||||||
|
#include "../util/stringutil.h"
|
||||||
|
#include "../delegates.h"
|
||||||
|
#include "../engine.h"
|
||||||
|
|
||||||
|
#include "WorldRenderer.h"
|
||||||
|
|
||||||
|
using namespace gui;
|
||||||
|
|
||||||
|
static std::shared_ptr<Label> create_label(wstringsupplier supplier) {
|
||||||
|
auto label = std::make_shared<Label>(L"-");
|
||||||
|
label->textSupplier(supplier);
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<UINode> create_debug_panel(
|
||||||
|
Engine* engine,
|
||||||
|
Level* level,
|
||||||
|
Player* player
|
||||||
|
) {
|
||||||
|
auto panel = std::make_shared<Panel>(glm::vec2(250, 200), glm::vec4(5.0f), 2.0f);
|
||||||
|
panel->setCoord(glm::vec2(10, 10));
|
||||||
|
|
||||||
|
static int fps = 0;
|
||||||
|
static int fpsMin = fps;
|
||||||
|
static int fpsMax = fps;
|
||||||
|
static std::wstring fpsString = L"";
|
||||||
|
|
||||||
|
panel->listenInterval(0.016f, [engine]() {
|
||||||
|
fps = 1.0f / engine->getDelta();
|
||||||
|
fpsMin = std::min(fps, fpsMin);
|
||||||
|
fpsMax = std::max(fps, fpsMax);
|
||||||
|
});
|
||||||
|
|
||||||
|
panel->listenInterval(0.5f, []() {
|
||||||
|
fpsString = std::to_wstring(fpsMax)+L" / "+std::to_wstring(fpsMin);
|
||||||
|
fpsMin = fps;
|
||||||
|
fpsMax = fps;
|
||||||
|
});
|
||||||
|
panel->add(create_label([](){ return L"fps: "+fpsString;}));
|
||||||
|
|
||||||
|
panel->add(create_label([](){
|
||||||
|
return L"meshes: " + std::to_wstring(Mesh::meshesCount);
|
||||||
|
}));
|
||||||
|
panel->add(create_label([=](){
|
||||||
|
auto& settings = engine->getSettings();
|
||||||
|
bool culling = settings.graphics.frustumCulling;
|
||||||
|
return L"frustum-culling: "+std::wstring(culling ? L"on" : L"off");
|
||||||
|
}));
|
||||||
|
panel->add(create_label([=]() {
|
||||||
|
return L"chunks: "+std::to_wstring(level->chunks->chunksCount)+
|
||||||
|
L" visible: "+std::to_wstring(level->chunks->visible);
|
||||||
|
}));
|
||||||
|
panel->add(create_label([=](){
|
||||||
|
auto* indices = level->content->getIndices();
|
||||||
|
auto def = indices->getBlockDef(player->selectedVoxel.id);
|
||||||
|
std::wstringstream stream;
|
||||||
|
stream << std::hex << player->selectedVoxel.states;
|
||||||
|
if (def) {
|
||||||
|
stream << L" (" << util::str2wstr_utf8(def->name) << L")";
|
||||||
|
}
|
||||||
|
return L"block: "+std::to_wstring(player->selectedVoxel.id)+
|
||||||
|
L" "+stream.str();
|
||||||
|
}));
|
||||||
|
panel->add(create_label([=](){
|
||||||
|
return L"seed: "+std::to_wstring(level->world->getSeed());
|
||||||
|
}));
|
||||||
|
|
||||||
|
for (int ax = 0; ax < 3; ax++) {
|
||||||
|
auto sub = std::make_shared<Container>(glm::vec2(), glm::vec2(250, 27));
|
||||||
|
|
||||||
|
std::wstring str = L"x: ";
|
||||||
|
str[0] += ax;
|
||||||
|
auto label = std::make_shared<Label>(str);
|
||||||
|
label->setMargin(glm::vec4(2, 3, 2, 3));
|
||||||
|
label->setSize(glm::vec2(20, 27));
|
||||||
|
sub->add(label);
|
||||||
|
sub->setColor(glm::vec4(0.0f));
|
||||||
|
|
||||||
|
// Coord input
|
||||||
|
auto box = std::make_shared<TextBox>(L"");
|
||||||
|
box->setTextSupplier([=]() {
|
||||||
|
Hitbox* hitbox = player->hitbox.get();
|
||||||
|
return util::to_wstring(hitbox->position[ax], 2);
|
||||||
|
});
|
||||||
|
box->setTextConsumer([=](std::wstring text) {
|
||||||
|
try {
|
||||||
|
glm::vec3 position = player->hitbox->position;
|
||||||
|
position[ax] = std::stoi(text);
|
||||||
|
player->teleport(position);
|
||||||
|
} catch (std::invalid_argument& _){
|
||||||
|
}
|
||||||
|
});
|
||||||
|
box->setOnEditStart([=](){
|
||||||
|
Hitbox* hitbox = player->hitbox.get();
|
||||||
|
box->setText(std::to_wstring(int(hitbox->position[ax])));
|
||||||
|
});
|
||||||
|
box->setSize(glm::vec2(230, 27));
|
||||||
|
|
||||||
|
sub->add(box, glm::vec2(20, 0));
|
||||||
|
panel->add(sub);
|
||||||
|
}
|
||||||
|
panel->add(create_label([=](){
|
||||||
|
int hour, minute, second;
|
||||||
|
timeutil::from_value(level->world->daytime, hour, minute, second);
|
||||||
|
|
||||||
|
std::wstring timeString =
|
||||||
|
util::lfill(std::to_wstring(hour), 2, L'0') + L":" +
|
||||||
|
util::lfill(std::to_wstring(minute), 2, L'0');
|
||||||
|
return L"time: "+timeString;
|
||||||
|
}));
|
||||||
|
{
|
||||||
|
auto bar = std::make_shared<TrackBar>(0.0f, 1.0f, 1.0f, 0.005f, 8);
|
||||||
|
bar->setSupplier([=]() {return level->world->daytime;});
|
||||||
|
bar->setConsumer([=](double val) {level->world->daytime = val;});
|
||||||
|
panel->add(bar);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
auto bar = std::make_shared<TrackBar>(0.0f, 1.0f, 0.0f, 0.005f, 8);
|
||||||
|
bar->setSupplier([=]() {return WorldRenderer::fog;});
|
||||||
|
bar->setConsumer([=](double val) {WorldRenderer::fog = val;});
|
||||||
|
panel->add(bar);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
auto checkbox = std::make_shared<FullCheckBox>(
|
||||||
|
L"Show Chunk Borders", glm::vec2(400, 24)
|
||||||
|
);
|
||||||
|
checkbox->setSupplier([=]() {
|
||||||
|
return engine->getSettings().debug.showChunkBorders;
|
||||||
|
});
|
||||||
|
checkbox->setConsumer([=](bool checked) {
|
||||||
|
engine->getSettings().debug.showChunkBorders = checked;
|
||||||
|
});
|
||||||
|
panel->add(checkbox);
|
||||||
|
}
|
||||||
|
panel->refresh();
|
||||||
|
return panel;
|
||||||
|
}
|
||||||
@ -1,15 +1,11 @@
|
|||||||
#include "hud.h"
|
#include "hud.h"
|
||||||
|
|
||||||
// TODO: refactor this garbage
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <GL/glew.h>
|
|
||||||
#include <GLFW/glfw3.h>
|
|
||||||
|
|
||||||
#include "../typedefs.h"
|
#include "../typedefs.h"
|
||||||
#include "../content/Content.h"
|
#include "../content/Content.h"
|
||||||
@ -55,14 +51,6 @@
|
|||||||
#include "../items/Inventories.h"
|
#include "../items/Inventories.h"
|
||||||
#include "../logic/scripting/scripting.h"
|
#include "../logic/scripting/scripting.h"
|
||||||
|
|
||||||
using namespace gui;
|
|
||||||
|
|
||||||
static std::shared_ptr<Label> create_label(wstringsupplier supplier) {
|
|
||||||
auto label = std::make_shared<Label>(L"-");
|
|
||||||
label->textSupplier(supplier);
|
|
||||||
return label;
|
|
||||||
}
|
|
||||||
|
|
||||||
HudElement::HudElement(
|
HudElement::HudElement(
|
||||||
hud_element_mode mode,
|
hud_element_mode mode,
|
||||||
UiDocument* document,
|
UiDocument* document,
|
||||||
@ -99,115 +87,6 @@ std::shared_ptr<gui::UINode> HudElement::getNode() const {
|
|||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<UINode> Hud::createDebugPanel(Engine* engine) {
|
|
||||||
auto level = frontend->getLevel();
|
|
||||||
|
|
||||||
auto panel = std::make_shared<Panel>(glm::vec2(250, 200), glm::vec4(5.0f), 2.0f);
|
|
||||||
panel->listenInterval(0.5f, [this]() {
|
|
||||||
fpsString = std::to_wstring(fpsMax)+L" / "+std::to_wstring(fpsMin);
|
|
||||||
fpsMin = fps;
|
|
||||||
fpsMax = fps;
|
|
||||||
});
|
|
||||||
panel->setCoord(glm::vec2(10, 10));
|
|
||||||
panel->add(create_label([this](){ return L"fps: "+this->fpsString;}));
|
|
||||||
panel->add(create_label([](){
|
|
||||||
return L"meshes: " + std::to_wstring(Mesh::meshesCount);
|
|
||||||
}));
|
|
||||||
panel->add(create_label([=](){
|
|
||||||
auto& settings = engine->getSettings();
|
|
||||||
bool culling = settings.graphics.frustumCulling;
|
|
||||||
return L"frustum-culling: "+std::wstring(culling ? L"on" : L"off");
|
|
||||||
}));
|
|
||||||
panel->add(create_label([=]() {
|
|
||||||
return L"chunks: "+std::to_wstring(level->chunks->chunksCount)+
|
|
||||||
L" visible: "+std::to_wstring(level->chunks->visible);
|
|
||||||
}));
|
|
||||||
panel->add(create_label([=](){
|
|
||||||
auto* indices = level->content->getIndices();
|
|
||||||
auto def = indices->getBlockDef(player->selectedVoxel.id);
|
|
||||||
std::wstringstream stream;
|
|
||||||
stream << std::hex << player->selectedVoxel.states;
|
|
||||||
if (def) {
|
|
||||||
stream << L" (" << util::str2wstr_utf8(def->name) << L")";
|
|
||||||
}
|
|
||||||
return L"block: "+std::to_wstring(player->selectedVoxel.id)+
|
|
||||||
L" "+stream.str();
|
|
||||||
}));
|
|
||||||
panel->add(create_label([=](){
|
|
||||||
return L"seed: "+std::to_wstring(level->world->getSeed());
|
|
||||||
}));
|
|
||||||
|
|
||||||
for (int ax = 0; ax < 3; ax++) {
|
|
||||||
auto sub = std::make_shared<Container>(glm::vec2(), glm::vec2(250, 27));
|
|
||||||
|
|
||||||
std::wstring str = L"x: ";
|
|
||||||
str[0] += ax;
|
|
||||||
auto label = std::make_shared<Label>(str);
|
|
||||||
label->setMargin(glm::vec4(2, 3, 2, 3));
|
|
||||||
label->setSize(glm::vec2(20, 27));
|
|
||||||
sub->add(label);
|
|
||||||
sub->setColor(glm::vec4(0.0f));
|
|
||||||
|
|
||||||
// Coord input
|
|
||||||
auto box = std::make_shared<TextBox>(L"");
|
|
||||||
box->setTextSupplier([=]() {
|
|
||||||
Hitbox* hitbox = player->hitbox.get();
|
|
||||||
return util::to_wstring(hitbox->position[ax], 2);
|
|
||||||
});
|
|
||||||
box->setTextConsumer([=](std::wstring text) {
|
|
||||||
try {
|
|
||||||
glm::vec3 position = player->hitbox->position;
|
|
||||||
position[ax] = std::stoi(text);
|
|
||||||
player->teleport(position);
|
|
||||||
} catch (std::invalid_argument& _){
|
|
||||||
}
|
|
||||||
});
|
|
||||||
box->setOnEditStart([=](){
|
|
||||||
Hitbox* hitbox = player->hitbox.get();
|
|
||||||
box->setText(std::to_wstring(int(hitbox->position[ax])));
|
|
||||||
});
|
|
||||||
box->setSize(glm::vec2(230, 27));
|
|
||||||
|
|
||||||
sub->add(box, glm::vec2(20, 0));
|
|
||||||
panel->add(sub);
|
|
||||||
}
|
|
||||||
panel->add(create_label([=](){
|
|
||||||
int hour, minute, second;
|
|
||||||
timeutil::from_value(level->world->daytime, hour, minute, second);
|
|
||||||
|
|
||||||
std::wstring timeString =
|
|
||||||
util::lfill(std::to_wstring(hour), 2, L'0') + L":" +
|
|
||||||
util::lfill(std::to_wstring(minute), 2, L'0');
|
|
||||||
return L"time: "+timeString;
|
|
||||||
}));
|
|
||||||
{
|
|
||||||
auto bar = std::make_shared<TrackBar>(0.0f, 1.0f, 1.0f, 0.005f, 8);
|
|
||||||
bar->setSupplier([=]() {return level->world->daytime;});
|
|
||||||
bar->setConsumer([=](double val) {level->world->daytime = val;});
|
|
||||||
panel->add(bar);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
auto bar = std::make_shared<TrackBar>(0.0f, 1.0f, 0.0f, 0.005f, 8);
|
|
||||||
bar->setSupplier([=]() {return WorldRenderer::fog;});
|
|
||||||
bar->setConsumer([=](double val) {WorldRenderer::fog = val;});
|
|
||||||
panel->add(bar);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
auto checkbox = std::make_shared<FullCheckBox>(
|
|
||||||
L"Show Chunk Borders", glm::vec2(400, 24)
|
|
||||||
);
|
|
||||||
checkbox->setSupplier([=]() {
|
|
||||||
return engine->getSettings().debug.showChunkBorders;
|
|
||||||
});
|
|
||||||
checkbox->setConsumer([=](bool checked) {
|
|
||||||
engine->getSettings().debug.showChunkBorders = checked;
|
|
||||||
});
|
|
||||||
panel->add(checkbox);
|
|
||||||
}
|
|
||||||
panel->refresh();
|
|
||||||
return panel;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::shared_ptr<InventoryView> Hud::createContentAccess() {
|
std::shared_ptr<InventoryView> Hud::createContentAccess() {
|
||||||
auto level = frontend->getLevel();
|
auto level = frontend->getLevel();
|
||||||
auto content = level->content;
|
auto content = level->content;
|
||||||
@ -251,6 +130,12 @@ std::shared_ptr<InventoryView> Hud::createHotbar() {
|
|||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern std::shared_ptr<gui::UINode> create_debug_panel(
|
||||||
|
Engine* engine,
|
||||||
|
Level* level,
|
||||||
|
Player* player
|
||||||
|
);
|
||||||
|
|
||||||
Hud::Hud(Engine* engine, LevelFrontend* frontend, Player* player)
|
Hud::Hud(Engine* engine, LevelFrontend* frontend, Player* player)
|
||||||
: engine(engine),
|
: engine(engine),
|
||||||
assets(engine->getAssets()),
|
assets(engine->getAssets()),
|
||||||
@ -275,7 +160,7 @@ Hud::Hud(Engine* engine, LevelFrontend* frontend, Player* player)
|
|||||||
grabbedItemView->setZIndex(1);
|
grabbedItemView->setZIndex(1);
|
||||||
|
|
||||||
contentAccess = createContentAccess();
|
contentAccess = createContentAccess();
|
||||||
contentAccessPanel = std::make_shared<Panel>(
|
contentAccessPanel = std::make_shared<gui::Panel>(
|
||||||
contentAccess->getSize(), glm::vec4(0.0f), 0.0f
|
contentAccess->getSize(), glm::vec4(0.0f), 0.0f
|
||||||
);
|
);
|
||||||
contentAccessPanel->setColor(glm::vec4());
|
contentAccessPanel->setColor(glm::vec4());
|
||||||
@ -283,7 +168,7 @@ Hud::Hud(Engine* engine, LevelFrontend* frontend, Player* player)
|
|||||||
contentAccessPanel->setScrollable(true);
|
contentAccessPanel->setScrollable(true);
|
||||||
|
|
||||||
hotbarView = createHotbar();
|
hotbarView = createHotbar();
|
||||||
darkOverlay = std::make_unique<Panel>(glm::vec2(4000.0f));
|
darkOverlay = std::make_unique<gui::Panel>(glm::vec2(4000.0f));
|
||||||
darkOverlay->setColor(glm::vec4(0, 0, 0, 0.5f));
|
darkOverlay->setColor(glm::vec4(0, 0, 0, 0.5f));
|
||||||
darkOverlay->setZIndex(-1);
|
darkOverlay->setZIndex(-1);
|
||||||
darkOverlay->setVisible(false);
|
darkOverlay->setVisible(false);
|
||||||
@ -292,7 +177,7 @@ Hud::Hud(Engine* engine, LevelFrontend* frontend, Player* player)
|
|||||||
uicamera->perspective = false;
|
uicamera->perspective = false;
|
||||||
uicamera->flipped = true;
|
uicamera->flipped = true;
|
||||||
|
|
||||||
debugPanel = createDebugPanel(engine);
|
debugPanel = create_debug_panel(engine, frontend->getLevel(), player);
|
||||||
menu->reset();
|
menu->reset();
|
||||||
|
|
||||||
debugPanel->setZIndex(2);
|
debugPanel->setZIndex(2);
|
||||||
@ -316,12 +201,6 @@ Hud::~Hud() {
|
|||||||
gui->remove(debugPanel);
|
gui->remove(debugPanel);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hud::drawDebug(int fps){
|
|
||||||
this->fps = fps;
|
|
||||||
fpsMin = min(fps, fpsMin);
|
|
||||||
fpsMax = max(fps, fpsMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @brief Remove all elements marked as removed
|
/// @brief Remove all elements marked as removed
|
||||||
void Hud::cleanup() {
|
void Hud::cleanup() {
|
||||||
auto it = std::remove_if(elements.begin(), elements.end(), [](const HudElement& e) {
|
auto it = std::remove_if(elements.begin(), elements.end(), [](const HudElement& e) {
|
||||||
@ -414,10 +293,8 @@ void Hud::update(bool visible) {
|
|||||||
|
|
||||||
/// @brief Show inventory on the screen and turn on inventory mode blocking movement
|
/// @brief Show inventory on the screen and turn on inventory mode blocking movement
|
||||||
void Hud::openInventory() {
|
void Hud::openInventory() {
|
||||||
auto inventory = player->getInventory();
|
|
||||||
|
|
||||||
inventoryOpen = true;
|
inventoryOpen = true;
|
||||||
|
auto inventory = player->getInventory();
|
||||||
auto inventoryDocument = assets->getLayout("core:inventory");
|
auto inventoryDocument = assets->getLayout("core:inventory");
|
||||||
inventoryView = std::dynamic_pointer_cast<InventoryView>(inventoryDocument->getRoot());
|
inventoryView = std::dynamic_pointer_cast<InventoryView>(inventoryDocument->getRoot());
|
||||||
inventoryView->bind(inventory, frontend, interaction.get());
|
inventoryView->bind(inventory, frontend, interaction.get());
|
||||||
@ -429,7 +306,12 @@ void Hud::openInventory() {
|
|||||||
/// @param doc block UI document (root element must be an InventoryView)
|
/// @param doc block UI document (root element must be an InventoryView)
|
||||||
/// @param blockinv block inventory.
|
/// @param blockinv block inventory.
|
||||||
/// If blockinv is nullptr a new virtual inventory will be created
|
/// If blockinv is nullptr a new virtual inventory will be created
|
||||||
void Hud::openInventory(glm::ivec3 block, UiDocument* doc, std::shared_ptr<Inventory> blockinv, bool playerInventory) {
|
void Hud::openInventory(
|
||||||
|
glm::ivec3 block,
|
||||||
|
UiDocument* doc,
|
||||||
|
std::shared_ptr<Inventory> blockinv,
|
||||||
|
bool playerInventory
|
||||||
|
) {
|
||||||
if (isInventoryOpen()) {
|
if (isInventoryOpen()) {
|
||||||
closeInventory();
|
closeInventory();
|
||||||
}
|
}
|
||||||
@ -522,7 +404,7 @@ void Hud::remove(HudElement& element) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// todo: refactor this garbage
|
// todo: refactor this garbage
|
||||||
void Hud::remove(std::shared_ptr<UINode> node) {
|
void Hud::remove(std::shared_ptr<gui::UINode> node) {
|
||||||
for (auto& element : elements) {
|
for (auto& element : elements) {
|
||||||
if (element.getNode() == node) {
|
if (element.getNode() == node) {
|
||||||
element.setRemoved();
|
element.setRemoved();
|
||||||
@ -570,14 +452,17 @@ void Hud::draw(const GfxContext& ctx){
|
|||||||
const int dmwidth = 256;
|
const int dmwidth = 256;
|
||||||
const float dmscale = 4000.0f;
|
const float dmscale = 4000.0f;
|
||||||
static float deltameter[dmwidth]{};
|
static float deltameter[dmwidth]{};
|
||||||
static int index=0;
|
static int index = 0;
|
||||||
index = index + 1 % dmwidth;
|
index = index + 1 % dmwidth;
|
||||||
deltameter[index%dmwidth] = glm::min(0.2f, 1.f/fps)*dmscale;
|
float delta = static_cast<float>(engine->getDelta());
|
||||||
|
deltameter[index%dmwidth] = glm::min(0.2f, delta)*dmscale;
|
||||||
batch->lineWidth(1);
|
batch->lineWidth(1);
|
||||||
for (int i = index+1; i < index+dmwidth; i++) {
|
for (int i = index+1; i < index+dmwidth; i++) {
|
||||||
int j = i % dmwidth;
|
int j = i % dmwidth;
|
||||||
batch->line(width-dmwidth+i-index, height-deltameter[j],
|
batch->line(
|
||||||
width-dmwidth+i-index, height, 1.0f, 1.0f, 1.0f, 0.2f);
|
width-dmwidth+i-index, height-deltameter[j],
|
||||||
|
width-dmwidth+i-index, height, 1.0f, 1.0f, 1.0f, 0.2f
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -9,11 +9,9 @@
|
|||||||
#include "../graphics/GfxContext.h"
|
#include "../graphics/GfxContext.h"
|
||||||
|
|
||||||
class Camera;
|
class Camera;
|
||||||
class Level;
|
|
||||||
class Block;
|
class Block;
|
||||||
class Assets;
|
class Assets;
|
||||||
class Player;
|
class Player;
|
||||||
class Level;
|
|
||||||
class Engine;
|
class Engine;
|
||||||
class SlotView;
|
class SlotView;
|
||||||
class Inventory;
|
class Inventory;
|
||||||
@ -68,11 +66,10 @@ class Hud {
|
|||||||
Engine* engine;
|
Engine* engine;
|
||||||
Assets* assets;
|
Assets* assets;
|
||||||
std::unique_ptr<Camera> uicamera;
|
std::unique_ptr<Camera> uicamera;
|
||||||
|
gui::GUI* gui;
|
||||||
|
LevelFrontend* frontend;
|
||||||
|
Player* player;
|
||||||
|
|
||||||
int fps = 60;
|
|
||||||
int fpsMin = 60;
|
|
||||||
int fpsMax = 60;
|
|
||||||
std::wstring fpsString;
|
|
||||||
bool inventoryOpen = false;
|
bool inventoryOpen = false;
|
||||||
bool pause = false;
|
bool pause = false;
|
||||||
|
|
||||||
@ -83,10 +80,6 @@ class Hud {
|
|||||||
std::shared_ptr<gui::Panel> darkOverlay;
|
std::shared_ptr<gui::Panel> darkOverlay;
|
||||||
std::unique_ptr<InventoryInteraction> interaction;
|
std::unique_ptr<InventoryInteraction> interaction;
|
||||||
std::shared_ptr<SlotView> grabbedItemView;
|
std::shared_ptr<SlotView> grabbedItemView;
|
||||||
gui::GUI* gui;
|
|
||||||
LevelFrontend* frontend;
|
|
||||||
Player* player;
|
|
||||||
|
|
||||||
std::vector<HudElement> elements;
|
std::vector<HudElement> elements;
|
||||||
|
|
||||||
std::shared_ptr<InventoryView> inventoryView = nullptr;
|
std::shared_ptr<InventoryView> inventoryView = nullptr;
|
||||||
@ -94,7 +87,6 @@ class Hud {
|
|||||||
glm::ivec3 currentblock {};
|
glm::ivec3 currentblock {};
|
||||||
blockid_t currentblockid = 0;
|
blockid_t currentblockid = 0;
|
||||||
|
|
||||||
std::shared_ptr<gui::UINode> createDebugPanel(Engine* engine);
|
|
||||||
std::shared_ptr<InventoryView> createContentAccess();
|
std::shared_ptr<InventoryView> createContentAccess();
|
||||||
std::shared_ptr<InventoryView> createHotbar();
|
std::shared_ptr<InventoryView> createHotbar();
|
||||||
|
|
||||||
@ -105,7 +97,6 @@ public:
|
|||||||
|
|
||||||
void update(bool hudVisible);
|
void update(bool hudVisible);
|
||||||
void draw(const GfxContext& context);
|
void draw(const GfxContext& context);
|
||||||
void drawDebug(int fps);
|
|
||||||
|
|
||||||
bool isInventoryOpen() const;
|
bool isInventoryOpen() const;
|
||||||
bool isPause() const;
|
bool isPause() const;
|
||||||
|
|||||||
@ -186,8 +186,5 @@ void LevelScreen::draw(float delta) {
|
|||||||
|
|
||||||
if (hudVisible) {
|
if (hudVisible) {
|
||||||
hud->draw(ctx);
|
hud->draw(ctx);
|
||||||
if (controller->getPlayer()->debug) {
|
|
||||||
hud->drawDebug(1 / delta);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user