Skip to content

Commit

Permalink
add 'Show Generator Minimap' checkbox
Browse files Browse the repository at this point in the history
  • Loading branch information
MihailRis committed Nov 5, 2024
1 parent dc8bad2 commit 80e48ae
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/frontend/debug_panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "delegates.hpp"
#include "engine.hpp"
#include "settings.hpp"
#include "hud.hpp"
#include "content/Content.hpp"
#include "graphics/core/Mesh.hpp"
#include "graphics/ui/elements/CheckBox.hpp"
Expand Down Expand Up @@ -37,6 +38,7 @@ static std::shared_ptr<Label> create_label(wstringsupplier supplier) {
}

// TODO: move to xml
// TODO: move to xml finally
std::shared_ptr<UINode> create_debug_panel(
Engine* engine,
Level* level,
Expand Down Expand Up @@ -213,6 +215,18 @@ std::shared_ptr<UINode> create_debug_panel(
});
panel->add(checkbox);
}
{
auto checkbox = std::make_shared<FullCheckBox>(
L"Show Generator Minimap", glm::vec2(400, 24)
);
checkbox->setSupplier([=]() {
return Hud::showGeneratorMinimap;
});
checkbox->setConsumer([=](bool checked) {
Hud::showGeneratorMinimap = checked;
});
panel->add(checkbox);
}
panel->refresh();
return panel;
}
4 changes: 3 additions & 1 deletion src/frontend/hud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@

using namespace gui;

bool Hud::showGeneratorMinimap = false;

// implemented in debug_panel.cpp
extern std::shared_ptr<UINode> create_debug_panel(
Engine* engine,
Expand Down Expand Up @@ -361,7 +363,7 @@ void Hud::update(bool visible) {
}
cleanup();

if (player->debug) {
if (player->debug && showGeneratorMinimap) {
updateWorldGenDebugVisualization();
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/frontend/hud.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ class Hud : public util::ObjectsKeeper {

std::shared_ptr<Inventory> getBlockInventory();

static bool showGeneratorMinimap;

/// @brief Runtime updating debug visualization texture
inline static std::string DEBUG_WORLDGEN_IMAGE = "#debug.img.worldgen";
};

0 comments on commit 80e48ae

Please sign in to comment.