From 4c9019e03cf8e982c2131830edff3abfbb7e1560 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Mon, 10 Mar 2025 23:09:50 +0300 Subject: [PATCH] small fixes --- src/frontend/hud.cpp | 8 +++++--- src/frontend/hud.hpp | 2 +- src/graphics/ui/GUI.cpp | 2 +- src/graphics/ui/elements/Plotter.hpp | 1 - src/graphics/ui/elements/TextBox.cpp | 6 ++++++ src/graphics/ui/elements/TextBox.hpp | 1 + src/graphics/ui/elements/UINode.cpp | 8 ++++++-- src/graphics/ui/elements/UINode.hpp | 2 +- 8 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/frontend/hud.cpp b/src/frontend/hud.cpp index 1684799f..48a699f1 100644 --- a/src/frontend/hud.cpp +++ b/src/frontend/hud.cpp @@ -262,7 +262,7 @@ void Hud::updateHotbarControl() { } } -void Hud::updateWorldGenDebugVisualization() { +void Hud::updateWorldGenDebug() { auto& level = frontend.getLevel(); const auto& chunks = *player.chunks; auto generator = @@ -314,7 +314,9 @@ void Hud::update(bool visible) { const auto& chunks = *player.chunks; const auto& menu = gui.getMenu(); - debugPanel->setVisible(debug && visible); + debugPanel->setVisible( + debug && visible && !(inventoryOpen && inventoryView == nullptr) + ); if (!visible && inventoryOpen) { closeInventory(); @@ -358,7 +360,7 @@ void Hud::update(bool visible) { debugMinimap->setVisible(debug && showGeneratorMinimap); if (debug && showGeneratorMinimap) { - updateWorldGenDebugVisualization(); + updateWorldGenDebug(); } } diff --git a/src/frontend/hud.hpp b/src/frontend/hud.hpp index a978e282..3522cd34 100644 --- a/src/frontend/hud.hpp +++ b/src/frontend/hud.hpp @@ -135,7 +135,7 @@ class Hud : public util::ObjectsKeeper { void dropExchangeSlot(); void showExchangeSlot(); - void updateWorldGenDebugVisualization(); + void updateWorldGenDebug(); public: Hud(Engine& engine, LevelFrontend& frontend, Player& player); ~Hud(); diff --git a/src/graphics/ui/GUI.cpp b/src/graphics/ui/GUI.cpp index 7821973b..60025d82 100644 --- a/src/graphics/ui/GUI.cpp +++ b/src/graphics/ui/GUI.cpp @@ -262,7 +262,7 @@ void GUI::draw(const DrawContext& pctx, const Assets& assets) { auto pos = node->calcPos(); auto size = node->getSize(); - batch2D->setColor(0, 0, 255); + batch2D->setColor(0, 255, 255); batch2D->lineRect(pos.x, pos.y, size.x-1, size.y-1); node = node->getParent(); diff --git a/src/graphics/ui/elements/Plotter.hpp b/src/graphics/ui/elements/Plotter.hpp index 776dda31..13fa3d89 100644 --- a/src/graphics/ui/elements/Plotter.hpp +++ b/src/graphics/ui/elements/Plotter.hpp @@ -4,7 +4,6 @@ #include "typedefs.hpp" #include -#include class Assets; class DrawContext; diff --git a/src/graphics/ui/elements/TextBox.cpp b/src/graphics/ui/elements/TextBox.cpp index 791dcde8..609231c0 100644 --- a/src/graphics/ui/elements/TextBox.cpp +++ b/src/graphics/ui/elements/TextBox.cpp @@ -404,6 +404,12 @@ void TextBox::onFocus(GUI* gui) { } } +void TextBox::reposition() { + auto size = getSize(); + UINode::reposition(); + refreshLabel(); +} + void TextBox::refresh() { Container::refresh(); label->setSize(size-glm::vec2(padding.z+padding.x, padding.w+padding.y)); diff --git a/src/graphics/ui/elements/TextBox.hpp b/src/graphics/ui/elements/TextBox.hpp index 0eff89f2..7dd77525 100644 --- a/src/graphics/ui/elements/TextBox.hpp +++ b/src/graphics/ui/elements/TextBox.hpp @@ -210,6 +210,7 @@ namespace gui { virtual void setShowLineNumbers(bool flag); virtual bool isShowLineNumbers() const; + virtual void reposition() override; virtual void onFocus(GUI*) override; virtual void refresh() override; virtual void doubleClick(GUI*, int x, int y) override; diff --git a/src/graphics/ui/elements/UINode.cpp b/src/graphics/ui/elements/UINode.cpp index 7a9e4b87..8dc04f68 100644 --- a/src/graphics/ui/elements/UINode.cpp +++ b/src/graphics/ui/elements/UINode.cpp @@ -301,9 +301,13 @@ const std::string& UINode::getId() const { void UINode::reposition() { if (sizefunc) { auto newSize = sizefunc(); + auto defsize = newSize; + if (parent) { + defsize = parent->getSize(); + } setSize( - {newSize.x < 0 ? size.x : newSize.x, - newSize.y < 0 ? size.y : newSize.y} + {newSize.x < 0 ? defsize.x : newSize.x, + newSize.y < 0 ? defsize.y : newSize.y} ); } if (positionfunc) { diff --git a/src/graphics/ui/elements/UINode.hpp b/src/graphics/ui/elements/UINode.hpp index 2f62dd27..58009e00 100644 --- a/src/graphics/ui/elements/UINode.hpp +++ b/src/graphics/ui/elements/UINode.hpp @@ -250,7 +250,7 @@ namespace gui { const std::string& getId() const; /// @brief Fetch pos from positionfunc if assigned - void reposition(); + virtual void reposition(); virtual void setGravity(Gravity gravity);