minor refactor and fixes

This commit is contained in:
MihailRis 2024-04-29 02:46:00 +03:00
parent 90c64a363a
commit 63768ccd6d
4 changed files with 13 additions and 19 deletions

View File

@ -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"

View File

@ -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 <vector>
#include <functional>
#include <glm/glm.hpp>
#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<void(uint, ItemStack&)>;
struct SlotLayout {

View File

@ -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<gui::Panel>(glm::vec2(4000.0f));
darkOverlay->setColor(glm::vec4(0, 0, 0, 0.5f));
darkOverlay->setZIndex(-1);
darkOverlay->setVisible(false);
darkOverlay = guiutil::create(
"<container size='4000' color='#00000080' z-index='-1' visible='false'/>"
);
uicamera = std::make_unique<Camera>(glm::vec3(), 1);
uicamera->perspective = false;
@ -299,11 +299,7 @@ void Hud::openInventory() {
exchangeSlot = std::make_shared<SlotView>(
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);

View File

@ -84,7 +84,7 @@ class Hud {
/// @brief Debug info and control panel (F3 key)
std::shared_ptr<gui::UINode> debugPanel;
/// @brief Overlay used in pause mode
std::shared_ptr<gui::Panel> darkOverlay;
std::shared_ptr<gui::UINode> darkOverlay;
/// @brief Inventories interaction agent (grabbed item)
std::shared_ptr<SlotView> exchangeSlot;
/// @brief Exchange slot inventory (1 slot only)