Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dragonflight Patch V5 #790

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion AdiBags_Config/AdiBags_Config.toc
@@ -1,4 +1,4 @@
## Interface: 100000
## Interface: 100002

## Title: AdiBags Configuration
## Notes: Adirelle's bag addon.
Expand Down
8 changes: 4 additions & 4 deletions config/Options.lua
Expand Up @@ -270,12 +270,12 @@ local function GetOptions()
end
end
options = {
--@debug@
--[===[@debug@
name = addonName..' DEV',
--@end-debug@
--[===[@non-debug@
--@end-debug@]===]
--@non-debug@
name = addonName..' @project-version@',
--@end-non-debug@]===]
--@end-non-debug@
type = 'group',
handler = addon:GetOptionHandler(addon),
get = 'Get',
Expand Down
3 changes: 3 additions & 0 deletions core/Bags.lua
Expand Up @@ -35,6 +35,9 @@ local pairs = _G.pairs
local setmetatable = _G.setmetatable
local tinsert = _G.tinsert
local tsort = _G.table.sort
local SortBags = C_Container and _G.C_Container.SortBags or _G.SortBags
local SortBankBags = C_Container and _G.C_Container.SortBankBags or _G.SortBankBags
local SortReagentBankBags = C_Container and _G.C_Container.SortReagentBankBags or _G.SortReagentBankBags
--GLOBALS>

local hookedBags = addon.hookedBags
Expand Down
19 changes: 13 additions & 6 deletions core/Constants.lua
Expand Up @@ -30,26 +30,31 @@ addon.isWrath = WOW_PROJECT_ID == WOW_PROJECT_WRATH_CLASSIC

--<GLOBALS
local _G = _G
local BACKPACK_CONTAINER = _G.BACKPACK_CONTAINER
local BANK_CONTAINER = _G.BANK_CONTAINER
local REAGENTBANK_CONTAINER = _G.REAGENTBANK_CONTAINER
local BACKPACK_CONTAINER = _G.BACKPACK_CONTAINER or ( Enum.BagIndex and Enum.BagIndex.Backpack ) or 0
local REAGENTBAG_CONTAINER = ( Enum.BagIndex and Enum.BagIndex.REAGENTBAG_CONTAINER ) or 5
local BANK_CONTAINER = _G.BANK_CONTAINER or ( Enum.BagIndex and Enum.BagIndex.Bank ) or -1
local REAGENTBANK_CONTAINER = _G.REAGENTBANK_CONTAINER or ( Enum.BagIndex and Enum.BagIndex.Reagentbank ) or -3
local NUM_BAG_SLOTS = _G.NUM_BAG_SLOTS
local NUM_REAGENTBAG_SLOTS = _G.NUM_REAGENTBAG_SLOTS
local NUM_TOTAL_EQUIPPED_BAG_SLOTS = _G.NUM_TOTAL_EQUIPPED_BAG_SLOTS
local NUM_BANKBAGSLOTS = _G.NUM_BANKBAGSLOTS
local pairs = _G.pairs
--GLOBALS>

-- Backpack and bags
local BAGS = { [BACKPACK_CONTAINER] = BACKPACK_CONTAINER }
for i = 1, NUM_BAG_SLOTS do BAGS[i] = i end

local BANK = {}
local BANK_ONLY = {}
local REAGENTBANK_ONLY = {}

if addon.isRetail then
-- Personal Bags
for i = 1, NUM_TOTAL_EQUIPPED_BAG_SLOTS do BAGS[i] = i end

-- Base nank bags
BANK_ONLY = { [BANK_CONTAINER] = BANK_CONTAINER }
for i = NUM_BAG_SLOTS + 1, NUM_BAG_SLOTS + NUM_BANKBAGSLOTS do BANK_ONLY[i] = i end
for i = NUM_TOTAL_EQUIPPED_BAG_SLOTS + 1, NUM_TOTAL_EQUIPPED_BAG_SLOTS + NUM_BANKBAGSLOTS do BANK_ONLY[i] = i end

--- Reagent bank bags
REAGENTBANK_ONLY = { [REAGENTBANK_CONTAINER] = REAGENTBANK_CONTAINER }
Expand All @@ -59,6 +64,7 @@ if addon.isRetail then
for id in pairs(bags) do BANK[id] = id end
end
else
for i = 1, NUM_BAG_SLOTS do BAGS[i] = i end
BANK = { [BANK_CONTAINER] = BANK_CONTAINER }
for i = NUM_BAG_SLOTS + 1, NUM_BAG_SLOTS + NUM_BANKBAGSLOTS do BANK[i] = i end
end
Expand Down Expand Up @@ -90,11 +96,11 @@ addon.FAMILY_TAGS = {
[0x00100] = L["KEYRING_TAG"], -- Keyring
[0x00200] = L["GEM_BAG_TAG"], -- Gem Bag
[0x00400] = L["MINING_BAG_TAG"], -- Mining Bag
[0x00800] = L["REAGENT_BAG_TAG"], -- Player Reagent Bag
[0x08000] = L["TACKLE_BOX_TAG"], -- Tackle Box
[0x10000] = L["COOKING_BAR_TAG"], -- Refrigerator
--@noloc]]
}

