From 63768ccd6dee9f463d8dbef5e8ab50fbba9049af Mon Sep 17 00:00:00 2001 From: MihailRis Date: Mon, 29 Apr 2024 02:46:00 +0300 Subject: [PATCH] minor refactor and fixes --- src/frontend/InventoryView.cpp | 1 + src/frontend/InventoryView.h | 15 ++++++--------- src/frontend/hud.cpp | 14 +++++--------- src/frontend/hud.h | 2 +- 4 files changed, 13 insertions(+), 19 deletions(-) diff --git a/src/frontend/InventoryView.cpp b/src/frontend/InventoryView.cpp index 5a81d330..27ee9db2 100644 --- a/src/frontend/InventoryView.cpp +++ b/src/frontend/InventoryView.cpp @@ -15,6 +15,7 @@ #include "../items/Inventories.h" #include "../items/Inventory.h" #include "../items/ItemDef.h" +#include "../items/ItemStack.h" #include "../logic/scripting/scripting.h" #include "../maths/voxmaths.h" #include "../objects/Player.h" diff --git a/src/frontend/InventoryView.h b/src/frontend/InventoryView.h index 9cdd8322..cd89fc19 100644 --- a/src/frontend/InventoryView.h +++ b/src/frontend/InventoryView.h @@ -1,18 +1,19 @@ #ifndef FRONTEND_INVENTORY_VIEW_H_ #define FRONTEND_INVENTORY_VIEW_H_ +#include "../graphics/ui/elements/UINode.hpp" +#include "../graphics/ui/elements/Container.hpp" +#include "../typedefs.h" +#include "../constants.h" + #include #include #include -#include "../graphics/ui/elements/UINode.hpp" -#include "../graphics/ui/elements/Container.hpp" -#include "../items/ItemStack.h" -#include "../typedefs.h" - class Assets; class GfxContext; class Content; +class ItemStack; class ContentIndices; class LevelFrontend; class Inventory; @@ -21,10 +22,6 @@ namespace gui { class UiXmlReader; } -namespace scripting { - class Environment; -} - using slotcallback = std::function; struct SlotLayout { diff --git a/src/frontend/hud.cpp b/src/frontend/hud.cpp index 7fa30c41..f1a638a4 100644 --- a/src/frontend/hud.cpp +++ b/src/frontend/hud.cpp @@ -20,6 +20,7 @@ #include "../graphics/ui/elements/Panel.hpp" #include "../graphics/ui/elements/Plotter.hpp" #include "../graphics/ui/GUI.hpp" +#include "../graphics/ui/gui_util.hpp" #include "../items/Inventories.h" #include "../items/Inventory.h" #include "../items/ItemDef.h" @@ -156,10 +157,9 @@ Hud::Hud(Engine* engine, LevelFrontend* frontend, Player* player) contentAccessPanel->setScrollable(true); hotbarView = createHotbar(); - darkOverlay = std::make_unique(glm::vec2(4000.0f)); - darkOverlay->setColor(glm::vec4(0, 0, 0, 0.5f)); - darkOverlay->setZIndex(-1); - darkOverlay->setVisible(false); + darkOverlay = guiutil::create( + "" + ); uicamera = std::make_unique(glm::vec3(), 1); uicamera->perspective = false; @@ -299,11 +299,7 @@ void Hud::openInventory() { exchangeSlot = std::make_shared( SlotLayout(-1, glm::vec2(), false, false, nullptr, nullptr, nullptr) ); - exchangeSlot->bind( - 0, - exchangeSlotInv->getSlot(0), - content - ); + exchangeSlot->bind(exchangeSlotInv->getId(), exchangeSlotInv->getSlot(0), content); exchangeSlot->setColor(glm::vec4()); exchangeSlot->setInteractive(false); exchangeSlot->setZIndex(1); diff --git a/src/frontend/hud.h b/src/frontend/hud.h index 17f58da6..c7ead508 100644 --- a/src/frontend/hud.h +++ b/src/frontend/hud.h @@ -84,7 +84,7 @@ class Hud { /// @brief Debug info and control panel (F3 key) std::shared_ptr debugPanel; /// @brief Overlay used in pause mode - std::shared_ptr darkOverlay; + std::shared_ptr darkOverlay; /// @brief Inventories interaction agent (grabbed item) std::shared_ptr exchangeSlot; /// @brief Exchange slot inventory (1 slot only)