From 5d66c41f80f3c0db2508c47f7f50af2dc29748d6 Mon Sep 17 00:00:00 2001 From: neveix Date: Fri, 14 Aug 2026 14:30:34 +0500 Subject: [PATCH] fix p.5 --- src/graphics/ui/elements/InventoryView.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/graphics/ui/elements/InventoryView.cpp b/src/graphics/ui/elements/InventoryView.cpp index 310c9fd28..333777857 100644 --- a/src/graphics/ui/elements/InventoryView.cpp +++ b/src/graphics/ui/elements/InventoryView.cpp @@ -366,10 +366,10 @@ void SlotView::performLeftClick(ItemStack& stack, ItemStack& grabbed) { ); return; } - + auto indices = *content->getIndices(); if (!layout.itemSource && stack.accepts(grabbed) && layout.placing) { action = InteractionAction::PUT; - stack.move(grabbed, *content->getIndices()); + stack.move(grabbed, indices); } else { if (layout.itemSource) { if (grabbed.isEmpty()) { @@ -379,8 +379,17 @@ void SlotView::performLeftClick(ItemStack& stack, ItemStack& grabbed) { grabbed.maximizeCount(*content->getIndices()); } } else { - action = InteractionAction::PUT; - grabbed.clear(); + // TODO: refactor to reduce nesting + if (grabbed.accepts(stack)) { + auto& def = indices.items.require(stack.getItemId()); + if (grabbed.getCount() < def.stackSize) { + action = InteractionAction::TAKE; + grabbed.setCount(grabbed.getCount() + 1); + } + } else { + action = InteractionAction::PUT; + grabbed.clear(); + } } } else if (grabbed.isEmpty()) { if (layout.taking) {