This Space For Rent
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.
|