mirror of
https://github.com/Bluewhale1337/ElvUIModernized.git
synced 2026-07-27 16:34:45 +00:00
test update Bags and Sort
Need more work. Also fixes Vendor & Delete Greys
This commit is contained in:
@@ -132,7 +132,7 @@ end
|
|||||||
--[[ Utilities ]]--
|
--[[ Utilities ]]--
|
||||||
|
|
||||||
function Lib:Find(search, ...)
|
function Lib:Find(search, ...)
|
||||||
for i = 1, getn(arg) do
|
for i = 1, arg.n do
|
||||||
local text = arg[i]
|
local text = arg[i]
|
||||||
if text and find(self:Clean(text), search) then
|
if text and find(self:Clean(text), search) then
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -3,17 +3,19 @@
|
|||||||
An item text search engine of some sort
|
An item text search engine of some sort
|
||||||
--]]
|
--]]
|
||||||
|
|
||||||
local Search = LibStub("CustomSearch-1.0");
|
local Search = LibStub("CustomSearch-1.0")
|
||||||
local Unfit = LibStub("Unfit-1.0");
|
local Unfit = LibStub("Unfit-1.0")
|
||||||
local Lib = LibStub:NewLibrary("LibItemSearch-1.2", 11);
|
local Lib = LibStub:NewLibrary("LibItemSearch-1.2", 11)
|
||||||
if Lib then
|
if Lib then
|
||||||
Lib.Filters = {}
|
Lib.Filters = {}
|
||||||
else
|
else
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local tonumber = tonumber
|
local pairs, select, tonumber = pairs, select, tonumber
|
||||||
local find, strmatch, lower = string.find, string.match, string.lower
|
local find, gsub, match, lower = string.find, string.gsub, string.match, string.lower
|
||||||
|
|
||||||
|
local GetItemInfo = GetItemInfo
|
||||||
|
|
||||||
--[[ User API ]]--
|
--[[ User API ]]--
|
||||||
|
|
||||||
@@ -22,11 +24,11 @@ function Lib:Matches(link, search)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Lib:Tooltip(link, search)
|
function Lib:Tooltip(link, search)
|
||||||
return link and strmatch(self.Filters.tip, link, nil, search)
|
return link and match(self.Filters.tip, link, nil, search)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Lib:TooltipPhrase(link, search)
|
function Lib:TooltipPhrase(link, search)
|
||||||
return link and strmatch(self.Filters.tipPhrases, link, nil, search)
|
return link and match(self.Filters.tipPhrases, link, nil, search)
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[ Basics ]]--
|
--[[ Basics ]]--
|
||||||
@@ -39,7 +41,7 @@ Lib.Filters.name = {
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
match = function(self, item, _, search)
|
match = function(self, item, _, search)
|
||||||
local name = strmatch(item, "%[(.-)%]")
|
local name = match(item, "%[(.-)%]")
|
||||||
return Search:Find(search, name)
|
return Search:Find(search, name)
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
@@ -52,7 +54,7 @@ Lib.Filters.type = {
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
match = function(self, item, _, search)
|
match = function(self, item, _, search)
|
||||||
local type, subType, _, equipSlot = select(6, GetItemInfo(item))
|
local type, subType, _, equipSlot = select(6, GetItemInfo(match(item, "item:(%d+)")))
|
||||||
return Search:Find(search, type, subType, _G[equipSlot])
|
return Search:Find(search, type, subType, _G[equipSlot])
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
@@ -65,7 +67,7 @@ Lib.Filters.level = {
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
match = function(self, link, operator, num)
|
match = function(self, link, operator, num)
|
||||||
local _, _, _, lvl = GetItemInfo(link)
|
local _, _, _, lvl = GetItemInfo(match(link, "item:(%d+)"))
|
||||||
if lvl then
|
if lvl then
|
||||||
return Search:Compare(operator, lvl, num)
|
return Search:Compare(operator, lvl, num)
|
||||||
end
|
end
|
||||||
@@ -80,7 +82,7 @@ Lib.Filters.requiredlevel = {
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
match = function(self, link, operator, num)
|
match = function(self, link, operator, num)
|
||||||
local _, _, _, _, lvl = GetItemInfo(link)
|
local _, _, _, _, lvl = GetItemInfo(match(link, "item:(%d+)"))
|
||||||
if lvl then
|
if lvl then
|
||||||
return Search:Compare(operator, lvl, num)
|
return Search:Compare(operator, lvl, num)
|
||||||
end
|
end
|
||||||
@@ -106,7 +108,7 @@ Lib.Filters.quality = {
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
match = function(self, link, operator, num)
|
match = function(self, link, operator, num)
|
||||||
local _, _, quality = GetItemInfo(link)
|
local _, _, quality = GetItemInfo(match(link, "item:(%d+)"))
|
||||||
return Search:Compare(operator, quality, num)
|
return Search:Compare(operator, quality, num)
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
@@ -122,7 +124,7 @@ Lib.Filters.usable = {
|
|||||||
|
|
||||||
match = function(self, link)
|
match = function(self, link)
|
||||||
if(not Unfit:IsItemUnusable(link)) then
|
if(not Unfit:IsItemUnusable(link)) then
|
||||||
local _, _, _, _, lvl = GetItemInfo(link)
|
local _, _, _, _, lvl = GetItemInfo(match(link, "item:(%d+)"))
|
||||||
return lvl and (lvl ~= 0 and lvl <= UnitLevel("player"))
|
return lvl and (lvl ~= 0 and lvl <= UnitLevel("player"))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -162,7 +164,7 @@ local escapes = {
|
|||||||
|
|
||||||
local function CleanString(str)
|
local function CleanString(str)
|
||||||
for k, v in pairs(escapes) do
|
for k, v in pairs(escapes) do
|
||||||
str = string.gsub(str, k, v)
|
str = gsub(str, k, v)
|
||||||
end
|
end
|
||||||
return str
|
return str
|
||||||
end
|
end
|
||||||
@@ -173,7 +175,7 @@ Lib.Filters.tipPhrases = {
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
match = function(self, link, _, search)
|
match = function(self, link, _, search)
|
||||||
local id = strmatch(link, "item:(%d+)")
|
local id = match(link, "item:(%d+)")
|
||||||
if not id then
|
if not id then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|||||||
+17
-15
@@ -6,13 +6,13 @@ local LIP = LibStub("ItemPrice-1.1", true);
|
|||||||
--Cache global variables
|
--Cache global variables
|
||||||
--Lua functions
|
--Lua functions
|
||||||
local _G = _G
|
local _G = _G
|
||||||
local type, ipairs, pairs, unpack, select, assert = type, ipairs, pairs, unpack, select, assert
|
local type, ipairs, pairs, unpack, select, assert, pcall = type, ipairs, pairs, unpack, select, assert, pcall
|
||||||
local tinsert = table.insert
|
local tinsert = table.insert
|
||||||
local floor, ceil = math.floor, math.ceil
|
local floor, ceil = math.floor, math.ceil
|
||||||
local len, gsub, sub, find, match = string.len, string.gsub, string.sub, string.find, string.match
|
local len, gsub, sub, find, match = string.len, string.gsub, string.sub, string.find, string.match
|
||||||
--WoW API / Variables
|
--WoW API / Variables
|
||||||
local BankFrameItemButton_Update = BankFrameItemButton_Update
|
local BankFrameItemButton_OnUpdate = BankFrameItemButton_OnUpdate
|
||||||
local BankFrameItemButton_UpdateLocked = BankFrameItemButton_UpdateLocked
|
local BankFrameItemButton_UpdateLock = BankFrameItemButton_UpdateLock
|
||||||
local CloseBag, CloseBackpack, CloseBankFrame = CloseBag, CloseBackpack, CloseBankFrame
|
local CloseBag, CloseBackpack, CloseBankFrame = CloseBag, CloseBackpack, CloseBankFrame
|
||||||
local CooldownFrame_SetTimer = CooldownFrame_SetTimer
|
local CooldownFrame_SetTimer = CooldownFrame_SetTimer
|
||||||
local CreateFrame = CreateFrame
|
local CreateFrame = CreateFrame
|
||||||
@@ -169,7 +169,7 @@ function B:SetSearch(query)
|
|||||||
button:SetAlpha(1)
|
button:SetAlpha(1)
|
||||||
else
|
else
|
||||||
SetItemButtonDesaturated(button, 1)
|
SetItemButtonDesaturated(button, 1)
|
||||||
button:SetAlpha(0.4)
|
button:SetAlpha(0.5)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -233,7 +233,7 @@ end
|
|||||||
function B:UpdateSlot(bagID, slotID)
|
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
|
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 slot = self.Bags[bagID][slotID]
|
||||||
local bagType = self.Bags[bagID].type
|
local bagType = self.Bags[bagID].type
|
||||||
local texture, count, locked = GetContainerItemInfo(bagID, slotID)
|
local texture, count, locked = GetContainerItemInfo(bagID, slotID)
|
||||||
local clink = GetContainerItemLink(bagID, slotID)
|
local clink = GetContainerItemLink(bagID, slotID)
|
||||||
@@ -293,7 +293,7 @@ function B:UpdateSlot(bagID, slotID)
|
|||||||
|
|
||||||
SetItemButtonTexture(slot, texture)
|
SetItemButtonTexture(slot, texture)
|
||||||
SetItemButtonCount(slot, count)
|
SetItemButtonCount(slot, count)
|
||||||
SetItemButtonDesaturated(slot, locked, 0.5, 0.5, 0.5)
|
SetItemButtonDesaturated(slot, locked)
|
||||||
|
|
||||||
if GameTooltip:IsOwned(slot) and not slot.hasItem then
|
if GameTooltip:IsOwned(slot) and not slot.hasItem then
|
||||||
B:Tooltip_Hide()
|
B:Tooltip_Hide()
|
||||||
@@ -426,7 +426,8 @@ function B:Layout(isBank)
|
|||||||
E:Size(f.ContainerHolder, ((buttonSize + buttonSpacing) * (isBank and i - 1 or i)) + buttonSpacing, buttonSize + (buttonSpacing * 2))
|
E:Size(f.ContainerHolder, ((buttonSize + buttonSpacing) * (isBank and i - 1 or i)) + buttonSpacing, buttonSize + (buttonSpacing * 2))
|
||||||
|
|
||||||
if isBank then
|
if isBank then
|
||||||
BankFrameItemButton_OnUpdate()
|
-- BankFrameItemButton_OnUpdate()
|
||||||
|
-- BankFrameItemButton_UpdateLock()
|
||||||
end
|
end
|
||||||
|
|
||||||
E:Size(f.ContainerHolder[i], buttonSize)
|
E:Size(f.ContainerHolder[i], buttonSize)
|
||||||
@@ -447,11 +448,13 @@ function B:Layout(isBank)
|
|||||||
f.Bags[bagID] = CreateFrame("Frame", f:GetName().."Bag"..bagID, f)
|
f.Bags[bagID] = CreateFrame("Frame", f:GetName().."Bag"..bagID, f)
|
||||||
f.Bags[bagID]:SetID(bagID)
|
f.Bags[bagID]:SetID(bagID)
|
||||||
f.Bags[bagID].UpdateBagSlots = B.UpdateBagSlots
|
f.Bags[bagID].UpdateBagSlots = B.UpdateBagSlots
|
||||||
-- f.Bags[bagID].UpdateSlot = B.UpdateSlot
|
-- f.Bags[bagID].UpdateSlot = UpdateSlot
|
||||||
end
|
end
|
||||||
|
|
||||||
f.Bags[bagID].numSlots = numSlots
|
f.Bags[bagID].numSlots = numSlots
|
||||||
-- f.Bags[bagID].type = select(2, GetContainerNumFreeSlots(bagID))
|
|
||||||
|
local _, _, id = strfind(GetInventoryItemLink("player", ContainerIDToInventoryID(bagID)) or "", "item:(%d+)")
|
||||||
|
f.Bags[bagID].type = select(6, GetItemInfo(id))
|
||||||
|
|
||||||
--Hide unused slots
|
--Hide unused slots
|
||||||
for i = 1, MAX_CONTAINER_ITEMS do
|
for i = 1, MAX_CONTAINER_ITEMS do
|
||||||
@@ -530,8 +533,8 @@ function B:Layout(isBank)
|
|||||||
|
|
||||||
if self.isBank then
|
if self.isBank then
|
||||||
if self.ContainerHolder[i] then
|
if self.ContainerHolder[i] then
|
||||||
BankFrameItemButton_Update(self.ContainerHolder[i])
|
BankFrameItemButton_OnUpdate()
|
||||||
BankFrameItemButton_UpdateLocked(self.ContainerHolder[i])
|
BankFrameItemButton_UpdateLock()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -602,7 +605,7 @@ function B:UpdateKeySlot(slotID)
|
|||||||
|
|
||||||
if clink then
|
if clink then
|
||||||
local _
|
local _
|
||||||
slot.name, _, slot.rarity = GetItemInfo(clink)
|
slot.name, _, slot.rarity = GetItemInfo(match(clink, "item:(%d+)"))
|
||||||
|
|
||||||
local r, g, b
|
local r, g, b
|
||||||
|
|
||||||
@@ -697,7 +700,7 @@ function B:GetGraysValue()
|
|||||||
local l = GetContainerItemLink(b, s)
|
local l = GetContainerItemLink(b, s)
|
||||||
if l and find(l,"ff9d9d9d") then
|
if l and find(l,"ff9d9d9d") then
|
||||||
local p = LIP:GetSellValue(l) * select(2, GetContainerItemInfo(b, s))
|
local p = LIP:GetSellValue(l) * select(2, GetContainerItemInfo(b, s))
|
||||||
if select(3, GetItemInfo(l)) == 0 and p > 0 then
|
if select(3, GetItemInfo(match(l, "item:(%d+)"))) == 0 and p > 0 then
|
||||||
c = c + p
|
c = c + p
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -749,7 +752,6 @@ 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
|
||||||
@@ -1185,7 +1187,7 @@ function B:Initialize()
|
|||||||
E:Point(BagFrameHolder, "BOTTOMRIGHT", RightChatPanel, "BOTTOMRIGHT", -(E.Border*2), 22 + E.Border*4 - E.Spacing*2)
|
E:Point(BagFrameHolder, "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)
|
||||||
|
|
||||||
-- self:SecureHook("UpdateContainerFrameAnchors")
|
self:SecureHook("UpdateContainerFrameAnchors")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ local Search = LibStub("LibItemSearch-1.2");
|
|||||||
|
|
||||||
--Cache global variables
|
--Cache global variables
|
||||||
--Lua functions
|
--Lua functions
|
||||||
local ipairs, pairs, tonumber, select, unpack = ipairs, pairs, tonumber, select, unpack
|
local ipairs, pairs, pcall, tonumber, select, unpack = ipairs, pairs, pcall, tonumber, select, unpack
|
||||||
local tinsert, tremove, tsort, twipe = table.insert, table.remove, table.sort, table.wipe
|
local tinsert, tremove, tsort, twipe = table.insert, table.remove, table.sort, table.wipe
|
||||||
local floor, mod = math.floor, math.mod
|
local floor, mod = math.floor, math.mod
|
||||||
local band = bit.band
|
local band = bit.band
|
||||||
@@ -361,26 +361,10 @@ function B:ScanBags()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local bagType = {
|
local function GetItemFamily(bag)
|
||||||
["Bag"] = 0,
|
local itemType = select(6, GetItemInfo(match(bag, "item:(%d+)")))
|
||||||
["Quiver"] = 1,
|
if itemType then
|
||||||
["Ammo Pouch"] = 2,
|
return itemType
|
||||||
["Soul Bag"] = 4,
|
|
||||||
}
|
|
||||||
|
|
||||||
function B:GetItemFamily(bagID)
|
|
||||||
if bagID == KEYRING_CONTAINER then return KEYRING_CONTAINER end
|
|
||||||
if bagID == 0 then return 0 end
|
|
||||||
|
|
||||||
local _, _, id = strfind(GetInventoryItemLink("player", ContainerIDToInventoryID(bagID)) or "", "item:(%d+)")
|
|
||||||
if id then
|
|
||||||
local _, _, _, _, itemType, subType = GetItemInfo(id)
|
|
||||||
local bagSubType = bagType[subType]
|
|
||||||
|
|
||||||
if bagSubType == 0 then return 0 end -- based off https://wow.gamepedia.com/ItemFamily
|
|
||||||
if bagSubType == 1 then return 1 end
|
|
||||||
if bagSubType == 2 then return 2 end
|
|
||||||
if bagSubType == 4 then return 4 end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@@ -395,16 +379,16 @@ function B:IsSpecialtyBag(bagID)
|
|||||||
local bag = GetInventoryItemLink("player", inventorySlot)
|
local bag = GetInventoryItemLink("player", inventorySlot)
|
||||||
if not bag then return false end
|
if not bag then return false end
|
||||||
|
|
||||||
local family = B:GetItemFamily(bagID)
|
local family = GetItemFamily(bag)
|
||||||
if family == 0 or family == nil then return false else return false end
|
if family == "Bag" or family == nil then return false else return false end
|
||||||
|
|
||||||
return family
|
return family
|
||||||
end
|
end
|
||||||
|
|
||||||
function B:CanItemGoInBag(bag, slot, targetBag)
|
function B:CanItemGoInBag(bag, slot, targetBag)
|
||||||
local item = bagIDs[B:Encode_BagSlot(bag, slot)]
|
local item = bagIDs[B:Encode_BagSlot(bag, slot)]
|
||||||
local itemFamily = B:GetItemFamily(item)
|
local itemFamily = GetItemFamily(item)
|
||||||
if itemFamily and itemFamily > 0 then
|
if itemFamily and (not itemFamily == "Bag") then
|
||||||
local equipSlot = select(8, GetItemInfo(item))
|
local equipSlot = select(8, GetItemInfo(item))
|
||||||
if equipSlot == "INVTYPE_BAG" then
|
if equipSlot == "INVTYPE_BAG" then
|
||||||
itemFamily = 1
|
itemFamily = 1
|
||||||
|
|||||||
Reference in New Issue
Block a user