small fixes

This commit is contained in:
MihailRis
2025-03-11 00:39:59 +03:00
parent 9a01b5ad2d
commit 4c9019e03c
8 changed files with 21 additions and 9 deletions
+5 -3
View File
@@ -262,7 +262,7 @@ void Hud::updateHotbarControl() {
} }
} }
void Hud::updateWorldGenDebugVisualization() { void Hud::updateWorldGenDebug() {
auto& level = frontend.getLevel(); auto& level = frontend.getLevel();
const auto& chunks = *player.chunks; const auto& chunks = *player.chunks;
auto generator = auto generator =
@@ -314,7 +314,9 @@ void Hud::update(bool visible) {
const auto& chunks = *player.chunks; const auto& chunks = *player.chunks;
const auto& menu = gui.getMenu(); const auto& menu = gui.getMenu();
debugPanel->setVisible(debug && visible); debugPanel->setVisible(
debug && visible && !(inventoryOpen && inventoryView == nullptr)
);
if (!visible && inventoryOpen) { if (!visible && inventoryOpen) {
closeInventory(); closeInventory();
@@ -358,7 +360,7 @@ void Hud::update(bool visible) {
debugMinimap->setVisible(debug && showGeneratorMinimap); debugMinimap->setVisible(debug && showGeneratorMinimap);
if (debug && showGeneratorMinimap) { if (debug && showGeneratorMinimap) {
updateWorldGenDebugVisualization(); updateWorldGenDebug();
} }
} }
+1 -1
View File
@@ -135,7 +135,7 @@ class Hud : public util::ObjectsKeeper {
void dropExchangeSlot(); void dropExchangeSlot();
void showExchangeSlot(); void showExchangeSlot();
void updateWorldGenDebugVisualization(); void updateWorldGenDebug();
public: public:
Hud(Engine& engine, LevelFrontend& frontend, Player& player); Hud(Engine& engine, LevelFrontend& frontend, Player& player);
~Hud(); ~Hud();
+1 -1
View File
@@ -262,7 +262,7 @@ void GUI::draw(const DrawContext& pctx, const Assets& assets) {
auto pos = node->calcPos(); auto pos = node->calcPos();
auto size = node->getSize(); 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); batch2D->lineRect(pos.x, pos.y, size.x-1, size.y-1);
node = node->getParent(); node = node->getParent();
-1
View File
@@ -4,7 +4,6 @@
#include "typedefs.hpp" #include "typedefs.hpp"
#include <memory> #include <memory>
#include <glm/glm.hpp>
class Assets; class Assets;
class DrawContext; class DrawContext;
+6
View File
@@ -404,6 +404,12 @@ void TextBox::onFocus(GUI* gui) {
} }
} }
void TextBox::reposition() {
auto size = getSize();
UINode::reposition();
refreshLabel();
}
void TextBox::refresh() { void TextBox::refresh() {
Container::refresh(); Container::refresh();
label->setSize(size-glm::vec2(padding.z+padding.x, padding.w+padding.y)); label->setSize(size-glm::vec2(padding.z+padding.x, padding.w+padding.y));
+1
View File
@@ -210,6 +210,7 @@ namespace gui {
virtual void setShowLineNumbers(bool flag); virtual void setShowLineNumbers(bool flag);
virtual bool isShowLineNumbers() const; virtual bool isShowLineNumbers() const;
virtual void reposition() override;
virtual void onFocus(GUI*) override; virtual void onFocus(GUI*) override;
virtual void refresh() override; virtual void refresh() override;
virtual void doubleClick(GUI*, int x, int y) override; virtual void doubleClick(GUI*, int x, int y) override;
+6 -2
View File
@@ -301,9 +301,13 @@ const std::string& UINode::getId() const {
void UINode::reposition() { void UINode::reposition() {
if (sizefunc) { if (sizefunc) {
auto newSize = sizefunc(); auto newSize = sizefunc();
auto defsize = newSize;
if (parent) {
defsize = parent->getSize();
}
setSize( setSize(
{newSize.x < 0 ? size.x : newSize.x, {newSize.x < 0 ? defsize.x : newSize.x,
newSize.y < 0 ? size.y : newSize.y} newSize.y < 0 ? defsize.y : newSize.y}
); );
} }
if (positionfunc) { if (positionfunc) {
+1 -1
View File
@@ -250,7 +250,7 @@ namespace gui {
const std::string& getId() const; const std::string& getId() const;
/// @brief Fetch pos from positionfunc if assigned /// @brief Fetch pos from positionfunc if assigned
void reposition(); virtual void reposition();
virtual void setGravity(Gravity gravity); virtual void setGravity(Gravity gravity);