mirror of
https://github.com/Bluewhale1337/ElvUIModernized.git
synced 2026-07-27 16:34:45 +00:00
update Bags and Sort (Need some more work)
This commit is contained in:
@@ -9,7 +9,7 @@ local _G = _G
|
||||
local type, ipairs, pairs, unpack, select, assert = type, ipairs, pairs, unpack, select, assert
|
||||
local tinsert = table.insert
|
||||
local floor, ceil = math.floor, math.ceil
|
||||
local len, gsub, sub, find = string.len, string.gsub, string.sub, string.find
|
||||
local len, gsub, sub, find, match = string.len, string.gsub, string.sub, string.find, string.match
|
||||
--WoW API / Variables
|
||||
local BankFrameItemButton_Update = BankFrameItemButton_Update
|
||||
local BankFrameItemButton_UpdateLocked = BankFrameItemButton_UpdateLocked
|
||||
@@ -54,7 +54,6 @@ B.ProfessionColors = {
|
||||
["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
|
||||
}
|
||||
@@ -116,15 +115,15 @@ function B:UpdateSearch()
|
||||
local MIN_REPEAT_CHARACTERS = 3
|
||||
local searchString = this:GetText()
|
||||
local prevSearchString = SEARCH_STRING
|
||||
if (len(searchString) > MIN_REPEAT_CHARACTERS) then
|
||||
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
|
||||
if sub(searchString,(0-i), (0-i)) ~= sub(searchString,(-1-i),(-1-i)) then
|
||||
repeatChar = false
|
||||
break
|
||||
end
|
||||
end
|
||||
if ( repeatChar ) then
|
||||
if repeatChar then
|
||||
B.ResetAndClear(this)
|
||||
return
|
||||
end
|
||||
@@ -244,11 +243,11 @@ function B:UpdateSlot(bagID, slotID)
|
||||
slot:Show()
|
||||
slot.itemLevel:SetText("")
|
||||
|
||||
--if(B.ProfessionColors[bagType]) then
|
||||
-- slot:SetBackdropBorderColor(unpack(B.ProfessionColors[bagType]))
|
||||
if clink then
|
||||
if B.ProfessionColors[bagType] then
|
||||
slot:SetBackdropBorderColor(unpack(B.ProfessionColors[bagType]))
|
||||
elseif clink then
|
||||
local iLvl, itemEquipLoc
|
||||
slot.name, _, slot.rarity, iLvl, _, _, _, _, itemEquipLoc = GetItemInfo(string.match(clink, "item:(%d+)"))
|
||||
slot.name, _, slot.rarity, iLvl, _, _, _, itemEquipLoc = GetItemInfo(match(clink, "item:(%d+)"))
|
||||
|
||||
local r, g, b
|
||||
|
||||
@@ -390,14 +389,14 @@ function B:Layout(isBank)
|
||||
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()
|
||||
f.ContainerHolder[i]:SetScript("OnClick", function()
|
||||
local inventoryID = this: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()
|
||||
f.ContainerHolder[i]:SetScript("OnClick", function()
|
||||
local id = this:GetID()
|
||||
PutItemInBag(id) --Put bag on empty slot, or drop item in this bag
|
||||
end)
|
||||
end
|
||||
@@ -450,7 +449,7 @@ function B:Layout(isBank)
|
||||
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
|
||||
-- f.Bags[bagID].UpdateSlot = B.UpdateSlot
|
||||
end
|
||||
|
||||
f.Bags[bagID].numSlots = numSlots
|
||||
|
||||
@@ -22,8 +22,8 @@ local GetContainerNumSlots = GetContainerNumSlots
|
||||
local GetContainerNumFreeSlots = GetContainerNumFreeSlots
|
||||
local ContainerIDToInventoryID = ContainerIDToInventoryID
|
||||
local GetInventoryItemLink = GetInventoryItemLink
|
||||
local GetCursorInfo = GetCursorInfo
|
||||
local ARMOR, ENCHSLOT_WEAPON = ARMOR, ENCHSLOT_WEAPON
|
||||
local CursorHasItem = CursorHasItem
|
||||
local ARMOR = ARMOR
|
||||
|
||||
local bankBags = {BANK_CONTAINER}
|
||||
local MAX_MOVE_TIME = 1.25
|
||||
@@ -38,10 +38,10 @@ for i = 0, NUM_BAG_SLOTS do
|
||||
end
|
||||
|
||||
local allBags = {}
|
||||
for _,i in ipairs(playerBags) do
|
||||
for _, i in ipairs(playerBags) do
|
||||
tinsert(allBags, i)
|
||||
end
|
||||
for _,i in ipairs(bankBags) do
|
||||
for _, i in ipairs(bankBags) do
|
||||
tinsert(allBags, i)
|
||||
end
|
||||
|
||||
@@ -199,7 +199,7 @@ local function DefaultSort(a, b)
|
||||
return (itemTypes[aType] or 99) < (itemTypes[bType] or 99)
|
||||
end
|
||||
|
||||
if aType == ARMOR or aType == ENCHSLOT_WEAPON then
|
||||
if aType == ARMOR then
|
||||
local aEquipLoc = inventorySlots[aEquipLoc] or -1
|
||||
local bEquipLoc = inventorySlots[bEquipLoc] or -1
|
||||
if aEquipLoc == bEquipLoc then
|
||||
@@ -210,6 +210,7 @@ local function DefaultSort(a, b)
|
||||
return aEquipLoc < bEquipLoc
|
||||
end
|
||||
end
|
||||
|
||||
if aSubType == bSubType then
|
||||
return PrimarySort(a, b)
|
||||
end
|
||||
@@ -243,7 +244,7 @@ end
|
||||
local function IterateForwards(bagList, i)
|
||||
i = i + 1
|
||||
local step = 1
|
||||
for _,bag in ipairs(bagList) do
|
||||
for _, bag in ipairs(bagList) do
|
||||
local slots = B:GetNumSlots(bag, bagRole)
|
||||
if i > slots + step then
|
||||
step = step + slots
|
||||
@@ -307,9 +308,8 @@ end
|
||||
|
||||
function B:GetNumSlots(bag, role)
|
||||
if bag then
|
||||
return GetContainerNumSlots(bag)
|
||||
return GetContainerNumSlots(bag);
|
||||
end
|
||||
|
||||
return 0
|
||||
end
|
||||
|
||||
@@ -362,7 +362,7 @@ function B:ScanBags()
|
||||
if itemID then
|
||||
bagMaxStacks[bagSlot] = select(7, GetItemInfo(itemID))
|
||||
bagIDs[bagSlot] = itemID
|
||||
bagQualities[bagSlot] = select(3, GetItemInfo(B:GetItemLink(bag, slot)))
|
||||
bagQualities[bagSlot] = select(3, GetItemInfo(itemID))
|
||||
bagStacks[bagSlot] = select(2, B:GetItemInfo(bag, slot))
|
||||
end
|
||||
end
|
||||
@@ -374,6 +374,8 @@ function B:GetItemFamily(bagType)
|
||||
|
||||
if strupper(itemSubType) == "BAG" then
|
||||
return 0
|
||||
elseif strupper(itemSubType) == "QUIVER" then
|
||||
return 1
|
||||
elseif strupper(itemSubType) == "KEYRING" then
|
||||
return -2
|
||||
else
|
||||
@@ -405,12 +407,12 @@ function B:CanItemGoInBag(bag, slot, targetBag)
|
||||
itemFamily = 1
|
||||
end
|
||||
end
|
||||
-- local bagFamily = select(2, GetContainerNumFreeSlots(targetBag))
|
||||
-- if itemFamily then
|
||||
-- return (bagFamily == 0) or band(itemFamily, bagFamily) > 0
|
||||
-- else
|
||||
local bagFamily = select(2, GetContainerNumFreeSlots(targetBag))
|
||||
if itemFamily then
|
||||
return (bagFamily == 0) or band(itemFamily, bagFamily) > 0
|
||||
else
|
||||
return false
|
||||
-- end
|
||||
end
|
||||
end
|
||||
|
||||
function B.Compress(...)
|
||||
@@ -422,6 +424,7 @@ 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]
|
||||
@@ -487,7 +490,7 @@ function B.Sort(bags, sorter, invertDirection)
|
||||
twipe(blackListedSlots)
|
||||
|
||||
buildBlacklist(B.db.ignoredItems)
|
||||
--buildBlacklist(E.global.bags.ignoredItems)
|
||||
buildBlacklist(E.global.bags.ignoredItems)
|
||||
|
||||
for i, bag, slot in B.IterateBags(bags, nil, "both") do
|
||||
local bagSlot = B:Encode_BagSlot(bag, slot)
|
||||
@@ -499,7 +502,7 @@ function B.Sort(bags, sorter, invertDirection)
|
||||
end
|
||||
|
||||
if not blackListedSlots[bagSlot] then
|
||||
for _,itemsearchquery in pairs(blackListQueries) do
|
||||
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
|
||||
@@ -603,7 +606,6 @@ function B.SortBags(...)
|
||||
if not bagCache[bagType] then bagCache[bagType] = {} end
|
||||
bagCache[bagType][i] = slotNum
|
||||
end
|
||||
|
||||
for bagType, sortedBags in pairs(bagCache) do
|
||||
if bagType ~= "Normal" then
|
||||
B.Stack(sortedBags, sortedBags, B.IsPartial)
|
||||
@@ -691,7 +693,6 @@ function B:DoMove(move)
|
||||
end
|
||||
|
||||
function B:DoMoves()
|
||||
--local cursorType, cursorItemID = GetCursorInfo()
|
||||
if CursorHasItem() and currentItemID then
|
||||
if lastItemID ~= currentItemID then
|
||||
return B:StopStacking(L["Confused.. Try Again!"])
|
||||
|
||||
Reference in New Issue
Block a user