diff --git a/Common.lua b/Common.lua
index 9df5801..f1e83bd 100644
--- a/Common.lua
+++ b/Common.lua
@@ -28,18 +28,24 @@ m.COOKINGB = { COOKING_RANK_1B, COOKING_RANK_2B, COOKING_RANK_3B, COOKING_RANK_4
m.CANLEARN = [[/esoui/art/loot/loot_finesseitem.dds]]
+local INVENTORIES = {
+ [PLAYER_INVENTORY.inventories[1].listView] = {GetItemLink, "bagId", "slotIndex"}, -- Backpack
+ [PLAYER_INVENTORY.inventories[3].listView] = {GetItemLink, "bagId", "slotIndex"}, -- Bank
+ [PLAYER_INVENTORY.inventories[4].listView] = {GetItemLink, "bagId", "slotIndex"}, -- GuildBank
+ [LOOT_WINDOW.list] = {GetLootItemLink, "lootId", nil} -- LootWindow
+}
local rowClicked = {}
function SousChef.HookInventory()
- for _,v in pairs(PLAYER_INVENTORY.inventories) do
- local listView = v.listView
- if listView and listView.dataTypes and listView.dataTypes[1] then
- SousChef.hookedFunctions = listView.dataTypes[1].setupCallback
- if SousChef.hookedFunctions then
- listView.dataTypes[1].setupCallback =
+ for list, funcs in pairs(INVENTORIES) do
+ if list and list.dataTypes and list.dataTypes[1] then
+ local listName = list:GetName()
+ SousChef.hookedFunctions[listName] = list.dataTypes[1].setupCallback
+ if SousChef.hookedFunctions[listName] then
+ list.dataTypes[1].setupCallback =
function(rowControl, slot)
- SousChef.hookedFunctions(rowControl, slot)
- SousChef.AddRankToSlot(rowControl)
+ SousChef.hookedFunctions[listName](rowControl, slot)
+ SousChef.AddRankToSlot(rowControl, funcs)
end
else
d("SousChef could not hook into the Inventory")
@@ -51,6 +57,7 @@ function SousChef.HookInventory()
ZO_ScrollList_RefreshVisible(BANK)
ZO_ScrollList_RefreshVisible(GUILD_BANK)
if not SousChef.settings.showOnClick then
+ ZO_PreHookHandler(ItemTooltip, "OnShow", function() zo_callLater(function() SousChef.AddDetails(moc()) end, 100) end)
ZO_PreHookHandler(ItemTooltip, "OnUpdate", function() return SousChef.AddDetails(moc()) end)
ZO_PreHookHandler(ItemTooltip, "OnHide", function() rowClicked = nil return false end )
end
@@ -73,10 +80,10 @@ function SousChef.AddDetails(row)
if not row.dataEntry or not row.dataEntry.data or rowClicked == row then return false end
rowClicked = row
local rowInfo = row.dataEntry.data
- local bagId = rowInfo.bagId
+ local bagId = rowInfo.bagId or rowInfo.lootId
local slotIndex = rowInfo.slotIndex
- if u.MatchesRecipe(rowInfo.name or "") then
+ if u.MatchesRecipe(rowInfo.name and rowInfo.name or "") then
local gmatch = u.MatchInGlobalCookbook(rowInfo.name)
if gmatch then
ZO_Tooltip_AddDivider(ItemTooltip)
@@ -86,10 +93,9 @@ function SousChef.AddDetails(row)
end
end
- if ((GetItemCraftingInfo(bagId, slotIndex)) ~= CRAFTING_TYPE_PROVISIONING) then return false end
-
- local usableIngredient = SousChef.ReverseCookbook[u.GetItemID(GetItemLink(bagId, slotIndex))]
- if SousChef.settings.showAltKnowledge then usableIngredient = SousChef.settings.ReverseCookbook[u.GetItemID(GetItemLink(bagId, slotIndex))] end
+ local itemId = u.GetItemID(slotIndex and GetItemLink(bagId, slotIndex) or GetLootItemLink(bagId)) -- Get itemId of inventory or loot slot
+ local usableIngredient = SousChef.ReverseCookbook[itemId]
+ if SousChef.settings.showAltKnowledge then usableIngredient = SousChef.settings.ReverseCookbook[itemId] end
if usableIngredient then
ZO_Tooltip_AddDivider(ItemTooltip)
ItemTooltip:AddLine("Used in:", "ZoFontWinH5", 1,1,1, BOTTOM, MODIFY_TEXT_TYPE_UPPERCASE)
diff --git a/Inventory.lua b/Inventory.lua
index 46525cc..7dec341 100644
--- a/Inventory.lua
+++ b/Inventory.lua
@@ -2,62 +2,66 @@ local SousChef = SousChef
local u = SousChef.Utility
local m = SousChef.Media
-function SousChef.AddRankToSlot(row)
+function SousChef.AddRankToSlot(row, funcs)
+ local idFunc = funcs[1]
local slot = row.dataEntry.data
- local bagId = slot.bagId
- local slotIndex = slot.slotIndex
+ local bagId = slot[funcs[2]]
+ local slotIndex = funcs[3] and slot[funcs[3]] or nil
+
+ if not slot.name or slot.name == "" then return end
+
local rankIcon = SousChef.getIcon(row)
-- Allow for ingeniousclown's Inventory Grid View
if row:GetWidth() - row:GetHeight() < 5 then -- if we're mostly square
rankIcon:SetDimensions(20,20)
+ rankIcon:ClearAnchors()
rankIcon:SetAnchor(TOPLEFT, row, TOPLEFT, 2)
- else
+ else
rankIcon:SetDimensions(30, 30)
- rankIcon:SetAnchor(CENTER, row, CENTER, 200)
+ rankIcon:ClearAnchors()
+ rankIcon:SetAnchor(RIGHT, row, RIGHT, -50)
end
rankIcon:SetHidden(true)
- if ((GetItemCraftingInfo(bagId, slotIndex)) == CRAFTING_TYPE_PROVISIONING) then
- local id = u.GetItemID(GetItemLink(bagId, slotIndex))
- local texture = SousChef.Pantry[id]
- if SousChef.settings.showAltKnowledge then texture = SousChef.settings.Pantry[id] end
- if texture then
-
- rankIcon:SetHidden(false)
-
- if SousChef.settings.boldIcon then
- rankIcon:SetTexture(m.COOKINGB[texture])
- else
- rankIcon:SetTexture(m.COOKING[texture])
- end
-
- if SousChef:IsOnShoppingList(id) then
- rankIcon:SetColor(SousChef.settings.shoppingColour[1], SousChef.settings.shoppingColour[2], SousChef.settings.shoppingColour[3])
- else
- if SousChef.settings.onlyShowShopping then return rankIcon:SetHidden(true) end
- rankIcon:SetColor(SousChef.settings.colour[1], SousChef.settings.colour[2], SousChef.settings.colour[3])
- end
+ local id = u.GetItemID(idFunc(bagId, slotIndex))
+ local texture = SousChef.Pantry[id]
+ if SousChef.settings.showAltKnowledge then texture = SousChef.settings.Pantry[id] end
+ if texture then
+
+ rankIcon:SetHidden(false)
+
+ if SousChef.settings.boldIcon then
+ rankIcon:SetTexture(m.COOKINGB[texture])
+ else
+ rankIcon:SetTexture(m.COOKING[texture])
+ end
- end
- else
- if SousChef.settings.processRecipes then
- if GetItemType(bagId, slotIndex) == ITEMTYPE_RECIPE then
- if u.MatchInIgnoreList(slot.name) then return end
- local match = u.MatchInCookbook(slot.name)
- local gmatch = u.MatchInGlobalCookbook(slot.name)
- if (match and SousChef.settings.checkKnown == "known") or
- (not match and SousChef.settings.checkKnown == "unknown")then
- rankIcon:SetTexture(m.CANLEARN)
- rankIcon:SetHidden(false)
- if not match and gmatch and SousChef.settings.checkKnown == "unknown" and SousChef.settings.markAlt then
- rankIcon:SetColor(1,1,1,0.2)
- else
- rankIcon:SetColor(1,1,1,1)
- end
- end
- end
- end
+ if SousChef:IsOnShoppingList(id) then
+ rankIcon:SetColor(SousChef.settings.shoppingColour[1], SousChef.settings.shoppingColour[2], SousChef.settings.shoppingColour[3])
+ else
+ if SousChef.settings.onlyShowShopping then return rankIcon:SetHidden(true) end
+ rankIcon:SetColor(SousChef.settings.colour[1], SousChef.settings.colour[2], SousChef.settings.colour[3])
+ end
+ return
end
+
+ if SousChef.settings.processRecipes then
+ if u.MatchInIgnoreList(slot.name) then return end
+ if slot.name:find(GetString(SI_ITEMTYPE29)) then
+ local match = u.MatchInCookbook(slot.name)
+ local gmatch = u.MatchInGlobalCookbook(slot.name)
+ if (match and SousChef.settings.checkKnown == "known") or
+ (not match and SousChef.settings.checkKnown == "unknown")then
+ rankIcon:SetTexture(m.CANLEARN)
+ rankIcon:SetHidden(false)
+ if not match and gmatch and SousChef.settings.checkKnown == "unknown" and SousChef.settings.markAlt then
+ rankIcon:SetColor(1,1,1,0.2)
+ else
+ rankIcon:SetColor(1,1,1,1)
+ end
+ end
+ end
+ end
end
diff --git a/SousChef.lua b/SousChef.lua
index b4838d6..045f7d1 100644
--- a/SousChef.lua
+++ b/SousChef.lua
@@ -51,7 +51,7 @@ function SousChef:ParseRecipes()
SousChef.settings.Cookbook[recipeName][GetUnitName("player")] = true
local _, _, ingredientCount, level, _, specialType = GetRecipeInfo(listIndex, recipeIndex)
for ingredientIndex = 1, ingredientCount do
- local link = u.GetItemID(GetRecipeIngredientItemLink(listIndex, recipeIndex, ingredientIndex, LINK_STYLE_NORMAL))
+ local link = u.GetItemID(GetRecipeIngredientItemLink(listIndex, recipeIndex, ingredientIndex, LINK_STYLE_DEFAULT))
-- Store the fact that the ingredient is used
if ingredientIndex < 3 or not SousChef.settings.showSpecialIngredients then
SousChef.Pantry[link] = math.max(level, SousChef.Pantry[link] or 0)
@@ -201,6 +201,7 @@ function SousChef.HookEvents()
EVENT_MANAGER:RegisterForEvent("SousChefLearnt", EVENT_RECIPE_LEARNED, SousChef.ParseRecipes)
EVENT_MANAGER:RegisterForEvent("SousChefProvi", EVENT_CRAFTING_STATION_INTERACT, function(...) SousChef:HookRecipeTree(...) end)
EVENT_MANAGER:RegisterForEvent("SousChefProviEnd", EVENT_END_CRAFTING_STATION_INTERACT, function() SousChef:UnhookRecipeTree() end)
+
SousChef.HookInventory()
end
diff --git a/Utility.lua b/Utility.lua
index b958f39..1370209 100644
--- a/Utility.lua
+++ b/Utility.lua
@@ -4,6 +4,7 @@ local SousChef = SousChef
local u = SousChef.Utility
function u.GetItemID(link)
+ if link == "" or not link then return -1 end
return tonumber(string.match(string.match(link, "%d+:"), "%d+"))
end