addon.FAMILY_ICONS = {
[0x00001] = [[Interface\Icons\INV_Misc_Ammo_Arrow_01]], -- Quiver
[0x00002] = [[Interface\Icons\INV_Misc_Ammo_Bullet_05]], -- Ammo Pouch
Expand All @@ -107,6 +113,7 @@ addon.FAMILY_ICONS = {
[0x00100] = [[Interface\Icons\INV_Misc_Key_14]], -- Keyring
[0x00200] = [[Interface\Icons\INV_Misc_Gem_BloodGem_01]], -- Gem Bag
[0x00400] = [[Interface\Icons\Trade_Mining]], -- Mining Bag
[0x00800] = 4549254, -- Player Reagent Bag
[0x08000] = [[Interface\Icons\Trade_Fishing]], -- Tackle Box
[0x10000] = [[Interface\Icons\INV_Misc_Bag_Cooking]], -- Refrigerator
}
Expand Down
29 changes: 15 additions & 14 deletions core/Core.lua
Expand Up @@ -25,7 +25,8 @@ local L = addon.L
--<GLOBALS
local _G = _G
local ADDON_LOAD_FAILED = _G.ADDON_LOAD_FAILED
local BANK_CONTAINER = _G.BANK_CONTAINER
local BANK_CONTAINER = _G.BANK_CONTAINER or ( Enum.BagIndex and Enum.BagIndex.Bank ) or -1
local REAGENTBAG_CONTAINER = ( Enum.BagIndex and Enum.BagIndex.REAGENTBAG_CONTAINER ) or 5
local CloseWindows = _G.CloseWindows
local CreateFrame = _G.CreateFrame
local format = _G.format
Expand All @@ -45,32 +46,32 @@ local unpack = _G.unpack
--GLOBALS>

LibStub('AceAddon-3.0'):NewAddon(addon, addonName, 'ABEvent-1.0', 'ABBucket-1.0', 'AceHook-3.0', 'AceConsole-3.0')
--@debug@
--[===[@debug@
_G[addonName] = addon
--@end-debug@
--@end-debug@]===]

--------------------------------------------------------------------------------
-- Debug stuff
--------------------------------------------------------------------------------

--@alpha@
--[===[@alpha@
if AdiDebug then
AdiDebug:Embed(addon, addonName)
else
--@end-alpha@
--@end-alpha@]===]
function addon.Debug() end
--@alpha@
--[===[@alpha@
end
--@end-alpha@
--@end-alpha@]===]

--@debug@
--[===[@debug@
local function DebugTable(t, prevKey)
local k, v = next(t, prevKey)
if k ~= nil then
return k, v, DebugTable(t, k)
end
end
--@end-debug@
--@end-debug@]===]

--------------------------------------------------------------------------------
-- Addon initialization and enabling
Expand Down Expand Up @@ -110,11 +111,11 @@ function addon:OnInitialize()
end, true)

-- Just a warning
--@alpha@
--[===[@alpha@
if geterrorhandler() == _G._ERRORMESSAGE and not GetCVarBool("scriptErrors") then
print('|cffffee00', L["Warning: You are using an alpha or beta version of AdiBags without displaying Lua errors. If anything goes wrong, AdiBags (or any other addon causing some error) will simply stop working for apparently no reason. Please either enable the display of Lua errors or install an error handler addon like BugSack or Swatter."], '|r')
end
--@end-alpha@
--@end-alpha@]===]

