Quantcast
aBags help - WoWInterface
Thread Tools Display Modes
06-09-11, 10:07 AM   #1
Haleth
This Space For Rent
 
Haleth's Avatar
Featured
Join Date: Sep 2008
Posts: 1,173
aBags help

Hello.

In FreeUI I still use aBags because I think it's awesome, but there's one big problem: you need to /reload every time you add or upgrade a bag, because aBags only runs its script to set up the frame once.

I've tried again and again to make it automatically change when there's a new slot, but I just haven't been able to.

I'd greatly appreciate it if someone could help me out here, really.

Below is the script.

Every time you open bags, ReanchorButtons is ran, but as you can see after the first time all it does is show the frame itself. The first time, ReanchorButtons triggers MoveButtons, which moves every button into place and sets the frame size.

Code:
-- aBags by Alza, modified.

local F, C, L = unpack(select(2, ...))

--[[ Get the number of bag and bank container slots used ]]

local function CheckSlots()
	if GetContainerNumSlots(4) == 0 then
		if GetContainerNumSlots(3) == 0 then
			if GetContainerNumSlots(2) == 0 then
				if GetContainerNumSlots(1) == 0 then
					return 1
				else
					return 2
				end
			else
				return 3
			end
		else
			return 4
		end
	else
		return 5
	end
end

local function CheckBankSlots()
		return GetNumBankSlots() + 1
end

local function GetColumns()
	return CheckSlots() + 4
end

-- [[ Local stuff ]]

local Spacing = 4
-- local Columns = 9
local BankColumns = 13

local _G = getfenv(0)
local bu, con, col, row
local buttons, bankbuttons = {}, {}
local firstopened, firstbankopened = 1, 1

--[[ Function to move buttons ]]
local MoveButtons = function(table, frame, columns)
	col, row = 0, 0
	for i = 1, #table do
		bu = table[i]
		bu:ClearAllPoints()
		bu:SetNormalTexture("")
		bu:SetPoint("TOPLEFT", frame, "TOPLEFT", col * (37 + Spacing) + 3, -1 * row * (37 + Spacing) - 3)
		bu.SetPoint = F.dummy
		if(col > (columns - 2)) then
			col = 0
			row = row + 1
		else
			col = col + 1
		end
	end

	frame:SetHeight((row + (col==0 and 0 or 1)) * (37 + Spacing) + 19)
	frame:SetWidth(columns * 37 + Spacing * (columns - 1) + 6)
	col, row = 0, 0
end

--[[ Bags ]]
local holder = CreateFrame("Button", "aBagsHolder", UIParent)
holder:SetPoint("BOTTOMRIGHT", UIParent, "BOTTOMRIGHT", -49, 49)
holder:SetFrameStrata("HIGH")
holder:Hide()

F.CreateBD(holder, .6)

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


local money = _G["ContainerFrame1MoneyFrame"]
money:SetFrameStrata("DIALOG")
money:SetParent(holder)
money:ClearAllPoints()
money:SetPoint("BOTTOMRIGHT", holder, "BOTTOMRIGHT", 12, 2)

--[[ Bank ]]
local bankholder = CreateFrame("Button", "aBagsBankHolder", UIParent)
bankholder:SetFrameStrata("HIGH")
bankholder:Hide()

F.CreateBD(bankholder, .6)

