From 927611c06ba4d2bd3a1d24e176fe3f561384f3d7 Mon Sep 17 00:00:00 2001 From: neveix Date: Thu, 13 Aug 2026 22:16:21 +0500 Subject: [PATCH] implement a bit --- src/graphics/ui/elements/InventoryView.cpp | 7 +++++++ src/items/ItemStack.cpp | 8 ++++++++ src/items/ItemStack.hpp | 1 + 3 files changed, 16 insertions(+) diff --git a/src/graphics/ui/elements/InventoryView.cpp b/src/graphics/ui/elements/InventoryView.cpp index e99a86d33..29111a4ad 100644 --- a/src/graphics/ui/elements/InventoryView.cpp +++ b/src/graphics/ui/elements/InventoryView.cpp @@ -1,5 +1,7 @@ #include "InventoryView.hpp" +#include + #include #include @@ -368,6 +370,7 @@ void SlotView::performLeftClick(ItemStack& stack, ItemStack& grabbed) { return; } + std::cout << "perform left click" << std::endl; if (!layout.itemSource && stack.accepts(grabbed) && layout.placing) { action = InteractionAction::PUT; stack.move(grabbed, *content->getIndices()); @@ -375,6 +378,10 @@ void SlotView::performLeftClick(ItemStack& stack, ItemStack& grabbed) { if (layout.itemSource) { if (grabbed.isEmpty()) { action = InteractionAction::TAKE; + if (input.pressed(Keycode::LEFT_SHIFT)) { + stack.maximizeCount(*content->getIndices()); + std::cout << "maximized grabbed item" << std::endl; + } grabbed.set(stack); } else { action = InteractionAction::PUT; diff --git a/src/items/ItemStack.cpp b/src/items/ItemStack.cpp index f99d8700a..d0f39d5fe 100644 --- a/src/items/ItemStack.cpp +++ b/src/items/ItemStack.cpp @@ -48,6 +48,14 @@ void ItemStack::setCount(itemcount_t count) { } } +void ItemStack::maximizeCount(const ContentIndices& indices) { + auto& def = indices.items.require(getItemId()); + this->count = def.stackSize; + if (count == 0) { + clear(); + } +} + void ItemStack::setField(std::string_view name, dv::value value) { if (fields == nullptr) { if (value == nullptr) { diff --git a/src/items/ItemStack.hpp b/src/items/ItemStack.hpp index 4896bc39e..1ec3fe41d 100644 --- a/src/items/ItemStack.hpp +++ b/src/items/ItemStack.hpp @@ -18,6 +18,7 @@ public: void set(const ItemStack& item); void set(ItemStack&& item); void setCount(itemcount_t count); + void maximizeCount(const ContentIndices& indices); /// @brief Set a field in the item stack data. void setField(std::string_view name, dv::value value);