mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-06-08 16:15:35 -04:00
fix(inventory): size backpack window to actual keyring contents
renderBagWindow reserved height for ALL 32 keyring slots at 40px in 6 columns, but the keyring renders at 24px in 8 columns and only draws rows that contain occupied slots. Result: a huge empty grey area below the items in the Backpack window. Mirror the render-side calculation (lastOccupied → visibleKeySlots → keyringRows at 24px) in the height math; skip the keyring height entirely when nothing is keyed.
This commit is contained in:
@@ -1094,9 +1094,24 @@ void InventoryScreen::renderBagWindow(const char* title, bool& isOpen,
|
||||
int rows = (numSlots + columns - 1) / columns;
|
||||
float contentH = rows * (slotSize + 4.0f) + 10.0f;
|
||||
if (bagIndex < 0) {
|
||||
int keyringRows = (inventory.getKeyringSize() + columns - 1) / columns;
|
||||
// Keyring renders at 24px in 8 columns and ONLY shows rows that have
|
||||
// occupied slots (rounded up to a full row of 8) — must match the
|
||||
// render logic below or we reserve huge empty space.
|
||||
constexpr float keySlotSize = 24.0f;
|
||||
constexpr int keyCols = 8;
|
||||
int lastOccupied = -1;
|
||||
if (showKeyring_) {
|
||||
for (int i = inventory.getKeyringSize() - 1; i >= 0; --i) {
|
||||
if (!inventory.getKeyringSlot(i).empty()) { lastOccupied = i; break; }
|
||||
}
|
||||
}
|
||||
int visibleKeySlots = (lastOccupied < 0) ? 0
|
||||
: ((lastOccupied / keyCols) + 1) * keyCols;
|
||||
int keyringRows = (visibleKeySlots + keyCols - 1) / keyCols;
|
||||
contentH += 36.0f; // separator + sort button + money display
|
||||
contentH += 30.0f + keyringRows * (slotSize + 4.0f); // keyring header + slots
|
||||
if (visibleKeySlots > 0) {
|
||||
contentH += 30.0f + keyringRows * (keySlotSize + 4.0f); // header + slots
|
||||
}
|
||||
}
|
||||
float gridW = columns * (slotSize + 4.0f) + 30.0f;
|
||||
// Ensure window is wide enough for the title + close button
|
||||
|
||||
Reference in New Issue
Block a user