self:Debug('Initialized')
end
Expand All @@ -134,7 +135,7 @@ function addon:OnEnable()

self:RegisterMessage('AdiBags_BagOpened', 'LayoutBags')
self:RegisterMessage('AdiBags_BagClosed', 'LayoutBags')

-- Track most windows involving items
self:RegisterEvent('BANKFRAME_OPENED', 'UpdateInteractingWindow')
self:RegisterEvent('BANKFRAME_CLOSED', 'UpdateInteractingWindow')
Expand Down Expand Up @@ -373,9 +374,9 @@ function addon:ReagentBankUpdated(slots)
end

function addon:ConfigChanged(vars)
--@debug@
--[===[@debug@
self:Debug('ConfigChanged', DebugTable(vars))
--@end-debug@
--@end-debug@]===]
if vars.enabled then
if self.db.profile.enabled then
self:Enable()
Expand Down
31 changes: 18 additions & 13 deletions core/DefaultFilters.lua
Expand Up @@ -25,10 +25,11 @@ function addon:SetupDefaultFilters()
-- Globals: GetEquipmentSetLocations
--<GLOBALS
local _G = _G
local BANK_CONTAINER = _G.BANK_CONTAINER
local BANK_CONTAINER = _G.BANK_CONTAINER or ( Enum.BagIndex and Enum.BagIndex.Bank ) or -1
local BANK_CONTAINER_INVENTORY_OFFSET = _G.BANK_CONTAINER_INVENTORY_OFFSET
local EquipmentManager_UnpackLocation = _G.EquipmentManager_UnpackLocation
local format = _G.format
local GetContainerItemQuestInfo = C_Container and _G.C_Container.GetContainerItemQuestInfo or _G.GetContainerItemQuestInfo
local GetEquipmentSetInfo = _G.C_EquipmentSet.GetEquipmentSetInfo
local GetItemIDs = _G.C_EquipmentSet.GetItemIDs
local GetEquipmentSetIDs = _G.C_EquipmentSet.GetEquipmentSetIDs
Expand All @@ -40,16 +41,16 @@ function addon:SetupDefaultFilters()
local L = addon.L

-- Make some strings local to speed things
local CONSUMMABLE = GetItemClassInfo(Enum.ItemClass.Consumable)
local GEM = GetItemClassInfo(Enum.ItemClass.Gem)
local GLYPH = GetItemClassInfo(Enum.ItemClass.Glyph)
local JUNK = GetItemSubClassInfo(Enum.ItemClass.Miscellaneous, 0)
local MISCELLANEOUS = GetItemClassInfo(Enum.ItemClass.Miscellaneous)
local QUEST = GetItemClassInfo(Enum.ItemClass.Questitem)
local RECIPE = GetItemClassInfo(Enum.ItemClass.Recipe)
local TRADE_GOODS = GetItemClassInfo(Enum.ItemClass.Tradegoods)
local WEAPON = GetItemClassInfo(Enum.ItemClass.Weapon)
local ARMOR = GetItemClassInfo(Enum.ItemClass.Armor)
local CONSUMMABLE = GetItemClassInfo(_G.Enum.ItemClass.Consumable)
local GEM = GetItemClassInfo(_G.Enum.ItemClass.Gem)
local GLYPH = GetItemClassInfo(_G.Enum.ItemClass.Glyph)
local JUNK = GetItemSubClassInfo(_G.Enum.ItemClass.Miscellaneous, 0)
local MISCELLANEOUS = GetItemClassInfo(_G.Enum.ItemClass.Miscellaneous)
local QUEST = GetItemClassInfo(_G.Enum.ItemClass.Questitem)
local RECIPE = GetItemClassInfo(_G.Enum.ItemClass.Recipe)
local TRADE_GOODS = GetItemClassInfo(_G.Enum.ItemClass.Tradegoods)
local WEAPON = GetItemClassInfo(_G.Enum.ItemClass.Weapon)
local ARMOR = GetItemClassInfo(_G.Enum.ItemClass.Armor)
local JEWELRY = L['Jewelry']
local EQUIPMENT = L['Equipment']
local AMMUNITION = L['Ammunition']
Expand Down Expand Up @@ -199,9 +200,13 @@ function addon:SetupDefaultFilters()
if slotData.class == QUEST or slotData.subclass == QUEST then
return QUEST
else
if addon.isRetail or addon.isWrath then
local isQuestItem, questId = addon:GetContainerItemQuestInfo(slotData.bag, slotData.slot)
if addon.isRetail then
local questId = addon:SafeGetItem(GetContainerItemQuestInfo(slotData.bag, slotData.slot), "questId")
local isQuestItem = addon:SafeGetItem(GetContainerItemQuestInfo(slotData.bag, slotData.slot), "isQuestItem")
return (questId or isQuestItem) and QUEST
elseif addon.isWrath then
local isQuestItem, questId = GetContainerItemQuestInfo(slotData.bag, slotData.slot)
return (questId or isQuestItem) and QUEST
else
return false
end
Expand Down
4 changes: 2 additions & 2 deletions core/Filters.lua
Expand Up @@ -145,10 +145,10 @@ function addon:Filter(slotData, defaultSection, defaultCategory)
for i, filter in ipairs(GetActiveFilters()) do
local sectionName, category = safecall(filter.Filter, filter, slotData)
if sectionName then
--@alpha@
--[===[@alpha@
assert(type(sectionName) == "string", "Filter "..filter.name.." returned "..type(sectionName).." as section name instead of a string")
assert(category == nil or type(category) == "string", "Filter "..filter.name.." returned "..type(category).." as category instead of a string")
--@end-alpha@
--@end-alpha@]===]
return sectionName, category, filter.uiName
end
end
Expand Down
7 changes: 5 additions & 2 deletions core/Hooks.lua
Expand Up @@ -24,11 +24,14 @@ local L = addon.L

