UiDocument is an asset now
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "../assets/Assets.h"
|
||||
#include "../content/Content.h"
|
||||
#include "../content/ContentPack.h"
|
||||
#include "../graphics/Atlas.h"
|
||||
#include "../voxels/Block.h"
|
||||
#include "../core_defs.h"
|
||||
@@ -37,3 +38,15 @@ ContentGfxCache::ContentGfxCache(const Content* content, Assets* assets) : conte
|
||||
|
||||
ContentGfxCache::~ContentGfxCache() {
|
||||
}
|
||||
|
||||
std::shared_ptr<UiDocument> ContentGfxCache::getLayout(const std::string& id) {
|
||||
auto found = layouts.find(id);
|
||||
if (found == layouts.end()) {
|
||||
return nullptr;
|
||||
}
|
||||
return found->second;
|
||||
}
|
||||
|
||||
const Content* ContentGfxCache::getContent() const {
|
||||
return content;
|
||||
}
|
||||
|
||||
@@ -28,6 +28,8 @@ public:
|
||||
}
|
||||
|
||||
std::shared_ptr<UiDocument> getLayout(const std::string& id);
|
||||
|
||||
const Content* getContent() const;
|
||||
};
|
||||
|
||||
#endif // FRONTEND_BLOCKS_GFX_CACHE_H_
|
||||
|
||||
+107
-100
@@ -39,11 +39,8 @@ SlotLayout::SlotLayout(
|
||||
shareFunc(shareFunc),
|
||||
rightClick(rightClick) {}
|
||||
|
||||
InventoryBuilder::InventoryBuilder(
|
||||
LevelFrontend* frontend,
|
||||
InventoryInteraction& interaction
|
||||
) {
|
||||
view = std::make_shared<InventoryView>(frontend, interaction);
|
||||
InventoryBuilder::InventoryBuilder() {
|
||||
view = std::make_shared<InventoryView>();
|
||||
}
|
||||
|
||||
void InventoryBuilder::addGrid(
|
||||
@@ -101,13 +98,8 @@ std::shared_ptr<InventoryView> InventoryBuilder::build() {
|
||||
}
|
||||
|
||||
SlotView::SlotView(
|
||||
LevelFrontend* frontend,
|
||||
InventoryInteraction& interaction,
|
||||
SlotLayout layout
|
||||
) : UINode(glm::vec2(), glm::vec2(InventoryView::SLOT_SIZE)),
|
||||
frontend(frontend),
|
||||
interaction(interaction),
|
||||
content(frontend->getLevel()->content),
|
||||
) : UINode(glm::vec2(), glm::vec2(InventoryView::SLOT_SIZE)),
|
||||
layout(layout)
|
||||
{
|
||||
setColor(glm::vec4(0, 0, 0, 0.2f));
|
||||
@@ -206,7 +198,7 @@ void SlotView::clicked(gui::GUI* gui, int button) {
|
||||
if (bound == nullptr)
|
||||
throw std::runtime_error("unbound slot");
|
||||
|
||||
ItemStack& grabbed = interaction.getGrabbedItem();
|
||||
ItemStack& grabbed = interaction->getGrabbedItem();
|
||||
ItemStack& stack = *bound;
|
||||
|
||||
if (button == mousecode::BUTTON_1) {
|
||||
@@ -260,23 +252,21 @@ void SlotView::focus(gui::GUI* gui) {
|
||||
clicked(gui, 0);
|
||||
}
|
||||
|
||||
void SlotView::bind(ItemStack& stack) {
|
||||
void SlotView::bind(
|
||||
ItemStack& stack,
|
||||
LevelFrontend* frontend,
|
||||
InventoryInteraction* interaction
|
||||
) {
|
||||
bound = &stack;
|
||||
content = frontend->getLevel()->content;
|
||||
this->frontend = frontend;
|
||||
}
|
||||
|
||||
const SlotLayout& SlotView::getLayout() const {
|
||||
return layout;
|
||||
}
|
||||
|
||||
InventoryView::InventoryView(
|
||||
LevelFrontend* frontend,
|
||||
InventoryInteraction& interaction
|
||||
) : Container(glm::vec2(), glm::vec2()),
|
||||
frontend(frontend),
|
||||
interaction(interaction)
|
||||
{
|
||||
content = frontend->getLevel()->content;
|
||||
indices = content->getIndices();
|
||||
InventoryView::InventoryView() : Container(glm::vec2(), glm::vec2()) {
|
||||
setColor(glm::vec4(0, 0, 0, 0.0f));
|
||||
}
|
||||
|
||||
@@ -297,9 +287,7 @@ std::shared_ptr<SlotView> InventoryView::addSlot(SlotLayout layout) {
|
||||
}
|
||||
setSize(vsize);
|
||||
|
||||
auto slot = std::make_shared<SlotView>(
|
||||
frontend, interaction, layout
|
||||
);
|
||||
auto slot = std::make_shared<SlotView>(layout);
|
||||
if (!layout.background) {
|
||||
slot->setColor(glm::vec4());
|
||||
}
|
||||
@@ -307,10 +295,21 @@ std::shared_ptr<SlotView> InventoryView::addSlot(SlotLayout layout) {
|
||||
return slot;
|
||||
}
|
||||
|
||||
void InventoryView::bind(std::shared_ptr<Inventory> inventory) {
|
||||
void InventoryView::bind(
|
||||
std::shared_ptr<Inventory> inventory,
|
||||
LevelFrontend* frontend,
|
||||
InventoryInteraction* interaction
|
||||
) {
|
||||
this->frontend = frontend;
|
||||
this->interaction = interaction;
|
||||
this->inventory = inventory;
|
||||
content = frontend->getLevel()->content;
|
||||
indices = content->getIndices();
|
||||
for (auto slot : slots) {
|
||||
slot->bind(inventory->getSlot(slot->getLayout().index));
|
||||
slot->bind(
|
||||
inventory->getSlot(slot->getLayout().index),
|
||||
frontend, interaction
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -340,90 +339,98 @@ void InventoryView::setInventory(std::shared_ptr<Inventory> inventory) {
|
||||
#include "../coders/xml.h"
|
||||
#include "gui/gui_xml.h"
|
||||
|
||||
static void readSlot(InventoryView* view, gui::UiXmlReader& reader, xml::xmlelement element) {
|
||||
int index = element->attr("index", "0").asInt();
|
||||
bool itemSource = element->attr("item-source", "false").asBool();
|
||||
SlotLayout layout(index, glm::vec2(), true, itemSource, nullptr, nullptr);
|
||||
if (element->has("coord")) {
|
||||
layout.position = element->attr("coord").asVec2();
|
||||
}
|
||||
auto slot = view->addSlot(layout);
|
||||
reader.readUINode(reader, element, *slot);
|
||||
view->add(slot);
|
||||
}
|
||||
|
||||
static void readSlotsGrid(InventoryView* view, gui::UiXmlReader& reader, xml::xmlelement element) {
|
||||
int startIndex = element->attr("start-index", "0").asInt();
|
||||
int rows = element->attr("rows", "0").asInt();
|
||||
int cols = element->attr("cols", "0").asInt();
|
||||
int count = element->attr("count", "0").asInt();
|
||||
const int slotSize = InventoryView::SLOT_SIZE;
|
||||
int interval = element->attr("interval", "-1").asInt();
|
||||
if (interval < 0) {
|
||||
interval = InventoryView::SLOT_INTERVAL;
|
||||
}
|
||||
int padding = element->attr("padding", "-1").asInt();
|
||||
if (padding < 0) {
|
||||
padding = interval;
|
||||
}
|
||||
if (rows == 0) {
|
||||
rows = ceildiv(count, cols);
|
||||
} else if (cols == 0) {
|
||||
cols = ceildiv(count, rows);
|
||||
} else if (count == 0) {
|
||||
count = rows * cols;
|
||||
}
|
||||
bool itemSource = element->attr("item-source", "false").asBool();
|
||||
SlotLayout layout(-1, glm::vec2(), true, itemSource, nullptr, nullptr);
|
||||
if (element->has("coord")) {
|
||||
layout.position = element->attr("coord").asVec2();
|
||||
}
|
||||
layout.padding = padding;
|
||||
|
||||
glm::vec2 size (
|
||||
cols * slotSize + (cols - 1) * interval + padding * 2,
|
||||
rows * slotSize + (rows - 1) * interval + padding * 2
|
||||
);
|
||||
int idx = 0;
|
||||
for (int row = 0; row < rows; row++) {
|
||||
for (int col = 0; col < cols; col++, idx++) {
|
||||
if (idx >= count) {
|
||||
return;
|
||||
}
|
||||
SlotLayout slotLayout = layout;
|
||||
slotLayout.index = startIndex + idx;
|
||||
slotLayout.position = glm::vec2(
|
||||
padding + col * (slotSize + interval),
|
||||
padding + row * (slotSize + interval)
|
||||
);
|
||||
auto slot = view->addSlot(slotLayout);
|
||||
view->add(slot, slotLayout.position);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<InventoryView> InventoryView::readXML(
|
||||
LevelFrontend* frontend,
|
||||
InventoryInteraction& interaction,
|
||||
const std::string& src,
|
||||
const std::string& file,
|
||||
const scripting::Environment& env
|
||||
) {
|
||||
auto view = std::make_shared<InventoryView>(frontend, interaction);
|
||||
auto view = std::make_shared<InventoryView>();
|
||||
|
||||
gui::UiXmlReader reader(env);
|
||||
reader.add("inventory", [=](gui::UiXmlReader& reader, xml::xmlelement element) {
|
||||
reader.readUINode(reader, element, *view);
|
||||
return view;
|
||||
});
|
||||
|
||||
reader.add("slot", [=](gui::UiXmlReader& reader, xml::xmlelement element) {
|
||||
int index = element->attr("index", "0").asInt();
|
||||
bool itemSource = element->attr("item-source", "false").asBool();
|
||||
SlotLayout layout(index, glm::vec2(), true, itemSource, nullptr, nullptr);
|
||||
if (element->has("coord")) {
|
||||
layout.position = element->attr("coord").asVec2();
|
||||
}
|
||||
auto slot = view->addSlot(layout);
|
||||
reader.readUINode(reader, element, *slot);
|
||||
return slot;
|
||||
});
|
||||
|
||||
reader.add("slots-grid", [=](gui::UiXmlReader& reader, xml::xmlelement element) {
|
||||
int startIndex = element->attr("start-index", "0").asInt();
|
||||
int rows = element->attr("rows", "0").asInt();
|
||||
int cols = element->attr("cols", "0").asInt();
|
||||
int count = element->attr("count", "0").asInt();
|
||||
const int slotSize = InventoryView::SLOT_SIZE;
|
||||
int interval = element->attr("interval", "-1").asInt();
|
||||
if (interval < 0) {
|
||||
interval = InventoryView::SLOT_INTERVAL;
|
||||
}
|
||||
int padding = element->attr("padding", "-1").asInt();
|
||||
if (padding < 0) {
|
||||
padding = interval;
|
||||
}
|
||||
if (rows == 0) {
|
||||
rows = ceildiv(count, cols);
|
||||
} else if (cols == 0) {
|
||||
cols = ceildiv(count, rows);
|
||||
} else if (count == 0) {
|
||||
count = rows * cols;
|
||||
}
|
||||
bool itemSource = element->attr("item-source", "false").asBool();
|
||||
SlotLayout layout(-1, glm::vec2(), true, itemSource, nullptr, nullptr);
|
||||
if (element->has("coord")) {
|
||||
layout.position = element->attr("coord").asVec2();
|
||||
}
|
||||
layout.padding = padding;
|
||||
|
||||
glm::vec2 size (
|
||||
cols * slotSize + (cols - 1) * interval + padding * 2,
|
||||
rows * slotSize + (rows - 1) * interval + padding * 2
|
||||
);
|
||||
auto container = std::make_shared<Container>(layout.position, size);
|
||||
int idx = 0;
|
||||
for (int row = 0; row < rows; row++) {
|
||||
for (int col = 0; col < cols; col++, idx++) {
|
||||
if (idx >= count) {
|
||||
return container;
|
||||
}
|
||||
SlotLayout slotLayout = layout;
|
||||
slotLayout.index = startIndex + idx;
|
||||
slotLayout.position = glm::vec2(
|
||||
padding + col * (slotSize + interval),
|
||||
padding + row * (slotSize + interval)
|
||||
);
|
||||
auto slot = view->addSlot(slotLayout);
|
||||
container->add(slot, slotLayout.position);
|
||||
}
|
||||
}
|
||||
return container;
|
||||
});
|
||||
createReaders(reader);
|
||||
|
||||
auto document = xml::parse(file, src);
|
||||
auto root = document->getRoot();
|
||||
if (root->getTag() != "inventory") {
|
||||
throw std::runtime_error("'inventory' element expected");
|
||||
}
|
||||
reader.readXML(file, root);
|
||||
return view;
|
||||
return std::dynamic_pointer_cast<InventoryView>(reader.readXML(file, root));
|
||||
}
|
||||
|
||||
void InventoryView::createReaders(gui::UiXmlReader& reader) {
|
||||
reader.add("inventory", [=](gui::UiXmlReader& reader, xml::xmlelement element) {
|
||||
auto view = std::make_shared<InventoryView>();
|
||||
reader.readUINode(reader, element, *view, true);
|
||||
|
||||
for (auto& sub : element->getElements()) {
|
||||
if (sub->getTag() == "slot") {
|
||||
readSlot(view.get(), reader, sub);
|
||||
} else if (sub->getTag() == "slots-grid") {
|
||||
readSlotsGrid(view.get(), reader, sub);
|
||||
}
|
||||
}
|
||||
return view;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -18,6 +18,10 @@ class ContentIndices;
|
||||
class LevelFrontend;
|
||||
class Inventory;
|
||||
|
||||
namespace gui {
|
||||
class UiXmlReader;
|
||||
}
|
||||
|
||||
namespace scripting {
|
||||
class Environment;
|
||||
}
|
||||
@@ -53,17 +57,15 @@ struct SlotLayout {
|
||||
};
|
||||
|
||||
class SlotView : public gui::UINode {
|
||||
LevelFrontend* frontend;
|
||||
InventoryInteraction& interaction;
|
||||
const Content* const content;
|
||||
LevelFrontend* frontend = nullptr;
|
||||
InventoryInteraction* interaction = nullptr;
|
||||
const Content* content;
|
||||
SlotLayout layout;
|
||||
bool highlighted = false;
|
||||
|
||||
ItemStack* bound = nullptr;
|
||||
public:
|
||||
SlotView(LevelFrontend* frontend,
|
||||
InventoryInteraction& interaction,
|
||||
SlotLayout layout);
|
||||
SlotView(SlotLayout layout);
|
||||
|
||||
virtual void draw(const GfxContext* pctx, Assets* assets) override;
|
||||
|
||||
@@ -73,7 +75,11 @@ public:
|
||||
virtual void clicked(gui::GUI*, int) override;
|
||||
virtual void focus(gui::GUI*) override;
|
||||
|
||||
void bind(ItemStack& stack);
|
||||
void bind(
|
||||
ItemStack& stack,
|
||||
LevelFrontend* frontend,
|
||||
InventoryInteraction* interaction
|
||||
);
|
||||
|
||||
const SlotLayout& getLayout() const;
|
||||
};
|
||||
@@ -83,13 +89,13 @@ class InventoryView : public gui::Container {
|
||||
const ContentIndices* indices;
|
||||
|
||||
std::shared_ptr<Inventory> inventory;
|
||||
LevelFrontend* frontend;
|
||||
InventoryInteraction& interaction;
|
||||
LevelFrontend* frontend = nullptr;
|
||||
InventoryInteraction* interaction = nullptr;
|
||||
|
||||
std::vector<SlotView*> slots;
|
||||
glm::vec2 origin {};
|
||||
public:
|
||||
InventoryView(LevelFrontend* frontend, InventoryInteraction& interaction);
|
||||
InventoryView();
|
||||
virtual ~InventoryView();
|
||||
|
||||
void setInventory(std::shared_ptr<Inventory> inventory);
|
||||
@@ -101,18 +107,22 @@ public:
|
||||
|
||||
void setSelected(int index);
|
||||
|
||||
void bind(std::shared_ptr<Inventory> inventory);
|
||||
void bind(
|
||||
std::shared_ptr<Inventory> inventory,
|
||||
LevelFrontend* frontend,
|
||||
InventoryInteraction* interaction
|
||||
);
|
||||
|
||||
std::shared_ptr<SlotView> addSlot(SlotLayout layout);
|
||||
|
||||
static std::shared_ptr<InventoryView> readXML(
|
||||
LevelFrontend* frontend,
|
||||
InventoryInteraction& interaction,
|
||||
const std::string& src,
|
||||
const std::string& file,
|
||||
const scripting::Environment& env
|
||||
);
|
||||
|
||||
static void createReaders(gui::UiXmlReader& reader);
|
||||
|
||||
static const int SLOT_INTERVAL = 4;
|
||||
static const int SLOT_SIZE = ITEM_ICON_SIZE;
|
||||
};
|
||||
@@ -120,7 +130,7 @@ public:
|
||||
class InventoryBuilder {
|
||||
std::shared_ptr<InventoryView> view;
|
||||
public:
|
||||
InventoryBuilder(LevelFrontend* frontend, InventoryInteraction& interaction);
|
||||
InventoryBuilder();
|
||||
|
||||
void addGrid(
|
||||
int cols, int count,
|
||||
|
||||
@@ -24,5 +24,4 @@ public:
|
||||
Atlas* getBlocksAtlas() const;
|
||||
};
|
||||
|
||||
|
||||
#endif // FRONTEND_LEVEL_FRONTEND_H_
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "InventoryView.h"
|
||||
#include "../logic/scripting/scripting.h"
|
||||
#include "../files/files.h"
|
||||
#include "../frontend/gui/gui_xml.h"
|
||||
|
||||
UiDocument::UiDocument(
|
||||
std::string namesp,
|
||||
@@ -27,16 +28,14 @@ void UiDocument::collect(uinodes_map& map, std::shared_ptr<gui::UINode> node) {
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<UiDocument> UiDocument::readInventory(
|
||||
std::string namesp,
|
||||
fs::path file,
|
||||
LevelFrontend* frontend,
|
||||
InventoryInteraction& interaction
|
||||
) {
|
||||
std::unique_ptr<UiDocument> UiDocument::read(std::string namesp, fs::path file) {
|
||||
const std::string text = files::read_string(file);
|
||||
auto xmldoc = xml::parse(file.u8string(), text);
|
||||
auto env = scripting::create_environment();
|
||||
auto view = InventoryView::readXML(
|
||||
frontend, interaction, text, file.u8string(), *env
|
||||
gui::UiXmlReader reader(*env);
|
||||
InventoryView::createReaders(reader);
|
||||
auto view = reader.readXML(
|
||||
file.u8string(), xmldoc->getRoot()
|
||||
);
|
||||
uidocscript script {};
|
||||
auto scriptFile = fs::path(file.u8string()+".lua");
|
||||
|
||||
@@ -12,9 +12,6 @@ namespace gui {
|
||||
class UINode;
|
||||
}
|
||||
|
||||
class InventoryInteraction;
|
||||
class LevelFrontend;
|
||||
|
||||
struct uidocscript {
|
||||
int environment;
|
||||
bool onopen : 1;
|
||||
@@ -37,13 +34,7 @@ public:
|
||||
/* Collect map of all uinodes having identifiers */
|
||||
static void collect(uinodes_map& map, std::shared_ptr<gui::UINode> node);
|
||||
|
||||
/* @return root node is always an InventoryView */
|
||||
static std::unique_ptr<UiDocument> readInventory (
|
||||
std::string namesp,
|
||||
fs::path file,
|
||||
LevelFrontend* frontend,
|
||||
InventoryInteraction& interaction
|
||||
);
|
||||
static std::unique_ptr<UiDocument> read (std::string namesp, fs::path file);
|
||||
};
|
||||
|
||||
#endif // FRONTEND_UI_DOCUMENT_H_
|
||||
|
||||
@@ -41,7 +41,7 @@ static void _readUINode(xml::xmlelement element, UINode& node) {
|
||||
}
|
||||
|
||||
|
||||
static void _readContainer(UiXmlReader& reader, xml::xmlelement element, Container& container) {
|
||||
static void _readContainer(UiXmlReader& reader, xml::xmlelement element, Container& container, bool ignoreUnknown) {
|
||||
_readUINode(element, container);
|
||||
|
||||
if (element->has("scrollable")) {
|
||||
@@ -50,12 +50,15 @@ static void _readContainer(UiXmlReader& reader, xml::xmlelement element, Contain
|
||||
for (auto& sub : element->getElements()) {
|
||||
if (sub->isText())
|
||||
continue;
|
||||
if (ignoreUnknown && !reader.hasReader(sub->getTag())) {
|
||||
continue;
|
||||
}
|
||||
container.add(reader.readUINode(sub));
|
||||
}
|
||||
}
|
||||
|
||||
void UiXmlReader::readUINode(UiXmlReader& reader, xml::xmlelement element, Container& container) {
|
||||
_readContainer(reader, element, container);
|
||||
void UiXmlReader::readUINode(UiXmlReader& reader, xml::xmlelement element, Container& container, bool ignoreUnknown) {
|
||||
_readContainer(reader, element, container, ignoreUnknown);
|
||||
}
|
||||
|
||||
void UiXmlReader::readUINode(UiXmlReader& reader, xml::xmlelement element, UINode& node) {
|
||||
@@ -104,7 +107,7 @@ static std::shared_ptr<UINode> readLabel(UiXmlReader& reader, xml::xmlelement el
|
||||
|
||||
static std::shared_ptr<UINode> readContainer(UiXmlReader& reader, xml::xmlelement element) {
|
||||
auto container = std::make_shared<Container>(glm::vec2(), glm::vec2());
|
||||
_readContainer(reader, element, *container);
|
||||
_readContainer(reader, element, *container, false);
|
||||
return container;
|
||||
}
|
||||
|
||||
@@ -153,6 +156,10 @@ void UiXmlReader::add(const std::string& tag, uinode_reader reader) {
|
||||
readers[tag] = reader;
|
||||
}
|
||||
|
||||
bool UiXmlReader::hasReader(const std::string& tag) const {
|
||||
return readers.find(tag) != readers.end();
|
||||
}
|
||||
|
||||
std::shared_ptr<UINode> UiXmlReader::readUINode(xml::xmlelement element) {
|
||||
const std::string& tag = element->getTag();
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ namespace gui {
|
||||
UiXmlReader(const scripting::Environment& env);
|
||||
|
||||
void add(const std::string& tag, uinode_reader reader);
|
||||
bool hasReader(const std::string& tag) const;
|
||||
|
||||
std::shared_ptr<UINode> readUINode(xml::xmlelement element);
|
||||
|
||||
@@ -36,7 +37,8 @@ namespace gui {
|
||||
void readUINode(
|
||||
UiXmlReader& reader,
|
||||
xml::xmlelement element,
|
||||
Container& container
|
||||
Container& container,
|
||||
bool ignoreUnknown=false
|
||||
);
|
||||
|
||||
std::shared_ptr<UINode> readXML(
|
||||
|
||||
+11
-9
@@ -189,10 +189,10 @@ std::shared_ptr<InventoryView> HudRenderer::createContentAccess() {
|
||||
inventory->getSlot(player->getChosenSlot()).set(item);
|
||||
});
|
||||
|
||||
InventoryBuilder builder(frontend, *interaction);
|
||||
InventoryBuilder builder;
|
||||
builder.addGrid(8, itemsCount-1, glm::vec2(), 8, true, slotLayout);
|
||||
auto view = builder.build();
|
||||
view->bind(accessInventory);
|
||||
view->bind(accessInventory, frontend, interaction.get());
|
||||
return view;
|
||||
}
|
||||
|
||||
@@ -202,12 +202,12 @@ std::shared_ptr<InventoryView> HudRenderer::createHotbar() {
|
||||
auto inventory = player->getInventory();
|
||||
|
||||
SlotLayout slotLayout(-1, glm::vec2(), false, false, nullptr, nullptr);
|
||||
InventoryBuilder builder(frontend, *interaction);
|
||||
InventoryBuilder builder;
|
||||
builder.addGrid(10, 10, glm::vec2(), 4, true, slotLayout);
|
||||
auto view = builder.build();
|
||||
|
||||
view->setOrigin(glm::vec2(view->getSize().x/2, 0));
|
||||
view->bind(inventory);
|
||||
view->bind(inventory, frontend, interaction.get());
|
||||
view->setInteractive(false);
|
||||
return view;
|
||||
}
|
||||
@@ -221,10 +221,10 @@ std::shared_ptr<InventoryView> HudRenderer::createInventory() {
|
||||
stack.clear();
|
||||
}, nullptr);
|
||||
|
||||
InventoryBuilder builder(frontend, *interaction);
|
||||
InventoryBuilder builder;
|
||||
builder.addGrid(10, inventory->size(), glm::vec2(), 4, true, slotLayout);
|
||||
auto view = builder.build();
|
||||
view->bind(inventory);
|
||||
view->bind(inventory, frontend, interaction.get());
|
||||
return view;
|
||||
}
|
||||
|
||||
@@ -237,11 +237,13 @@ HudRenderer::HudRenderer(Engine* engine, LevelFrontend* frontend)
|
||||
|
||||
interaction = std::make_unique<InventoryInteraction>();
|
||||
grabbedItemView = std::make_shared<SlotView>(
|
||||
frontend,
|
||||
*interaction,
|
||||
SlotLayout(-1, glm::vec2(), false, false, nullptr, nullptr)
|
||||
);
|
||||
grabbedItemView->bind(interaction->getGrabbedItem());
|
||||
grabbedItemView->bind(
|
||||
interaction->getGrabbedItem(),
|
||||
frontend,
|
||||
interaction.get()
|
||||
);
|
||||
grabbedItemView->setColor(glm::vec4());
|
||||
grabbedItemView->setInteractive(false);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user