complete rewrite of bags.lua

This commit is contained in:
shagu
2016-10-10 00:08:42 +02:00
parent bf7067830e
commit fb323e22a2
2 changed files with 422 additions and 389 deletions
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

+422 -389
View File
@@ -1,30 +1,29 @@
pfUI:RegisterModule("bags", function ()
-- overwrite some bag functions
function OpenAllBags()
if pfUI.bag:IsShown() then
pfUI.bag:Hide()
if pfUI.bag.right:IsShown() then
pfUI.bag.right:Hide()
else
pfUI.bag:Show()
pfUI.bag.right:Show()
end
end
function CloseAllBags()
pfUI.bag:Hide()
pfUI.bag.right:Hide()
end
function ToggleBackpack()
if pfUI.bag:IsShown() then
pfUI.bag:Hide()
if pfUI.bag.right:IsShown() then
pfUI.bag.right:Hide()
else
pfUI.bag:Show()
pfUI.bag.right:Show()
end
end
function OpenBackpack()
if ( pfUI.bag:IsShown() ) then
if ( pfUI.bag.right:IsShown() ) then
ContainerFrame1.backpackWasOpen = 1
return;
return
else
ContainerFrame1.backpackWasOpen = nil
end
@@ -34,438 +33,472 @@ pfUI:RegisterModule("bags", function ()
end
end
function ToggleBag()
function ToggleBag()
return
end
-- avoid vertexcolor updates on item buttons
function SetItemButtonNormalTextureVertexColor () return end
function SetItemButtonNormalTextureVertexColor() return end
-- bags
pfUI.bag = CreateFrame("Frame", "pfBag")
pfUI.bag:SetFrameStrata("HIGH")
pfUI.bag:SetPoint("BOTTOMLEFT", pfUI.chat.right, "BOTTOMLEFT", 0, 0)
pfUI.bag:SetPoint("BOTTOMRIGHT", pfUI.chat.right, "BOTTOMRIGHT", 0, 0)
pfUI.bag:SetBackdrop(pfUI.backdrop)
pfUI.bag.button_size = (pfUI.bag:GetWidth() - pfUI_config.bars.border*3) / 10 - pfUI_config.bars.border
pfUI.bag:Hide()
-- hide blizzard's bankframe
BankFrame:SetScale(0.001)
BankFrame:SetPoint("TOPLEFT", 0,0)
BankFrame:SetAlpha(0)
-- bag parents
for i=1, 5 do
pfUI.bag[i] = CreateFrame("Frame")
pfUI.bag[i]:SetID(i-1)
pfUI.bag[i]:SetParent(pfUI.bag)
pfUI.bag[i]:SetAllPoints(pfUI.bag)
end
pfUI.bag = CreateFrame("Frame", "pfUIBag")
pfUI.bag:RegisterEvent("PLAYER_ENTERING_WORLD")
pfUI.bag:RegisterEvent("UPDATE_FACTION")
pfUI.bag:RegisterEvent("BAG_UPDATE")
pfUI.bag:RegisterEvent("PLAYERBANKSLOTS_CHANGED")
pfUI.bag:RegisterEvent("PLAYERBANKBAGSLOTS_CHANGED")
pfUI.bag:RegisterEvent("BAG_UPDATE_COOLDOWN")
pfUI.bag:RegisterEvent("BAG_CLOSED")
pfUI.bag:RegisterEvent("BANKFRAME_CLOSED")
pfUI.bag:RegisterEvent("BANKFRAME_OPENED")
-- bag overview panel
pfUI.bag.bagframe = CreateFrame("Frame", "pfBagBags", pfUI.bag)
pfUI.bag.bagframe:SetFrameStrata("MEDIUM")
pfUI.bag.bagframe:SetBackdrop(pfUI.backdrop)
pfUI.bag.bagframe:Hide()
function pfUI.bag:UpdateBag(arg1)
if not pfUI.bag.initialized then
pfUI.bag.initialized = "yes"
pfUI.bag:SetupPositions()
return
end
for i=1, GetContainerNumSlots(arg1) do
local f = getglobal("ContainerFrame" .. arg1 + 1 .. "Item" .. i)
if f then
local texture, itemCount, locked, quality, readable = GetContainerItemInfo(arg1, i);
f:SetNormalTexture(nil)
f:SetBackdrop(
{ bgFile = texture, tile = false, tileSize = pfUI_config.unitframes.buff_size,
edgeFile = "Interface\\AddOns\\pfUI\\img\\border_col", edgeSize = 8,
insets = { left = 0, right = 0, top = 0, bottom = 0}
})
if quality and quality > 1 then
f:SetBackdropBorderColor(GetItemQualityColor(quality))
else
f:SetBackdropBorderColor(.3,.3,.3,1)
end
SetItemButtonCount(getglobal("ContainerFrame" .. arg1 + 1 .. "Item" .. i), itemCount);
if ( texture ) then
local cooldown = getglobal(getglobal("ContainerFrame" .. arg1 + 1 .. "Item" .. i):GetName().."Cooldown");
local start, duration, enable = GetContainerItemCooldown(arg1, getglobal("ContainerFrame" .. arg1 + 1 .. "Item" .. i):GetID());
CooldownFrame_SetTimer(cooldown, start, duration, enable);
if ( duration > 0 and enable == 0 ) then
SetItemButtonTextureVertexColor(button, 0.4, 0.4, 0.4);
end
getglobal("ContainerFrame" .. arg1 + 1 .. "Item" .. i .. "Cooldown"):Show();
else
getglobal("ContainerFrame" .. arg1 + 1 .. "Item" .. i .. "Cooldown"):Hide();
end
end
end
end
function pfUI.bag:SetupPositions()
-- setup bag positions
local x = -1
local y = 0
local x_max = 10
pfUI.bag.button_size = (pfUI.bag:GetWidth() - pfUI_config.bars.border*3) / 10 - pfUI_config.bars.border
for i=0, NUM_BAG_SLOTS do
pfUI.bag:UpdateBag(i)
end
for j=1, 5 do
for i=1, GetContainerNumSlots(j-1) do
x = x + 1
if x >= x_max then y = y + 1; x = 0 end
getglobal("ContainerFrame" .. j).size = GetContainerNumSlots(j-1)
local f = getglobal("ContainerFrame" .. j .. "Item" .. i)
f:SetParent(pfUI.bag[j])
f:SetID(i)
f:SetPoint("TOPLEFT", pfUI.bag, "TOPLEFT", pfUI_config.bars.border*2 + x*pfUI.bag.button_size + x*pfUI_config.bars.border, -pfUI_config.bars.border*2 - y*pfUI.bag.button_size - y * pfUI_config.bars.border - 17)
f:Show()
f:SetHeight(pfUI.bag.button_size)
f:SetWidth(pfUI.bag.button_size)
getglobal("ContainerFrame" .. j .. "Item" .. i .. "Count"):SetPoint("BOTTOMLEFT", 0,0)
getglobal("ContainerFrame" .. j .. "Item" .. i .. "Count"):SetFont("Interface\\AddOns\\pfUI\\fonts\\arial.ttf", pfUI_config.global.font_size, "OUTLINE")
for i,v in ipairs({f:GetRegions()}) do
if i == 4 then v:SetAlpha(0) end
end
end
end
y = y + 1
pfUI.bag:SetHeight( y * pfUI.bag.button_size + y * pfUI_config.bars.border + pfUI_config.bars.border*3 + 17 + 17)
-- setup bag overview panel
pfUI.bag.bagframe:SetPoint("BOTTOMLEFT", pfUI.bag, "TOPLEFT", 0, pfUI_config.bars.border)
pfUI.bag.bagframe:SetWidth(3 * pfUI_config.bars.border + 4*(pfUI_config.bars.border+pfUI.bag.button_size))
pfUI.bag.bagframe:SetHeight(pfUI.bag.button_size + 2 * (pfUI_config.bars.border*2))
for i=0, 3 do
local bag = getglobal("CharacterBag" .. i .. "Slot")
bag:ClearAllPoints()
bag:SetParent(pfUI.bag.bagframe)
bag:SetWidth(pfUI.bag.button_size)
bag:SetHeight(pfUI.bag.button_size)
bag:SetNormalTexture(nil)
bag:SetPushedTexture(nil)
bag:SetBackdrop(
{ bgFile = texture, tile = false, tileSize = pfUI_config.unitframes.buff_size,
edgeFile = "Interface\\AddOns\\pfUI\\img\\border_col", edgeSize = 8,
insets = { left = 0, right = 0, top = 0, bottom = 0}
})
bag:SetBackdropBorderColor(.3,.3,.3,1)
bag.SetBackdrop = function () return end
bag:SetPoint("TOPLEFT", pfUI.bag.bagframe, "TOPLEFT", pfUI_config.bars.border*2 + i*pfUI.bag.button_size + i*pfUI_config.bars.border, -pfUI_config.bars.border*2)
bag:SetAlpha(1)
bag:Show()
end
end
-- close pfUI.bag on escape
tinsert(UISpecialFrames,"pfBag");
pfUI.bag:SetScript("OnShow", function ()
pfUI.bag:SetupPositions()
end)
-- bag events (all necessary?)
pfUI.bag:RegisterEvent("BAG_UPDATE");
pfUI.bag:SetScript("OnEvent", function()
pfUI.bag:UpdateBag(arg1)
end)
if event == "PLAYER_ENTERING_WORLD" or event == "UPDATE_FACTION" then
pfUI.bag:CreateBags()
pfUI.bag.right:Hide()
-- bag money display
pfUI.bag.money = CreateFrame("Frame", "pfUIBagsMoney", pfUI.bag, "SmallMoneyFrameTemplate")
pfUI.bag.money:ClearAllPoints()
pfUI.bag.money:SetPoint("TOPRIGHT", pfUI.bag, "TOPRIGHT", -13, -6)
pfUIBagsMoneyGoldButton:SetFont("Interface\\AddOns\\pfUI\\fonts\\arial.ttf", pfUI_config.global.font_size, "OUTLINE")
for i,v in ipairs({pfUIBagsMoneyGoldButton:GetRegions()}) do if i == 1 then v:SetHeight(10); v:SetWidth(10) end end
pfUIBagsMoneySilverButton:SetFont("Interface\\AddOns\\pfUI\\fonts\\arial.ttf", pfUI_config.global.font_size, "OUTLINE")
for i,v in ipairs({pfUIBagsMoneySilverButton:GetRegions()}) do if i == 1 then v:SetHeight(10); v:SetWidth(10) end end
pfUIBagsMoneyCopperButton:SetFont("Interface\\AddOns\\pfUI\\fonts\\arial.ttf", pfUI_config.global.font_size, "OUTLINE")
for i,v in ipairs({pfUIBagsMoneyCopperButton:GetRegions()}) do if i == 1 then v:SetHeight(10); v:SetWidth(10) end end
pfUI.bag:CreateBags("bank")
pfUI.bag.left:Hide()
-- bag close button
pfUI.bag.close = CreateFrame("Button")
pfUI.bag.close:SetParent(pfUI.bag)
pfUI.bag.close:RegisterForClicks("LeftButtonUp", "RightButtonUp")
pfUI.bag.close:SetPoint("TOPRIGHT", -pfUI_config.bars.border*2,-pfUI_config.bars.border*2 )
pfUI.bag.close:SetBackdrop(pfUI.backdrop)
pfUI.bag.close:SetHeight(15)
pfUI.bag.close:SetWidth(15)
pfUI.bag.close:SetText("x")
pfUI.bag.close:SetTextColor(1,.25,.25,1)
pfUI.bag.close:SetFont("Interface\\AddOns\\pfUI\\fonts\\arial.ttf", pfUI_config.global.font_size, "OUTLINE")
pfUI.bag.close:SetScript("OnEnter", function ()
pfUI.bag.close:SetBackdrop(pfUI.backdrop_col)
pfUI.bag.close:SetBackdropBorderColor(1,.25,.25,1)
end)
pfUI.bag:CreateBagSlots(pfUI.bag.right)
pfUI.bag:CreateBagSlots(pfUI.bag.left)
end
pfUI.bag.close:SetScript("OnLeave", function ()
pfUI.bag.close:SetBackdrop(pfUI.backdrop)
pfUI.bag.close:SetBackdropBorderColor(1,1,1,1)
end)
pfUI.bag.close:SetScript("OnClick", function()
if arg1 == "RightButton" then
if pfUI.bag.bagframe:IsShown() then
pfUI.bag.bagframe:Hide()
pfUI.bank.bagframe:Hide()
if event == "BAG_UPDATE" and arg1 then
if pfUI.bag.nextUpdateIsFull then
pfUI.bag:CreateBags()
pfUI.bag:CreateBags("bank")
pfUI.bag.nextUpdateIsFull = nil
else
pfUI.bag.bagframe:Show()
pfUI.bank.bagframe:Show()
pfUI.bag:UpdateBag(arg1)
end
else
CloseAllBags()
end
if event == "BAG_UPDATE_COOLDOWN" then
pfUI.bag:CreateBags()
pfUI.bag:CreateBags("bank")
end
if event == "BAG_CLOSED" and arg1 then
pfUI.bag:CreateBags()
pfUI.bag:CreateBags("bank")
pfUI.bag.nextUpdateIsFull = "yes"
end
if event == "PLAYERBANKSLOTS_CHANGED" then
pfUI.bag:UpdateBag(-1)
end
if event == "PLAYERBANKBAGSLOTS_CHANGED" then
pfUI.bag:CreateBagSlots(pfUI.bag.left)
pfUI.bag.left.bagslots:Show()
end
if event == "BANKFRAME_OPENED" then
pfUI.bag:CreateBags("bank")
pfUI.bag.left:Show()
OpenBackpack()
end
if event == "BANKFRAME_CLOSED" then
pfUI.bag:CreateBags("bank")
pfUI.bag.left:Hide()
end
end)
-- bag search
pfUI.bag.search = CreateFrame("Frame", pfUI.bag)
pfUI.bag.search:SetParent(pfUI.bag)
pfUI.bag.search:SetHeight(15)
pfUI.bag.search:SetWidth(100)
pfUI.bag.search:SetPoint("TOPLEFT", pfUI.bag, "TOPLEFT", pfUI_config.bars.border*2, -pfUI_config.bars.border*2)
pfUI.bag.search:SetBackdrop(pfUI.backdrop)
pfUI.bag.search:SetBackdropBorderColor(0,0,0,1)
tinsert(UISpecialFrames,"pfBag")
pfUI.bag.search.edit = CreateFrame("EditBox", "pfUIBagSearch", pfUI.bag.search, "InputBoxTemplate")
pfUIBagSearchLeft:SetTexture(nil);
pfUIBagSearchMiddle:SetTexture(nil);
pfUIBagSearchRight:SetTexture(nil);
pfUI.bag.search.edit:ClearAllPoints()
pfUI.bag.search.edit:SetScript("OnEditFocusGained", function()
pfUI.bag.search.edit:SetTextColor(1,1,1,1)
pfUI.bag.search:SetBackdropBorderColor(1,1,1,1)
this:SetText("")
pfUI.BACKPACK = { 0, 1, 2, 3, 4 }
pfUI.BANK = { -1, 5, 6, 7, 8, 9, 10, 11 }
pfUI.KEYRING = { -2 }
pfUI.bag.search:SetPoint("TOPLEFT", pfUI.bag, "TOPLEFT", pfUI_config.bars.border*2, -pfUI_config.bars.border*2)
pfUI.bag.search:SetPoint("TOPRIGHT", pfUI.bag, "TOPRIGHT", -pfUI_config.bars.border*2 - 16, -pfUI_config.bars.border*2)
pfUI.bags = {}
pfUI.slots = {}
pfUI.bag.money:Hide()
end)
pfUI.bag.search.edit:SetScript("OnEditFocusLost", function()
pfUI.bag.search.edit:SetTextColor(.5,.5,.5,1)
pfUI.bag.search:SetBackdropBorderColor(0,0,0,1)
this:SetText("Search")
function pfUI.bag:CreateBags(object)
local x = 0
local y = 0
local frame = {}
local iterate = {}
pfUI.bag.search:ClearAllPoints()
pfUI.bag.search:SetWidth(100)
pfUI.bag.search:SetPoint("TOPLEFT", pfUI.bag, "TOPLEFT", pfUI_config.bars.border*2, -pfUI_config.bars.border*2)
if object == "bank" then
if not pfUI.bag.left then pfUI.bag.left = CreateFrame("Frame", "pfBank") end
pfUI.bag.left:SetPoint("BOTTOMLEFT", pfUI.chat.left, "BOTTOMLEFT", 0, 0)
pfUI.bag.left:SetPoint("BOTTOMRIGHT", pfUI.chat.left, "BOTTOMRIGHT", 0, 0)
iterate = pfUI.BANK
frame = pfUI.bag.left
else
if not pfUI.bag.right then pfUI.bag.right = CreateFrame("Frame", "pfBag") end
pfUI.bag.right:SetPoint("BOTTOMLEFT", pfUI.chat.right, "BOTTOMLEFT", 0, 0)
pfUI.bag.right:SetPoint("BOTTOMRIGHT", pfUI.chat.right, "BOTTOMRIGHT", 0, 0)
iterate = pfUI.BACKPACK
frame = pfUI.bag.right
pfUI.bag:CreateAdditions(frame)
end
for j=1, 12 do
local frame, container = nil
if j > 11 then
frame = "BankFrame"
container = -1
else
frame = "ContainerFrame" .. j
container = j - 1
end
for i=1, GetContainerNumSlots(container) do
getglobal(frame .. "Item" .. i):SetAlpha(1)
frame:SetFrameStrata("HIGH")
frame:SetBackdrop(pfUI.backdrop)
pfUI.bag.button_size = (frame:GetWidth() - pfUI_config.bars.border*3) / 10 - pfUI_config.bars.border
local topspace = 18
if object == "bank" then topspace = 0 end
for id, bag in pairs(iterate) do
if not pfUI.bags[bag] then
pfUI.bags[bag] = CreateFrame("Frame", nil, frame)
pfUI.bags[bag]:SetAllPoints(frame)
pfUI.bags[bag].slots = {}
end
pfUI.bags[bag]:SetID(bag)
-- clean other buttons
for slot=GetContainerNumSlots(bag), 30 do
if pfUI.bags[bag].slots[slot] then
pfUI.bags[bag].slots[slot].frame:Hide()
pfUI.bags[bag].slots[slot] = nil
end
end
pfUI.bag.money:Show()
end)
pfUI.bag.search.edit:SetPoint("TOPLEFT", pfUI.bag.search, "TOPLEFT", pfUI_config.bars.border*2, 0)
pfUI.bag.search.edit:SetPoint("BOTTOMRIGHT", pfUI.bag.search, "BOTTOMRIGHT", -pfUI_config.bars.border*2, 0)
pfUI.bag.search.edit:SetFont("Interface\\AddOns\\pfUI\\fonts\\arial.ttf", pfUI_config.global.font_size, "OUTLINE")
pfUI.bag.search.edit:SetAutoFocus(false)
pfUI.bag.search.edit:SetText("Search")
pfUI.bag.search.edit:SetTextColor(.5,.5,.5,1)
pfUI.bag.search.edit:SetScript("OnTextChanged", function(self)
if pfUI.bag.search.edit:GetText() == "Search" then return end
for j=1, 12 do
local frame, container = nil
if j > 11 then
frame = "BankFrame"
container = -1
else
frame = "ContainerFrame" .. j
container = j - 1
for slot=1, GetContainerNumSlots(bag) do
if not pfUI.bags[bag].slots[slot] then
local tpl = "ContainerFrameItemButtonTemplate"
if bag == -1 then tpl = "BankItemButtonGenericTemplate" end
pfUI.bags[bag].slots[slot] = {}
pfUI.bags[bag].slots[slot].frame = CreateFrame("Button", "pfUIbag" .. bag .. "item" .. slot, pfUI.bags[bag], tpl)
pfUI.bags[bag].slots[slot].bag = bag
pfUI.bags[bag].slots[slot].slot = slot
pfUI.bags[bag].slots[slot].frame:SetID(slot)
end
for i=1, GetContainerNumSlots(container) do
local texture, itemCount, locked, quality, readable = GetContainerItemInfo(container, i);
if itemCount then
local itemLink = GetContainerItemLink(container, i);
local itemstring = string.sub(itemLink, string.find(itemLink, "%[")+1, string.find(itemLink, "%]")-1);
if strfind(strlower(itemstring), strlower(pfUI.bag.search.edit:GetText())) then
getglobal(frame .. "Item" .. i):SetAlpha(1)
else
getglobal(frame .. "Item" .. i):SetAlpha(.25)
end
end
if bag == -1 then
local count = getglobal("pfUIbag" .. bag .. "item" .. slot .. "Count")
count:Hide()
end
pfUI.bags[bag].slots[slot].frame:ClearAllPoints()
pfUI.bags[bag].slots[slot].frame:SetPoint("TOPLEFT", x*(pfUI.bag.button_size+pfUI_config.bars.border) + (pfUI_config.bars.border * 2), - (y*(pfUI.bag.button_size+pfUI_config.bars.border) + (pfUI_config.bars.border * 2)+ topspace))
pfUI.bags[bag].slots[slot].frame:SetHeight(pfUI.bag.button_size)
pfUI.bags[bag].slots[slot].frame:SetWidth(pfUI.bag.button_size)
pfUI.bag:UpdateSlot(bag, slot)
if x >= 9 then
y = y + 1
x = 0
else
x = x + 1
end
end
end)
end
-- bank
pfUI.bank = CreateFrame("Frame", "pfBank")
pfUI.bank:SetFrameStrata("HIGH")
pfUI.bank:SetPoint("BOTTOMLEFT", pfUI.chat.left, "BOTTOMLEFT", 0, 0)
pfUI.bank:SetPoint("BOTTOMRIGHT", pfUI.chat.left, "BOTTOMRIGHT", 0, 0)
pfUI.bank:SetBackdrop(pfUI.backdrop)
pfUI.bank:Hide()
if x > 0 then y = y + 1 end
frame:SetHeight( y * pfUI.bag.button_size + y * pfUI_config.bars.border + pfUI_config.bars.border*3 + 17 + topspace )
pfUI.bank.bagframe = CreateFrame("Frame", "pfBankBags", pfUI.bank)
pfUI.bank.bagframe:SetFrameStrata("MEDIUM")
pfUI.bank.bagframe:SetBackdrop(pfUI.backdrop)
pfUI.bank.bagframe:Hide()
-- skin the bank-bag overview
for i=1, 6 do
local bag = getglobal("BankFrameBag" .. i)
bag:SetNormalTexture(nil)
bag:SetPushedTexture(nil)
bag:SetBackdrop(
{ bgFile = texture, tile = false, tileSize = pfUI_config.unitframes.buff_size,
edgeFile = "Interface\\AddOns\\pfUI\\img\\border_col", edgeSize = 8,
insets = { left = 0, right = 0, top = 0, bottom = 0}
})
bag:SetBackdropBorderColor(.3,.3,.3,1)
frame:SetScript("OnShow", function() pfUI.bag:CreateBags(object) end)
frame:SetScript("OnHide", function() pfUI.bag:CreateBags(object) end)
end
for i=6, 12 do
pfUI.bank[i] = CreateFrame("Frame")
pfUI.bank[i]:SetID(i-1)
pfUI.bank[i]:SetParent(pfUI.bank)
pfUI.bank[i]:SetAllPoints(pfUI.bank)
function pfUI.bag:UpdateBag(bag)
for slot=1, GetContainerNumSlots(bag) do
pfUI.bag:UpdateSlot(bag, slot)
end
end
pfUI.bank:RegisterEvent("BAG_UPDATE");
pfUI.bank:RegisterEvent("BANKFRAME_OPENED");
pfUI.bank:RegisterEvent("BANKFRAME_CLOSED");
pfUI.bank:RegisterEvent("PLAYERBANKSLOTS_CHANGED");
pfUI.bank:RegisterEvent("PLAYERBANKBAGSLOTS_CHANGED");
pfUI.bank:SetScript("OnEvent", function()
if event == "BANKFRAME_OPENED" then pfUI.bank:Show(); pfUI.bag:Show() end
if event == "BANKFRAME_CLOSED" then pfUI.bank:Hide(); HideUIPanel(this) end
if not pfUI.bank:IsShown() and pfUI.bank.initialized then
message("ignore")
pfUI.bank.initialized = "yes"
function pfUI.bag:UpdateSlot(bag, slot)
if not pfUI.bags[bag] or not pfUI.bags[bag].slots[slot] then
pfUI.bag:CreateBags()
pfUI.bag:CreateBags("bank")
return
end
BankFrame:SetWidth(.1)
BankFrame:SetHeight(.1)
BankFrame:SetAlpha(0)
pfUI.bags[bag].slots[slot].frame:SetPushedTexture("")
pfUI.bags[bag].slots[slot].frame:SetNormalTexture("")
pfUI.bags[bag].slots[slot].frame:Show()
local x = -1
local y = 0
local x_max = 10
function SetItemButtonNormalTextureVertexColor() return end
local button_size = (this:GetWidth() - pfUI_config.bars.border*3) / x_max - pfUI_config.bars.border
local texture, count, locked, quality = GetContainerItemInfo(bag, slot)
pfUI.bags[bag].slots[slot].frame:SetBackdrop({
bgFile = texture, tile = true, tileSize = pfUI.bag.button_size,
edgeFile = "Interface\\AddOns\\pfUI\\img\\border_col", edgeSize = 8,
insets = {left = 0, right = 0, top = 0, bottom = 0},
})
-- put bagslots into pfUI bagslot frame
pfUI.bank.bagframe:SetPoint("BOTTOMLEFT", pfUI.bank, "TOPLEFT", 0, pfUI_config.bars.border)
pfUI.bank.bagframe:SetWidth(3 * pfUI_config.bars.border + 6*(pfUI_config.bars.border+button_size))
pfUI.bank.bagframe:SetHeight(button_size + 2 * (pfUI_config.bars.border*2))
BankFramePurchaseButton:SetParent(pfUI.bank.bagframe)
BankFramePurchaseButton:SetAlpha(1)
BankFramePurchaseButton:SetWidth(button_size)
BankFramePurchaseButton:SetHeight(button_size)
BankFramePurchaseButton:SetPoint("RIGHT", pfUI.bank.bagframe, "RIGHT", -pfUI_config.bars.border*2, 0)
BankFramePurchaseButton:SetText("+")
BankFramePurchaseButton:SetBackdrop(pfUI.backdrop)
BankFramePurchaseButton:SetNormalTexture(nil)
BankFramePurchaseButton:SetPushedTexture(nil)
if BankFramePurchaseInfo:IsShown() then
pfUI.bank.bagframe:SetWidth(pfUI.bank.bagframe:GetWidth() + button_size + pfUI_config.bars.border)
if quality and quality > 1 then
pfUI.bags[bag].slots[slot].frame:SetBackdropBorderColor(GetItemQualityColor(quality))
else
pfUI.bags[bag].slots[slot].frame:SetBackdropBorderColor(.3,.3,.3,1)
end
for i=1, 6 do
local bag = getglobal("BankFrameBag" .. i)
bag:ClearAllPoints()
bag:SetParent(pfUI.bank.bagframe)
bag:SetWidth(button_size)
bag:SetHeight(button_size)
bag:SetNormalTexture(nil)
bag:SetPushedTexture(nil)
bag:SetBackdrop(
{ bgFile = texture, tile = false, tileSize = pfUI_config.unitframes.buff_size,
edgeFile = "Interface\\AddOns\\pfUI\\img\\border_col", edgeSize = 8,
insets = { left = 0, right = 0, top = 0, bottom = 0}
})
bag:SetBackdropBorderColor(.3,.3,.3,1)
bag.SetBackdrop = function () return end
bag:SetPoint("TOPLEFT", pfUI.bank.bagframe, "TOPLEFT", pfUI_config.bars.border*2 + (i-1)*button_size + (i-1)*pfUI_config.bars.border, -pfUI_config.bars.border*2)
bag:SetAlpha(1)
if not pfUI.bags[bag].slots[slot].count then
pfUI.bags[bag].slots[slot].count = pfUI.bags[bag].slots[slot].frame:CreateFontString("Status", "DIALOG", "GameFontWhite")
pfUI.bags[bag].slots[slot].count:SetFont("Interface\\AddOns\\pfUI\\fonts\\homespun.ttf", pfUI_config.global.font_size, "OUTLINE")
pfUI.bags[bag].slots[slot].count:SetParent(pfUI.bags[bag].slots[slot].frame)
pfUI.bags[bag].slots[slot].count:SetAllPoints(pfUI.bags[bag].slots[slot].frame)
pfUI.bags[bag].slots[slot].count:SetJustifyV("BOTTOM")
pfUI.bags[bag].slots[slot].count:SetJustifyH("RIGHT")
end
for j=5, 11 do
local frame, container = nil
if j == 5 then
frame = "BankFrame"
container = -1
else
frame = "ContainerFrame" .. j
container = j - 1
if count and count > 1 then
pfUI.bags[bag].slots[slot].count:SetText(count)
pfUI.bags[bag].slots[slot].count:Show()
else
pfUI.bags[bag].slots[slot].count:SetText("")
pfUI.bags[bag].slots[slot].count:Hide()
end
-- hide duplicate itemcount in bankframe
if bag == -1 then
local count = getglobal("pfUIbag" .. bag .. "item" .. slot .. "Count")
function count.Show() return end
count:Hide()
end
-- bankframe does not have a cooldown
if bag ~= -1 then
ContainerFrame_UpdateCooldown(bag, pfUI.bags[bag].slots[slot].frame)
end
end
function pfUI.bag:CreateBagSlots(frame)
if not frame.bagslots then
frame.bagslots = CreateFrame("Frame", nil, frame)
frame.bagslots.slots = {}
end
local min, max = 0, 3
local tpl = "BagSlotButtonTemplate"
local name, append = "pfUIBagsBBag", "Slot"
local position = "RIGHT"
if frame == pfUI.bag.left then
min, max = 1, GetNumBankSlots()
tpl = "BankItemButtonBagTemplate"
name, append = "pfUIBankBBag", ""
position = "LEFT"
end
frame.bagslots:SetPoint("BOTTOM"..position, frame, "TOP"..position, 0, pfUI_config.bars.border)
frame.bagslots:SetBackdrop(pfUI.backdrop)
local extra = 0
if frame == pfUI.bag.left and GetNumBankSlots() < 6 then extra = 1 end
local width = 3 * pfUI_config.bars.border + (pfUI.bag.button_size/5*4 + pfUI_config.bars.border) * (max-min+1+extra)
local height = 3 * pfUI_config.bars.border + (pfUI.bag.button_size/5*4 + pfUI_config.bars.border)
frame.bagslots:SetWidth(width)
frame.bagslots:SetHeight(height)
for slot=min, max do
if not frame.bagslots.slots[slot] then
frame.bagslots.slots[slot] = {}
frame.bagslots.slots[slot].frame = CreateFrame("CheckButton", name .. slot .. append, frame.bagslots, tpl)
if frame == pfUI.bag.left then
frame.bagslots.slots[slot].frame:SetID(slot + 4)
else
frame.bagslots.slots[slot].slot = slot
end
end
for i=1, GetContainerNumSlots(container) do
x = x + 1
if x >= x_max then y = y + 1; x = 0 end
getglobal(frame).size = GetContainerNumSlots(j-1)
f = getglobal(frame .. "Item" .. i)
if j == 5 then f:SetParent(pfUI.bank[12]) else f:SetParent(pfUI.bank[j]) end
f:Show()
f:SetID(i)
f:SetPoint("TOPLEFT", pfUI.bank, "TOPLEFT", pfUI_config.bars.border*2 + x*button_size + x*pfUI_config.bars.border, -pfUI_config.bars.border*2 - y*button_size - y * pfUI_config.bars.border)
f:SetAlpha(1)
f:SetHeight(button_size)
f:SetWidth(button_size)
local texture, itemCount, locked, quality, readable = GetContainerItemInfo(container, i);
f:SetNormalTexture(nil)
local left = (slot-min)*(pfUI.bag.button_size/5*4+pfUI_config.bars.border) + pfUI_config.bars.border*2
local top = -2 * pfUI_config.bars.border
f:SetBackdrop(
{ bgFile = texture, tile = false, tileSize = pfUI_config.unitframes.buff_size,
edgeFile = "Interface\\AddOns\\pfUI\\img\\border_col", edgeSize = 8,
insets = { left = 0, right = 0, top = 0, bottom = 0}
})
if quality and quality > 1 then
f:SetBackdropBorderColor(GetItemQualityColor(quality))
else
f:SetBackdropBorderColor(.3,.3,.3,1)
frame.bagslots.slots[slot].frame:ClearAllPoints()
frame.bagslots.slots[slot].frame:SetPoint("TOPLEFT", frame.bagslots, "TOPLEFT", left, top)
frame.bagslots.slots[slot].frame:SetHeight(pfUI.bag.button_size/5*4)
frame.bagslots.slots[slot].frame:SetWidth(pfUI.bag.button_size/5*4)
local id, texture, checkRelic = GetInventorySlotInfo("Bag" .. slot .. append)
frame.bagslots.slots[slot].frame:SetBackdrop({
bgFile = texture, tile = true, tileSize = pfUI.bag.button_size/5*4,
edgeFile = "Interface\\AddOns\\pfUI\\img\\border_col", edgeSize = 8,
insets = {left = 0, right = 0, top = 0, bottom = 0},
})
frame.bagslots.slots[slot].frame:SetBackdropBorderColor(.3,.3,.3,1)
frame.bagslots.slots[slot].frame.SetBackdrop = function () return end
frame.bagslots.slots[slot].frame:SetNormalTexture(nil)
frame.bagslots.slots[slot].frame:SetPushedTexture(nil)
frame.bagslots.slots[slot].frame:Show()
local numSlots, full = GetNumBankSlots()
if ( slot <= numSlots ) then
frame.bagslots.slots[slot].frame.tooltipText = BANK_BAG
else
frame.bagslots.slots[slot].frame.tooltipText = BANK_BAG_PURCHASE
end
end
if frame == pfUI.bag.left then
if GetNumBankSlots() < 6 then
if not frame.bagslots.buy then
frame.bagslots.buy = CreateFrame("Button", nil, frame.bagslots)
end
frame.bagslots.buy:SetPoint("RIGHT", frame.bagslots, "RIGHT", -2 * pfUI_config.bars.border, 0)
frame.bagslots.buy:SetBackdrop(pfUI.backdrop)
frame.bagslots.buy:SetHeight(pfUI.bag.button_size/5*4)
frame.bagslots.buy:SetWidth(pfUI.bag.button_size/5*4)
frame.bagslots.buy:SetText("+")
frame.bagslots.buy:SetTextColor(.5,.5,1,1)
frame.bagslots.buy:SetFont("Interface\\AddOns\\pfUI\\fonts\\arial.ttf", pfUI_config.global.font_size, "OUTLINE")
frame.bagslots.buy:SetScript("OnEnter", function ()
frame.bagslots.buy:SetTextColor(1,1,1,1)
end)
frame.bagslots.buy:SetScript("OnLeave", function ()
frame.bagslots.buy:SetTextColor(.5,.5,1,1)
end)
frame.bagslots.buy:SetScript("OnClick", function()
StaticPopup_Show("CONFIRM_BUY_BANK_SLOT")
end)
else
if frame.bagslots.buy then frame.bagslots.buy:Hide() end
end
end
frame.bagslots:Hide()
end
SetItemButtonCount(getglobal(frame .. "Item" .. i), itemCount);
if ( texture ) then
local cooldown = getglobal(getglobal(frame .. "Item" .. i):GetName().."Cooldown");
if cooldown then
local start, duration, enable = GetContainerItemCooldown(container, getglobal(frame .. "Item" .. i):GetID());
CooldownFrame_SetTimer(cooldown, start, duration, enable);
if ( duration > 0 and enable == 0 ) then
SetItemButtonTextureVertexColor(button, 0.4, 0.4, 0.4);
function pfUI.bag:CreateAdditions(frame)
-- bag money display
if not frame.money then
frame.money = CreateFrame("Frame", "pfUIBagsMoney", frame, "SmallMoneyFrameTemplate")
frame.money:ClearAllPoints()
frame.money:SetPoint("TOPRIGHT", frame, "TOPRIGHT", -23, -6)
pfUIBagsMoneyGoldButton:SetFont("Interface\\AddOns\\pfUI\\fonts\\arial.ttf", pfUI_config.global.font_size, "OUTLINE")
for i,v in ipairs({pfUIBagsMoneyGoldButton:GetRegions()}) do if i == 1 then v:SetHeight(10); v:SetWidth(10) end end
pfUIBagsMoneySilverButton:SetFont("Interface\\AddOns\\pfUI\\fonts\\arial.ttf", pfUI_config.global.font_size, "OUTLINE")
for i,v in ipairs({pfUIBagsMoneySilverButton:GetRegions()}) do if i == 1 then v:SetHeight(10); v:SetWidth(10) end end
pfUIBagsMoneyCopperButton:SetFont("Interface\\AddOns\\pfUI\\fonts\\arial.ttf", pfUI_config.global.font_size, "OUTLINE")
for i,v in ipairs({pfUIBagsMoneyCopperButton:GetRegions()}) do if i == 1 then v:SetHeight(10); v:SetWidth(10) end end
end
-- bag close button
if not frame.close then
frame.close = CreateFrame("Button")
frame.close:SetParent(frame)
frame.close:SetPoint("TOPRIGHT", -pfUI_config.bars.border*2,-pfUI_config.bars.border*2 )
frame.close:SetBackdrop(pfUI.backdrop)
frame.close:SetHeight(15)
frame.close:SetWidth(15)
frame.close:SetText("x")
frame.close:SetTextColor(1,.25,.25,1)
frame.close:SetFont("Interface\\AddOns\\pfUI\\fonts\\arial.ttf", pfUI_config.global.font_size, "OUTLINE")
frame.close:SetScript("OnEnter", function ()
frame.close:SetBackdrop(pfUI.backdrop_col)
frame.close:SetBackdropBorderColor(1,.25,.25,1)
end)
frame.close:SetScript("OnLeave", function ()
frame.close:SetBackdrop(pfUI.backdrop)
frame.close:SetBackdropBorderColor(1,1,1,1)
end)
frame.close:SetScript("OnClick", function()
CloseAllBags()
end)
end
-- bags button
if not frame.bags then
frame.bags = CreateFrame("Button")
frame.bags:SetParent(frame)
frame.bags:SetPoint("TOPRIGHT", -pfUI_config.bars.border*2 - 15 , -pfUI_config.bars.border*2 )
frame.bags:SetBackdrop(pfUI.backdrop)
frame.bags:SetHeight(15)
frame.bags:SetWidth(15)
frame.bags:SetTextColor(1,1,.25,1)
frame.bags:SetFont("Interface\\AddOns\\pfUI\\fonts\\arial.ttf", pfUI_config.global.font_size, "OUTLINE")
frame.bags.texture = frame.bags:CreateTexture(nil,"BACKGROUND")
frame.bags.texture:SetTexture("Interface\\AddOns\\pfUI\\img\\arrow_up")
frame.bags.texture:ClearAllPoints()
frame.bags.texture:SetPoint("TOPLEFT", frame.bags, "TOPLEFT", 4, -2)
frame.bags.texture:SetPoint("BOTTOMRIGHT", frame.bags, "BOTTOMRIGHT", -4, 2)
frame.bags.texture:SetVertexColor(.25,.25,.25,1)
frame.bags:SetScript("OnEnter", function ()
frame.bags:SetBackdrop(pfUI.backdrop_col)
frame.bags:SetBackdropBorderColor(1,1,.25,1)
frame.bags.texture:SetVertexColor(1,1,.25,1)
end)
frame.bags:SetScript("OnLeave", function ()
frame.bags:SetBackdrop(pfUI.backdrop)
frame.bags:SetBackdropBorderColor(1,1,1,1)
frame.bags.texture:SetVertexColor(.25,.25,.25,1)
end)
frame.bags:SetScript("OnClick", function()
if pfUI.bag.right.bagslots:IsShown() then
pfUI.bag.right.bagslots:Hide()
pfUI.bag.left.bagslots:Hide()
else
pfUI.bag.left.bagslots:Show()
pfUI.bag.right.bagslots:Show()
end
end)
end
-- bag search
if not frame.search then
frame.search = CreateFrame("Frame", frame)
frame.search:SetParent(frame)
frame.search:SetHeight(15)
frame.search:SetWidth(100)
frame.search:SetPoint("TOPLEFT", frame, "TOPLEFT", pfUI_config.bars.border*2, -pfUI_config.bars.border*2)
frame.search:SetBackdrop(pfUI.backdrop)
frame.search:SetBackdropBorderColor(0,0,0,1)
frame.search.edit = CreateFrame("EditBox", "pfUIBagSearch", frame.search, "InputBoxTemplate")
pfUIBagSearchLeft:SetTexture(nil)
pfUIBagSearchMiddle:SetTexture(nil)
pfUIBagSearchRight:SetTexture(nil)
frame.search.edit:ClearAllPoints()
frame.search.edit:SetPoint("TOPLEFT", frame.search, "TOPLEFT", pfUI_config.bars.border*2, 0)
frame.search.edit:SetPoint("BOTTOMRIGHT", frame.search, "BOTTOMRIGHT", -pfUI_config.bars.border*2, 0)
frame.search.edit:SetFont("Interface\\AddOns\\pfUI\\fonts\\arial.ttf", pfUI_config.global.font_size, "OUTLINE")
frame.search.edit:SetAutoFocus(false)
frame.search.edit:SetText("Search")
frame.search.edit:SetTextColor(.5,.5,.5,1)
frame.search.edit:SetScript("OnEditFocusGained", function()
this:SetText("")
end)
frame.search.edit:SetScript("OnEditFocusLost", function()
this:SetText("Search")
for bag=-1, 11 do
for slot=1, GetContainerNumSlots(bag) do
local texture, itemCount, locked, quality, readable = GetContainerItemInfo(bag, slot)
if itemCount then
pfUI.bags[bag].slots[slot].frame:SetAlpha(1)
end
end
end
end)
getglobal(frame .. "Item" .. i .. "Count"):SetPoint("BOTTOMLEFT", 0,0)
getglobal(frame .. "Item" .. i .. "Count"):SetFont("Interface\\AddOns\\pfUI\\fonts\\arial.ttf", pfUI_config.global.font_size, "OUTLINE")
for i,v in ipairs({f:GetRegions()}) do
if i == 4 then v:SetAlpha(0) end
if j == 5 and i == 1 then v:SetAlpha(0) end
frame.search.edit:SetScript("OnTextChanged", function()
if this:GetText() == "Search" then return end
for bag=-1, 11 do
for slot=1, GetContainerNumSlots(bag) do
local texture, itemCount, locked, quality, readable = GetContainerItemInfo(bag, slot)
if itemCount then
local itemLink = GetContainerItemLink(bag, slot)
local itemstring = string.sub(itemLink, string.find(itemLink, "%[")+1, string.find(itemLink, "%]")-1)
if strfind(strlower(itemstring), strlower(this:GetText())) then
pfUI.bags[bag].slots[slot].frame:SetAlpha(1)
else
pfUI.bags[bag].slots[slot].frame:SetAlpha(.25)
end
end
end
end
end
end)
end
y = y + 1
pfUI.bank:SetHeight( y * button_size + y * pfUI_config.bars.border + pfUI_config.bars.border*3 + 17)
end)
end
end)