Skip to content

Commit

Permalink
Crafting/trade goods filter update (#899)
Browse files Browse the repository at this point in the history
* Tradeskill goods can now be broken up by expansion pack in the Filters -> Item Category menu.

Co-authored-by: Talyrius <[email protected]>
  • Loading branch information
Cidan and Talyrius authored Jan 11, 2023
1 parent be39d56 commit 3f42c74
Show file tree
Hide file tree
Showing 10 changed files with 170 additions and 31 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/libs/**
/libs/**
/.vscode/settings.json
1 change: 1 addition & 0 deletions AdiBags.toc
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ modules\BankSwitcher.lua
modules\ChangeHighlight.lua
modules\Masque.lua

core\ItemDatabase.lua
core\DefaultFilters.lua

#@debug@
Expand Down
1 change: 1 addition & 0 deletions AdiBags_TBC.toc
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ modules\BankSwitcher.lua
modules\ChangeHighlight.lua
modules\Masque.lua

core\ItemDatabase.lua
core\DefaultFilters.lua

#@debug@
Expand Down
1 change: 1 addition & 0 deletions AdiBags_Vanilla.toc
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ modules\BankSwitcher.lua
modules\ChangeHighlight.lua
modules\Masque.lua

core\ItemDatabase.lua
core\DefaultFilters.lua

#@debug@
Expand Down
1 change: 1 addition & 0 deletions AdiBags_Wrath.toc
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ modules\BankSwitcher.lua
modules\ChangeHighlight.lua
modules\Masque.lua

core\ItemDatabase.lua
core\DefaultFilters.lua

#@debug@
Expand Down
47 changes: 47 additions & 0 deletions Localization.lua
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,13 @@ L["Virtual stacks display in one place items that actually spread over several b
L["Virtual stacks"] = true
L["When checked, right-clicking on an empty space of a bag opens the configuration panel."] = true

-- core/Constants.lua
L["Engineering"] = true
L["Tailoring"] = true
L["Leatherworking"] = true
L["Mining"] = true
L["Herbalism"] = true

-- core/Core.lua
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."] = true

Expand Down Expand Up @@ -376,6 +383,11 @@ L["enabled"] = true
------------------------ frFR ------------------------
local locale = GetLocale()
if locale == 'frFR' then
L["Engineering"] = "Ingénierie"
L["Tailoring"] = "Couture"
L["Leatherworking"] = "Travail du cuir"
L["Mining"] = "Minage"
L["Herbalism"] = "Herboristerie"
L["Add a dropdown menu to bags that allow to hide the sections."] = "Ajoute un menu déroulant aux sacs pour cacher les sections."
L["Add association"] = "Ajouter l'association"
L["Add more information in tooltips related to items in your bags."] = "Ajoute des informations additionnelles dans les bulles d'aides des objets de vos sacs."
Expand Down Expand Up @@ -627,6 +639,11 @@ L["Which color scheme should be used to display the item level ?"] = "Quel thèm

------------------------ deDE ------------------------
elseif locale == 'deDE' then
L["Engineering"] = "Ingenieurskunst"
L["Tailoring"] = "Schneiderei"
L["Leatherworking"] = "Lederverarbeitung"
L["Mining"] = "Bergbau"
L["Herbalism"] = "Kräuterkunde"
L["Add a dropdown menu to bags that allow to hide the sections."] = "Fügt den Taschen ein Dropdown-Menü hinzu, welches es erlaubt die Abteilung zu verstecken."
L["Add association"] = "Füge Zuweisung hinzu"
L["Add more information in tooltips related to items in your bags."] = "Füge mehr Informationen bezüglich der Items in deinen Taschen zum Tooltip hinzu"
Expand Down Expand Up @@ -797,6 +814,11 @@ L["When shift is held down"] = "Wenn Umschalt gedrückt ist"

------------------------ ruRU ------------------------
elseif locale == 'ruRU' then
L["Engineering"] = "Инженерное дело"
L["Tailoring"] = "Портняжное дело"
L["Leatherworking"] = "Кожевничество"
L["Mining"] = "Горное дело"
L["Herbalism"] = "Травничество"
L["Add a dropdown menu to bags that allow to hide the sections."] = "Добавить выпадающее меню для сумок, в котором можно настроить отображение секций."
L["Add association"] = "Добавить объединение"
L["Add more information in tooltips related to items in your bags."] = "Добавить Дополнительную информацию во всплывающих подсказках, касающихся предметов, в вашей сумке"
Expand Down Expand Up @@ -968,6 +990,11 @@ L["When shift is held down"] = "Когда кнопка Shift нажата"

------------------------ esES ------------------------
elseif locale == 'esES' then
L["Engineering"] = "Ingeniería"
L["Tailoring"] = "Sastrería"
L["Leatherworking"] = "Peletería"
L["Mining"] = "Minería"
L["Herbalism"] = "Herboristería"
L["Adjust the maximum height of the bags, relative to screen size."] = "Ajustar al maximo la altura de las bolsas, en relación a el tamaño de la pantalla."
L["Allow you manually redefine the section in which an item should be put. Simply drag an item on the section title."] = "Permite redefinir manualmente la sección en la que un objeto debe situarse. Solo arrastra un objeto dentro del título de la sección"
L["Always"] = "Siempre"
Expand Down Expand Up @@ -1064,6 +1091,11 @@ L["Use this to adjust the quality-based border opacity. 100% means fully opaque.

------------------------ zhTW ------------------------
elseif locale == 'zhTW' then
L["Engineering"] = "工程學"
L["Tailoring"] = "裁縫"
L["Leatherworking"] = "製皮"
L["Mining"] = "採礦"
L["Herbalism"] = "草藥學"
L["Add a dropdown menu to bags that allow to hide the sections."] = "增加下拉式選單來隱藏類別" -- Needs review
L["Add association"] = "新增關聯"
L["Add more information in tooltips related to items in your bags."] = "顯示物品的額外資訊提示"
Expand Down Expand Up @@ -1318,6 +1350,11 @@ L["Which color scheme should be used to display the item level ?"] = "應該使

------------------------ zhCN ------------------------
elseif locale == 'zhCN' then
L["Engineering"] = "工程学"
L["Tailoring"] = "裁缝"
L["Leatherworking"] = "制皮"
L["Mining"] = "采矿"
L["Herbalism"] = "草药学"
L["Add a dropdown menu to bags that allow to hide the sections."] = "给背包添加下拉菜单, 允许隐藏分组."
L["Add association"] = "添加过滤"
L["Add more information in tooltips related to items in your bags."] = "显示物品的额外提示信息"
Expand Down Expand Up @@ -1568,6 +1605,11 @@ L["Which color scheme should be used to display the item level ?"] = "应该使

------------------------ koKR ------------------------
elseif locale == 'koKR' then
L["Engineering"] = "기계공학"
L["Tailoring"] = "재봉술"
L["Leatherworking"] = "가죽세공"
L["Mining"] = "채광"
L["Herbalism"] = "약초채집"
L["%s is: %s."] = "%s|1은;는; %s입니다."
L["... including incomplete stacks"] = "... 불완전 중첩 포함"
L["6.0"] = "6.0"
Expand Down Expand Up @@ -1840,6 +1882,11 @@ L["You can block auto-deposit ponctually by pressing a modified key while talkin

------------------------ ptBR ------------------------
elseif locale == 'ptBR' then
L["Engineering"] = "Engenharia"
L["Tailoring"] = "Alfaiataria"
L["Leatherworking"] = "Couraria"
L["Mining"] = "Mineração"
L["Herbalism"] = "Herborismo"
L["Add a dropdown menu to bags that allow to hide the sections."] = "Adicione um menu retrátil nas bolsas que permitem esconder as seções"
L["Add association"] = "Adicionar associação"
L["Add more information in tooltips related to items in your bags."] = "Adicionar mais informação nas janelas de saque relacionadas aos itens em suas bolsas"
Expand Down
45 changes: 43 additions & 2 deletions core/Constants.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ 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 TRADE_GOODS = _G.Enum.ItemClass.Tradegoods
local GetItemSubClassInfo = _G.GetItemSubClassInfo
local pairs = _G.pairs
--GLOBALS>

Expand Down Expand Up @@ -76,6 +78,45 @@ for _, bags in ipairs { BAGS, BANK } do
for id in pairs(bags) do ALL[id] = id end
end

-- Expansion names
addon.EXPANSION_MAP = {
[_G.LE_EXPANSION_CLASSIC] = _G.EXPANSION_NAME0,
[_G.LE_EXPANSION_BURNING_CRUSADE] = _G.EXPANSION_NAME1,
[_G.LE_EXPANSION_WRATH_OF_THE_LICH_KING] = _G.EXPANSION_NAME2,
[_G.LE_EXPANSION_CATACLYSM] = _G.EXPANSION_NAME3,
[_G.LE_EXPANSION_MISTS_OF_PANDARIA] = _G.EXPANSION_NAME4,
[_G.LE_EXPANSION_WARLORDS_OF_DRAENOR] = _G.EXPANSION_NAME5,
[_G.LE_EXPANSION_LEGION] = _G.EXPANSION_NAME6,
[_G.LE_EXPANSION_BATTLE_FOR_AZEROTH] = _G.EXPANSION_NAME7,
[_G.LE_EXPANSION_SHADOWLANDS] = _G.EXPANSION_NAME8,
[_G.LE_EXPANSION_DRAGONFLIGHT] = _G.EXPANSION_NAME9,
}

-- Tradeskill subclassID -> subclassName
-- Note that this differs from what GetItemSubClassInfo returns (in comments); non-retail client returns aren't obsoleted.
addon.TRADESKILL_MAP = {
[ 0] = GetItemSubClassInfo(TRADE_GOODS, 0), -- "Trade Goods (OBSOLETE)"
[ 1] = L["Engineering"], -- "Parts"
[ 2] = GetItemSubClassInfo(TRADE_GOODS, 2), -- "Explosives (OBSOLETE)"
[ 3] = GetItemSubClassInfo(TRADE_GOODS, 3), -- "Devices (OBSOLETE)"
[ 4] = GetItemSubClassInfo(TRADE_GOODS, 4), -- "Jewelcrafting"
[ 5] = L["Tailoring"], -- "Cloth"
[ 6] = L["Leatherworking"], -- "Leather"
[ 7] = L["Mining"], -- "Metal & Stone"
[ 8] = GetItemSubClassInfo(TRADE_GOODS, 8), -- "Cooking"
[ 9] = L["Herbalism"], -- "Herb"
[10] = GetItemSubClassInfo(TRADE_GOODS, 10), -- "Elemental"
[11] = GetItemSubClassInfo(TRADE_GOODS, 11), -- "Other"
[12] = GetItemSubClassInfo(TRADE_GOODS, 12), -- "Enchanting"
[13] = GetItemSubClassInfo(TRADE_GOODS, 13), -- "Materials (OBSOLETE)"
[14] = GetItemSubClassInfo(TRADE_GOODS, 14), -- "Item Enchantment (OBSOLETE)"
[15] = GetItemSubClassInfo(TRADE_GOODS, 15), -- "Weapon Enchantment - Obsolete"
[16] = GetItemSubClassInfo(TRADE_GOODS, 16), -- "Inscription"
[17] = GetItemSubClassInfo(TRADE_GOODS, 17), -- "Explosives and Devices (OBSOLETE)"
[18] = GetItemSubClassInfo(TRADE_GOODS, 18), -- "Optional Reagents"
[19] = GetItemSubClassInfo(TRADE_GOODS, 19), -- "Finishing Reagents"
}

addon.BAG_IDS = {
BAGS = BAGS,
BANK = BANK,
Expand All @@ -97,7 +138,7 @@ 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
[0x00800] = L["REAGENT_BAG_TAG"], -- Reagent Bag
[0x08000] = L["TACKLE_BOX_TAG"], -- Tackle Box
[0x10000] = L["COOKING_BAR_TAG"], -- Refrigerator
--@noloc]]
Expand All @@ -115,7 +156,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
[0x00800] = [[Interface\Icons\INV_10_Tailoring_CraftingOptionalReagent_ExtraPockets_Color2]], -- Reagent Bag
[0x08000] = [[Interface\Icons\Trade_Fishing]], -- Tackle Box
[0x10000] = [[Interface\Icons\INV_Misc_Bag_Cooking]], -- Refrigerator
}
Expand Down
54 changes: 30 additions & 24 deletions core/DefaultFilters.lua
Original file line number Diff line number Diff line change
Expand Up @@ -307,28 +307,23 @@ function addon:SetupDefaultFilters()
splitBySubclass = { false },
mergeGems = true,
mergeGlyphs = true,
splitExpansion = false,
}
})
end

function itemCat:GetOptions()
local values = {}
if addon.isRetail then
values = {
[TRADE_GOODS] = TRADE_GOODS,
[CONSUMMABLE] = CONSUMMABLE,
[MISCELLANEOUS] = MISCELLANEOUS,
[GEM] = GEM,
[GLYPH] = GLYPH,
[RECIPE] = RECIPE,
}
else
values = {
[TRADE_GOODS] = TRADE_GOODS,
[CONSUMMABLE] = CONSUMMABLE,
[MISCELLANEOUS] = MISCELLANEOUS,
[RECIPE] = RECIPE,
}
local values = {
[TRADE_GOODS] = TRADE_GOODS,
[CONSUMMABLE] = CONSUMMABLE,
[MISCELLANEOUS] = MISCELLANEOUS,
[RECIPE] = RECIPE,
}
if addon.isBCC then
values[GEM] = GEM
elseif not addon.isClassic then
values[GEM] = GEM
values[GLYPH] = GLYPH
end

return {
Expand All @@ -340,19 +335,26 @@ function addon:SetupDefaultFilters()
values = values
},
mergeGems = {
name = L['Gems are trade goods'],
desc = L['Consider gems as a subcategory of trade goods'],
name = L['Gems are trade/crafting goods'],
desc = L['Consider gems as a subcategory of trade/crafting goods'],
type = 'toggle',
width = 'double',
order = 20,
},
mergeGlyphs = {
name = L['Glyphs are trade goods'],
desc = L['Consider glyphs as a subcategory of trade goods'],
name = L['Glyphs are trade/crafting goods'],
desc = L['Consider glyphs as a subcategory of trade/crafting goods'],
type = 'toggle',
width = 'double',
order = 30,
},
splitExpansion = {
name = L['Split trade/crafting goods by expansion'],
desc = L['Split trade/crafting goods by expansion'],
type = 'toggle',
width = 'double',
order = 40,
},
}, addon:GetOptionHandler(self, true)
end

Expand All @@ -363,13 +365,17 @@ function addon:SetupDefaultFilters()
elseif class == GLYPH and self.db.profile.mergeGlyphs then
class, subclass = TRADE_GOODS, class
end

--TODO: Implement an option to override `subclass` with professions from our `addon.TRADESKILL_MAP`?
local reagentData = addon.ItemDatabase:ReagentData(slotData)
if self.db.profile.splitBySubclass[class] then
return subclass, class
return (self.db.profile.splitExpansion and reagentData and subclass..": "..reagentData.expacName)
or subclass, class
else
return class
return (self.db.profile.splitExpansion and reagentData and class..": "..reagentData.expacName)
or class
end
end

end

end
40 changes: 40 additions & 0 deletions core/ItemDatabase.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
--[[
AdiBags - Adirelle's bag addon.
Copyright 2010-2023 Adirelle ([email protected])
All rights reserved.
This file is part of AdiBags.
AdiBags is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
AdiBags is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with AdiBags. If not, see <http://www.gnu.org/licenses/>.
--]]

--<GLOBALS
local _G = _G
local TRADE_GOODS = _G.Enum.ItemClass.Tradegoods
local UNKNOWN = _G.UNKNOWN
--GLOBALS>

local addonName, addon = ...

addon.ItemDatabase = addon:NewModule("ItemDatabase", "AceEvent-3.0")
local db = addon.ItemDatabase

function db:ReagentData(slotData)
if not slotData.isCraftingReagent then return false end
if not slotData.classID == TRADE_GOODS then return false end
return {
expacName = addon.EXPANSION_MAP[slotData.expacID],
subclassName = addon.TRADESKILL_MAP[slotData.subclassID] or UNKNOWN,
}
end
8 changes: 4 additions & 4 deletions widgets/ContainerFrame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -709,11 +709,11 @@ function containerProto:UpdateContent(bag)
content[slot] = slotData
end

local name, count, quality, iLevel, reqLevel, class, subclass, maxStack, equipSlot, texture, vendorPrice
local name, count, quality, iLevel, reqLevel, class, subclass, maxStack, equipSlot, texture, vendorPrice, classID, subclassID, bindType, expacID, setID, isCraftingReagent
if link then
name, _, quality, iLevel, reqLevel, class, subclass, maxStack, equipSlot, texture, vendorPrice = GetItemInfo(link)
name, _, quality, iLevel, reqLevel, class, subclass, maxStack, equipSlot, texture, vendorPrice, classID, subclassID, bindType, expacID, setID, isCraftingReagent = GetItemInfo(link)
if not name then
name, _, quality, iLevel, reqLevel, class, subclass, maxStack, equipSlot, texture, vendorPrice = GetItemInfo(itemId)
name, _, quality, iLevel, reqLevel, class, subclass, maxStack, equipSlot, texture, vendorPrice, classID, subclassID, bindType, expacID, setID, isCraftingReagent = GetItemInfo(itemId)
end
-- Correctly catch battlepets and store their name.
if string.match(link, "|Hbattlepet:") then
Expand Down Expand Up @@ -743,6 +743,7 @@ function containerProto:UpdateContent(bag)
slotData.guid = guid
slotData.itemLocation = itemLocation
slotData.name, slotData.quality, slotData.iLevel, slotData.reqLevel, slotData.class, slotData.subclass, slotData.equipSlot, slotData.texture, slotData.vendorPrice = name, quality, iLevel, reqLevel, class, subclass, equipSlot, texture, vendorPrice
slotData.classID, slotData.subclassID, slotData.bindType, slotData.expacID, slotData.setID, slotData.isCraftingReagent = classID, subclassID, bindType, expacID, setID, isCraftingReagent
slotData.maxStack = maxStack or (link and 1 or 0)
if sameItem then
changed[slotData.slotId] = slotData
Expand Down Expand Up @@ -895,7 +896,6 @@ function containerProto:DispatchItem(slotData, fullUpdate)
self.ToSortSection:AddItemButton(slotId, button)
return
end

local section = self:GetSection(sectionName, category or sectionName)
section:AddItemButton(slotId, button)
end
Expand Down

0 comments on commit 3f42c74

Please sign in to comment.