From ce1919c195962ef683ad0af7ee33ce7973c0f03c Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 30 Oct 2015 21:50:44 +0300 Subject: Fix resize item container in npc dialog. --- src/gui/widgets/itemcontainer.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/gui/widgets') diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index 2ec0209ee..b7af26a95 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -883,14 +883,17 @@ void ItemContainer::adjustHeight() if (mGridRows == 0 || (mLastUsedSlot + 1) % mGridColumns > 0) ++mGridRows; - const unsigned int invSize = mInventory->getSize(); - const int maxRows = mShowEmptyRows == ShowEmptyRows_true ? + int maxRows = mShowEmptyRows == ShowEmptyRows_true ? std::max(invSize / mGridColumns, static_cast(mGridRows)) : mGridRows; if (mShowEmptyRows == ShowEmptyRows_true) + { + if (mGridColumns * maxRows < invSize) + maxRows ++; mGridRows = maxRows; + } setHeight(maxRows * mBoxHeight); updateMatrix(); @@ -1019,7 +1022,6 @@ int ItemContainer::getSlotByXY(int x, int y) const if (x > mBoxWidth * mGridColumns) return Inventory::NO_SLOT_INDEX; const int idx = (y / mBoxHeight) * mGridColumns + (x / mBoxWidth); - logger->log("getSlotByXY 3: %d, %d*%d", idx, mGridRows, mGridColumns); if (idx >= 0 && idx < mGridRows * mGridColumns) return idx; } -- cgit v1.2.3-60-g2f50