InventoryView.addGrid semantics changed
This commit is contained in:
@@ -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);
|
||||||
|
|||||||
+4
-10
@@ -186,12 +186,10 @@ 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>(
|
||||||
content,
|
content,
|
||||||
frontend,
|
frontend,
|
||||||
@@ -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));
|
||||||
@@ -236,13 +234,9 @@ std::shared_ptr<InventoryView> HudRenderer::createInventory() {
|
|||||||
SlotLayout slotLayout(glm::vec2(), true, false, [=](ItemStack& stack) {
|
SlotLayout slotLayout(glm::vec2(), true, false, [=](ItemStack& stack) {
|
||||||
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>(
|
||||||
|
|||||||
Reference in New Issue
Block a user