So I'm using my own version of Alza's aBags. For a while I've been trying to make it automatically update when a new/bigger bag is equipped, but it requires a Reload UI first. This is because the script that reskins bags is only ran once, to save CPU:
Code:
local firstopened = 1
...
local ReanchorButtons = function()
if(firstopened==1) then
for f = 1, CheckSlots() do
con = "ContainerFrame"..f
_G[con]:EnableMouse(false)
_G[con.."CloseButton"]:Hide()
_G[con.."PortraitButton"]:EnableMouse(false)
for i = 1, 7 do
select(i, _G[con]:GetRegions()):SetAlpha(0)
end
for i = GetContainerNumSlots(f-1), 1, -1 do
bu = _G[con.."Item"..i]
bu:SetFrameStrata("HIGH")
tinsert(buttons, bu)
_G[con.."Item"..i.."Count"]:SetFont(C.media.font, 8, "OUTLINEMONOCHROME")
_G[con.."Item"..i.."Count"]:ClearAllPoints()
_G[con.."Item"..i.."Count"]:SetPoint("TOP", bu, 0, -2)
_G[con.."Item"..i.."IconTexture"]:SetTexCoord(.1,.9,.1,.9)
_G[con.."Item"..i.."IconQuestTexture"]:SetTexture(C.media.questborder)
_G[con.."Item"..i.."IconQuestTexture"]:SetVertexColor(1, 0, 0)
_G[con.."Item"..i.."IconQuestTexture"]:SetTexCoord(0.05, .955, 0.05, .965)
_G[con.."Item"..i.."IconQuestTexture"].SetTexture = F.dummy
end
end
MoveButtons(buttons, holder, GetColumns())
firstopened = 0
end
holder:Show()
end
...
for i = 1, 5 do
hooksecurefunc(_G["ContainerFrame"..i], "Show", ReanchorButtons)
...
end
(CheckSlots is a function that returns the number of bags)
What would be a good way to make sure that it's also ran again when a new bag is equipped?