local ReanchorBankButtons = function()
	if(firstbankopened==1) then
		for f = 1, 28 do
			bu = _G["BankFrameItem"..f]
			bu:SetFrameStrata("HIGH")
			tinsert(bankbuttons, bu)
		end
		_G["BankFrame"]:EnableMouse(false)
		_G["BankCloseButton"]:Hide()

		for f = 1, 5 do
			select(f, _G["BankFrame"]:GetRegions()):SetAlpha(0)
		end

		for f = CheckSlots() + 1, CheckSlots() + CheckBankSlots(), 1 do
			con = "ContainerFrame"..f
			ban = "BankFrame"
			_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(bankbuttons, 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
			for i = 1, 28 do
				bbu = _G[ban.."Item"..i]
				bbu:SetFrameStrata("HIGH")
				_G[ban.."Item"..i.."IconTexture"]:SetTexCoord(.1,.9,.1,.9)
				_G[ban.."Item"..i.."Count"]:SetFont(C.media.font, 8, "OUTLINEMONOCHROME")
				_G[ban.."Item"..i.."Count"]:ClearAllPoints()
				_G[ban.."Item"..i.."Count"]:SetPoint("TOP", bbu, 0, -2)
				_G[ban.."Item"..i.."IconQuestTexture"]:SetTexture(C.media.questborder)
				_G[ban.."Item"..i.."IconQuestTexture"]:SetVertexColor(1, 0, 0)
				_G[ban.."Item"..i.."IconQuestTexture"]:SetTexCoord(0.05, .955, 0.05, .965)
				_G[ban.."Item"..i.."IconQuestTexture"].SetTexture = F.dummy
			end
		end
		MoveButtons(bankbuttons, bankholder, GetColumns() + 4)
		bankholder:SetPoint("BOTTOMRIGHT", "aBagsHolder", "BOTTOMLEFT", -10 , 0)
		firstbankopened = 0
	end
	bankholder:Show()
end

local money = _G["BankFrameMoneyFrame"]
money:SetFrameStrata("DIALOG")
money:ClearAllPoints()
money:SetPoint("BOTTOMRIGHT", bankholder, "BOTTOMRIGHT", 12, 2)

--[[ Hiding misc. frames ]]
_G["BankFramePurchaseInfo"]:Hide()
_G["BankFramePurchaseInfo"].Show = F.dummy

local BankBagButtons = {
	BankFrameBag1, 
	BankFrameBag2, 
	BankFrameBag3, 
	BankFrameBag4, 
	BankFrameBag5, 
	BankFrameBag6, 
	BankFrameBag7,
}

local BagButtons = {
	CharacterBag0Slot, 
	CharacterBag1Slot, 
	CharacterBag2Slot, 
	CharacterBag3Slot, 
}


for f = 1, 7 do
	_G["BankFrameBag"..f]:SetParent(bankholder)
	_G["BankFrameBag"..f]:ClearAllPoints()

	if f==1 then
		_G["BankFrameBag"..f]:SetPoint("BOTTOM", bankholder, "TOP", -120, 4)
	else
		_G["BankFrameBag"..f]:SetPoint("CENTER", _G["BankFrameBag"..f-1], 38, 0)
	end
	
	_G["BankFrameBag"..f]:SetAlpha(0)
	_G["BankFrameBag"..f]:HookScript("OnEnter", function(self)
		for _, g in pairs(BankBagButtons) do
			g:SetAlpha(1)
		end
	end)
	_G["BankFrameBag"..f]:HookScript("OnLeave", function(self)
		for _, g in pairs(BankBagButtons) do
			g:SetAlpha(0)
		end
	end)
end

for i = 0, 3 do
	_G["CharacterBag"..i.."Slot"]:SetParent(holder)
	_G["CharacterBag"..i.."Slot"]:ClearAllPoints()

	if i==0 then
		_G["CharacterBag"..i.."Slot"]:SetPoint("BOTTOMRIGHT", holder, "TOPRIGHT", 0, 4)
	else
		_G["CharacterBag"..i.."Slot"]:SetPoint("CENTER", _G["CharacterBag"..(i-1).."Slot"], -30, 0)
	end

	_G["CharacterBag"..i.."Slot"]:SetAlpha(0)
	_G["CharacterBag"..i.."Slot"]:HookScript("OnEnter", function(self)
		for _, g in pairs(BagButtons) do
			g:SetAlpha(1)
		end
	 end)
	_G["CharacterBag"..i.."Slot"]:HookScript("OnLeave", function(self)
		for _, g in pairs(BagButtons) do
			g:SetAlpha(0)
		end
	end)
end

local MoneyText = {
	_G["ContainerFrame1MoneyFrameGoldButtonText"], 
	_G["ContainerFrame1MoneyFrameSilverButtonText"],
	_G["ContainerFrame1MoneyFrameCopperButtonText"],
	_G["BankFrameMoneyFrameGoldButtonText"],
	_G["BankFrameMoneyFrameSilverButtonText"],
	_G["BankFrameMoneyFrameCopperButtonText"],
}

for _, f in pairs(MoneyText) do
	f:SetFont(C.media.font, 8, "OUTLINEMONOCHROME")
end

--[[ Show & Hide functions etc ]]
tinsert(UISpecialFrames, bankholder)
tinsert(UISpecialFrames, holder)

local CloseBags = function()
	bankholder:Hide()
	holder:Hide()
	for i = 0, 11 do
		CloseBag(i)
	end
end

local CloseBags2 = function()
	bankholder:Hide()
	holder:Hide()
end

local OpenBags = function()
	for i = 0, 11 do
		OpenBag(i)
	end
end

local ToggleBags = function()
	if(IsBagOpen(0)) then
		CloseBankFrame()
		CloseBags()
	else
		OpenBags()
	end
end

for i = 1, 5 do
	hooksecurefunc(_G["ContainerFrame"..i], "Show", ReanchorButtons)
	hooksecurefunc(_G["ContainerFrame"..i], "Hide", CloseBags2)
end
hooksecurefunc(BankFrame, "Show", function()
	OpenBags()
	ReanchorBankButtons()
end)
hooksecurefunc(BankFrame, "Hide", CloseBags)

ToggleBackpack = ToggleBags
OpenAllBags = OpenBags
--OpenAllBags = ToggleBags
--OpenAllBags = F.dummy
OpenBackpack = OpenBags
CloseAllBags = CloseBags

if Aero then Aero:RegisterFrames("aBagsHolder", "aBagsBankHolder") end
  Reply With Quote
06-09-11, 03:54 PM   #2
Lordyfrb
A Cliff Giant
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 71
Hi Haleth,

I've just looked through all the events over on wowpedia, and the only suggestion I can make is to create a frame and register for the event "BAG_CLOSED", and when this event fires have the frame onevent reset
the values of firstopened and firstbankopened to 1.

The reason I suggest this is because this events fires when a bag is removed from its bag slot and its fired for both bags and banks slots.
Quoted from Wowpedia.org:
"BAG_CLOSED"
Fired when a bag is (re)moved from its bagslot. Fires both for player bags and bank bags.
Hope I've helped you out.

Lordy
__________________

Last edited by Lordyfrb : 06-09-11 at 03:56 PM. Reason: Added Quote for wowpedia
  Reply With Quote
06-09-11, 04:43 PM   #3
Haleth
This Space For Rent
 
Haleth's Avatar
Featured
Join Date: Sep 2008
Posts: 1,173
Hi there, thanks for the advice. I'll try this and update with progress.
  Reply With Quote
06-10-11, 02:05 PM   #4
Haleth
This Space For Rent
 
Haleth's Avatar
Featured
Join Date: Sep 2008
Posts: 1,173
That method didn't quite work out, however using a different method I almost got it to work. New bag buttons are appropriately moved - the only problem is that after killing bu.SetPoint, I need to find a way to make that function work again, because the already existing buttons need to move to make space for the new ones. Currently, they overlap.

This is my current code:

Code:
-- aBags by Alza, modified.

local F, C, L = unpack(select(2, ...))

--[[ Get the number of bag and bank container slots used ]]

local function CheckSlots()
	if GetContainerNumSlots(4) == 0 then
		if GetContainerNumSlots(3) == 0 then
			if GetContainerNumSlots(2) == 0 then
				if GetContainerNumSlots(1) == 0 then
					return 1
				else
					return 2
				end
			else
				return 3
			end
		else
			return 4
		end
	else
		return 5
	end
end

local function CheckBankSlots()
		return GetNumBankSlots() + 1
end

local function GetColumns()
	return CheckSlots() + 4
end

-- [[ Local stuff ]]

local Spacing = 4
-- local Columns = 9
local BankColumns = 13

local _G = getfenv(0)
local bu, con, col, row
local buttons, bankbuttons = {}, {}
local firstopened, firstbankopened = 1, 1
local needsmoving = true

--[[ Function to move buttons ]]
local MoveButtons = function(table, frame, columns)
	col, row = 0, 0
	if needsmoving == true then
		for i = 1, #table do
			bu = table[i]
			bu.SetPoint = bu:SetPoint()
			bu:ClearAllPoints()
			bu:SetNormalTexture("")
			bu:SetPoint("TOPLEFT", frame, "TOPLEFT", col * (37 + Spacing) + 3, -1 * row * (37 + Spacing) - 3)
			bu.SetPoint = F.dummy
			if(col > (columns - 2)) then
				col = 0
				row = row + 1
			else
				col = col + 1
			end
		end

	frame:SetHeight((row + (col==0 and 0 or 1)) * (37 + Spacing) + 19)
	frame:SetWidth(columns * 37 + Spacing * (columns - 1) + 6)
		needsmoving = false
	end

	col, row = 0, 0
end

--[[ Bags ]]
local holder = CreateFrame("Button", "aBagsHolder", UIParent)
holder:SetPoint("BOTTOMRIGHT", UIParent, "BOTTOMRIGHT", -49, 49)
holder:SetFrameStrata("HIGH")
holder:Hide()

F.CreateBD(holder, .6)

local ReanchorButtons = function()
	for f = 1, CheckSlots() do
		con = "ContainerFrame"..f
		if not _G[con].reskinned then
			_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

			_G[con].reskinned = true
		end

		for i = GetContainerNumSlots(f-1), 1, -1  do
			bu = _G[con.."Item"..i]
			if not bu.reskinned then
				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
				bu.reskinned = true
			end
		end
	end
	MoveButtons(buttons, holder, GetColumns())
	holder:Show()
end

local money = _G["ContainerFrame1MoneyFrame"]
money:SetFrameStrata("DIALOG")
money:SetParent(holder)
money:ClearAllPoints()
money:SetPoint("BOTTOMRIGHT", holder, "BOTTOMRIGHT", 12, 2)

local reset = CreateFrame("Frame")
reset:RegisterEvent("BAG_CLOSED")
reset:SetScript("OnEvent", function()
	needsmoving = true
end)

--[[ Bank ]]
local bankholder = CreateFrame("Button", "aBagsBankHolder", UIParent)
bankholder:SetFrameStrata("HIGH")
bankholder:Hide()

F.CreateBD(bankholder, .6)

local ReanchorBankButtons = function()
	if(firstbankopened==1) then
		for f = 1, 28 do
			bu = _G["BankFrameItem"..f]
			bu:SetFrameStrata("HIGH")
			tinsert(bankbuttons, bu)
		end
		_G["BankFrame"]:EnableMouse(false)
		_G["BankCloseButton"]:Hide()

		for f = 1, 5 do
			select(f, _G["BankFrame"]:GetRegions()):SetAlpha(0)
		end

		for f = CheckSlots() + 1, CheckSlots() + CheckBankSlots(), 1 do
			con = "ContainerFrame"..f
			ban = "BankFrame"
			_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(bankbuttons, 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
			for i = 1, 28 do
				bbu = _G[ban.."Item"..i]
				bbu:SetFrameStrata("HIGH")
				_G[ban.."Item"..i.."IconTexture"]:SetTexCoord(.1,.9,.1,.9)
				_G[ban.."Item"..i.."Count"]:SetFont(C.media.font, 8, "OUTLINEMONOCHROME")
				_G[ban.."Item"..i.."Count"]:ClearAllPoints()
				_G[ban.."Item"..i.."Count"]:SetPoint("TOP", bbu, 0, -2)
				_G[ban.."Item"..i.."IconQuestTexture"]:SetTexture(C.media.questborder)
				_G[ban.."Item"..i.."IconQuestTexture"]:SetVertexColor(1, 0, 0)
				_G[ban.."Item"..i.."IconQuestTexture"]:SetTexCoord(0.05, .955, 0.05, .965)
				_G[ban.."Item"..i.."IconQuestTexture"].SetTexture = F.dummy
			end
		end
		MoveButtons(bankbuttons, bankholder, GetColumns() + 4)
		bankholder:SetPoint("BOTTOMRIGHT", "aBagsHolder", "BOTTOMLEFT", -10 , 0)
		firstbankopened = 0
	end
	bankholder:Show()
end

local money = _G["BankFrameMoneyFrame"]
money:SetFrameStrata("DIALOG")
money:ClearAllPoints()
money:SetPoint("BOTTOMRIGHT", bankholder, "BOTTOMRIGHT", 12, 2)

--[[ Hiding misc. frames ]]
_G["BankFramePurchaseInfo"]:Hide()
_G["BankFramePurchaseInfo"].Show = F.dummy

local BankBagButtons = {
	BankFrameBag1, 
	BankFrameBag2, 
	BankFrameBag3, 
	BankFrameBag4, 
	BankFrameBag5, 
	BankFrameBag6, 
	BankFrameBag7,
}

local BagButtons = {
	CharacterBag0Slot, 
	CharacterBag1Slot, 
	CharacterBag2Slot, 
	CharacterBag3Slot, 
}


for f = 1, 7 do
	_G["BankFrameBag"..f]:SetParent(bankholder)
	_G["BankFrameBag"..f]:ClearAllPoints()

	if f==1 then
		_G["BankFrameBag"..f]:SetPoint("BOTTOM", bankholder, "TOP", -120, 4)
	else
		_G["BankFrameBag"..f]:SetPoint("CENTER", _G["BankFrameBag"..f-1], 38, 0)
	end
	
	_G["BankFrameBag"..f]:SetAlpha(0)
	_G["BankFrameBag"..f]:HookScript("OnEnter", function(self)
		for _, g in pairs(BankBagButtons) do
			g:SetAlpha(1)
		end
	end)
	_G["BankFrameBag"..f]:HookScript("OnLeave", function(self)
		for _, g in pairs(BankBagButtons) do
			g:SetAlpha(0)
		end
	end)
end

for i = 0, 3 do
	_G["CharacterBag"..i.."Slot"]:SetParent(holder)
	_G["CharacterBag"..i.."Slot"]:ClearAllPoints()

	if i==0 then
		_G["CharacterBag"..i.."Slot"]:SetPoint("BOTTOMRIGHT", holder, "TOPRIGHT", 0, 4)
	else
		_G["CharacterBag"..i.."Slot"]:SetPoint("CENTER", _G["CharacterBag"..(i-1).."Slot"], -30, 0)
	end

	_G["CharacterBag"..i.."Slot"]:SetAlpha(0)
	_G["CharacterBag"..i.."Slot"]:HookScript("OnEnter", function(self)
		for _, g in pairs(BagButtons) do
			g:SetAlpha(1)
		end
	 end)
	_G["CharacterBag"..i.."Slot"]:HookScript("OnLeave", function(self)
		for _, g in pairs(BagButtons) do
			g:SetAlpha(0)
		end
	end)
end

local MoneyText = {
	_G["ContainerFrame1MoneyFrameGoldButtonText"], 
	_G["ContainerFrame1MoneyFrameSilverButtonText"],
	_G["ContainerFrame1MoneyFrameCopperButtonText"],
	_G["BankFrameMoneyFrameGoldButtonText"],
	_G["BankFrameMoneyFrameSilverButtonText"],
	_G["BankFrameMoneyFrameCopperButtonText"],
}

for _, f in pairs(MoneyText) do
	f:SetFont(C.media.font, 8, "OUTLINEMONOCHROME")
end

--[[ Show & Hide functions etc ]]
tinsert(UISpecialFrames, bankholder)
tinsert(UISpecialFrames, holder)

local CloseBags = function()
	bankholder:Hide()
	holder:Hide()
	for i = 0, 11 do
		CloseBag(i)
	end
end

local CloseBags2 = function()
	bankholder:Hide()
	holder:Hide()
end

local OpenBags = function()
	for i = 0, 11 do
		OpenBag(i)
	end
end

local ToggleBags = function()
	if(IsBagOpen(0)) then
		CloseBankFrame()
		CloseBags()
	else
		OpenBags()
	end
end

for i = 1, 5 do
	hooksecurefunc(_G["ContainerFrame"..i], "Show", ReanchorButtons)
	hooksecurefunc(_G["ContainerFrame"..i], "Hide", CloseBags2)
end
hooksecurefunc(BankFrame, "Show", function()
	OpenBags()
	ReanchorBankButtons()
end)
hooksecurefunc(BankFrame, "Hide", CloseBags)

ToggleBackpack = ToggleBags
OpenAllBags = OpenBags
--OpenAllBags = ToggleBags
--OpenAllBags = F.dummy
OpenBackpack = OpenBags
CloseAllBags = CloseBags

if Aero then Aero:RegisterFrames("aBagsHolder", "aBagsBankHolder") end
Bank frame doesn't work yet but I'll sort that out later.

So, essentially, does anyone know how I can 're-activate' a function after killing it? I know you can do it for function that don't require arguments, but for SetPoint I get an error for doing so.

Edit: I got everything working. The only downside is that every button has its point set again every time the bags are opened because I can't figure out how to re-enable SetPoint after killing it.

Last edited by Haleth : 06-11-11 at 06:48 AM.
  Reply With Quote
06-13-11, 07:30 AM   #5
Mischback
A Cobalt Mageweaver
 
Mischback's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 221
I had this thread going, posted solution works fine for me

http://www.wowinterface.com/forums/s...ad.php?t=40305
__________________
  Reply With Quote
06-13-11, 10:15 AM   #6
Haleth
This Space For Rent
 
Haleth's Avatar
Featured
Join Date: Sep 2008
Posts: 1,173
Hey there, thanks for the reply. That does indeed work, but I discovered there is one flaw if I were to use my method with your suggestion; the BAG_CLOSED event only triggers when a bag is removed or upgraded, but not when a new bag is added entirely.

I guess I'll just have to wipe the button table and call SetPoint on all of them every time the bags open. It's probably still more efficient than doing it on every BAG_UPDATE - the only other option, seeing as there is no specific event fired when a new bag is added.
  Reply With Quote
06-13-11, 11:10 AM   #7
Lily.Petal
A Molten Giant
 
Lily.Petal's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2010
Posts: 540
Are you planning to release your(edited) bag addon as a standalone by chance?
__________________

Aggro Color to KG Panels Borders - Nibelheim
Lua Based UI Hider - Nibelheim
Custom LUA PowerText - Stuf - Nibelheim, Seerah
  Reply With Quote
06-13-11, 11:52 AM   #8
Haleth
This Space For Rent
 
Haleth's Avatar
Featured
Join Date: Sep 2008
Posts: 1,173
aBags is still at the core, so I can't claim it as my own. I just have permission to include it in my UI.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » aBags help

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off