--<GLOBALS
local _G = _G
local BACKPACK_CONTAINER = _G.BACKPACK_CONTAINER
local BACKPACK_CONTAINER = _G.BACKPACK_CONTAINER or ( Enum.BagIndex and Enum.BagIndex.Backpack ) or 0
local REAGENTBAG_CONTAINER = ( Enum.BagIndex and Enum.BagIndex.REAGENTBAG_CONTAINER ) or 5
local ContainerFrame_GenerateFrame = _G.ContainerFrame_GenerateFrame
local ContainerFrame_GetOpenFrame = _G.ContainerFrame_GetOpenFrame
local GetContainerNumSlots = C_Container and C_Container.GetContainerNumSlots or GetContainerNumSlots
local GetContainerNumSlots = C_Container and _G.C_Container.GetContainerNumSlots or _G.GetContainerNumSlots
local NUM_BAG_SLOTS = _G.NUM_BAG_SLOTS
local NUM_REAGENTBAG_SLOTS = _G.NUM_REAGENTBAG_SLOTS
local NUM_TOTAL_EQUIPPED_BAG_SLOTS = _G.NUM_TOTAL_EQUIPPED_BAG_SLOTS
local NUM_BANKBAGSLOTS = _G.NUM_BANKBAGSLOTS
local NUM_CONTAINER_FRAMES = _G.NUM_CONTAINER_FRAMES
local pairs = _G.pairs
Expand Down
4 changes: 2 additions & 2 deletions core/OO.lua
Expand Up @@ -221,7 +221,7 @@ function addon:GetPool(name)
return name and pools[name]
end

--@debug@
--[===[@debug@
-- Globals: SLASH_ADIBAGSOODEBUG1
SLASH_ADIBAGSOODEBUG1 = "/aboo"
function SlashCmdList.ADIBAGSOODEBUG()
Expand All @@ -241,4 +241,4 @@ function SlashCmdList.ADIBAGSOODEBUG()
print(format("- %s: heap size: %d, number of active objects: %d", name, heapSize, numActives))
end
end
--@end-debug@
--@end-debug@]===]
73 changes: 8 additions & 65 deletions core/Utility.lua
Expand Up @@ -29,9 +29,7 @@ local _G = _G
local band = _G.bit.band
local floor = _G.floor
local GameTooltip = _G.GameTooltip
local GetContainerItemInfo = C_Container and C_Container.GetContainerItemInfo or GetContainerItemInfo
local GetContainerItemQuestInfo = C_Container and C_Container.GetContainerItemQuestInfo or GetContainerItemQuestInfo
local GetContainerNumFreeSlots = C_Container and C_Container.GetContainerNumFreeSlots or GetContainerNumFreeSlots
local GetContainerNumFreeSlots = C_Container and _G.C_Container.GetContainerNumFreeSlots or _G.GetContainerNumFreeSlots
local geterrorhandler = _G.geterrorhandler
local GetItemFamily = _G.GetItemFamily
local GetItemInfo = _G.GetItemInfo
Expand Down Expand Up @@ -333,7 +331,7 @@ end
-- Basic junk test
--------------------------------------------------------------------------------

