diff --git a/2/3/4/5/6/7/ElvUI/Core/Config.lua b/2/3/4/5/6/7/ElvUI/Core/Config.lua
index fadccdb..a900fa3 100644
--- a/2/3/4/5/6/7/ElvUI/Core/Config.lua
+++ b/2/3/4/5/6/7/ElvUI/Core/Config.lua
@@ -256,7 +256,7 @@ function E:CreateMoverPopup()
E:ToggleConfigMode(true)
if(IsAddOnLoaded("ElvUI_Config")) then
- LibStub("AceConfigDialog-3.0-ElvUI"):Open("ElvUI")
+ LibStub("AceConfigDialog-3.0"):Open("ElvUI")
end
selectedValue = "ALL"
diff --git a/2/3/4/5/6/7/ElvUI/Modules/Bags/BagBar.lua b/2/3/4/5/6/7/ElvUI/Modules/Bags/BagBar.lua
new file mode 100644
index 0000000..0544204
--- /dev/null
+++ b/2/3/4/5/6/7/ElvUI/Modules/Bags/BagBar.lua
@@ -0,0 +1,159 @@
+local E, L, V, P, G = unpack(ElvUI)
+local B = E:GetModule("Bags")
+
+local _G = _G
+local unpack = unpack
+local tinsert = table.insert
+
+local CreateFrame = CreateFrame
+local NUM_BAG_FRAMES = NUM_BAG_FRAMES
+
+local TOTAL_BAGS = NUM_BAG_FRAMES + 2
+
+local ElvUIKeyRing = CreateFrame("CheckButton", "ElvUIKeyRingButton", UIParent, "ItemButtonTemplate")
+ElvUIKeyRing:RegisterForClicks("anyUp")
+ElvUIKeyRing:StripTextures()
+ElvUIKeyRing:SetScript("OnClick", function() if CursorHasItem() then PutKeyInKeyRing() else ToggleKeyRing() end end)
+ElvUIKeyRing:SetScript("OnReceiveDrag", function() if CursorHasItem() then PutKeyInKeyRing() end end)
+ElvUIKeyRing:SetScript("OnEnter", function(self) GameTooltip:SetOwner(self, "ANCHOR_LEFT") local color = HIGHLIGHT_FONT_COLOR GameTooltip:SetText(KEYRING, color.r, color.g, color.b) GameTooltip:AddLine() end)
+ElvUIKeyRing:SetScript("OnLeave", function() GameTooltip:Hide() end)
+_G[ElvUIKeyRing:GetName().."IconTexture"]:SetTexture("Interface\\ContainerFrame\\KeyRing-Bag-Icon")
+_G[ElvUIKeyRing:GetName().."IconTexture"]:SetTexCoord(unpack(E.TexCoords))
+
+local function OnEnter()
+ if not E.db.bags.bagBar.mouseover then return end
+ E:UIFrameFadeOut(ElvUIBags, 0.2, ElvUIBags:GetAlpha(), 1)
+end
+
+local function OnLeave()
+ if not E.db.bags.bagBar.mouseover then return end
+ E:UIFrameFadeOut(ElvUIBags, 0.2, ElvUIBags:GetAlpha(), 0)
+end
+
+function B:SkinBag(bag)
+ local icon = _G[bag:GetName().."IconTexture"]
+ bag.oldTex = icon:GetTexture()
+
+ bag:StripTextures()
+ bag:CreateBackdrop("Default", true)
+ bag.backdrop:SetAllPoints()
+ bag:StyleButton(true)
+ icon:SetTexture(bag.oldTex)
+ icon:SetInside()
+ icon:SetTexCoord(unpack(E.TexCoords))
+end
+
+function B:SizeAndPositionBagBar()
+ if not ElvUIBags then return end
+
+ local buttonSpacing = E.db.bags.bagBar.spacing
+ local backdropSpacing = E.db.bags.bagBar.backdropSpacing
+ local bagBarSize = E.db.bags.bagBar.size
+ local showBackdrop = E.db.bags.bagBar.showBackdrop
+ local growthDirection = E.db.bags.bagBar.growthDirection
+ local sortDirection = E.db.bags.bagBar.sortDirection
+
+ if E.db.bags.bagBar.mouseover then
+ ElvUIBags:SetAlpha(0)
+ else
+ ElvUIBags:SetAlpha(1)
+ end
+
+ if showBackdrop then
+ ElvUIBags.backdrop:Show()
+ else
+ ElvUIBags.backdrop:Hide()
+ end
+
+ ElvUIKeyRingButton:Size(bagBarSize)
+ ElvUIKeyRingButton:ClearAllPoints()
+
+ for i = 1, #ElvUIBags.buttons do
+ local button = ElvUIBags.buttons[i]
+ local prevButton = ElvUIBags.buttons[i-1]
+ button:Size(E.db.bags.bagBar.size)
+ button:ClearAllPoints()
+ button:Show()
+
+ if growthDirection == "HORIZONTAL" and sortDirection == "ASCENDING" then
+ if i == 1 then
+ button:Point("LEFT", ElvUIBags, "LEFT", (showBackdrop and (backdropSpacing + E.Border) or 0), 0)
+ elseif prevButton then
+ button:Point("LEFT", prevButton, "RIGHT", buttonSpacing, 0)
+ end
+ elseif growthDirection == "VERTICAL" and sortDirection == "ASCENDING" then
+ if i == 1 then
+ button:Point("TOP", ElvUIBags, "TOP", 0, -(showBackdrop and (backdropSpacing + E.Border) or 0))
+ elseif prevButton then
+ button:Point("TOP", prevButton, "BOTTOM", 0, -buttonSpacing)
+ end
+ elseif growthDirection == "HORIZONTAL" and sortDirection == "DESCENDING" then
+ if i == 1 then
+ button:Point("RIGHT", ElvUIBags, "RIGHT", -(showBackdrop and (backdropSpacing + E.Border) or 0), 0)
+ elseif prevButton then
+ button:Point("RIGHT", prevButton, "LEFT", -buttonSpacing, 0)
+ end
+ else
+ if i == 1 then
+ button:Point("BOTTOM", ElvUIBags, "BOTTOM", 0, (showBackdrop and (backdropSpacing + E.Border) or 0))
+ elseif prevButton then
+ button:Point("BOTTOM", prevButton, "TOP", 0, buttonSpacing)
+ end
+ end
+ end
+
+ if growthDirection == "HORIZONTAL" then
+ ElvUIBags:Width(bagBarSize*(TOTAL_BAGS) + buttonSpacing*(TOTAL_BAGS-1) + ((showBackdrop == true and (E.Border + backdropSpacing) or E.Spacing)*2))
+ ElvUIBags:Height(bagBarSize + ((showBackdrop and (E.Border + backdropSpacing) or E.Spacing)*2))
+ else
+ ElvUIBags:Height(bagBarSize*(TOTAL_BAGS) + buttonSpacing*(TOTAL_BAGS-1) + ((showBackdrop == true and (E.Border + backdropSpacing) or E.Spacing)*2))
+ ElvUIBags:Width(bagBarSize + ((showBackdrop and (E.Border + backdropSpacing) or E.Spacing)*2))
+ end
+end
+
+function B:LoadBagBar()
+ if not E.private.bags.bagBar then return end
+
+ local ElvUIBags = CreateFrame("Frame", "ElvUIBags", E.UIParent)
+ ElvUIBags:SetPoint("TOPRIGHT", RightChatPanel, "TOPLEFT", -4, 0)
+ ElvUIBags.buttons = {}
+ ElvUIBags:CreateBackdrop()
+ ElvUIBags.backdrop:SetAllPoints()
+ ElvUIBags:EnableMouse(true)
+ ElvUIBags:SetScript("OnEnter", OnEnter)
+ ElvUIBags:SetScript("OnLeave", OnLeave)
+
+ MainMenuBarBackpackButton:SetParent(ElvUIBags)
+ MainMenuBarBackpackButton.SetParent = E.dummy
+ MainMenuBarBackpackButton:ClearAllPoints()
+ MainMenuBarBackpackButtonCount:FontTemplate(nil, 10)
+ MainMenuBarBackpackButtonCount:ClearAllPoints()
+ MainMenuBarBackpackButtonCount:Point("BOTTOMRIGHT", MainMenuBarBackpackButton, "BOTTOMRIGHT", -1, 4)
+ MainMenuBarBackpackButton:HookScript("OnEnter", OnEnter)
+ MainMenuBarBackpackButton:HookScript("OnLeave", OnLeave)
+ tinsert(ElvUIBags.buttons, MainMenuBarBackpackButton)
+ self:SkinBag(MainMenuBarBackpackButton)
+
+ for i = 0, NUM_BAG_FRAMES - 1 do
+ local b = _G["CharacterBag"..i.."Slot"]
+ b:SetParent(ElvUIBags)
+ b.SetParent = E.dummy
+ b:HookScript("OnEnter", OnEnter)
+ b:HookScript("OnLeave", OnLeave)
+
+ self:SkinBag(b)
+ tinsert(ElvUIBags.buttons, b)
+ end
+
+ ElvUIKeyRingButton:SetTemplate()
+ ElvUIKeyRingButton:StyleButton(true)
+ _G[ElvUIKeyRingButton:GetName().."IconTexture"]:SetInside()
+ ElvUIKeyRingButton:SetParent(ElvUIBags)
+ ElvUIKeyRingButton.SetParent = E.dummy
+ ElvUIKeyRingButton:HookScript("OnEnter", OnEnter)
+ ElvUIKeyRingButton:HookScript("OnLeave", OnLeave)
+ tinsert(ElvUIBags.buttons, ElvUIKeyRingButton)
+
+ self:SizeAndPositionBagBar()
+ E:CreateMover(ElvUIBags, "BagsMover", L["Bags"])
+end
\ No newline at end of file
diff --git a/2/3/4/5/6/7/ElvUI/Modules/Bags/Bags.lua b/2/3/4/5/6/7/ElvUI/Modules/Bags/Bags.lua
new file mode 100644
index 0000000..e2a2c90
--- /dev/null
+++ b/2/3/4/5/6/7/ElvUI/Modules/Bags/Bags.lua
@@ -0,0 +1,1301 @@
+local E, L, V, P, G = unpack(ElvUI)
+local B = E:NewModule("Bags", "AceHook-3.0", "AceEvent-3.0", "AceTimer-3.0")
+local Search = LibStub("LibItemSearch-1.2", true)
+local LIP = LibStub("ItemPrice-1.1", true)
+
+local _G = _G
+local type, ipairs, pairs, unpack, select, assert = type, ipairs, pairs, unpack, select, assert
+local tinsert = table.insert
+local floor, ceil, mod = math.floor, math.ceil, math.mod
+local len, sub, gsub, find = string.len, string.sub, string.gsub, string.find
+
+local BankFrameItemButton_Update = BankFrameItemButton_Update
+local BankFrameItemButton_UpdateLocked = BankFrameItemButton_UpdateLocked
+local CloseBag, CloseBackpack, CloseBankFrame = CloseBag, CloseBackpack, CloseBankFrame
+local CooldownFrame_SetTimer = CooldownFrame_SetTimer
+local CreateFrame = CreateFrame
+local DeleteCursorItem = DeleteCursorItem
+local GetContainerItemCooldown = GetContainerItemCooldown
+local GetContainerItemInfo = GetContainerItemInfo
+local GetContainerItemInfo = GetContainerItemInfo
+local GetContainerItemLink = GetContainerItemLink
+local GetContainerNumFreeSlots = GetContainerNumFreeSlots
+local GetContainerNumSlots = GetContainerNumSlots
+local GetCurrentGuildBankTab = GetCurrentGuildBankTab
+local GetGuildBankItemLink = GetGuildBankItemLink
+local GetGuildBankTabInfo = GetGuildBankTabInfo
+local GetItemInfo = GetItemInfo
+local GetItemQualityColor = GetItemQualityColor
+local GetKeyRingSize = GetKeyRingSize
+local GetMoney = GetMoney
+local GetNumBankSlots = GetNumBankSlots
+local IsBagOpen, IsOptionFrameOpen = IsBagOpen, IsOptionFrameOpen
+local IsControlKeyDown = IsControlKeyDown
+local PickupContainerItem = PickupContainerItem
+local PickupMerchantItem = PickupMerchantItem
+local PlaySound = PlaySound
+local SetItemButtonCount = SetItemButtonCount
+local SetItemButtonDesaturated = SetItemButtonDesaturated
+local SetItemButtonTexture = SetItemButtonTexture
+local SetItemButtonTextureVertexColor = SetItemButtonTextureVertexColor
+local ToggleFrame = ToggleFrame
+local UseContainerItem = UseContainerItem
+
+local BANK_CONTAINER = BANK_CONTAINER
+local KEYRING_CONTAINER = KEYRING_CONTAINER
+local MAX_CONTAINER_ITEMS = MAX_CONTAINER_ITEMS
+local NUM_BAG_FRAMES = NUM_BAG_FRAMES
+local NUM_CONTAINER_FRAMES = NUM_CONTAINER_FRAMES
+local SEARCH = SEARCH
+
+local SEARCH_STRING = ""
+
+B.ProfessionColors = {
+ ["0x0008"] = {224/255, 187/255, 74/255}, -- Leatherworking
+ ["0x0010"] = {74/255, 77/255, 224/255}, -- Inscription
+ ["0x0020"] = {18/255, 181/255, 32/255}, -- Herbs
+ ["0x0040"] = {160/255, 3/255, 168/255}, -- Enchanting
+ ["0x0080"] = {232/255, 118/255, 46/255}, -- Engineering
+ ["0x0200"] = {8/255, 180/255, 207/255}, -- Gems
+ ["0x0400"] = {105/255, 79/255, 7/255}, -- Mining
+ ["0x010000"] = {222/255, 13/255, 65/255} -- Cooking
+}
+
+function B:GetContainerFrame(arg)
+ if type(arg) == "boolean" and arg == true then
+ return self.BankFrame
+ elseif type(arg) == "number" then
+ if self.BankFrame then
+ for _, bagID in ipairs(self.BankFrame.BagIDs) do
+ if bagID == arg then
+ return self.BankFrame
+ end
+ end
+ end
+ end
+
+ return self.BagFrame
+end
+
+function B:Tooltip_Show()
+ GameTooltip:SetOwner(this)
+ GameTooltip:ClearLines()
+ GameTooltip:AddLine(this.ttText)
+
+ if(this.ttText2) then
+ GameTooltip:AddLine(" ")
+ GameTooltip:AddDoubleLine(this.ttText2, this.ttText2desc, 1, 1, 1)
+ end
+
+ GameTooltip:Show()
+end
+
+function B:Tooltip_Hide()
+ GameTooltip:Hide()
+end
+
+function B:DisableBlizzard()
+ BankFrame:UnregisterAllEvents()
+
+ for i=1, NUM_CONTAINER_FRAMES do
+ E:Kill(_G["ContainerFrame"..i])
+ end
+end
+
+function B:SearchReset()
+ SEARCH_STRING = ""
+end
+
+function B:IsSearching()
+ if SEARCH_STRING ~= "" and SEARCH_STRING ~= SEARCH then
+ return true
+ end
+ return false
+end
+
+function B:UpdateSearch()
+ if this.Instructions then this.Instructions:SetShown(this:GetText() == "") end
+ local MIN_REPEAT_CHARACTERS = 3
+ local searchString = this:GetText()
+ local prevSearchString = SEARCH_STRING
+ if (len(searchString) > MIN_REPEAT_CHARACTERS) then
+ local repeatChar = true
+ for i=1, MIN_REPEAT_CHARACTERS, 1 do
+ if ( sub(searchString,(0-i), (0-i)) ~= sub(searchString,(-1-i),(-1-i)) ) then
+ repeatChar = false
+ break
+ end
+ end
+ if ( repeatChar ) then
+ B.ResetAndClear(this)
+ return
+ end
+ end
+
+ --Keep active search term when switching between bank and reagent bank
+ if searchString == SEARCH and prevSearchString ~= "" then
+ searchString = prevSearchString
+ elseif searchString == SEARCH then
+ searchString = ""
+ end
+
+ SEARCH_STRING = searchString
+
+ --B:SetSearch(SEARCH_STRING)
+ B:SetGuildBankSearch(SEARCH_STRING)
+end
+
+function B:OpenEditbox()
+ self.BagFrame.detail:Hide()
+ self.BagFrame.editBox:Show()
+ self.BagFrame.editBox:SetText(SEARCH)
+ self.BagFrame.editBox:HighlightText()
+end
+
+function B:ResetAndClear()
+ local editbox = self:GetParent().editBox or self
+ if editbox then editbox:SetText(SEARCH) end
+
+ self:ClearFocus()
+ B:SearchReset()
+end
+
+function B:SetSearch(query)
+ local empty = len(gsub(query, " ", "")) == 0
+ for _, bagFrame in pairs(self.BagFrames) do
+ for _, bagID in ipairs(bagFrame.BagIDs) do
+ for slotID = 1, GetContainerNumSlots(bagID) do
+ local link = GetContainerItemLink(bagID, slotID)
+ local button = bagFrame.Bags[bagID][slotID]
+ local success, result = pcall(Search.Matches, Search, link, query)
+ if(empty or (success and result)) then
+ SetItemButtonDesaturated(button)
+ button:SetAlpha(1)
+ else
+ SetItemButtonDesaturated(button, 1)
+ button:SetAlpha(0.4)
+ end
+ end
+ end
+ end
+
+ if(ElvUIKeyFrameItem1) then
+ local numKey = GetKeyRingSize()
+ for slotID = 1, numKey do
+ local link = GetContainerItemLink(KEYRING_CONTAINER, slotID)
+ local button = _G["ElvUIKeyFrameItem"..slotID]
+ local success, result = pcall(Search.Matches, Search, link, query)
+ if(empty or (success and result)) then
+ SetItemButtonDesaturated(button)
+ button:SetAlpha(1)
+ else
+ SetItemButtonDesaturated(button, 1)
+ button:SetAlpha(0.4)
+ end
+ end
+ end
+end
+
+function B:SetGuildBankSearch(query)
+ local empty = len(gsub(query, " ", "")) == 0
+ if GuildBankFrame and GuildBankFrame:IsShown() then
+ local tab = GetCurrentGuildBankTab()
+ local _, _, isViewable = GetGuildBankTabInfo(tab)
+
+ if isViewable then
+ for slotID = 1, MAX_GUILDBANK_SLOTS_PER_TAB do
+ local link = GetGuildBankItemLink(tab, slotID)
+ --A column goes from 1-14, e.g. GuildBankColumn1Button14 (slotID 14) or GuildBankColumn2Button3 (slotID 17)
+ local col = ceil(slotID / 14)
+ local btn = mod(slotID, 14)
+ if col == 0 then col = 1 end
+ if btn == 0 then btn = 14 end
+ local button = _G["GuildBankColumn"..col.."Button"..btn]
+ local success, result = pcall(Search.Matches, Search, link, query)
+ if(empty or (success and result)) then
+ SetItemButtonDesaturated(button)
+ button:SetAlpha(1)
+ else
+ SetItemButtonDesaturated(button, 1)
+ button:SetAlpha(0.4)
+ end
+ end
+ end
+ end
+end
+
+function B:UpdateItemLevelDisplay()
+ if(E.private.bags.enable ~= true) then return end
+ for _, bagFrame in pairs(self.BagFrames) do
+ for _, bagID in ipairs(bagFrame.BagIDs) do
+ for slotID = 1, GetContainerNumSlots(bagID) do
+ local slot = bagFrame.Bags[bagID][slotID]
+ if(slot and slot.itemLevel) then
+ slot.itemLevel:FontTemplate(E.LSM:Fetch("font", E.db.bags.itemLevelFont), E.db.bags.itemLevelFontSize, E.db.bags.itemLevelFontOutline)
+ end
+ end
+ end
+
+ if(bagFrame.UpdateAllSlots) then
+ bagFrame:UpdateAllSlots()
+ end
+ end
+end
+
+function B:UpdateCountDisplay()
+ if(E.private.bags.enable ~= true) then return end
+ local color = E.db.bags.countFontColor
+
+ for _, bagFrame in pairs(self.BagFrames) do
+ for _, bagID in ipairs(bagFrame.BagIDs) do
+ for slotID = 1, GetContainerNumSlots(bagID) do
+ local slot = bagFrame.Bags[bagID][slotID]
+ if(slot and slot.Count) then
+ slot.Count:FontTemplate(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)
+ end
+ end
+ end
+ if(bagFrame.UpdateAllSlots) then
+ bagFrame:UpdateAllSlots()
+ end
+ end
+end
+
+function B:UpdateSlot(bagID, slotID)
+ if (self.Bags[bagID] and self.Bags[bagID].numSlots ~= GetContainerNumSlots(bagID)) or not self.Bags[bagID] or not self.Bags[bagID][slotID] then return end
+
+ local slot, _ = self.Bags[bagID][slotID], nil
+ --local bagType = self.Bags[bagID].type
+ local texture, count, locked = GetContainerItemInfo(bagID, slotID)
+ local clink = GetContainerItemLink(bagID, slotID)
+
+ slot.name, slot.rarity = nil, nil
+
+ slot:Show()
+ slot.itemLevel:SetText("")
+
+ --if(B.ProfessionColors[bagType]) then
+ -- slot:SetBackdropBorderColor(unpack(B.ProfessionColors[bagType]))
+ if(clink) then
+ local iLvl, itemEquipLoc
+ slot.name, _, slot.rarity, iLvl, _, _, _, _, itemEquipLoc = GetItemInfo(string.match(clink, "item:(%d+)"))
+
+ local r, g, b
+
+ if(slot.rarity) then
+ r, g, b = GetItemQualityColor(slot.rarity)
+ end
+
+ --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 >= E.db.bags.itemLevelThreshold) then
+ slot.itemLevel:SetText(iLvl)
+ slot.itemLevel:SetTextColor(r, g, b)
+ end
+ end
+
+ -- color slot according to item quality
+ if slot.rarity and slot.rarity > 1 then
+ slot:SetBackdropBorderColor(r, g, b)
+ else
+ slot:SetBackdropBorderColor(unpack(E.media.bordercolor))
+ end
+ else
+ slot:SetBackdropBorderColor(unpack(E.media.bordercolor))
+ end
+
+ if texture then
+ if bagID ~= BANK_CONTAINER then
+ local start, duration, enable = GetContainerItemCooldown(bagID, slotID)
+ CooldownFrame_SetTimer(slot.cooldown, start, duration, enable)
+ if duration > 0 and enable == 0 then
+ SetItemButtonTextureVertexColor(slot, 0.4, 0.4, 0.4)
+ else
+ SetItemButtonTextureVertexColor(slot, 1, 1, 1)
+ end
+ end
+ slot.hasItem = 1
+ else
+ if bagID ~= BANK_CONTAINER then
+ slot.cooldown:Hide()
+ end
+ slot.hasItem = nil
+ end
+
+ SetItemButtonTexture(slot, texture)
+ SetItemButtonCount(slot, count)
+ SetItemButtonDesaturated(slot, locked, 0.5, 0.5, 0.5)
+
+ if GameTooltip:IsOwned(slot) and not slot.hasItem then
+ B:Tooltip_Hide()
+ end
+end
+
+function B:UpdateBagSlots(bagID)
+ for slotID = 1, GetContainerNumSlots(bagID) do
+ if self.UpdateSlot then
+ self:UpdateSlot(bagID, slotID)
+ else
+ self:GetParent():UpdateSlot(bagID, slotID)
+ end
+ end
+end
+
+function B:UpdateCooldowns()
+ for _, bagID in ipairs(self.BagIDs) do
+ if bagID ~= BANK_CONTAINER then
+ for slotID = 1, GetContainerNumSlots(bagID) do
+ local start, duration, enable = GetContainerItemCooldown(bagID, slotID)
+ CooldownFrame_SetTimer(self.Bags[bagID][slotID].cooldown, start, duration, enable)
+ if (duration > 0 and enable == 0) then
+ SetItemButtonTextureVertexColor(self.Bags[bagID][slotID], 0.4, 0.4, 0.4)
+ else
+ SetItemButtonTextureVertexColor(self.Bags[bagID][slotID], 1, 1, 1)
+ end
+ end
+ end
+ end
+end
+
+function B:UpdateAllSlots()
+ for _, bagID in ipairs(self.BagIDs) do
+ if self.Bags[bagID] then
+ self.Bags[bagID]:UpdateBagSlots(bagID)
+ end
+ end
+end
+
+function B:SetSlotAlphaForBag(f)
+ for _, bagID in ipairs(f.BagIDs) do
+ if f.Bags[bagID] then
+ local numSlots = GetContainerNumSlots(bagID)
+ for slotID = 1, numSlots do
+ if f.Bags[bagID][slotID] then
+ if bagID == self.id then
+ f.Bags[bagID][slotID]:SetAlpha(1)
+ else
+ f.Bags[bagID][slotID]:SetAlpha(0.1)
+ end
+ end
+ end
+ end
+ end
+end
+
+function B:ResetSlotAlphaForBags(f)
+ for _, bagID in ipairs(f.BagIDs) do
+ if f.Bags[bagID] then
+ local numSlots = GetContainerNumSlots(bagID)
+ for slotID = 1, numSlots do
+ if f.Bags[bagID][slotID] then
+ f.Bags[bagID][slotID]:SetAlpha(1)
+ end
+ end
+ end
+ end
+end
+
+function B:Layout(isBank)
+ if E.private.bags.enable ~= true then return end
+ local f = self:GetContainerFrame(isBank)
+
+ if not f then return end
+ local buttonSize = isBank and self.db.bankSize or self.db.bagSize
+ local buttonSpacing = E.PixelMode and 2 or 4
+ local containerWidth = ((isBank and self.db.bankWidth) or self.db.bagWidth)
+ local numContainerColumns = floor(containerWidth / (buttonSize + buttonSpacing))
+ local holderWidth = ((buttonSize + buttonSpacing) * numContainerColumns) - buttonSpacing
+ local numContainerRows = 0
+ local countColor = E.db.bags.countFontColor
+ f.holderFrame:SetWidth(holderWidth)
+
+ f.totalSlots = 0
+ local lastButton
+ local lastRowButton
+ local lastContainerButton
+ local numContainerSlots = GetNumBankSlots()
+ for i, bagID in ipairs(f.BagIDs) do
+ --Bag Containers
+ 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 isBank then
+ f.ContainerHolder[i] = CreateFrame("CheckButton", "ElvUIBankBag" .. bagID - 4, f.ContainerHolder, "BankItemButtonBagTemplate")
+ f.ContainerHolder[i]:SetScript("OnClick", function(self)
+ local inventoryID = self:GetInventorySlot()
+ PutItemInBag(inventoryID) --Put bag on empty slot, or drop item in this bag
+ end)
+ else
+ f.ContainerHolder[i] = CreateFrame("CheckButton", "ElvUIMainBag" .. bagID .. "Slot", f.ContainerHolder, "BagSlotButtonTemplate")
+ f.ContainerHolder[i]:SetScript("OnClick", function(self)
+ local id = self:GetID()
+ PutItemInBag(id) --Put bag on empty slot, or drop item in this bag
+ end)
+ end
+
+ E:CreateBackdrop(f.ContainerHolder[i], "Default", true)
+ f.ContainerHolder[i].backdrop:SetAllPoints()
+ E:StyleButton(f.ContainerHolder[i])
+ f.ContainerHolder[i]:SetNormalTexture("")
+ f.ContainerHolder[i]:SetCheckedTexture("")
+ f.ContainerHolder[i]:SetPushedTexture("")
+ f.ContainerHolder[i].id = isBank and bagID or bagID + 1
+ HookScript(f.ContainerHolder[i], "OnEnter", function() B.SetSlotAlphaForBag(thid, f) end)
+ HookScript(f.ContainerHolder[i], "OnLeave", function() B.ResetSlotAlphaForBags(thid, f) end)
+
+ if isBank then
+ f.ContainerHolder[i]:SetID(bagID)
+ if not f.ContainerHolder[i].tooltipText then
+ f.ContainerHolder[i].tooltipText = ""
+ end
+ end
+
+ f.ContainerHolder[i].iconTexture = _G[f.ContainerHolder[i]:GetName().."IconTexture"]
+ E:SetInside(f.ContainerHolder[i].iconTexture)
+ f.ContainerHolder[i].iconTexture:SetTexCoord(unpack(E.TexCoords))
+ end
+
+ f.ContainerHolder:SetWidth(((buttonSize + buttonSpacing) * (isBank and i - 1 or i)) + buttonSpacing,buttonSize + (buttonSpacing * 2))
+ f.ContainerHolder:SetHeight(((buttonSize + buttonSpacing) * (isBank and i - 1 or i)) + buttonSpacing,buttonSize + (buttonSpacing * 2))
+
+ if isBank then
+ BankFrameItemButton_Update(f.ContainerHolder[i])
+ BankFrameItemButton_UpdateLocked(f.ContainerHolder[i])
+ end
+
+ f.ContainerHolder[i]:SetWidth(buttonSize)
+ f.ContainerHolder[i]:SetHeight(buttonSize)
+ f.ContainerHolder[i]:ClearAllPoints()
+ if (isBank and i == 2) or (not isBank and i == 1) then
+ f.ContainerHolder[i]:SetPoint("BOTTOMLEFT", f.ContainerHolder, "BOTTOMLEFT", buttonSpacing, buttonSpacing)
+ else
+ f.ContainerHolder[i]:SetPoint("LEFT", lastContainerButton, "RIGHT", buttonSpacing, 0)
+ end
+
+ lastContainerButton = f.ContainerHolder[i]
+ end
+
+ --Bag Slots
+ local numSlots = GetContainerNumSlots(bagID)
+ if numSlots > 0 then
+ if not f.Bags[bagID] then
+ f.Bags[bagID] = CreateFrame("Frame", f:GetName().."Bag"..bagID, f)
+ f.Bags[bagID]:SetID(bagID)
+ f.Bags[bagID].UpdateBagSlots = B.UpdateBagSlots
+ -- f.Bags[bagID].UpdateSlot = B.UpdateSlot
+ end
+
+ f.Bags[bagID].numSlots = numSlots
+ --f.Bags[bagID].type = select(2, GetContainerNumFreeSlots(bagID))
+
+ --Hide unused slots
+ for i = 1, MAX_CONTAINER_ITEMS do
+ if f.Bags[bagID][i] then
+ f.Bags[bagID][i]:Hide()
+ end
+ end
+
+ for slotID = 1, numSlots do
+ f.totalSlots = f.totalSlots + 1
+ if not f.Bags[bagID][slotID] then
+ f.Bags[bagID][slotID] = CreateFrame("CheckButton", f.Bags[bagID]:GetName().."Slot"..slotID, f.Bags[bagID], bagID == -1 and "BankItemButtonGenericTemplate" or "ContainerFrameItemButtonTemplate")
+ E:StyleButton(f.Bags[bagID][slotID])
+ E:SetTemplate(f.Bags[bagID][slotID], "Default", true)
+ f.Bags[bagID][slotID]:SetNormalTexture("")
+ f.Bags[bagID][slotID]:SetCheckedTexture("")
+
+ f.Bags[bagID][slotID].Count = _G[f.Bags[bagID][slotID]:GetName() .. "Count"]
+ f.Bags[bagID][slotID].Count:ClearAllPoints()
+ f.Bags[bagID][slotID].Count:SetPoint("BOTTOMRIGHT", 0, 2)
+ E:FontTemplate(f.Bags[bagID][slotID].Count, E.LSM:Fetch("font", E.db.bags.countFont), E.db.bags.countFontSize, E.db.bags.countFontOutline)
+ f.Bags[bagID][slotID].Count:SetTextColor(countColor.r, countColor.g, countColor.b)
+
+ f.Bags[bagID][slotID].iconTexture = _G[f.Bags[bagID][slotID]:GetName().."IconTexture"]
+ E:SetInside(f.Bags[bagID][slotID].iconTexture, f.Bags[bagID][slotID])
+ f.Bags[bagID][slotID].iconTexture:SetTexCoord(unpack(E.TexCoords))
+
+ if bagID ~= BANK_CONTAINER then
+ f.Bags[bagID][slotID].cooldown = _G[f.Bags[bagID][slotID]:GetName().."Cooldown"]
+ E:RegisterCooldown(f.Bags[bagID][slotID].cooldown)
+ f.Bags[bagID][slotID].bagID = bagID
+ f.Bags[bagID][slotID].slotID = slotID
+ end
+
+ f.Bags[bagID][slotID].itemLevel = f.Bags[bagID][slotID]:CreateFontString(nil, "OVERLAY")
+ f.Bags[bagID][slotID].itemLevel:SetPoint("BOTTOMRIGHT", 0, 2)
+ E:FontTemplate(f.Bags[bagID][slotID].itemLevel, E.LSM:Fetch("font", E.db.bags.itemLevelFont), E.db.bags.itemLevelFontSize, E.db.bags.itemLevelFontOutline)
+ end
+
+ f.Bags[bagID][slotID]:SetID(slotID)
+ f.Bags[bagID][slotID]:SetWidth(buttonSize)
+ f.Bags[bagID][slotID]:SetHeight(buttonSize)
+
+ f:UpdateSlot(bagID, slotID)
+
+ if f.Bags[bagID][slotID]:GetPoint() then
+ f.Bags[bagID][slotID]:ClearAllPoints()
+ end
+
+ if lastButton then
+ if mod(f.totalSlots - 1, numContainerColumns) == 0 then
+ f.Bags[bagID][slotID]:SetPoint("TOP", lastRowButton, "BOTTOM", 0, -buttonSpacing)
+ lastRowButton = f.Bags[bagID][slotID]
+ numContainerRows = numContainerRows + 1
+ else
+ f.Bags[bagID][slotID]:SetPoint("LEFT", lastButton, "RIGHT", buttonSpacing, 0)
+ end
+ else
+ f.Bags[bagID][slotID]:SetPoint("TOPLEFT", f.holderFrame, "TOPLEFT")
+ lastRowButton = f.Bags[bagID][slotID]
+ numContainerRows = numContainerRows + 1
+ end
+
+ lastButton = f.Bags[bagID][slotID]
+ end
+ else
+ for i = 1, MAX_CONTAINER_ITEMS do
+ if f.Bags[bagID] and f.Bags[bagID][i] then
+ f.Bags[bagID][i]:Hide()
+ end
+ end
+
+ if f.Bags[bagID] then
+ f.Bags[bagID].numSlots = numSlots
+ end
+
+ if self.isBank then
+ if self.ContainerHolder[i] then
+ BankFrameItemButton_Update(self.ContainerHolder[i])
+ BankFrameItemButton_UpdateLocked(self.ContainerHolder[i])
+ end
+ end
+ end
+ end
+
+ local numKey = GetKeyRingSize()
+ local numKeyColumns = 6
+ if(not isBank) then
+ local totalSlots = 0
+ local lastRowButton
+ local numKeyRows = 1
+ for i = 1, numKey do
+ totalSlots = totalSlots + 1
+
+ if(not f.keyFrame.slots[i]) then
+ f.keyFrame.slots[i] = CreateFrame("CheckButton", "ElvUIKeyFrameItem"..i, f.keyFrame, "ContainerFrameItemButtonTemplate")
+ E:StyleButton(f.keyFrame.slots[i], nil, nil, true)
+ E:SetTemplate(f.keyFrame.slots[i], "Default", true)
+ f.keyFrame.slots[i]:SetNormalTexture("")
+ f.keyFrame.slots[i]:SetID(i)
+
+ f.keyFrame.slots[i].cooldown = _G[f.keyFrame.slots[i]:GetName().."Cooldown"]
+ E:RegisterCooldown(f.keyFrame.slots[i].cooldown)
+
+ f.keyFrame.slots[i].iconTexture = _G[f.keyFrame.slots[i]:GetName().."IconTexture"]
+ E:SetInside(f.keyFrame.slots[i].iconTexture, f.keyFrame.slots[i])
+ f.keyFrame.slots[i].iconTexture:SetTexCoord(unpack(E.TexCoords))
+ end
+
+ f.keyFrame.slots[i]:ClearAllPoints()
+ f.keyFrame.slots[i]:SetWidth(buttonSize)
+ f.keyFrame.slots[i]:SetHeight(buttonSize)
+ if(f.keyFrame.slots[i-1]) then
+ if mod(totalSlots - 1, numKeyColumns) == 0 then
+ f.keyFrame.slots[i]:SetPoint("TOP", lastRowButton, "BOTTOM", 0, -buttonSpacing)
+ lastRowButton = f.keyFrame.slots[i]
+ numKeyRows = numKeyRows + 1
+ else
+ f.keyFrame.slots[i]:SetPoint("RIGHT", f.keyFrame.slots[i-1], "LEFT", -buttonSpacing, 0)
+ end
+ else
+ f.keyFrame.slots[i]:SetPoint("TOPRIGHT", f.keyFrame, "TOPRIGHT", -buttonSpacing, -buttonSpacing)
+ lastRowButton = f.keyFrame.slots[i]
+ end
+
+ self:UpdateKeySlot(i)
+ end
+
+ if(numKey < numKeyColumns) then
+ numKeyColumns = numKey
+ end
+ f.keyFrame:SetWidth(((buttonSize + buttonSpacing) * numKeyColumns) + buttonSpacing)
+ f.keyFrame:SetHeight(((buttonSize + buttonSpacing) * numKeyRows) + buttonSpacing)
+ end
+
+ f:SetWidth(containerWidth)
+ f:SetHeight((((buttonSize + buttonSpacing) * numContainerRows) - buttonSpacing) + f.topOffset + f.bottomOffset) -- 8 is the cussion of the f.holderFrame
+end
+
+function B:UpdateKeySlot(slotID)
+ assert(slotID)
+ local bagID = KEYRING_CONTAINER
+ local texture, count, locked = GetContainerItemInfo(bagID, slotID)
+ local clink = GetContainerItemLink(bagID, slotID)
+ local slot = _G["ElvUIKeyFrameItem"..slotID]
+ if not slot then return end
+
+ slot.name, slot.rarity = nil, nil
+ slot:Show()
+
+ if clink then
+ local _
+ slot.name, _, slot.rarity = GetItemInfo(clink)
+
+ local r, g, b
+
+ if slot.rarity then
+ r, g, b = GetItemQualityColor(slot.rarity)
+ end
+
+ if slot.rarity and slot.rarity > 1 then
+ slot:SetBackdropBorderColor(r, g, b)
+ else
+ slot:SetBackdropBorderColor(unpack(E.media.bordercolor))
+ end
+ else
+ slot:SetBackdropBorderColor(unpack(E.media.bordercolor))
+ end
+
+ if texture then
+ local start, duration, enable = GetContainerItemCooldown(bagID, slotID)
+ CooldownFrame_SetTimer(slot.cooldown, start, duration, enable)
+ if duration > 0 and enable == 0 then
+ SetItemButtonTextureVertexColor(slot, 0.4, 0.4, 0.4)
+ else
+ SetItemButtonTextureVertexColor(slot, 1, 1, 1)
+ end
+ else
+ slot.cooldown:Hide()
+ end
+
+ SetItemButtonTexture(slot, texture)
+ SetItemButtonCount(slot, count)
+ SetItemButtonDesaturated(slot, locked, 0.5, 0.5, 0.5)
+end
+
+function B:UpdateAll()
+ if self.BagFrame then
+ self:Layout()
+ end
+
+ if self.BankFrame then
+ self:Layout(true)
+ end
+end
+
+function B:OnEvent()
+ if event == "ITEM_LOCK_CHANGED" or event == "ITEM_UNLOCKED" then
+ local bag, slot = arg1, arg2
+ if bag == KEYRING_CONTAINER then
+ B:UpdateKeySlot(slot)
+ else
+ this:UpdateSlot(bag, slot)
+ end
+ elseif event == "BAG_UPDATE" then
+ local bag = arg1
+ if(bag == KEYRING_CONTAINER) then
+ if not _G["ElvUIKeyFrameItem"..GetKeyRingSize()] then
+ B:Layout(false)
+ end
+ for slotID = 1, GetKeyRingSize() do
+ B:UpdateKeySlot(slotID)
+ end
+ end
+
+ for _, bagID in ipairs(this.BagIDs) do
+ local numSlots = GetContainerNumSlots(bagID)
+ if (not this.Bags[bagID] and numSlots ~= 0) or (this.Bags[bagID] and numSlots ~= this.Bags[bagID].numSlots) then
+ B:Layout(this.isBank)
+ return
+ end
+ end
+
+ this:UpdateBagSlots(arg1, arg2)
+ if(B:IsSearching()) then
+ -- B:SetSearch(SEARCH_STRING)
+ end
+ elseif event == "BAG_UPDATE_COOLDOWN" then
+ if not this:IsShown() then return end
+ this:UpdateCooldowns()
+ elseif event == "PLAYERBANKSLOTS_CHANGED" then
+ this:UpdateAllSlots()
+ end
+end
+
+function B:UpdateGoldText()
+ self.BagFrame.goldText:SetText(E:FormatMoney(GetMoney(), E.db["bags"].moneyFormat, not E.db["bags"].moneyCoins))
+end
+
+function B:GetGraysValue()
+ local c = 0
+
+ for b = 0, NUM_BAG_FRAMES do
+ for s = 0, GetContainerNumSlots(b) do
+ local l = GetContainerItemLink(b, s)
+ if l and find(l,"ff9d9d9d") then
+ local p = LIP:GetSellValue(l) * select(2, GetContainerItemInfo(b, s))
+ if(select(3, GetItemInfo(l)) == 0 and p > 0) then
+ c = c + p
+ end
+ end
+ end
+ end
+
+ return c
+end
+
+function B:VendorGrays(delete, _, getValue)
+ if (not MerchantFrame or not MerchantFrame:IsShown()) and not delete and not getValue then
+ E:Print(L["You must be at a vendor."])
+ return
+ end
+
+ local c = 0
+ local count = 0
+ for b = 0, NUM_BAG_FRAMES do
+ for s = 1, GetContainerNumSlots(b) do
+ local l = GetContainerItemLink(b, s)
+ if l and find(l,"ff9d9d9d") then
+ local p = LIP:GetSellValue(l) * select(2, GetContainerItemInfo(b, s))
+
+ if delete then
+ if find(l,"ff9d9d9d") then
+ if not getValue then
+ PickupContainerItem(b, s)
+ DeleteCursorItem()
+ end
+ c = c + p
+ count = count + 1
+ end
+ else
+ if select(3, GetItemInfo(l)) == 0 and p > 0 then
+ if not getValue then
+ UseContainerItem(b, s)
+ PickupMerchantItem()
+ end
+ c = c + p
+ end
+ end
+ end
+ end
+ end
+
+ if getValue then
+ return c
+ end
+
+ if c > 0 and not delete then
+ local g, s, c = floor(c / 10000) or 0, floor(mod(c, 10000) / 100) or 0, mod(c, 100)
+ E:Print(L["Vendored gray items for:"].." |cffffffff"..g..L.goldabbrev.." |cffffffff"..s..L.silverabbrev.." |cffffffff"..c..L.copperabbrev..".")
+ end
+end
+
+function B:VendorGrayCheck()
+ local value = B:GetGraysValue()
+
+ if(value == 0) then
+ E:Print(L["No gray items to delete."])
+ elseif(not MerchantFrame or not MerchantFrame:IsShown()) then
+ E.PopupDialogs["DELETE_GRAYS"].Money = value
+ E:StaticPopup_Show("DELETE_GRAYS")
+ else
+ B:VendorGrays()
+ end
+end
+
+function B:ContructContainerFrame(name, isBank)
+ local f = CreateFrame("Button", name, E.UIParent)
+ E:SetTemplate(f, "Transparent")
+ f:SetFrameStrata("DIALOG")
+ f.UpdateSlot = B.UpdateSlot
+ f.UpdateAllSlots = B.UpdateAllSlots
+ f.UpdateBagSlots = B.UpdateBagSlots
+ f.UpdateCooldowns = B.UpdateCooldowns
+ f:RegisterEvent("ITEM_LOCK_CHANGED")
+ f:RegisterEvent("ITEM_UNLOCKED")
+ f:RegisterEvent("BAG_UPDATE_COOLDOWN")
+ f:RegisterEvent("BAG_UPDATE")
+ f:RegisterEvent("PLAYERBANKSLOTS_CHANGED")
+
+ f:SetScript("OnEvent", B.OnEvent)
+ f:Hide()
+
+ f.isBank = isBank
+
+ f.bottomOffset = isBank and 8 or 28
+ f.topOffset = isBank and 45 or 50
+ f.BagIDs = isBank and {-1, 5, 6, 7, 8, 9, 10, 11} or {0, 1, 2, 3, 4}
+ f.Bags = {}
+
+ local mover = (isBank and ElvUIBankMover or ElvUIBagMover)
+ if(mover) then
+ f:SetPoint(mover.POINT, mover)
+ f.mover = mover
+ end
+
+ f:SetMovable(true)
+ f:RegisterForDrag("LeftButton", "RightButton")
+ f:RegisterForClicks("LeftButtonUp", "RightButtonUp")
+ f:SetScript("OnDragStart", function() if IsShiftKeyDown() then this:StartMoving() end end)
+ f:SetScript("OnDragStop", function() this:StopMovingOrSizing() end)
+ f:SetScript("OnClick", function() if IsControlKeyDown() then B.PostBagMove(this.mover) end end)
+ f:SetScript("OnEnter", function()
+ GameTooltip:SetOwner(this, "ANCHOR_TOPLEFT", 0, 4)
+ GameTooltip:ClearLines()
+ GameTooltip:AddDoubleLine(L["Hold Shift + Drag:"], L["Temporary Move"], 1, 1, 1)
+ GameTooltip:AddDoubleLine(L["Hold Control + Right Click:"], L["Reset Position"], 1, 1, 1)
+
+ GameTooltip:Show()
+ end)
+ f:SetScript("OnLeave", function() GameTooltip:Hide() end)
+
+ f.closeButton = CreateFrame("Button", name.."CloseButton", f, "UIPanelCloseButton")
+ f.closeButton:SetPoint("TOPRIGHT", -4, -4)
+
+ E:GetModule("Skins"):HandleCloseButton(f.closeButton)
+
+ f.holderFrame = CreateFrame("Frame", nil, f)
+ f.holderFrame:SetPoint("TOP", f, "TOP", 0, -f.topOffset)
+ f.holderFrame:SetPoint("BOTTOM", f, "BOTTOM", 0, 8)
+
+ f.ContainerHolder = CreateFrame("Button", name.."ContainerHolder", f)
+ f.ContainerHolder:SetPoint("BOTTOMLEFT", f, "TOPLEFT", 0, 1)
+ E:SetTemplate(f.ContainerHolder, "Transparent")
+ f.ContainerHolder:Hide()
+
+ if(isBank) then
+ f.bagText = f:CreateFontString(nil, "OVERLAY")
+ E:FontTemplate(f.bagText)
+ f.bagText:SetPoint("BOTTOMRIGHT", f.holderFrame, "TOPRIGHT", -2, 4)
+ f.bagText:SetJustifyH("RIGHT")
+ f.bagText:SetText(L["Bank"])
+
+ f.sortButton = CreateFrame("Button", name.."SortButton", f)
+ f.sortButton:SetWidth(16 + E.Border)
+ f.sortButton:SetHeight(16 + E.Border)
+ E:SetTemplate(f.sortButton)
+ f.sortButton:SetPoint("RIGHT", f.bagText, "LEFT", -5, E.Border * 2)
+ f.sortButton:SetNormalTexture("Interface\\AddOns\\ElvUI\\media\\textures\\INV_Pet_RatCage")
+ --f.sortButton:GetNormalTexture():SetTexCoord(unpack(E.TexCoords))
+ --E:SetInside(f.sortButton:GetNormalTexture())
+ f.sortButton:SetPushedTexture("Interface\\AddOns\\ElvUI\\media\\textures\\INV_Pet_RatCage")
+ --f.sortButton:GetPushedTexture():SetTexCoord(unpack(E.TexCoords))
+ --E:SetInside(f.sortButton:GetPushedTexture())
+ f.sortButton:SetDisabledTexture("Interface\\AddOns\\ElvUI\\media\\textures\\INV_Pet_RatCage")
+ --f.sortButton:GetDisabledTexture():SetTexCoord(unpack(E.TexCoords))
+ --E:SetInside(f.sortButton:GetDisabledTexture())
+ --f.sortButton:GetDisabledTexture():SetDesaturated(true)
+ E:StyleButton(f.sortButton, nil, true)
+ f.sortButton.ttText = L["Sort Bags"]
+ f.sortButton:SetScript("OnEnter", self.Tooltip_Show)
+ f.sortButton:SetScript("OnLeave", self.Tooltip_Hide)
+ f.sortButton:SetScript("OnClick", function() B:CommandDecorator(B.SortBags, "bank")() end)
+ if(E.db.bags.disableBankSort) then
+ f.sortButton:Disable()
+ end
+
+ f.bagsButton = CreateFrame("Button", name.."BagsButton", f.holderFrame)
+ f.bagsButton:SetWidth(16 + E.Border)
+ f.bagsButton:SetHeight(16 + E.Border)
+ E:SetTemplate(f.bagsButton)
+ f.bagsButton:SetPoint("RIGHT", f.sortButton, "LEFT", -5, 0)
+ f.bagsButton:SetNormalTexture("Interface\\Buttons\\Button-Backpack-Up")
+ f.bagsButton:GetNormalTexture():SetTexCoord(unpack(E.TexCoords))
+ E:SetInside(f.bagsButton:GetNormalTexture())
+ f.bagsButton:SetPushedTexture("Interface\\Buttons\\Button-Backpack-Up")
+ f.bagsButton:GetPushedTexture():SetTexCoord(unpack(E.TexCoords))
+ E:SetInside(f.bagsButton:GetPushedTexture())
+ E:StyleButton(f.bagsButton, nil, true)
+ f.bagsButton.ttText = L["Toggle Bags"]
+ f.bagsButton:SetScript("OnEnter", self.Tooltip_Show)
+ f.bagsButton:SetScript("OnLeave", self.Tooltip_Hide)
+ f.bagsButton:SetScript("OnClick", function()
+ local numSlots = GetNumBankSlots()
+ PlaySound("igMainMenuOption")
+ if(numSlots >= 1) then
+ ToggleFrame(f.ContainerHolder)
+ else
+ E:StaticPopup_Show("NO_BANK_BAGS")
+ end
+ end)
+
+ f.purchaseBagButton = CreateFrame("Button", nil, f.holderFrame)
+ f.purchaseBagButton:SetWidth(16 + E.Border)
+ f.purchaseBagButton:SetHeight(16 + E.Border)
+ E:SetTemplate(f.purchaseBagButton)
+ f.purchaseBagButton:SetPoint("RIGHT", f.bagsButton, "LEFT", -5, 0)
+ f.purchaseBagButton:SetNormalTexture("Interface\\ICONS\\INV_Misc_Coin_01")
+ f.purchaseBagButton:GetNormalTexture():SetTexCoord(unpack(E.TexCoords))
+ E:SetInside(f.purchaseBagButton:GetNormalTexture())
+ f.purchaseBagButton:SetPushedTexture("Interface\\ICONS\\INV_Misc_Coin_01")
+ f.purchaseBagButton:GetPushedTexture():SetTexCoord(unpack(E.TexCoords))
+ E:SetInside(f.purchaseBagButton:GetPushedTexture())
+ E:StyleButton(f.purchaseBagButton, nil, true)
+ f.purchaseBagButton.ttText = L["Purchase Bags"]
+ f.purchaseBagButton:SetScript("OnEnter", self.Tooltip_Show)
+ f.purchaseBagButton:SetScript("OnLeave", self.Tooltip_Hide)
+ f.purchaseBagButton:SetScript("OnClick", function()
+ local _, full = GetNumBankSlots()
+ if(full) then
+ E:StaticPopup_Show("CANNOT_BUY_BANK_SLOT")
+ else
+ E:StaticPopup_Show("BUY_BANK_SLOT")
+ end
+ end)
+
+ f:SetScript("OnHide", function()
+ CloseBankFrame()
+
+ if E.db.bags.clearSearchOnClose then
+ B.ResetAndClear(f.editBox)
+ end
+ end)
+
+ f.editBox = CreateFrame("EditBox", name.."EditBox", f)
+ f.editBox:SetFrameLevel(f.editBox:GetFrameLevel() + 2)
+ E:CreateBackdrop(f.editBox, "Default")
+ f.editBox.backdrop:SetPoint("TOPLEFT", f.editBox, "TOPLEFT", -20, 2)
+ f.editBox:SetHeight(15)
+ f.editBox:SetPoint("BOTTOMLEFT", f.holderFrame, "TOPLEFT", (E.Border * 2) + 18, E.Border * 2 + 2)
+ f.editBox:SetPoint("RIGHT", f.purchaseBagButton, "LEFT", -5, 0)
+ f.editBox:SetAutoFocus(false)
+ f.editBox:SetScript("OnEscapePressed", self.ResetAndClear)
+ f.editBox:SetScript("OnEnterPressed", function(self) self:ClearFocus() end)
+ f.editBox:SetScript("OnEditFocusGained", f.editBox.HighlightText)
+ f.editBox:SetScript("OnTextChanged", self.UpdateSearch)
+ f.editBox:SetScript("OnChar", self.UpdateSearch)
+ f.editBox:SetText(SEARCH)
+ E:FontTemplate(f.editBox)
+
+ f.editBox.searchIcon = f.editBox:CreateTexture(nil, "OVERLAY")
+ f.editBox.searchIcon:SetTexture("Interface\\AddOns\\ElvUI\\media\\textures\\UI-Searchbox-Icon")
+ f.editBox.searchIcon:SetPoint("LEFT", f.editBox.backdrop, "LEFT", E.Border + 1, -1)
+ f.editBox.searchIcon:SetWidth(15)
+ f.editBox.searchIcon:SetHeight(15)
+ else
+ f.keyFrame = CreateFrame("Frame", name.."KeyFrame", f)
+ f.keyFrame:SetPoint("TOPRIGHT", f, "TOPLEFT", -(E.PixelMode and 1 or 3), 0)
+ E:SetTemplate(f.keyFrame, "Transparent")
+ f.keyFrame:SetID(KEYRING_CONTAINER)
+ f.keyFrame.slots = {}
+ f.keyFrame:Hide()
+
+ f.goldText = f:CreateFontString(nil, "OVERLAY")
+ E:FontTemplate(f.goldText)
+ f.goldText:SetPoint("BOTTOMRIGHT", f.holderFrame, "TOPRIGHT", -2, 4)
+ f.goldText:SetJustifyH("RIGHT")
+
+ f.sortButton = CreateFrame("Button", name.."SortButton", f)
+ f.sortButton:SetWidth(16 + E.Border)
+ f.sortButton:SetHeight(16 + E.Border)
+ E:SetTemplate(f.sortButton)
+ f.sortButton:SetPoint("RIGHT", f.goldText, "LEFT", -5, E.Border * 2)
+ f.sortButton:SetNormalTexture("Interface\\AddOns\\ElvUI\\media\\textures\\INV_Pet_RatCage")
+ --f.sortButton:GetNormalTexture():SetTexCoord(unpack(E.TexCoords))
+ --E:SetInside(f.sortButton:GetNormalTexture())
+ f.sortButton:SetPushedTexture("Interface\\AddOns\\ElvUI\\media\\textures\\INV_Pet_RatCage")
+ --f.sortButton:GetPushedTexture():SetTexCoord(unpack(E.TexCoords))
+ --E:SetInside(f.sortButton:GetPushedTexture())
+ f.sortButton:SetDisabledTexture("Interface\\AddOns\\ElvUI\\media\\textures\\INV_Pet_RatCage")
+ --f.sortButton:GetDisabledTexture():SetTexCoord(unpack(E.TexCoords))
+ --E:SetInside(f.sortButton:GetDisabledTexture())
+ --f.sortButton:GetDisabledTexture():SetDesaturated(true)
+ E:StyleButton(f.sortButton, nil, true)
+ f.sortButton.ttText = L["Sort Bags"]
+ f.sortButton:SetScript("OnEnter", self.Tooltip_Show)
+ f.sortButton:SetScript("OnLeave", self.Tooltip_Hide)
+ f.sortButton:SetScript("OnClick", function() B:CommandDecorator(B.SortBags, "bags")() end)
+ if(E.db.bags.disableBagSort) then
+ f.sortButton:Disable()
+ end
+
+ f.keyButton = CreateFrame("Button", name.."KeyButton", f)
+ f.keyButton:SetWidth(16 + E.Border)
+ f.keyButton:SetHeight(16 + E.Border)
+ E:SetTemplate(f.keyButton)
+ f.keyButton:SetPoint("RIGHT", f.sortButton, "LEFT", -5, 0)
+ f.keyButton:SetNormalTexture("Interface\\ICONS\\INV_Misc_Key_14")
+ f.keyButton:GetNormalTexture():SetTexCoord(unpack(E.TexCoords))
+ E:SetInside(f.keyButton:GetNormalTexture())
+ f.keyButton:SetPushedTexture("Interface\\ICONS\\INV_Misc_Key_14")
+ f.keyButton:GetPushedTexture():SetTexCoord(unpack(E.TexCoords))
+ E:SetInside(f.keyButton:GetPushedTexture())
+ E:StyleButton(f.keyButton, nil, true)
+ f.keyButton.ttText = L["Toggle Key"]
+ f.keyButton:SetScript("OnEnter", self.Tooltip_Show)
+ f.keyButton:SetScript("OnLeave", self.Tooltip_Hide)
+ f.keyButton:SetScript("OnClick", function() ToggleFrame(f.keyFrame) end)
+
+ f.bagsButton = CreateFrame("Button", name.."BagsButton", f)
+ f.bagsButton:SetWidth(16 + E.Border)
+ f.bagsButton:SetHeight(16 + E.Border)
+ E:SetTemplate(f.bagsButton)
+ f.bagsButton:SetPoint("RIGHT", f.keyButton, "LEFT", -5, 0)
+ f.bagsButton:SetNormalTexture("Interface\\Buttons\\Button-Backpack-Up")
+ f.bagsButton:GetNormalTexture():SetTexCoord(unpack(E.TexCoords))
+ E:SetInside(f.bagsButton:GetNormalTexture())
+ f.bagsButton:SetPushedTexture("Interface\\Buttons\\Button-Backpack-Up")
+ f.bagsButton:GetPushedTexture():SetTexCoord(unpack(E.TexCoords))
+ E:SetInside(f.bagsButton:GetPushedTexture())
+ E:StyleButton(f.bagsButton, nil, true)
+ f.bagsButton.ttText = L["Toggle Bags"]
+ f.bagsButton:SetScript("OnEnter", self.Tooltip_Show)
+ f.bagsButton:SetScript("OnLeave", self.Tooltip_Hide)
+ f.bagsButton:SetScript("OnClick", function() ToggleFrame(f.ContainerHolder) end)
+
+ f.vendorGraysButton = CreateFrame("Button", nil, f.holderFrame)
+ f.vendorGraysButton:SetWidth(16 + E.Border)
+ f.vendorGraysButton:SetHeight(16 + E.Border)
+ E:SetTemplate(f.vendorGraysButton)
+ f.vendorGraysButton:SetPoint("RIGHT", f.bagsButton, "LEFT", -5, 0)
+ f.vendorGraysButton:SetNormalTexture("Interface\\ICONS\\INV_Misc_Coin_01")
+ f.vendorGraysButton:GetNormalTexture():SetTexCoord(unpack(E.TexCoords))
+ E:SetInside(f.vendorGraysButton:GetNormalTexture())
+ f.vendorGraysButton:SetPushedTexture("Interface\\ICONS\\INV_Misc_Coin_01")
+ f.vendorGraysButton:GetPushedTexture():SetTexCoord(unpack(E.TexCoords))
+ E:SetInside(f.vendorGraysButton:GetPushedTexture())
+ E:StyleButton(f.vendorGraysButton, nil, true)
+ f.vendorGraysButton.ttText = L["Vendor Grays"]
+ f.vendorGraysButton:SetScript("OnEnter", self.Tooltip_Show)
+ f.vendorGraysButton:SetScript("OnLeave", self.Tooltip_Hide)
+ f.vendorGraysButton:SetScript("OnClick", B.VendorGrayCheck)
+
+ f.editBox = CreateFrame("EditBox", name.."EditBox", f)
+ f.editBox:SetFrameLevel(f.editBox:GetFrameLevel() + 2)
+ E:CreateBackdrop(f.editBox, "Default")
+ f.editBox.backdrop:SetPoint("TOPLEFT", f.editBox, "TOPLEFT", -20, 2)
+ f.editBox:SetHeight(15)
+ f.editBox:SetPoint("BOTTOMLEFT", f.holderFrame, "TOPLEFT", (E.Border * 2) + 18, E.Border * 2 + 2)
+ f.editBox:SetPoint("RIGHT", f.vendorGraysButton, "LEFT", -5, 0)
+ f.editBox:SetAutoFocus(false)
+ f.editBox:SetScript("OnEscapePressed", self.ResetAndClear)
+ f.editBox:SetScript("OnEnterPressed", function(self) self:ClearFocus() end)
+ f.editBox:SetScript("OnEditFocusGained", f.editBox.HighlightText)
+ f.editBox:SetScript("OnTextChanged", self.UpdateSearch)
+ f.editBox:SetScript("OnChar", self.UpdateSearch)
+ f.editBox:SetText(SEARCH)
+ E:FontTemplate(f.editBox)
+
+ f.editBox.searchIcon = f.editBox:CreateTexture(nil, "OVERLAY")
+ f.editBox.searchIcon:SetTexture("Interface\\AddOns\\ElvUI\\media\\textures\\UI-Searchbox-Icon")
+ f.editBox.searchIcon:SetPoint("LEFT", f.editBox.backdrop, "LEFT", E.Border + 1, -1)
+ f.editBox.searchIcon:SetWidth(15)
+ f.editBox.searchIcon:SetHeight(15)
+
+ f:SetScript("OnHide", function()
+ CloseBackpack()
+ for i = 1, NUM_BAG_FRAMES do
+ CloseBag(i)
+ end
+
+ if(ElvUIBags and ElvUIBags.buttons) then
+ for _, bagButton in pairs(ElvUIBags.buttons) do
+ bagButton:SetChecked(false)
+ end
+ end
+ if(E.db.bags.clearSearchOnClose) then
+ B.ResetAndClear(f.editBox)
+ end
+ end)
+ end
+
+ f:SetScript("OnShow", function()
+ this:UpdateCooldowns()
+ end)
+
+ tinsert(UISpecialFrames, f:GetName()) --Keep an eye on this for taints..
+ tinsert(self.BagFrames, f)
+ return f
+end
+
+function B:ToggleBags(id)
+ --Closes a bag when inserting a new container..
+ if id and GetContainerNumSlots(id) == 0 then return end
+
+ if self.BagFrame:IsShown() then
+ self:CloseBags()
+ else
+ self:OpenBags()
+ end
+end
+
+function B:ToggleBackpack()
+ if(IsOptionFrameOpen()) then
+ return
+ end
+
+ if(IsBagOpen(0)) then
+ self:OpenBags()
+ else
+ self:CloseBags()
+ end
+end
+
+function B:OpenAllBags()
+ if IsOptionFrameOpen() then
+ return
+ end
+
+ if self.BagFrame:IsShown() then
+ self:CloseBags()
+ else
+ self:OpenBags()
+ end
+end
+
+function B:ToggleSortButtonState(isBank)
+ local button, disable
+ if isBank and self.BankFrame then
+ button = self.BankFrame.sortButton
+ disable = E.db.bags.disableBankSort
+ elseif not isBank and self.BagFrame then
+ button = self.BagFrame.sortButton
+ disable = E.db.bags.disableBagSort
+ end
+
+ if button and disable then
+ button:Disable()
+ elseif button and not disable then
+ button:Enable()
+ end
+end
+
+function B:OpenBags()
+ self.BagFrame:Show()
+ self.BagFrame:UpdateAllSlots()
+ E:GetModule("Tooltip"):GameTooltip_SetDefaultAnchor(GameTooltip)
+end
+
+function B:CloseBags()
+ self.BagFrame:Hide()
+
+ if self.BankFrame then
+ self.BankFrame:Hide()
+ end
+
+ E:GetModule("Tooltip"):GameTooltip_SetDefaultAnchor(GameTooltip)
+end
+
+function B:OpenBank()
+ if not self.BankFrame then
+ self.BankFrame = self:ContructContainerFrame("ElvUI_BankContainerFrame", true)
+ end
+
+ self:Layout(true)
+ self.BankFrame:Show()
+ self.BankFrame:UpdateAllSlots()
+ self:OpenBags()
+end
+
+function B:PLAYERBANKBAGSLOTS_CHANGED()
+ self:Layout(true)
+end
+
+function B:GUILDBANKBAGSLOTS_CHANGED()
+ self:SetGuildBankSearch(SEARCH_STRING)
+end
+
+function B:CloseBank()
+ if not self.BankFrame then return end -- WHY???, WHO KNOWS!
+ self.BankFrame:Hide()
+end
+
+function B:PostBagMove()
+ if(not E.private.bags.enable) then return end
+
+ local x, y = self:GetCenter()
+ local screenHeight = UIParent:GetTop()
+ local screenWidth = UIParent:GetRight()
+
+ if not x then return end
+
+ if(y > (screenHeight / 2)) then
+ --self:SetText(self.textGrowDown)
+ self.POINT = ((x > (screenWidth/2)) and "TOPRIGHT" or "TOPLEFT")
+ else
+ --self:SetText(self.textGrowUp)
+ self.POINT = ((x > (screenWidth/2)) and "BOTTOMRIGHT" or "BOTTOMLEFT")
+ end
+
+ local bagFrame
+ if(self.name == "ElvUIBankMover") then
+ bagFrame = B.BankFrame
+ else
+ bagFrame = B.BagFrame
+ end
+
+ if(bagFrame) then
+ bagFrame:ClearAllPoints()
+ bagFrame:SetPoint(self.POINT, self)
+ end
+end
+
+function B:Initialize()
+ --self:LoadBagBar()
+
+ local BagFrameHolder = CreateFrame("Frame", nil, E.UIParent)
+ BagFrameHolder:SetWidth(200)
+ BagFrameHolder:SetHeight(22)
+ BagFrameHolder:SetFrameLevel(BagFrameHolder:GetFrameLevel() + 400)
+
+ if(not E.private.bags.enable) then
+ 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)
+
+ -- self:SecureHook("UpdateContainerFrameAnchors")
+ return
+ end
+
+ E.bags = self
+ self.db = E.db.bags
+ self.BagFrames = {}
+
+ BagFrameHolder:SetPoint("BOTTOMRIGHT", RightChatPanel, "BOTTOMRIGHT", 0, 22 + E.Border*4 - E.Spacing*2)
+ E:CreateMover(BagFrameHolder, "ElvUIBagMover", L["Bag Mover (Grow Up)"], nil, nil, B.PostBagMove)
+
+ local BankFrameHolder = CreateFrame("Frame", nil, E.UIParent)
+ BankFrameHolder:SetWidth(200)
+ BankFrameHolder:SetHeight(22)
+ BankFrameHolder:SetPoint("BOTTOMLEFT", LeftChatPanel, "BOTTOMLEFT", 0, 22 + E.Border*4 - E.Spacing*2)
+ BankFrameHolder:SetFrameLevel(BankFrameHolder:GetFrameLevel() + 400)
+ E:CreateMover(BankFrameHolder, "ElvUIBankMover", L["Bank Mover (Grow Up)"], nil, nil, B.PostBagMove)
+
+ ElvUIBagMover.textGrowUp = L["Bag Mover (Grow Up)"]
+ ElvUIBagMover.textGrowDown = L["Bag Mover (Grow Down)"]
+ ElvUIBagMover.POINT = "BOTTOMRIGHT"
+ ElvUIBankMover.textGrowUp = L["Bank Mover (Grow Up)"]
+ ElvUIBankMover.textGrowDown = L["Bank Mover (Grow Down)"]
+ ElvUIBankMover.POINT = "BOTTOMLEFT"
+
+ self.BagFrame = self:ContructContainerFrame("ElvUI_ContainerFrame")
+
+ --Hook onto Blizzard Functions
+ --self:SecureHook("ToggleBackpack")
+ self:SecureHook("ToggleBag", "ToggleBags")
+ self:SecureHook("OpenBackpack", "OpenBags")
+ self:SecureHook("CloseAllBags", "CloseBags")
+ self:SecureHook("CloseBackpack", "CloseBags")
+ self:RawHook("OpenAllBags", "OpenAllBags", true)
+
+ self:Layout()
+
+ E.Bags = self
+
+ self:DisableBlizzard()
+ self:RegisterEvent("GUILDBANKBAGSLOTS_CHANGED")
+ self:RegisterEvent("PLAYER_MONEY", "UpdateGoldText")
+ self:RegisterEvent("PLAYER_ENTERING_WORLD", "UpdateGoldText")
+ self:RegisterEvent("PLAYER_TRADE_MONEY", "UpdateGoldText")
+ self:RegisterEvent("TRADE_MONEY_CHANGED", "UpdateGoldText")
+ self:RegisterEvent("BANKFRAME_OPENED", "OpenBank")
+ self:RegisterEvent("BANKFRAME_CLOSED", "CloseBank")
+ self:RegisterEvent("PLAYERBANKBAGSLOTS_CHANGED")
+
+ StackSplitFrame:SetFrameStrata("DIALOG")
+end
+
+local function InitializeCallback()
+ B:Initialize()
+end
+
+E:RegisterModule(B:GetName(), InitializeCallback)
\ No newline at end of file
diff --git a/2/3/4/5/6/7/ElvUI/Modules/Bags/Load_Bags.xml b/2/3/4/5/6/7/ElvUI/Modules/Bags/Load_Bags.xml
new file mode 100644
index 0000000..d540aa0
--- /dev/null
+++ b/2/3/4/5/6/7/ElvUI/Modules/Bags/Load_Bags.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/2/3/4/5/6/7/ElvUI/Modules/Bags/Sort.lua b/2/3/4/5/6/7/ElvUI/Modules/Bags/Sort.lua
new file mode 100644
index 0000000..6b28df8
--- /dev/null
+++ b/2/3/4/5/6/7/ElvUI/Modules/Bags/Sort.lua
@@ -0,0 +1,864 @@
+local E, L, V, P, G = unpack(ElvUI)
+local B = E:GetModule("Bags")
+
+local Search = LibStub("LibItemSearch-1.2")
+
+local ipairs, pairs, tonumber, select, unpack = ipairs, pairs, tonumber, select, unpack
+local tinsert, tremove, tsort, twipe = table.insert, table.remove, table.sort, table.wipe
+local floor = math.floor
+local band = bit.band
+local match, gmatch, find = string.match, string.gmatch, string.find
+
+local GetTime = GetTime
+local InCombatLockdown = InCombatLockdown
+local GetItemInfo = GetItemInfo
+local GetAuctionItemClasses = GetAuctionItemClasses
+local GetAuctionItemSubClasses = GetAuctionItemSubClasses
+local GetGuildBankItemInfo = GetGuildBankItemInfo
+local GetContainerItemInfo = GetContainerItemInfo
+local GetGuildBankItemLink = GetGuildBankItemLink
+local GetContainerItemLink = GetContainerItemLink
+local PickupGuildBankItem = PickupGuildBankItem
+local PickupContainerItem = PickupContainerItem
+local SplitGuildBankItem = SplitGuildBankItem
+local SplitContainerItem = SplitContainerItem
+local GetGuildBankTabInfo = GetGuildBankTabInfo
+local GetContainerNumSlots = GetContainerNumSlots
+local GetContainerNumFreeSlots = GetContainerNumFreeSlots
+local ContainerIDToInventoryID = ContainerIDToInventoryID
+local GetInventoryItemLink = GetInventoryItemLink
+local GetItemFamily = GetItemFamily
+local GetCursorInfo = GetCursorInfo
+local QueryGuildBankTab = QueryGuildBankTab
+local GetCurrentGuildBankTab = GetCurrentGuildBankTab
+local ARMOR, ENCHSLOT_WEAPON = ARMOR, ENCHSLOT_WEAPON
+
+local guildBags = {51,52,53,54,55,56,57,58}
+local bankBags = {BANK_CONTAINER}
+local MAX_MOVE_TIME = 1.25
+
+for i = NUM_BAG_SLOTS + 1, NUM_BAG_SLOTS + NUM_BANKBAGSLOTS do
+ tinsert(bankBags, i)
+end
+
+local playerBags = {}
+for i = 0, NUM_BAG_SLOTS do
+ tinsert(playerBags, i)
+end
+
+local allBags = {}
+for _,i in ipairs(playerBags) do
+ tinsert(allBags, i)
+end
+for _,i in ipairs(bankBags) do
+ tinsert(allBags, i)
+end
+
+for _,i in ipairs(guildBags) do
+ tinsert(allBags, i)
+end
+
+local coreGroups = {
+ guild = guildBags,
+ bank = bankBags,
+ bags = playerBags,
+ all = allBags,
+}
+
+local bagCache = {}
+local bagIDs = {}
+local bagQualities = {}
+local bagStacks = {}
+local bagMaxStacks = {}
+local bagGroups = {}
+local initialOrder = {}
+local itemTypes, itemSubTypes
+local bagSorted, bagLocked = {}, {}
+local bagRole
+local moves = {}
+local targetItems = {}
+local sourceUsed = {}
+local targetSlots = {}
+local specialtyBags = {}
+local emptySlots = {}
+
+local moveRetries = 0
+local lastItemID, lockStop, lastDestination, lastMove
+local moveTracker = {}
+
+local inventorySlots = {
+ INVTYPE_AMMO = 0,
+ INVTYPE_HEAD = 1,
+ INVTYPE_NECK = 2,
+ INVTYPE_SHOULDER = 3,
+ INVTYPE_BODY = 4,
+ INVTYPE_CHEST = 5,
+ INVTYPE_ROBE = 5,
+ INVTYPE_WAIST = 6,
+ INVTYPE_LEGS = 7,
+ INVTYPE_FEET = 8,
+ INVTYPE_WRIST = 9,
+ INVTYPE_HAND = 10,
+ INVTYPE_FINGER = 11,
+ INVTYPE_TRINKET = 12,
+ INVTYPE_CLOAK = 13,
+ INVTYPE_WEAPON = 14,
+ INVTYPE_SHIELD = 15,
+ INVTYPE_2HWEAPON = 16,
+ INVTYPE_WEAPONMAINHAND = 18,
+ INVTYPE_WEAPONOFFHAND = 19,
+ INVTYPE_HOLDABLE = 20,
+ INVTYPE_RANGED = 21,
+ INVTYPE_THROWN = 22,
+ INVTYPE_RANGEDRIGHT = 23,
+ INVTYPE_RELIC = 24,
+ INVTYPE_TABARD = 25,
+}
+
+local safe = {
+ [BANK_CONTAINER] = true,
+ [0] = true
+}
+
+local frame = CreateFrame("Frame")
+local t, WAIT_TIME = 0, 0.05
+frame:SetScript("OnUpdate", function(_, elapsed)
+ t = t + (elapsed or 0.01)
+ if t > WAIT_TIME then
+ t = 0
+ B:DoMoves()
+ end
+end)
+frame:Hide()
+B.SortUpdateTimer = frame
+
+local function IsGuildBankBag(bagid)
+ return (bagid > 50 and bagid <= 58)
+end
+
+local function BuildSortOrder()
+ itemTypes = {}
+ itemSubTypes = {}
+ for i, iType in ipairs({GetAuctionItemClasses()}) do
+ itemTypes[iType] = i
+ itemSubTypes[iType] = {}
+ for ii, isType in ipairs({GetAuctionItemSubClasses(i)}) do
+ itemSubTypes[iType][isType] = ii
+ end
+ end
+end
+
+local function UpdateLocation(from, to)
+ if (bagIDs[from] == bagIDs[to]) and (bagStacks[to] < bagMaxStacks[to]) then
+ local stackSize = bagMaxStacks[to]
+ if (bagStacks[to] + bagStacks[from]) > stackSize then
+ bagStacks[from] = bagStacks[from] - (stackSize - bagStacks[to])
+ bagStacks[to] = stackSize
+ else
+ bagStacks[to] = bagStacks[to] + bagStacks[from]
+ bagStacks[from] = nil
+ bagIDs[from] = nil
+ bagQualities[from] = nil
+ bagMaxStacks[from] = nil
+ end
+ else
+ bagIDs[from], bagIDs[to] = bagIDs[to], bagIDs[from]
+ bagQualities[from], bagQualities[to] = bagQualities[to], bagQualities[from]
+ bagStacks[from], bagStacks[to] = bagStacks[to], bagStacks[from]
+ bagMaxStacks[from], bagMaxStacks[to] = bagMaxStacks[to], bagMaxStacks[from]
+ end
+end
+
+local function PrimarySort(a, b)
+ local aName, _, _, aLvl, _, _, _, _, _, _, aPrice = GetItemInfo(bagIDs[a])
+ local bName, _, _, bLvl, _, _, _, _, _, _, bPrice = GetItemInfo(bagIDs[b])
+
+ if aLvl ~= bLvl and aLvl and bLvl then
+ return aLvl > bLvl
+ end
+ if aPrice ~= bPrice and aPrice and bPrice then
+ return aPrice > bPrice
+ end
+
+ if aName and bName then
+ return aName < bName
+ end
+end
+
+local function DefaultSort(a, b)
+ local aID = bagIDs[a]
+ local bID = bagIDs[b]
+
+ if (not aID) or (not bID) then return aID end
+
+ local aOrder, bOrder = initialOrder[a], initialOrder[b]
+
+ if aID == bID then
+ local aCount = bagStacks[a]
+ local bCount = bagStacks[b]
+ if aCount and bCount and aCount == bCount then
+ return aOrder < bOrder
+ elseif aCount and bCount then
+ return aCount < bCount
+ end
+ end
+
+ local _, _, aRarity, _, _, aType, aSubType, _, aEquipLoc = GetItemInfo(aID)
+ local _, _, bRarity, _, _, bType, bSubType, _, bEquipLoc = GetItemInfo(bID)
+
+ aRarity = bagQualities[a]
+ bRarity = bagQualities[b]
+
+ if aRarity ~= bRarity and aRarity and bRarity then
+ return aRarity > bRarity
+ end
+
+ if itemTypes[aType] ~= itemTypes[bType] then
+ return (itemTypes[aType] or 99) < (itemTypes[bType] or 99)
+ end
+
+ if aType == ARMOR or aType == ENCHSLOT_WEAPON then
+ local aEquipLoc = inventorySlots[aEquipLoc] or -1
+ local bEquipLoc = inventorySlots[bEquipLoc] or -1
+ if aEquipLoc == bEquipLoc then
+ return PrimarySort(a, b)
+ end
+
+ if aEquipLoc and bEquipLoc then
+ return aEquipLoc < bEquipLoc
+ end
+ end
+ if aSubType == bSubType then
+ return PrimarySort(a, b)
+ end
+
+ return ((itemSubTypes[aType] or {})[aSubType] or 99) < ((itemSubTypes[bType] or {})[bSubType] or 99)
+end
+
+local function ReverseSort(a, b)
+ return DefaultSort(b, a)
+end
+
+local function UpdateSorted(source, destination)
+ for i, bs in pairs(bagSorted) do
+ if bs == source then
+ bagSorted[i] = destination
+ elseif bs == destination then
+ bagSorted[i] = source
+ end
+ end
+end
+
+local function ShouldMove(source, destination)
+ if destination == source then return end
+
+ if not bagIDs[source] then return end
+ if bagIDs[source] == bagIDs[destination] and bagStacks[source] == bagStacks[destination] then return end
+
+ return true
+end
+
+local function IterateForwards(bagList, i)
+ i = i + 1
+ local step = 1
+ for _,bag in ipairs(bagList) do
+ local slots = B:GetNumSlots(bag, bagRole)
+ if i > slots + step then
+ step = step + slots
+ else
+ for slot = 1, slots do
+ if step == i then
+ return i, bag, slot
+ end
+ step = step + 1
+ end
+ end
+ end
+ bagRole = nil
+end
+
+local function IterateBackwards(bagList, i)
+ i = i + 1
+ local step = 1
+ for ii = #bagList, 1, -1 do
+ local bag = bagList[ii]
+ local slots = B:GetNumSlots(bag, bagRole)
+ if i > slots + step then
+ step = step + slots
+ else
+ for slot=slots, 1, -1 do
+ if step == i then
+ return i, bag, slot
+ end
+ step = step + 1
+ end
+ end
+ end
+ bagRole = nil
+end
+
+function B.IterateBags(bagList, reverse, role)
+ bagRole = role
+ return (reverse and IterateBackwards or IterateForwards), bagList, 0
+end
+
+function B:GetItemID(bag, slot)
+ local link = self:GetItemLink(bag, slot)
+ return link and tonumber(match(link, "item:(%d+)"))
+end
+
+function B:GetItemInfo(bag, slot)
+ if IsGuildBankBag(bag) then
+ return GetGuildBankItemInfo(bag - 50, slot)
+ else
+ return GetContainerItemInfo(bag, slot)
+ end
+end
+
+function B:GetItemLink(bag, slot)
+ if IsGuildBankBag(bag) then
+ return GetGuildBankItemLink(bag - 50, slot)
+ else
+ return GetContainerItemLink(bag, slot)
+ end
+end
+
+function B:PickupItem(bag, slot)
+ if IsGuildBankBag(bag) then
+ return PickupGuildBankItem(bag - 50, slot)
+ else
+ return PickupContainerItem(bag, slot)
+ end
+end
+
+function B:SplitItem(bag, slot, amount)
+ if IsGuildBankBag(bag) then
+ return SplitGuildBankItem(bag - 50, slot, amount)
+ else
+ return SplitContainerItem(bag, slot, amount)
+ end
+end
+
+function B:GetNumSlots(bag, role)
+ if IsGuildBankBag(bag) then
+ if not role then role = "deposit" end
+ local name, _, canView, canDeposit, numWithdrawals = GetGuildBankTabInfo(bag - 50)
+ if name and canView --[[and ((role == "withdraw" and numWithdrawals ~= 0) or (role == "deposit" and canDeposit) or (role == "both" and numWithdrawals ~= 0 and canDeposit))]] then
+ return 98
+ end
+ else
+ return GetContainerNumSlots(bag)
+ end
+
+ return 0
+end
+
+local function ConvertLinkToID(link)
+ if(not link) then return end
+
+ if(tonumber(match(link, "item:(%d+)"))) then
+ return tonumber(match(link, "item:(%d+)"))
+ end
+end
+
+local function DefaultCanMove()
+ return true
+end
+
+function B:Encode_BagSlot(bag, slot)
+ return (bag*100) + slot
+end
+
+function B:Decode_BagSlot(int)
+ return floor(int/100), int % 100
+end
+
+function B:IsPartial(bag, slot)
+ local bagSlot = B:Encode_BagSlot(bag, slot)
+ return ((bagMaxStacks[bagSlot] or 0) - (bagStacks[bagSlot] or 0)) > 0
+end
+
+function B:EncodeMove(source, target)
+ return (source * 10000) + target
+end
+
+function B:DecodeMove(move)
+ local s = floor(move/10000)
+ local t = move%10000
+ s = (t>9000) and (s+1) or s
+ t = (t>9000) and (t-10000) or t
+ return s, t
+end
+
+function B:AddMove(source, destination)
+ UpdateLocation(source, destination)
+ tinsert(moves, 1, B:EncodeMove(source, destination))
+end
+
+function B:ScanBags()
+ for _, bag, slot in B.IterateBags(allBags) do
+ local bagSlot = B:Encode_BagSlot(bag, slot)
+ local itemID = ConvertLinkToID(B:GetItemLink(bag, slot))
+ if(itemID) then
+ bagMaxStacks[bagSlot] = select(8, GetItemInfo(itemID))
+ bagIDs[bagSlot] = itemID
+ bagQualities[bagSlot] = select(3, GetItemInfo(B:GetItemLink(bag, slot)))
+ bagStacks[bagSlot] = select(2, B:GetItemInfo(bag, slot))
+ end
+ end
+end
+
+function B:IsSpecialtyBag(bagID)
+ if safe[bagID] or IsGuildBankBag(bagID) then return false end
+
+ local inventorySlot = ContainerIDToInventoryID(bagID)
+ if not inventorySlot then return false end
+
+ local bag = GetInventoryItemLink("player", inventorySlot)
+ if not bag then return false end
+
+ local family = GetItemFamily(bag)
+ if family == 0 or family == nil then return false end
+
+ return family
+end
+
+function B:CanItemGoInBag(bag, slot, targetBag)
+ if IsGuildBankBag(targetBag) then return true end
+
+ local item = bagIDs[B:Encode_BagSlot(bag, slot)]
+ local itemFamily = GetItemFamily(item)
+ if itemFamily and itemFamily > 0 then
+ local equipSlot = select(9, GetItemInfo(item))
+ if equipSlot == "INVTYPE_BAG" then
+ itemFamily = 1
+ end
+ end
+ local bagFamily = select(2, GetContainerNumFreeSlots(targetBag))
+ if itemFamily then
+ return (bagFamily == 0) or band(itemFamily, bagFamily) > 0
+ else
+ return false
+ end
+end
+
+function B.Compress(...)
+ for i=1, select("#", ...) do
+ local bags = select(i, ...)
+ B.Stack(bags, bags, B.IsPartial)
+ end
+end
+
+function B.Stack(sourceBags, targetBags, canMove)
+ if not canMove then canMove = DefaultCanMove end
+ for _, bag, slot in B.IterateBags(targetBags, nil, "deposit") do
+ local bagSlot = B:Encode_BagSlot(bag, slot)
+ local itemID = bagIDs[bagSlot]
+
+ if itemID and (bagStacks[bagSlot] ~= bagMaxStacks[bagSlot]) then
+ targetItems[itemID] = (targetItems[itemID] or 0) + 1
+ tinsert(targetSlots, bagSlot)
+ end
+ end
+
+ for _, bag, slot in B.IterateBags(sourceBags, true, "withdraw") do
+ local sourceSlot = B:Encode_BagSlot(bag, slot)
+ local itemID = bagIDs[sourceSlot]
+ if itemID and targetItems[itemID] and canMove(itemID, bag, slot) then
+ for i = #targetSlots, 1, -1 do
+ local targetedSlot = targetSlots[i]
+ if bagIDs[sourceSlot] and bagIDs[targetedSlot] == itemID and targetedSlot ~= sourceSlot and not (bagStacks[targetedSlot] == bagMaxStacks[targetedSlot]) and not sourceUsed[targetedSlot] then
+ B:AddMove(sourceSlot, targetedSlot)
+ sourceUsed[sourceSlot] = true
+
+ if bagStacks[targetedSlot] == bagMaxStacks[targetedSlot] then
+ targetItems[itemID] = (targetItems[itemID] > 1) and (targetItems[itemID] - 1) or nil
+ end
+ if bagStacks[sourceSlot] == 0 then
+ targetItems[itemID] = (targetItems[itemID] > 1) and (targetItems[itemID] - 1) or nil
+ break
+ end
+ if not targetItems[itemID] then break end
+ end
+ end
+ end
+ end
+
+ twipe(targetItems)
+ twipe(targetSlots)
+ twipe(sourceUsed)
+end
+
+local blackListedSlots = {}
+local blackList = {}
+local blackListQueries = {}
+
+local function buildBlacklist(...)
+ for entry in pairs(...) do
+ local itemName = GetItemInfo(entry)
+ if(itemName) then
+ blackList[itemName] = true
+ elseif(entry ~= "") then
+ if(find(entry, "%[") and find(entry, "%]")) then
+ entry = match(entry, "%[(.*)%]")
+ end
+ blackListQueries[#blackListQueries+1] = entry
+ end
+ end
+end
+
+function B.Sort(bags, sorter, invertDirection)
+ if not sorter then sorter = invertDirection and ReverseSort or DefaultSort end
+ if not itemTypes then BuildSortOrder() end
+
+ twipe(blackList)
+ twipe(blackListQueries)
+ twipe(blackListedSlots)
+
+ buildBlacklist(B.db.ignoredItems)
+ buildBlacklist(E.global.bags.ignoredItems)
+
+ for i, bag, slot in B.IterateBags(bags, nil, "both") do
+ local bagSlot = B:Encode_BagSlot(bag, slot)
+ local link = B:GetItemLink(bag, slot)
+
+ if(link) then
+ if(blackList[GetItemInfo(link)]) then
+ blackListedSlots[bagSlot] = true
+ end
+
+ if(not blackListedSlots[bagSlot]) then
+ for _,itemsearchquery in pairs(blackListQueries) do
+ local success, result = pcall(Search.Matches, Search, link, itemsearchquery)
+ if(success and result) then
+ blackListedSlots[bagSlot] = blackListedSlots[bagSlot] or result
+ break
+ end
+ end
+ end
+ end
+
+ if not blackListedSlots[bagSlot] then
+ initialOrder[bagSlot] = i
+ tinsert(bagSorted, bagSlot)
+ end
+ end
+
+ tsort(bagSorted, sorter)
+
+ local passNeeded = true
+ while passNeeded do
+ passNeeded = false
+ local i = 1
+ for _, bag, slot in B.IterateBags(bags, nil, "both") do
+ local destination = B:Encode_BagSlot(bag, slot)
+ local source = bagSorted[i]
+
+ if not blackListedSlots[destination] then
+ if ShouldMove(source, destination) then
+ if not (bagLocked[source] or bagLocked[destination]) then
+ B:AddMove(source, destination)
+ UpdateSorted(source, destination)
+ bagLocked[source] = true
+ bagLocked[destination] = true
+ else
+ passNeeded = true
+ end
+ end
+ i = i + 1
+ end
+ end
+ twipe(bagLocked)
+ end
+
+ twipe(bagSorted)
+ twipe(initialOrder)
+end
+
+function B.FillBags(from, to)
+ B.Stack(from, to)
+ for _, bag in ipairs(to) do
+ if B:IsSpecialtyBag(bag) then
+ tinsert(specialtyBags, bag)
+ end
+ end
+ if #specialtyBags > 0 then
+ B:Fill(from, specialtyBags)
+ end
+
+ B.Fill(from, to)
+ twipe(specialtyBags)
+end
+
+function B.Fill(sourceBags, targetBags, reverse, canMove)
+ if not canMove then canMove = DefaultCanMove end
+
+ twipe(blackList)
+ twipe(blackListedSlots)
+
+ buildBlacklist(B.db.ignoredItems)
+ buildBlacklist(E.global.bags.ignoredItems)
+
+ for _, bag, slot in B.IterateBags(targetBags, reverse, "deposit") do
+ local bagSlot = B:Encode_BagSlot(bag, slot)
+ if not bagIDs[bagSlot] then
+ tinsert(emptySlots, bagSlot)
+ end
+ end
+
+ for _, bag, slot in B.IterateBags(sourceBags, not reverse, "withdraw") do
+ if #emptySlots == 0 then break end
+ local bagSlot = B:Encode_BagSlot(bag, slot)
+ local targetBag = B:Decode_BagSlot(emptySlots[1])
+ local link = B:GetItemLink(bag, slot)
+
+ if(link and blackList[GetItemInfo(link)]) then
+ blackListedSlots[bagSlot] = true
+ end
+
+ if(bagIDs[bagSlot] and B:CanItemGoInBag(bag, slot, targetBag) and canMove(bagIDs[bagSlot], bag, slot) and not blackListedSlots[bagSlot]) then
+ B:AddMove(bagSlot, tremove(emptySlots, 1))
+ end
+ end
+ twipe(emptySlots)
+end
+
+function B.SortBags(...)
+ for i=1, select("#", ...) do
+ local bags = select(i, ...)
+ for _, slotNum in ipairs(bags) do
+ local bagType = B:IsSpecialtyBag(slotNum)
+ if bagType == false then bagType = "Normal" end
+ if not bagCache[bagType] then bagCache[bagType] = {} end
+ tinsert(bagCache[bagType], slotNum)
+ end
+
+ for bagType, sortedBags in pairs(bagCache) do
+ if bagType ~= "Normal" then
+ B.Stack(sortedBags, sortedBags, B.IsPartial)
+ B.Stack(bagCache["Normal"], sortedBags)
+ B.Fill(bagCache["Normal"], sortedBags, B.db.sortInverted)
+ B.Sort(sortedBags, nil, B.db.sortInverted)
+ twipe(sortedBags)
+ end
+ end
+
+ if bagCache["Normal"] then
+ B.Stack(bagCache["Normal"], bagCache["Normal"], B.IsPartial)
+ B.Sort(bagCache["Normal"], nil, B.db.sortInverted)
+ twipe(bagCache["Normal"])
+ end
+ twipe(bagCache)
+ twipe(bagGroups)
+ end
+end
+
+function B:StartStacking()
+ twipe(bagMaxStacks)
+ twipe(bagStacks)
+ twipe(bagIDs)
+ twipe(bagQualities)
+ twipe(moveTracker)
+
+ if #moves > 0 then
+ self.SortUpdateTimer:Show()
+ else
+ B:StopStacking()
+ end
+end
+
+function B:StopStacking(message)
+ twipe(moves)
+ twipe(moveTracker)
+ moveRetries, lastItemID, lockStop, lastDestination, lastMove = 0, nil, nil, nil, nil
+
+ self.SortUpdateTimer:Hide()
+ if message then
+ E:Print(message)
+ end
+end
+
+function B:DoMove(move)
+ if GetCursorInfo() == "item" then
+ return false, "cursorhasitem"
+ end
+
+ local source, target = B:DecodeMove(move)
+ local sourceBag, sourceSlot = B:Decode_BagSlot(source)
+ local targetBag, targetSlot = B:Decode_BagSlot(target)
+
+ local _, sourceCount, sourceLocked = B:GetItemInfo(sourceBag, sourceSlot)
+ local _, targetCount, targetLocked = B:GetItemInfo(targetBag, targetSlot)
+
+ if sourceLocked or targetLocked then
+ return false, "source/target_locked"
+ end
+
+ local sourceItemID = self:GetItemID(sourceBag, sourceSlot)
+ local targetItemID = self:GetItemID(targetBag, targetSlot)
+
+ if not sourceItemID then
+ if moveTracker[source] then
+ return false, "move incomplete"
+ else
+ return B:StopStacking(L["Confused.. Try Again!"])
+ end
+ end
+
+ local stackSize = select(8, GetItemInfo(sourceItemID))
+ if (sourceItemID == targetItemID) and (targetCount ~= stackSize) and ((targetCount + sourceCount) > stackSize) then
+ B:SplitItem(sourceBag, sourceSlot, stackSize - targetCount)
+ else
+ B:PickupItem(sourceBag, sourceSlot)
+ end
+
+ if GetCursorInfo() == "item" then
+ B:PickupItem(targetBag, targetSlot)
+ end
+
+ local sourceGuild = IsGuildBankBag(sourceBag)
+ local targetGuild = IsGuildBankBag(targetBag)
+
+ if sourceGuild then
+ QueryGuildBankTab(sourceBag - 50)
+ end
+ if targetGuild then
+ QueryGuildBankTab(targetBag - 50)
+ end
+
+ return true, sourceItemID, source, targetItemID, target, sourceGuild or targetGuild
+end
+
+function B:DoMoves()
+ if InCombatLockdown() then
+ return B:StopStacking(L["Confused.. Try Again!"])
+ end
+
+ local cursorType, cursorItemID = GetCursorInfo()
+ if cursorType == "item" and cursorItemID then
+ if lastItemID ~= cursorItemID then
+ return B:StopStacking(L["Confused.. Try Again!"])
+ end
+
+ if moveRetries < 100 then
+ local targetBag, targetSlot = self:Decode_BagSlot(lastDestination)
+ local _, _, targetLocked = self:GetItemInfo(targetBag, targetSlot)
+ if not targetLocked then
+ self:PickupItem(targetBag, targetSlot)
+ WAIT_TIME = 0.1
+ lockStop = GetTime()
+ moveRetries = moveRetries + 1
+ return
+ end
+ end
+ end
+
+ if lockStop then
+ for slot, itemID in pairs(moveTracker) do
+ local actualItemID = self:GetItemID(self:Decode_BagSlot(slot))
+ if(actualItemID ~= itemID) then
+ WAIT_TIME = 0.1
+ if (GetTime() - lockStop) > MAX_MOVE_TIME then
+ if lastMove and moveRetries < 100 then
+ local success, moveID, moveSource, targetID, moveTarget, wasGuild = self:DoMove(lastMove)
+ WAIT_TIME = wasGuild and 0.5 or 0.1
+
+ if not success then
+ lockStop = GetTime()
+ moveRetries = moveRetries + 1
+ return
+ end
+
+ moveTracker[moveSource] = targetID
+ moveTracker[moveTarget] = moveID
+ lastDestination = moveTarget
+ --lastMove = moves[i]
+ lastItemID = moveID
+ --tremove(moves, i)
+ return
+ end
+
+ B:StopStacking()
+ return
+ end
+ return --give processing time to happen
+ end
+ moveTracker[slot] = nil
+ end
+ end
+
+ lastItemID, lockStop, lastDestination, lastMove = nil, nil, nil, nil
+ twipe(moveTracker)
+
+ local success, moveID, targetID, moveSource, moveTarget, wasGuild
+ if #moves > 0 then
+ for i = #moves, 1, -1 do
+ success, moveID, moveSource, targetID, moveTarget, wasGuild = B:DoMove(moves[i])
+ if not success then
+ WAIT_TIME = wasGuild and 0.3 or 0.1
+ lockStop = GetTime()
+ return
+ end
+ moveTracker[moveSource] = targetID
+ moveTracker[moveTarget] = moveID
+ lastDestination = moveTarget
+ lastMove = moves[i]
+ lastItemID = moveID
+ tremove(moves, i)
+
+ if moves[i-1] then
+ WAIT_TIME = wasGuild and 0.3 or 0
+ return
+ end
+ end
+ end
+ B:StopStacking()
+end
+
+function B:GetGroup(id)
+ if match(id, "^[-%d,]+$") then
+ local bags = {}
+ for b in gmatch(id, "-?%d+") do
+ tinsert(bags, tonumber(b))
+ end
+ return bags
+ end
+ return coreGroups[id]
+end
+
+function B:CommandDecorator(func, groupsDefaults)
+ local bagGroups = {}
+
+ return function(groups)
+ if self.SortUpdateTimer:IsShown() then
+ E:Print(L["Already Running.. Bailing Out!"])
+ B:StopStacking()
+ return
+ end
+
+ twipe(bagGroups)
+ if not groups or #groups == 0 then
+ groups = groupsDefaults
+ end
+ for bags in (groups or ""):gmatch("[^%s]+") do
+ if bags == "guild" then
+ bags = B:GetGroup(bags)
+ if bags then
+ tinsert(bagGroups, {bags[GetCurrentGuildBankTab()]})
+ end
+ else
+ bags = B:GetGroup(bags)
+ if bags then
+ tinsert(bagGroups, bags)
+ end
+ end
+ end
+
+ B:ScanBags()
+ if func(unpack(bagGroups)) == false then
+ return
+ end
+ twipe(bagGroups)
+ B:StartStacking()
+ end
+end
diff --git a/2/3/4/5/6/7/ElvUI/Modules/Load_Modules.xml b/2/3/4/5/6/7/ElvUI/Modules/Load_Modules.xml
index ec4e5fd..923fa89 100644
--- a/2/3/4/5/6/7/ElvUI/Modules/Load_Modules.xml
+++ b/2/3/4/5/6/7/ElvUI/Modules/Load_Modules.xml
@@ -7,6 +7,7 @@
+
\ No newline at end of file
diff --git a/2/3/4/5/6/7/ElvUI/Modules/Tooltip/Tooltip.lua b/2/3/4/5/6/7/ElvUI/Modules/Tooltip/Tooltip.lua
index 8b80846..0ad2399 100644
--- a/2/3/4/5/6/7/ElvUI/Modules/Tooltip/Tooltip.lua
+++ b/2/3/4/5/6/7/ElvUI/Modules/Tooltip/Tooltip.lua
@@ -167,6 +167,14 @@ function TT:SetUnit(tt, unit)
self:UPDATE_MOUSEOVER_UNIT(nil, unit)
end
+function TT:SetItemRef(link)
+ if string.find(link, "^item:") then
+ local id = tonumber(string.match(link, "(%d+)"))
+ ItemRefTooltip:AddLine(string.format("|cFFCA3C3C%s|r %d", ID, id))
+ ItemRefTooltip:Show()
+ end
+end
+
function TT:CheckBackdropColor()
if not GameTooltip:IsShown() then return end
@@ -239,6 +247,7 @@ function TT:Initialize()
self:SetTooltipFonts()
self:SecureHook("GameTooltip_SetDefaultAnchor")
+ self:SecureHook("SetItemRef")
self:SecureHook(GameTooltip, "SetUnit")
self:RegisterEvent("UPDATE_MOUSEOVER_UNIT")
end
diff --git a/2/3/4/5/6/7/ElvUI/Settings/Private.lua b/2/3/4/5/6/7/ElvUI/Settings/Private.lua
index aeb0085..c2fa32d 100644
--- a/2/3/4/5/6/7/ElvUI/Settings/Private.lua
+++ b/2/3/4/5/6/7/ElvUI/Settings/Private.lua
@@ -14,6 +14,11 @@ V["general"] = {
},
}
+V["bags"] = {
+ ["enable"] = true,
+ ["bagBar"] = false,
+}
+
V["auras"] = {
["enable"] = true,
["disableBlizzard"] = true,
diff --git a/2/3/4/5/6/7/ElvUI/Settings/Profile.lua b/2/3/4/5/6/7/ElvUI/Settings/Profile.lua
index 2c49e58..492a30a 100644
--- a/2/3/4/5/6/7/ElvUI/Settings/Profile.lua
+++ b/2/3/4/5/6/7/ElvUI/Settings/Profile.lua
@@ -276,6 +276,39 @@ P["tooltip"] = {
}
}
+P["bags"] = {
+ ["sortInverted"] = true,
+ ["bagSize"] = 34,
+ ["bankSize"] = 34,
+ ["bagWidth"] = 406,
+ ["bankWidth"] = 406,
+ ["currencyFormat"] = "ICON_TEXT",
+ ["moneyFormat"] = "SMART",
+ ["moneyCoins"] = true,
+ ["ignoredItems"] = {},
+ ["itemLevel"] = true,
+ ["itemLevelThreshold"] = 1,
+ ["itemLevelFont"] = "Homespun",
+ ["itemLevelFontSize"] = 10,
+ ["itemLevelFontOutline"] = "MONOCHROMEOUTLINE",
+ ["countFont"] = "Homespun",
+ ["countFontSize"] = 10,
+ ["countFontOutline"] = "MONOCHROMEOUTLINE",
+ ["countFontColor"] = {r = 1, g = 1, b = 1},
+ ["clearSearchOnClose"] = false,
+ ["disableBagSort"] = false,
+ ["disableBankSort"] = false,
+ ["bagBar"] = {
+ ["growthDirection"] = "VERTICAL",
+ ["sortDirection"] = "ASCENDING",
+ ["size"] = 30,
+ ["spacing"] = 4,
+ ["backdropSpacing"] = 4,
+ ["showBackdrop"] = false,
+ ["mouseover"] = false
+ }
+};
+
--UnitFrame
P["unitframe"] = {
["smoothbars"] = false,