test update Bags and Sort

Need more work.
Also fixes Vendor & Delete Greys
This commit is contained in:
Crum
2018-07-01 23:35:08 -05:00
parent 0bce1f6cb6
commit 8fd70922da
4 changed files with 44 additions and 56 deletions
+17 -15
View File
@@ -6,13 +6,13 @@ local LIP = LibStub("ItemPrice-1.1", true);
--Cache global variables
--Lua functions
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 floor, ceil = math.floor, math.ceil
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
local BankFrameItemButton_OnUpdate = BankFrameItemButton_OnUpdate
local BankFrameItemButton_UpdateLock = BankFrameItemButton_UpdateLock
local CloseBag, CloseBackpack, CloseBankFrame = CloseBag, CloseBackpack, CloseBankFrame
local CooldownFrame_SetTimer = CooldownFrame_SetTimer
local CreateFrame = CreateFrame
@@ -169,7 +169,7 @@ function B:SetSearch(query)
button:SetAlpha(1)
else
SetItemButtonDesaturated(button, 1)
button:SetAlpha(0.4)
button:SetAlpha(0.5)
end
end
end
@@ -233,7 +233,7 @@ 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 slot = self.Bags[bagID][slotID]
local bagType = self.Bags[bagID].type
local texture, count, locked = GetContainerItemInfo(bagID, slotID)
local clink = GetContainerItemLink(bagID, slotID)
@@ -293,7 +293,7 @@ function B:UpdateSlot(bagID, slotID)
SetItemButtonTexture(slot, texture)
SetItemButtonCount(slot, count)
SetItemButtonDesaturated(slot, locked, 0.5, 0.5, 0.5)
SetItemButtonDesaturated(slot, locked)
if GameTooltip:IsOwned(slot) and not slot.hasItem then
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))
if isBank then
BankFrameItemButton_OnUpdate()
-- BankFrameItemButton_OnUpdate()
-- BankFrameItemButton_UpdateLock()
end
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]:SetID(bagID)
f.Bags[bagID].UpdateBagSlots = B.UpdateBagSlots
-- f.Bags[bagID].UpdateSlot = B.UpdateSlot
-- f.Bags[bagID].UpdateSlot = UpdateSlot
end
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
for i = 1, MAX_CONTAINER_ITEMS do
@@ -530,8 +533,8 @@ function B:Layout(isBank)
if self.isBank then
if self.ContainerHolder[i] then
BankFrameItemButton_Update(self.ContainerHolder[i])
BankFrameItemButton_UpdateLocked(self.ContainerHolder[i])
BankFrameItemButton_OnUpdate()
BankFrameItemButton_UpdateLock()
end
end
end
@@ -602,7 +605,7 @@ function B:UpdateKeySlot(slotID)
if clink then
local _
slot.name, _, slot.rarity = GetItemInfo(clink)
slot.name, _, slot.rarity = GetItemInfo(match(clink, "item:(%d+)"))
local r, g, b
@@ -697,7 +700,7 @@ function B:GetGraysValue()
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
if select(3, GetItemInfo(match(l, "item:(%d+)"))) == 0 and p > 0 then
c = c + p
end
end
@@ -749,7 +752,6 @@ 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
@@ -1185,7 +1187,7 @@ function B:Initialize()
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)
-- self:SecureHook("UpdateContainerFrameAnchors")
self:SecureHook("UpdateContainerFrameAnchors")
return
end
+9 -25
View File
@@ -4,7 +4,7 @@ local Search = LibStub("LibItemSearch-1.2");
--Cache global variables
--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 floor, mod = math.floor, math.mod
local band = bit.band
@@ -361,26 +361,10 @@ function B:ScanBags()
end
end
local bagType = {
["Bag"] = 0,
["Quiver"] = 1,
["Ammo Pouch"] = 2,
["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
local function GetItemFamily(bag)
local itemType = select(6, GetItemInfo(match(bag, "item:(%d+)")))
if itemType then
return itemType
end
return nil
@@ -395,16 +379,16 @@ function B:IsSpecialtyBag(bagID)
local bag = GetInventoryItemLink("player", inventorySlot)
if not bag then return false end
local family = B:GetItemFamily(bagID)
if family == 0 or family == nil then return false else return false end
local family = GetItemFamily(bag)
if family == "Bag" or family == nil then return false else return false end
return family
end
function B:CanItemGoInBag(bag, slot, targetBag)
local item = bagIDs[B:Encode_BagSlot(bag, slot)]
local itemFamily = B:GetItemFamily(item)
if itemFamily and itemFamily > 0 then
local itemFamily = GetItemFamily(item)
if itemFamily and (not itemFamily == "Bag") then
local equipSlot = select(8, GetItemInfo(item))
if equipSlot == "INVTYPE_BAG" then
itemFamily = 1