category view spacing bug fixed
This commit is contained in:
@@ -15,6 +15,9 @@ addon.DEBUG = false
|
|||||||
-- Debug sort flag (verbose sorting output)
|
-- Debug sort flag (verbose sorting output)
|
||||||
addon.DEBUG_SORT = false
|
addon.DEBUG_SORT = false
|
||||||
|
|
||||||
|
-- Debug category view flag (for troubleshooting category view layout issues)
|
||||||
|
addon.DEBUG_CATEGORY = false
|
||||||
|
|
||||||
-- Constants
|
-- Constants
|
||||||
addon.Constants = {
|
addon.Constants = {
|
||||||
-- Bag IDs
|
-- Bag IDs
|
||||||
@@ -243,6 +246,14 @@ function addon:DebugSort(msg, a1, a2, a3, a4, a5, a6, a7)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Debug category view print (only shows when DEBUG_CATEGORY is enabled)
|
||||||
|
function addon:DebugCategory(msg, a1, a2, a3, a4, a5, a6, a7)
|
||||||
|
if self.DEBUG_CATEGORY then
|
||||||
|
local text = string.format(msg or "nil", a1 or "", a2 or "", a3 or "", a4 or "", a5 or "", a6 or "", a7 or "")
|
||||||
|
DEFAULT_CHAT_FRAME:AddMessage("|cFFFF69B4[Category]|r |cFF00FF96Guda:|r " .. text)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Error handler
|
-- Error handler
|
||||||
function addon:Error(msg, a1, a2, a3, a4, a5, a6, a7)
|
function addon:Error(msg, a1, a2, a3, a4, a5, a6, a7)
|
||||||
local text = string.format(msg, a1, a2, a3, a4, a5, a6, a7)
|
local text = string.format(msg, a1, a2, a3, a4, a5, a6, a7)
|
||||||
|
|||||||
@@ -132,6 +132,11 @@ function Main:SetupSlashCommands()
|
|||||||
addon.DEBUG_SORT = not addon.DEBUG_SORT
|
addon.DEBUG_SORT = not addon.DEBUG_SORT
|
||||||
addon:Print("Debug sort mode: %s", addon.DEBUG_SORT and "ON" or "OFF")
|
addon:Print("Debug sort mode: %s", addon.DEBUG_SORT and "ON" or "OFF")
|
||||||
|
|
||||||
|
elseif msg == "debugcat" then
|
||||||
|
-- Toggle debug category view (for troubleshooting layout issues)
|
||||||
|
addon.DEBUG_CATEGORY = not addon.DEBUG_CATEGORY
|
||||||
|
addon:Print("Debug category mode: %s", addon.DEBUG_CATEGORY and "ON" or "OFF")
|
||||||
|
|
||||||
elseif msg == "quest" then
|
elseif msg == "quest" then
|
||||||
-- Toggle quest bar
|
-- Toggle quest bar
|
||||||
local show = not addon.Modules.DB:GetSetting("showQuestBar")
|
local show = not addon.Modules.DB:GetSetting("showQuestBar")
|
||||||
|
|||||||
@@ -422,6 +422,9 @@ function BagFrame:Update()
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local viewType = addon.Modules.DB:GetSetting("bagViewType") or "single"
|
||||||
|
addon:DebugCategory("Update() START: viewType=%s", viewType)
|
||||||
|
|
||||||
-- Report entry for frame budget tracking
|
-- Report entry for frame budget tracking
|
||||||
if addon.Modules.Utils and addon.Modules.Utils.ReportEntry then
|
if addon.Modules.Utils and addon.Modules.Utils.ReportEntry then
|
||||||
addon.Modules.Utils:ReportEntry()
|
addon.Modules.Utils:ReportEntry()
|
||||||
@@ -453,16 +456,23 @@ function BagFrame:Update()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Mark all existing buttons as not in use (we'll mark active ones during display)
|
-- Mark all existing buttons as not in use (we'll mark active ones during display)
|
||||||
|
local totalButtonsBefore = 0
|
||||||
|
local shownButtonsBefore = 0
|
||||||
for _, bagParent in pairs(bagParents) do
|
for _, bagParent in pairs(bagParents) do
|
||||||
if bagParent then
|
if bagParent then
|
||||||
local buttons = { bagParent:GetChildren() }
|
local buttons = { bagParent:GetChildren() }
|
||||||
for _, button in ipairs(buttons) do
|
for _, button in ipairs(buttons) do
|
||||||
if button.hasItem ~= nil then
|
if button.hasItem ~= nil then
|
||||||
|
totalButtonsBefore = totalButtonsBefore + 1
|
||||||
|
if button:IsShown() then
|
||||||
|
shownButtonsBefore = shownButtonsBefore + 1
|
||||||
|
end
|
||||||
button.inUse = false
|
button.inUse = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
addon:DebugCategory("Update() BEFORE: totalButtons=%d, shownButtons=%d", totalButtonsBefore, shownButtonsBefore)
|
||||||
|
|
||||||
local bagData
|
local bagData
|
||||||
local isOtherChar = false
|
local isOtherChar = false
|
||||||
@@ -515,7 +525,9 @@ function BagFrame:Update()
|
|||||||
end
|
end
|
||||||
|
|
||||||
if viewType == "category" then
|
if viewType == "category" then
|
||||||
|
addon:DebugCategory("Update() calling DisplayItemsByCategory")
|
||||||
self:DisplayItemsByCategory(bagData, isOtherChar, charName)
|
self:DisplayItemsByCategory(bagData, isOtherChar, charName)
|
||||||
|
addon:DebugCategory("Update() DisplayItemsByCategory returned, itemButtons count=%d", table.getn(itemButtons))
|
||||||
-- Show sort button with merge icon/tooltip for category view
|
-- Show sort button with merge icon/tooltip for category view
|
||||||
local sortBtn = getglobal("Guda_BagFrame_SortButton")
|
local sortBtn = getglobal("Guda_BagFrame_SortButton")
|
||||||
if sortBtn then
|
if sortBtn then
|
||||||
@@ -544,6 +556,8 @@ function BagFrame:Update()
|
|||||||
self:UpdateBaglineLayout()
|
self:UpdateBaglineLayout()
|
||||||
|
|
||||||
-- Clean up unused buttons AFTER display is complete (prevents drag/drop issues)
|
-- Clean up unused buttons AFTER display is complete (prevents drag/drop issues)
|
||||||
|
local hiddenCount = 0
|
||||||
|
local stillShownCount = 0
|
||||||
for _, bagParent in pairs(bagParents) do
|
for _, bagParent in pairs(bagParents) do
|
||||||
if bagParent then
|
if bagParent then
|
||||||
local buttons = { bagParent:GetChildren() }
|
local buttons = { bagParent:GetChildren() }
|
||||||
@@ -551,15 +565,20 @@ function BagFrame:Update()
|
|||||||
if button.hasItem ~= nil and not button.inUse then
|
if button.hasItem ~= nil and not button.inUse then
|
||||||
button:Hide()
|
button:Hide()
|
||||||
button:ClearAllPoints()
|
button:ClearAllPoints()
|
||||||
|
hiddenCount = hiddenCount + 1
|
||||||
|
elseif button.hasItem ~= nil and button:IsShown() then
|
||||||
|
stillShownCount = stillShownCount + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
addon:DebugCategory("Update() CLEANUP: hidden=%d, stillShown=%d", hiddenCount, stillShownCount)
|
||||||
|
|
||||||
-- Record performance metrics
|
-- Record performance metrics
|
||||||
if addon.Modules.Utils and addon.Modules.Utils.RecordUpdateEnd then
|
if addon.Modules.Utils and addon.Modules.Utils.RecordUpdateEnd then
|
||||||
addon.Modules.Utils:RecordUpdateEnd()
|
addon.Modules.Utils:RecordUpdateEnd()
|
||||||
end
|
end
|
||||||
|
addon:DebugCategory("Update() END")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Delegate to centralized helpers
|
-- Delegate to centralized helpers
|
||||||
@@ -578,11 +597,14 @@ function BagFrame:DisplayItemsByCategory(bagData, isOtherChar, charName)
|
|||||||
local perRow = addon.Modules.DB:GetSetting("bagColumns") or 10
|
local perRow = addon.Modules.DB:GetSetting("bagColumns") or 10
|
||||||
local itemContainer = getglobal("Guda_BagFrame_ItemContainer")
|
local itemContainer = getglobal("Guda_BagFrame_ItemContainer")
|
||||||
|
|
||||||
|
addon:DebugCategory("DisplayItemsByCategory START: buttonSize=%d, spacing=%d, perRow=%d", buttonSize, spacing, perRow)
|
||||||
|
|
||||||
-- Use centralized category initialization
|
-- Use centralized category initialization
|
||||||
local categories, specialItems = Guda_InitCategories()
|
local categories, specialItems = Guda_InitCategories()
|
||||||
local categoryList = Guda_CategoryList
|
local categoryList = Guda_CategoryList
|
||||||
|
|
||||||
-- Categorize all items using centralized function
|
-- Categorize all items using centralized function
|
||||||
|
local totalItemsCategorized = 0
|
||||||
for _, bagID in ipairs(addon.Constants.BAGS) do
|
for _, bagID in ipairs(addon.Constants.BAGS) do
|
||||||
if not hiddenBags[bagID] then
|
if not hiddenBags[bagID] then
|
||||||
local bag = bagData[bagID]
|
local bag = bagData[bagID]
|
||||||
@@ -590,11 +612,13 @@ function BagFrame:DisplayItemsByCategory(bagData, isOtherChar, charName)
|
|||||||
for slotID, itemData in pairs(bag.slots) do
|
for slotID, itemData in pairs(bag.slots) do
|
||||||
if itemData then
|
if itemData then
|
||||||
Guda_CategorizeItem(itemData, bagID, slotID, categories, specialItems, isOtherChar)
|
Guda_CategorizeItem(itemData, bagID, slotID, categories, specialItems, isOtherChar)
|
||||||
|
totalItemsCategorized = totalItemsCategorized + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
addon:DebugCategory("DisplayItemsByCategory: totalItemsCategorized=%d", totalItemsCategorized)
|
||||||
|
|
||||||
-- Calculate total empty slots and find first available one for drop target
|
-- Calculate total empty slots and find first available one for drop target
|
||||||
local totalFreeSlots = 0
|
local totalFreeSlots = 0
|
||||||
@@ -640,10 +664,12 @@ function BagFrame:DisplayItemsByCategory(bagData, isOtherChar, charName)
|
|||||||
local categoryItemsProcessed = 0
|
local categoryItemsProcessed = 0
|
||||||
local CATEGORY_ITEMS_PER_BUDGET_CHECK = 8
|
local CATEGORY_ITEMS_PER_BUDGET_CHECK = 8
|
||||||
|
|
||||||
|
local totalButtonsCreated = 0
|
||||||
for _, catName in ipairs(categoryList) do
|
for _, catName in ipairs(categoryList) do
|
||||||
local items = categories[catName]
|
local items = categories[catName]
|
||||||
local numItems = items and table.getn(items) or 0
|
local numItems = items and table.getn(items) or 0
|
||||||
if numItems > 0 then
|
if numItems > 0 then
|
||||||
|
addon:DebugCategory(" Category '%s': %d items, pos=(%d,%d)", catName, numItems, currentX, currentY)
|
||||||
-- Sort items using centralized sorter
|
-- Sort items using centralized sorter
|
||||||
Guda_SortCategoryItems(items)
|
Guda_SortCategoryItems(items)
|
||||||
|
|
||||||
@@ -658,6 +684,7 @@ function BagFrame:DisplayItemsByCategory(bagData, isOtherChar, charName)
|
|||||||
currentX = 0
|
currentX = 0
|
||||||
currentY = currentY + rowMaxHeight
|
currentY = currentY + rowMaxHeight
|
||||||
rowMaxHeight = 0
|
rowMaxHeight = 0
|
||||||
|
addon:DebugCategory(" -> wrap to new row, Y=%d", currentY)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Add Header
|
-- Add Header
|
||||||
@@ -725,10 +752,12 @@ function BagFrame:DisplayItemsByCategory(bagData, isOtherChar, charName)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
totalButtonsCreated = totalButtonsCreated + numItems
|
||||||
if blockHeight > rowMaxHeight then rowMaxHeight = blockHeight end
|
if blockHeight > rowMaxHeight then rowMaxHeight = blockHeight end
|
||||||
currentX = currentX + blockWidth + 20
|
currentX = currentX + blockWidth + 20
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
addon:DebugCategory("DisplayItemsByCategory: totalButtonsCreated=%d from categories", totalButtonsCreated)
|
||||||
|
|
||||||
-- Update Y for bottom sections
|
-- Update Y for bottom sections
|
||||||
local y = currentY + rowMaxHeight
|
local y = currentY + rowMaxHeight
|
||||||
@@ -868,6 +897,7 @@ function BagFrame:DisplayItemsByCategory(bagData, isOtherChar, charName)
|
|||||||
local finalHeight = math.abs(y) + 20
|
local finalHeight = math.abs(y) + 20
|
||||||
itemContainer:SetHeight(finalHeight)
|
itemContainer:SetHeight(finalHeight)
|
||||||
self:ResizeFrame(nil, nil, perRow, finalHeight)
|
self:ResizeFrame(nil, nil, perRow, finalHeight)
|
||||||
|
addon:DebugCategory("DisplayItemsByCategory END: finalHeight=%d, itemButtons=%d", finalHeight, table.getn(itemButtons))
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Display items
|
-- Display items
|
||||||
@@ -2698,6 +2728,9 @@ function BagFrame:Initialize()
|
|||||||
-- Only handle player bags (0-4)
|
-- Only handle player bags (0-4)
|
||||||
if not arg1 or arg1 < 0 or arg1 > 4 then return end
|
if not arg1 or arg1 < 0 or arg1 > 4 then return end
|
||||||
|
|
||||||
|
local viewType = addon.Modules.DB:GetSetting("bagViewType") or "single"
|
||||||
|
addon:DebugCategory("BAG_UPDATE: bagID=%s, viewType=%s", tostring(arg1), viewType)
|
||||||
|
|
||||||
-- Check if sorting is in progress - use full redraw with throttle
|
-- Check if sorting is in progress - use full redraw with throttle
|
||||||
local isSorting = addon.Modules.SortEngine and addon.Modules.SortEngine.sortingInProgress
|
local isSorting = addon.Modules.SortEngine and addon.Modules.SortEngine.sortingInProgress
|
||||||
|
|
||||||
@@ -2708,11 +2741,14 @@ function BagFrame:Initialize()
|
|||||||
|
|
||||||
-- Try to update only changed slots in this bag
|
-- Try to update only changed slots in this bag
|
||||||
local result = BagFrame:UpdateChangedSlots(arg1)
|
local result = BagFrame:UpdateChangedSlots(arg1)
|
||||||
|
addon:DebugCategory("BAG_UPDATE: UpdateChangedSlots result=%s", tostring(result))
|
||||||
if result >= 0 then
|
if result >= 0 then
|
||||||
-- Success - updated slots without full redraw
|
-- Success - updated slots without full redraw
|
||||||
|
addon:DebugCategory("BAG_UPDATE: Incremental update succeeded, skipping full redraw")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
-- Fall through to full redraw if incremental update failed
|
-- Fall through to full redraw if incremental update failed
|
||||||
|
addon:DebugCategory("BAG_UPDATE: Incremental update failed, doing full redraw")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Sorting in progress or incremental update failed - use throttled full redraw
|
-- Sorting in progress or incremental update failed - use throttled full redraw
|
||||||
|
|||||||
+21
-1
@@ -143,10 +143,21 @@ local categoriesCache = nil
|
|||||||
local specialItemsCache = nil
|
local specialItemsCache = nil
|
||||||
|
|
||||||
-- Clear a table without creating a new one (Lua 5.0 compatible)
|
-- Clear a table without creating a new one (Lua 5.0 compatible)
|
||||||
|
-- For arrays, iterate backwards to safely remove all elements
|
||||||
local function WipeTable(t)
|
local function WipeTable(t)
|
||||||
if not t then return end
|
if not t then return end
|
||||||
|
-- For arrays (numeric keys), remove from end to start
|
||||||
|
local n = table.getn(t)
|
||||||
|
if n > 0 then
|
||||||
|
for i = n, 1, -1 do
|
||||||
|
table.remove(t, i)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- Also clear any non-numeric keys (hash part)
|
||||||
for k in pairs(t) do
|
for k in pairs(t) do
|
||||||
t[k] = nil
|
if type(k) ~= "number" then
|
||||||
|
t[k] = nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -161,10 +172,19 @@ function Guda_InitCategories()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Clear existing category arrays (don't recreate the main table)
|
-- Clear existing category arrays (don't recreate the main table)
|
||||||
|
local totalItemsBeforeWipe = 0
|
||||||
for cat, items in pairs(categoriesCache) do
|
for cat, items in pairs(categoriesCache) do
|
||||||
|
totalItemsBeforeWipe = totalItemsBeforeWipe + table.getn(items)
|
||||||
WipeTable(items)
|
WipeTable(items)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Verify wipe worked
|
||||||
|
local totalItemsAfterWipe = 0
|
||||||
|
for cat, items in pairs(categoriesCache) do
|
||||||
|
totalItemsAfterWipe = totalItemsAfterWipe + table.getn(items)
|
||||||
|
end
|
||||||
|
addon:DebugCategory("InitCategories: beforeWipe=%d, afterWipe=%d", totalItemsBeforeWipe, totalItemsAfterWipe)
|
||||||
|
|
||||||
if addon.Modules.CategoryManager then
|
if addon.Modules.CategoryManager then
|
||||||
-- Get full category order (all categories, not just enabled)
|
-- Get full category order (all categories, not just enabled)
|
||||||
local allCategories = addon.Modules.CategoryManager:GetCategoryOrder()
|
local allCategories = addon.Modules.CategoryManager:GetCategoryOrder()
|
||||||
|
|||||||
Reference in New Issue
Block a user