Every time UpdateLootWindow runs, it's creating a new set of widgets (Fontstrings and Buttons) on top of the old ones.
You should only create them once (and maybe add extras (once) if needed)
Very rough example:
Lua Code:
LootAddonFrame.LootWindow = CreateFrame("Frame", "LootAddonFrame_LootWindow", UIParent, "UIPanelDialogTemplate")
LootAddonFrame.LootWindow.PlayerInfo = {} -- a table to store created FontString references
UpdateLootWindow()
Lua Code:
local count = 0
for playerName, lootList in pairs(lootHistory) do
-- ...
local playerLabel
count = count + 1
local last = #LootAddonFrame.LootWindow.PlayerInfo -- How many have we created previously
if last < count -- not enough widgets so create new FontString and Button
playerLabel = LootAddonFrame.LootWindow:CreateFontString(nil, "OVERLAY", "GameFontNormal")
local whisperButton = CreateFrame("Button", nil, LootAddonFrame.LootWindow, "UIPanelButtonTemplate")
-- configure the fontstring and button scripts etc.
if count = 1 then -- place them relative to the frame or previous string/buttons (instead of calculating y offset
playerLabel:SetPoint("TOPLEFT", 10, -30)
else
local lastInList = LootAddonFrame.LootWindow.PlayerInfo[last]
playerLabel:SetPoint("TOPLEFT", lastInList, "BOTTOMLEFT", 0, -3)
end
whisperButton:SetPoint("LEFT", playerLabel, "RIGHT", 5, 0)
tinsert(LootAddonFrame.LootWindow.PlayerInfo, playerLabel) -- add the label to the reacking table
else
playerLabel = LootAddonFrame.LootWindow.PlayerInfo[last] -- a fonstring exists so re-use those first
end
-- update the FontString text and whatever else.
playerLabel:SetText(coloredPlayerName .. " looted:")
-- ...
end