local JUNK = GetItemSubClassInfo(Enum.ItemClass.Miscellaneous, 0)
local JUNK = GetItemSubClassInfo(_G.Enum.ItemClass.Miscellaneous, 0)
function addon:IsJunk(itemId)
local _, _, quality, _, _, class, subclass = GetItemInfo(itemId)
return quality == ITEM_QUALITY_POOR or (quality and quality < ITEM_QUALITY_UNCOMMON and (class == JUNK or subclass == JUNK))
Expand Down Expand Up @@ -401,66 +399,11 @@ function addon:GetFamilyTag(family)
end
end

--------------------------------------------------------------------------------
-- Wrappers for GetContainerItemInfo
--------------------------------------------------------------------------------
local fieldMappings = {
texture = {field = "iconFileID", returnSlot = 1},
stackCount = {field = "stackCount", returnSlot = 2},
locked = {field = "isLocked", returnSlot = 3},
quality = {field = "quality", returnSlot = 4},
filtered = {field = "isFiltered", returnSlot = 8},
}

local function unwrapItemInfo(field, ...)
if not select(1, ...) then
return
elseif type(select(1, ...)) == "table" then
local result = ...
return result and result[fieldMappings[field].field]
-- Helper function, guard nil table access
function addon:SafeGetItem(table, key)
if table ~= nil then
return table[key]
else
return select(fieldMappings[field].returnSlot, ...)
return nil
end
end

function addon:GetContainerItemLocked(containerIndex, slotIndex)
return unwrapItemInfo("locked", GetContainerItemInfo(containerIndex, slotIndex))
end

function addon:GetContainerItemQuality(containerIndex, slotIndex)
return unwrapItemInfo("quality", GetContainerItemInfo(containerIndex, slotIndex))
end

function addon:GetContainerItemStackCount(containerIndex, slotIndex)
return unwrapItemInfo("stackCount", GetContainerItemInfo(containerIndex, slotIndex))
end

function addon:GetContainerItemTexture(containerIndex, slotIndex)
return unwrapItemInfo("texture", GetContainerItemInfo(containerIndex, slotIndex))
end

function addon:GetContainerItemTextureCountLocked(containerIndex, slotIndex)
local texture, slotCount, locked = GetContainerItemInfo(containerIndex, slotIndex)

if texture and type(texture) == "table" then
local result = texture
return result.iconFileID, result.stackCount, result.isLocked
else
return texture, slotCount, locked
end
end

function addon:GetContainerItemFiltered(containerIndex, slotIndex)
return unwrapItemInfo("filtered", GetContainerItemInfo(containerIndex, slotIndex))
end

function addon:GetContainerItemQuestInfo(containerIndex, slotIndex)
-- This function isn't present on classic-era in any form

if C_Container then
local result = C_Container.GetContainerItemQuestInfo(containerIndex, slotIndex)
return result.isQuestItem, result.questID, result.isActive
elseif GetContainerItemQuestInfo then
return GetContainerItemQuestInfo(containerIndex, slotIndex)
end
end
end
4 changes: 2 additions & 2 deletions modules/BankSwitcher.lua
Expand Up @@ -25,7 +25,7 @@ local L = addon.L
--<GLOBALS
local _G = _G
local GameTooltip = _G.GameTooltip
local UseContainerItem = C_Container and C_Container.UseContainerItem or UseContainerItem
local UseContainerItem = C_Container and _G.C_Container.UseContainerItem or _G.UseContainerItem
--GLOBALS>

local mod = addon:NewModule('BankSwitcher', 'ABEvent-1.0')
Expand Down Expand Up @@ -60,4 +60,4 @@ function mod:AdiBags_InteractingWindowChanged(_, new, old)
elseif old == "BANKFRAME" then
addon.UnregisterAllSectionHeaderScripts(self)
end
end
end