cleanup Bags

This commit is contained in:
Crum
2018-01-11 12:56:22 -06:00
parent 1feaf7ff5b
commit bdfde6c0c8
+48 -48
View File
@@ -80,7 +80,7 @@ function B:Tooltip_Show()
GameTooltip:ClearLines() GameTooltip:ClearLines()
GameTooltip:AddLine(this.ttText) GameTooltip:AddLine(this.ttText)
if(this.ttText2) then if this.ttText2 then
GameTooltip:AddLine(" ") GameTooltip:AddLine(" ")
GameTooltip:AddDoubleLine(this.ttText2, this.ttText2desc, 1, 1, 1) GameTooltip:AddDoubleLine(this.ttText2, this.ttText2desc, 1, 1, 1)
end end
@@ -153,7 +153,7 @@ function B:ResetAndClear()
local editbox = this:GetParent().editBox or this local editbox = this:GetParent().editBox or this
if editbox then editbox:SetText(SEARCH) end if editbox then editbox:SetText(SEARCH) end
this:ClearFocus() -- this:ClearFocus()
B:SearchReset() B:SearchReset()
end end
@@ -165,7 +165,7 @@ function B:SetSearch(query)
local link = GetContainerItemLink(bagID, slotID) local link = GetContainerItemLink(bagID, slotID)
local button = bagFrame.Bags[bagID][slotID] local button = bagFrame.Bags[bagID][slotID]
-- local success, result = pcall(Search.Matches, Search, link, query) -- local success, result = pcall(Search.Matches, Search, link, query)
if(empty or (success and result)) then if empty or (success and result) then
SetItemButtonDesaturated(button) SetItemButtonDesaturated(button)
button:SetAlpha(1) button:SetAlpha(1)
else else
@@ -176,13 +176,13 @@ function B:SetSearch(query)
end end
end end
if(ElvUIKeyFrameItem1) then if ElvUIKeyFrameItem1 then
local numKey = GetKeyRingSize() local numKey = GetKeyRingSize()
for slotID = 1, numKey do for slotID = 1, numKey do
local link = GetContainerItemLink(KEYRING_CONTAINER, slotID) local link = GetContainerItemLink(KEYRING_CONTAINER, slotID)
local button = _G["ElvUIKeyFrameItem"..slotID] local button = _G["ElvUIKeyFrameItem"..slotID]
-- local success, result = pcall(Search.Matches, Search, link, query) -- local success, result = pcall(Search.Matches, Search, link, query)
if(empty or (success and result)) then if empty or (success and result) then
SetItemButtonDesaturated(button) SetItemButtonDesaturated(button)
button:SetAlpha(1) button:SetAlpha(1)
else else
@@ -194,38 +194,38 @@ function B:SetSearch(query)
end end
function B:UpdateItemLevelDisplay() function B:UpdateItemLevelDisplay()
if(E.private.bags.enable ~= true) then return end if E.private.bags.enable ~= true then return end
for _, bagFrame in pairs(self.BagFrames) do for _, bagFrame in pairs(self.BagFrames) do
for _, bagID in ipairs(bagFrame.BagIDs) do for _, bagID in ipairs(bagFrame.BagIDs) do
for slotID = 1, GetContainerNumSlots(bagID) do for slotID = 1, GetContainerNumSlots(bagID) do
local slot = bagFrame.Bags[bagID][slotID] local slot = bagFrame.Bags[bagID][slotID]
if(slot and slot.itemLevel) then if slot and slot.itemLevel then
E:FontTemplate(slot.itemLevel, E.LSM:Fetch("font", E.db.bags.itemLevelFont), E.db.bags.itemLevelFontSize, E.db.bags.itemLevelFontOutline) E:FontTemplate(slot.itemLevel, E.LSM:Fetch("font", E.db.bags.itemLevelFont), E.db.bags.itemLevelFontSize, E.db.bags.itemLevelFontOutline)
end end
end end
end end
if(bagFrame.UpdateAllSlots) then if bagFrame.UpdateAllSlots then
bagFrame:UpdateAllSlots() bagFrame:UpdateAllSlots()
end end
end end
end end
function B:UpdateCountDisplay() function B:UpdateCountDisplay()
if(E.private.bags.enable ~= true) then return end if E.private.bags.enable ~= true then return end
local color = E.db.bags.countFontColor local color = E.db.bags.countFontColor
for _, bagFrame in pairs(self.BagFrames) do for _, bagFrame in pairs(self.BagFrames) do
for _, bagID in ipairs(bagFrame.BagIDs) do for _, bagID in ipairs(bagFrame.BagIDs) do
for slotID = 1, GetContainerNumSlots(bagID) do for slotID = 1, GetContainerNumSlots(bagID) do
local slot = bagFrame.Bags[bagID][slotID] local slot = bagFrame.Bags[bagID][slotID]
if(slot and slot.Count) then if slot and slot.Count then
E:FontTemplate(slot.Count, E.LSM:Fetch("font", E.db.bags.countFont), E.db.bags.countFontSize, E.db.bags.countFontOutline) E:FontTemplate(slot.Count, E.LSM:Fetch("font", E.db.bags.countFont), E.db.bags.countFontSize, E.db.bags.countFontOutline)
slot.Count:SetTextColor(color.r, color.g, color.b) slot.Count:SetTextColor(color.r, color.g, color.b)
end end
end end
end end
if(bagFrame.UpdateAllSlots) then if bagFrame.UpdateAllSlots then
bagFrame:UpdateAllSlots() bagFrame:UpdateAllSlots()
end end
end end
@@ -246,26 +246,26 @@ function B:UpdateSlot(bagID, slotID)
--if(B.ProfessionColors[bagType]) then --if(B.ProfessionColors[bagType]) then
-- slot:SetBackdropBorderColor(unpack(B.ProfessionColors[bagType])) -- slot:SetBackdropBorderColor(unpack(B.ProfessionColors[bagType]))
if(clink) then if clink then
local iLvl, itemEquipLoc local iLvl, itemEquipLoc
slot.name, _, slot.rarity, iLvl, _, _, _, _, itemEquipLoc = GetItemInfo(string.match(clink, "item:(%d+)")) slot.name, _, slot.rarity, iLvl, _, _, _, _, itemEquipLoc = GetItemInfo(string.match(clink, "item:(%d+)"))
local r, g, b local r, g, b
if(slot.rarity) then if slot.rarity then
r, g, b = GetItemQualityColor(slot.rarity) r, g, b = GetItemQualityColor(slot.rarity)
end end
--Item Level --Item Level
if(iLvl and B.db.itemLevel and (itemEquipLoc ~= nil and itemEquipLoc ~= "" and itemEquipLoc ~= "INVTYPE_AMMO" and itemEquipLoc ~= "INVTYPE_BAG" and itemEquipLoc ~= "INVTYPE_QUIVER" and itemEquipLoc ~= "INVTYPE_TABARD") and (slot.rarity and slot.rarity > 1)) then if iLvl and B.db.itemLevel and (itemEquipLoc ~= nil and itemEquipLoc ~= "" and itemEquipLoc ~= "INVTYPE_AMMO" and itemEquipLoc ~= "INVTYPE_BAG" and itemEquipLoc ~= "INVTYPE_QUIVER" and itemEquipLoc ~= "INVTYPE_TABARD") and (slot.rarity and slot.rarity > 1) then
if(iLvl >= E.db.bags.itemLevelThreshold) then if iLvl >= E.db.bags.itemLevelThreshold then
slot.itemLevel:SetText(iLvl) slot.itemLevel:SetText(iLvl)
slot.itemLevel:SetTextColor(r, g, b) slot.itemLevel:SetTextColor(r, g, b)
end end
end end
-- color slot according to item quality -- color slot according to item quality
if slot.rarity and slot.rarity > 1 then if slot.rarity then
slot:SetBackdropBorderColor(r, g, b) slot:SetBackdropBorderColor(r, g, b)
else else
slot:SetBackdropBorderColor(unpack(E.media.bordercolor)) slot:SetBackdropBorderColor(unpack(E.media.bordercolor))
@@ -317,7 +317,7 @@ function B:UpdateCooldowns()
for slotID = 1, GetContainerNumSlots(bagID) do for slotID = 1, GetContainerNumSlots(bagID) do
local start, duration, enable = GetContainerItemCooldown(bagID, slotID) local start, duration, enable = GetContainerItemCooldown(bagID, slotID)
CooldownFrame_SetTimer(self.Bags[bagID][slotID].cooldown, start, duration, enable) CooldownFrame_SetTimer(self.Bags[bagID][slotID].cooldown, start, duration, enable)
if (duration > 0 and enable == 0) then if duration > 0 and enable == 0 then
SetItemButtonTextureVertexColor(self.Bags[bagID][slotID], 0.4, 0.4, 0.4) SetItemButtonTextureVertexColor(self.Bags[bagID][slotID], 0.4, 0.4, 0.4)
else else
SetItemButtonTextureVertexColor(self.Bags[bagID][slotID], 1, 1, 1) SetItemButtonTextureVertexColor(self.Bags[bagID][slotID], 1, 1, 1)
@@ -389,13 +389,13 @@ function B:Layout(isBank)
if (not isBank and bagID <= 3 ) or (isBank and bagID ~= -1 and numContainerSlots >= 1 and not (i - 1 > numContainerSlots)) then if (not isBank and bagID <= 3 ) or (isBank and bagID ~= -1 and numContainerSlots >= 1 and not (i - 1 > numContainerSlots)) then
if not f.ContainerHolder[i] then if not f.ContainerHolder[i] then
if isBank then if isBank then
f.ContainerHolder[i] = CreateFrame("CheckButton", "ElvUIBankBag" .. bagID - 4, f.ContainerHolder, "BankItemButtonBagTemplate") f.ContainerHolder[i] = CreateFrame("CheckButton", "ElvUIBankBag"..bagID - 4, f.ContainerHolder, "BankItemButtonBagTemplate")
f.ContainerHolder[i]:SetScript("OnClick", function(self) f.ContainerHolder[i]:SetScript("OnClick", function(self)
local inventoryID = self:GetInventorySlot() local inventoryID = self:GetInventorySlot()
PutItemInBag(inventoryID) --Put bag on empty slot, or drop item in this bag PutItemInBag(inventoryID) --Put bag on empty slot, or drop item in this bag
end) end)
else else
f.ContainerHolder[i] = CreateFrame("CheckButton", "ElvUIMainBag" .. bagID .. "Slot", f.ContainerHolder, "BagSlotButtonTemplate") f.ContainerHolder[i] = CreateFrame("CheckButton", "ElvUIMainBag"..bagID.."Slot", f.ContainerHolder, "BagSlotButtonTemplate")
f.ContainerHolder[i]:SetScript("OnClick", function(self) f.ContainerHolder[i]:SetScript("OnClick", function(self)
local id = self:GetID() local id = self:GetID()
PutItemInBag(id) --Put bag on empty slot, or drop item in this bag PutItemInBag(id) --Put bag on empty slot, or drop item in this bag
@@ -425,11 +425,11 @@ function B:Layout(isBank)
end end
f.ContainerHolder:SetWidth(((buttonSize + buttonSpacing) * (isBank and i - 1 or i)) + buttonSpacing) f.ContainerHolder:SetWidth(((buttonSize + buttonSpacing) * (isBank and i - 1 or i)) + buttonSpacing)
f.ContainerHolder:SetHeight(buttonSize + (buttonSpacing * 2)) f.ContainerHolder:SetHeight(buttonSize + (buttonwwSpacing * 2))
if isBank then --[[if isBank then
BankFrameItemButton_OnUpdate(f.ContainerHolder[i]) BankFrameItemButton_OnUpdate()
end end--]]
f.ContainerHolder[i]:SetWidth(buttonSize) f.ContainerHolder[i]:SetWidth(buttonSize)
f.ContainerHolder[i]:SetHeight(buttonSize) f.ContainerHolder[i]:SetHeight(buttonSize)
@@ -542,14 +542,14 @@ function B:Layout(isBank)
local numKey = GetKeyRingSize() local numKey = GetKeyRingSize()
local numKeyColumns = 6 local numKeyColumns = 6
if(not isBank) then if not isBank then
local totalSlots = 0 local totalSlots = 0
local lastRowButton local lastRowButton
local numKeyRows = 1 local numKeyRows = 1
for i = 1, numKey do for i = 1, numKey do
totalSlots = totalSlots + 1 totalSlots = totalSlots + 1
if(not f.keyFrame.slots[i]) then if not f.keyFrame.slots[i] then
f.keyFrame.slots[i] = CreateFrame("CheckButton", "ElvUIKeyFrameItem"..i, f.keyFrame, "ContainerFrameItemButtonTemplate") f.keyFrame.slots[i] = CreateFrame("CheckButton", "ElvUIKeyFrameItem"..i, f.keyFrame, "ContainerFrameItemButtonTemplate")
E:StyleButton(f.keyFrame.slots[i], nil, nil, true) E:StyleButton(f.keyFrame.slots[i], nil, nil, true)
E:SetTemplate(f.keyFrame.slots[i], "Default", true) E:SetTemplate(f.keyFrame.slots[i], "Default", true)
@@ -567,7 +567,7 @@ function B:Layout(isBank)
f.keyFrame.slots[i]:ClearAllPoints() f.keyFrame.slots[i]:ClearAllPoints()
f.keyFrame.slots[i]:SetWidth(buttonSize) f.keyFrame.slots[i]:SetWidth(buttonSize)
f.keyFrame.slots[i]:SetHeight(buttonSize) f.keyFrame.slots[i]:SetHeight(buttonSize)
if(f.keyFrame.slots[i-1]) then if f.keyFrame.slots[i-1] then
if mod(totalSlots - 1, numKeyColumns) == 0 then if mod(totalSlots - 1, numKeyColumns) == 0 then
f.keyFrame.slots[i]:SetPoint("TOP", lastRowButton, "BOTTOM", 0, -buttonSpacing) f.keyFrame.slots[i]:SetPoint("TOP", lastRowButton, "BOTTOM", 0, -buttonSpacing)
lastRowButton = f.keyFrame.slots[i] lastRowButton = f.keyFrame.slots[i]
@@ -583,7 +583,7 @@ function B:Layout(isBank)
self:UpdateKeySlot(i) self:UpdateKeySlot(i)
end end
if(numKey < numKeyColumns) then if numKey < numKeyColumns then
numKeyColumns = numKey numKeyColumns = numKey
end end
f.keyFrame:SetWidth(((buttonSize + buttonSpacing) * numKeyColumns) + buttonSpacing) f.keyFrame:SetWidth(((buttonSize + buttonSpacing) * numKeyColumns) + buttonSpacing)
@@ -661,7 +661,7 @@ function B:OnEvent()
end end
elseif event == "BAG_UPDATE" then elseif event == "BAG_UPDATE" then
local bag = arg1 local bag = arg1
if(bag == KEYRING_CONTAINER) then if bag == KEYRING_CONTAINER then
if not _G["ElvUIKeyFrameItem"..GetKeyRingSize()] then if not _G["ElvUIKeyFrameItem"..GetKeyRingSize()] then
B:Layout(false) B:Layout(false)
end end
@@ -679,7 +679,7 @@ function B:OnEvent()
end end
this:UpdateBagSlots(arg1, arg2) this:UpdateBagSlots(arg1, arg2)
if(B:IsSearching()) then if B:IsSearching() then
B:SetSearch(SEARCH_STRING) B:SetSearch(SEARCH_STRING)
end end
elseif event == "BAG_UPDATE_COOLDOWN" then elseif event == "BAG_UPDATE_COOLDOWN" then
@@ -761,9 +761,9 @@ end
function B:VendorGrayCheck() function B:VendorGrayCheck()
local value = B:GetGraysValue() local value = B:GetGraysValue()
if(value == 0) then if value == 0 then
E:Print(L["No gray items to delete."]) E:Print(L["No gray items to delete."])
elseif(not MerchantFrame or not MerchantFrame:IsShown()) then elseif not MerchantFrame or not MerchantFrame:IsShown() then
E.PopupDialogs["DELETE_GRAYS"].Money = value E.PopupDialogs["DELETE_GRAYS"].Money = value
E:StaticPopup_Show("DELETE_GRAYS") E:StaticPopup_Show("DELETE_GRAYS")
else else
@@ -796,7 +796,7 @@ function B:ContructContainerFrame(name, isBank)
f.Bags = {} f.Bags = {}
local mover = (isBank and ElvUIBankMover or ElvUIBagMover) local mover = (isBank and ElvUIBankMover or ElvUIBagMover)
if(mover) then if mover then
f:SetPoint(mover.POINT, mover) f:SetPoint(mover.POINT, mover)
f.mover = mover f.mover = mover
end end
@@ -804,9 +804,9 @@ function B:ContructContainerFrame(name, isBank)
f:SetMovable(true) f:SetMovable(true)
f:RegisterForDrag("LeftButton", "RightButton") f:RegisterForDrag("LeftButton", "RightButton")
f:RegisterForClicks("AnyUp") f:RegisterForClicks("AnyUp")
f:SetScript("OnDragStart", function() if(IsShiftKeyDown()) then this:StartMoving() end end) f:SetScript("OnDragStart", function() if IsShiftKeyDown() then this:StartMoving() end end)
f:SetScript("OnDragStop", function() this:StopMovingOrSizing() end) f:SetScript("OnDragStop", function() this:StopMovingOrSizing() end)
f:SetScript("OnClick", function() if(IsControlKeyDown()) then B.PostBagMove(this.mover) end end) f:SetScript("OnClick", function() if IsControlKeyDown() then B.PostBagMove(this.mover) end end)
f:SetScript("OnEnter", function() f:SetScript("OnEnter", function()
GameTooltip:SetOwner(this, "ANCHOR_TOPLEFT", 0, 4) GameTooltip:SetOwner(this, "ANCHOR_TOPLEFT", 0, 4)
GameTooltip:ClearLines() GameTooltip:ClearLines()
@@ -831,7 +831,7 @@ function B:ContructContainerFrame(name, isBank)
E:SetTemplate(f.ContainerHolder, "Transparent") E:SetTemplate(f.ContainerHolder, "Transparent")
f.ContainerHolder:Hide() f.ContainerHolder:Hide()
if(isBank) then if isBank then
f.bagText = f:CreateFontString(nil, "OVERLAY") f.bagText = f:CreateFontString(nil, "OVERLAY")
E:FontTemplate(f.bagText) E:FontTemplate(f.bagText)
f.bagText:SetPoint("BOTTOMRIGHT", f.holderFrame, "TOPRIGHT", -2, 4) f.bagText:SetPoint("BOTTOMRIGHT", f.holderFrame, "TOPRIGHT", -2, 4)
@@ -858,7 +858,7 @@ function B:ContructContainerFrame(name, isBank)
f.sortButton:SetScript("OnEnter", self.Tooltip_Show) f.sortButton:SetScript("OnEnter", self.Tooltip_Show)
f.sortButton:SetScript("OnLeave", self.Tooltip_Hide) f.sortButton:SetScript("OnLeave", self.Tooltip_Hide)
f.sortButton:SetScript("OnClick", function() B:CommandDecorator(B.SortBags, "bank")() end) f.sortButton:SetScript("OnClick", function() B:CommandDecorator(B.SortBags, "bank")() end)
if(E.db.bags.disableBankSort) then if E.db.bags.disableBankSort then
f.sortButton:Disable() f.sortButton:Disable()
end end
@@ -880,7 +880,7 @@ function B:ContructContainerFrame(name, isBank)
f.bagsButton:SetScript("OnClick", function() f.bagsButton:SetScript("OnClick", function()
local numSlots = GetNumBankSlots() local numSlots = GetNumBankSlots()
PlaySound("igMainMenuOption") PlaySound("igMainMenuOption")
if(numSlots >= 1) then if numSlots >= 1 then
ToggleFrame(f.ContainerHolder) ToggleFrame(f.ContainerHolder)
else else
E:StaticPopup_Show("NO_BANK_BAGS") E:StaticPopup_Show("NO_BANK_BAGS")
@@ -904,7 +904,7 @@ function B:ContructContainerFrame(name, isBank)
f.purchaseBagButton:SetScript("OnLeave", self.Tooltip_Hide) f.purchaseBagButton:SetScript("OnLeave", self.Tooltip_Hide)
f.purchaseBagButton:SetScript("OnClick", function() f.purchaseBagButton:SetScript("OnClick", function()
local _, full = GetNumBankSlots() local _, full = GetNumBankSlots()
if(full) then if full then
E:StaticPopup_Show("CANNOT_BUY_BANK_SLOT") E:StaticPopup_Show("CANNOT_BUY_BANK_SLOT")
else else
E:StaticPopup_Show("BUY_BANK_SLOT") E:StaticPopup_Show("BUY_BANK_SLOT")
@@ -973,7 +973,7 @@ function B:ContructContainerFrame(name, isBank)
f.sortButton:SetScript("OnEnter", self.Tooltip_Show) f.sortButton:SetScript("OnEnter", self.Tooltip_Show)
f.sortButton:SetScript("OnLeave", self.Tooltip_Hide) f.sortButton:SetScript("OnLeave", self.Tooltip_Hide)
f.sortButton:SetScript("OnClick", function() B:CommandDecorator(B.SortBags, "bags")() end) f.sortButton:SetScript("OnClick", function() B:CommandDecorator(B.SortBags, "bags")() end)
if(E.db.bags.disableBagSort) then if E.db.bags.disableBagSort then
f.sortButton:Disable() f.sortButton:Disable()
end end
@@ -1056,12 +1056,12 @@ function B:ContructContainerFrame(name, isBank)
CloseBag(i) CloseBag(i)
end end
if(ElvUIBags and ElvUIBags.buttons) then if ElvUIBags and ElvUIBags.buttons then
for _, bagButton in pairs(ElvUIBags.buttons) do for _, bagButton in pairs(ElvUIBags.buttons) do
bagButton:SetChecked(false) bagButton:SetChecked(false)
end end
end end
if(E.db.bags.clearSearchOnClose) then if E.db.bags.clearSearchOnClose then
B.ResetAndClear(f.editBox) B.ResetAndClear(f.editBox)
end end
end) end)
@@ -1088,11 +1088,11 @@ function B:ToggleBags(id)
end end
function B:ToggleBackpack() function B:ToggleBackpack()
if(IsOptionFrameOpen()) then if IsOptionFrameOpen() then
return return
end end
if(IsBagOpen(0)) then if IsBagOpen(0) then
self:OpenBags() self:OpenBags()
else else
self:CloseBags() self:CloseBags()
@@ -1165,7 +1165,7 @@ function B:CloseBank()
end end
function B:PostBagMove() function B:PostBagMove()
if(not E.private.bags.enable) then return end if not E.private.bags.enable then return end
local x, y = self:GetCenter() local x, y = self:GetCenter()
local screenHeight = UIParent:GetTop() local screenHeight = UIParent:GetTop()
@@ -1173,7 +1173,7 @@ function B:PostBagMove()
if not x then return end if not x then return end
if(y > (screenHeight / 2)) then if y > (screenHeight / 2) then
self:SetText(self.textGrowDown) self:SetText(self.textGrowDown)
self.POINT = ((x > (screenWidth/2)) and "TOPRIGHT" or "TOPLEFT") self.POINT = ((x > (screenWidth/2)) and "TOPRIGHT" or "TOPLEFT")
else else
@@ -1182,13 +1182,13 @@ function B:PostBagMove()
end end
local bagFrame local bagFrame
if(self.name == "ElvUIBankMover") then if self.name == "ElvUIBankMover" then
bagFrame = B.BankFrame bagFrame = B.BankFrame
else else
bagFrame = B.BagFrame bagFrame = B.BagFrame
end end
if(bagFrame) then if bagFrame then
bagFrame:ClearAllPoints() bagFrame:ClearAllPoints()
bagFrame:SetPoint(self.POINT, self) bagFrame:SetPoint(self.POINT, self)
end end
@@ -1202,7 +1202,7 @@ function B:Initialize()
BagFrameHolder:SetHeight(22) BagFrameHolder:SetHeight(22)
BagFrameHolder:SetFrameLevel(BagFrameHolder:GetFrameLevel() + 400) BagFrameHolder:SetFrameLevel(BagFrameHolder:GetFrameLevel() + 400)
if(not E.private.bags.enable) then if not E.private.bags.enable then
BagFrameHolder:SetPoint("BOTTOMRIGHT", RightChatPanel, "BOTTOMRIGHT", -(E.Border*2), 22 + E.Border*4 - E.Spacing*2) BagFrameHolder:SetPoint("BOTTOMRIGHT", RightChatPanel, "BOTTOMRIGHT", -(E.Border*2), 22 + E.Border*4 - E.Spacing*2)
E:CreateMover(BagFrameHolder, "ElvUIBagMover", L["Bag Mover"], nil, nil, B.PostBagMove) E:CreateMover(BagFrameHolder, "ElvUIBagMover", L["Bag Mover"], nil, nil, B.PostBagMove)