mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-12 14:31:50 +00:00
InventoryView.addGrid semantics changed
This commit is contained in:
parent
9e3c4fb00c
commit
aa93c27159
3 changed files with 8 additions and 12 deletions
|
|
@ -72,7 +72,7 @@ InventoryBuilder::InventoryBuilder()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void InventoryBuilder::addGrid(
|
void InventoryBuilder::addGrid(
|
||||||
int cols, int rows,
|
int cols, int count,
|
||||||
glm::vec2 coord,
|
glm::vec2 coord,
|
||||||
int padding,
|
int padding,
|
||||||
SlotLayout slotLayout)
|
SlotLayout slotLayout)
|
||||||
|
|
@ -80,6 +80,8 @@ void InventoryBuilder::addGrid(
|
||||||
const int slotSize = InventoryView::SLOT_SIZE;
|
const int slotSize = InventoryView::SLOT_SIZE;
|
||||||
const int interval = InventoryView::SLOT_INTERVAL;
|
const int interval = InventoryView::SLOT_INTERVAL;
|
||||||
|
|
||||||
|
int rows = ceildiv(count, cols);
|
||||||
|
|
||||||
uint width = cols * (slotSize + interval) - interval + padding*2;
|
uint width = cols * (slotSize + interval) - interval + padding*2;
|
||||||
uint height = rows * (slotSize + interval) - interval + padding*2;
|
uint height = rows * (slotSize + interval) - interval + padding*2;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ public:
|
||||||
InventoryBuilder();
|
InventoryBuilder();
|
||||||
|
|
||||||
void addGrid(
|
void addGrid(
|
||||||
int cols, int rows,
|
int cols, int count,
|
||||||
glm::vec2 coord,
|
glm::vec2 coord,
|
||||||
int padding,
|
int padding,
|
||||||
SlotLayout slotLayout);
|
SlotLayout slotLayout);
|
||||||
|
|
|
||||||
|
|
@ -186,10 +186,8 @@ std::shared_ptr<InventoryView> HudRenderer::createContentAccess() {
|
||||||
inventory->getSlot(player->getChosenSlot()).set(item);
|
inventory->getSlot(player->getChosenSlot()).set(item);
|
||||||
});
|
});
|
||||||
|
|
||||||
int columns = 8;
|
|
||||||
int rows = ceildiv(itemsCount-1, columns);
|
|
||||||
InventoryBuilder builder;
|
InventoryBuilder builder;
|
||||||
builder.addGrid(columns, rows, glm::vec2(), 8, slotLayout);
|
builder.addGrid(8, itemsCount-1, glm::vec2(), 8, slotLayout);
|
||||||
auto layout = builder.build();
|
auto layout = builder.build();
|
||||||
|
|
||||||
auto contentAccess = std::make_shared<InventoryView>(
|
auto contentAccess = std::make_shared<InventoryView>(
|
||||||
|
|
@ -211,7 +209,7 @@ std::shared_ptr<InventoryView> HudRenderer::createHotbar() {
|
||||||
|
|
||||||
SlotLayout slotLayout(glm::vec2(), false, false, nullptr, nullptr);
|
SlotLayout slotLayout(glm::vec2(), false, false, nullptr, nullptr);
|
||||||
InventoryBuilder builder;
|
InventoryBuilder builder;
|
||||||
builder.addGrid(10, 1, glm::vec2(), 4, slotLayout);
|
builder.addGrid(10, 10, glm::vec2(), 4, slotLayout);
|
||||||
auto layout = builder.build();
|
auto layout = builder.build();
|
||||||
|
|
||||||
layout->setOrigin(glm::vec2(layout->getSize().x/2, 0));
|
layout->setOrigin(glm::vec2(layout->getSize().x/2, 0));
|
||||||
|
|
@ -237,12 +235,8 @@ std::shared_ptr<InventoryView> HudRenderer::createInventory() {
|
||||||
stack.clear();
|
stack.clear();
|
||||||
}, nullptr);
|
}, nullptr);
|
||||||
|
|
||||||
int columns = 10;
|
|
||||||
int rows = ceildiv(inventory->size(), columns);
|
|
||||||
int padding = 4;
|
|
||||||
|
|
||||||
InventoryBuilder builder;
|
InventoryBuilder builder;
|
||||||
builder.addGrid(columns, rows, glm::vec2(), padding, slotLayout);
|
builder.addGrid(10, inventory->size(), glm::vec2(), 4, slotLayout);
|
||||||
auto layout = builder.build();
|
auto layout = builder.build();
|
||||||
|
|
||||||
auto view = std::make_shared<InventoryView>(
|
auto view = std::make_shared<InventoryView>(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue