Fixed the tooltip error. Now, however, you have to click on the ingredient to add the recipes used.
Wobin [04-13-14 - 10:19]
Fixed the tooltip error. Now, however, you have to click on the ingredient to add the recipes used.
diff --git a/SousChef.lua b/SousChef.lua
index b5215a7..a7c7962 100644
--- a/SousChef.lua
+++ b/SousChef.lua
@@ -40,6 +40,27 @@ local function MatchInGlobalCookbook(bag, slot)
return settings.Cookbook[GetItemName(bag,slot):lower():gsub(" ", "")]
end
+local function AddDetails(row)
+ if not row.dataEntry or not row.dataEntry.data then return false end
+ local bagId = row.dataEntry.data.bagId
+ local slotIndex = row.dataEntry.data.slotIndex
+ if ((GetItemCraftingInfo(bagId, slotIndex)) ~= CRAFTING_TYPE_PROVISIONING) then return false end
+
+ local usableIngredient = ReverseCookbook[GetItemID(GetItemLink(bagId, slotIndex))]
+ if usableIngredient then
+ d(row)
+ ItemTooltip:AddLine("Used in:")
+ for i,v in ipairs(usableIngredient) do
+ ItemTooltip:AddLine(v)
+ end
+ end
+ return false
+end
+
+
+
+rowHandler = {}
+
local function AddRankToSlot(row)
local bagId = row.dataEntry.data.bagId
local slotIndex = row.dataEntry.data.slotIndex
@@ -48,6 +69,10 @@ local function AddRankToSlot(row)
if(not rankIcon) then
rankIcon = WINDOW_MANAGER:CreateControl(row:GetName() .. "SousChef", row, CT_TEXTURE)
slotLines[row:GetName()] = rankIcon
+ if not rowHandler[row] then
+ rowHandler[row] = row:GetHandler("OnMouseEnter")
+ ZO_PreHookHandler(row, "OnMouseDown", AddDetails)
+ end
end
-- Allow for ingeniousclown's Inventory Grid View
@@ -89,22 +114,6 @@ local function AddRankToSlot(row)
end
end
-local function AddDetails(row, ...)
- d("adding")
- if not row.dataEntry or not row.dataEntry.data then return ... end
- local bagId = row.dataEntry.data.bagId
- local slotIndex = row.dataEntry.data.slotIndex
- if ((GetItemCraftingInfo(bagId, slotIndex)) ~= CRAFTING_TYPE_PROVISIONING) then return ... end
- local usableIngredient = ReverseCookbook[GetItemID(GetItemLink(bagId, slotIndex))]
- if usableIngredient then
- ItemTooltip:AddLine("Used in:")
- for i,v in ipairs(usableIngredient) do
- ItemTooltip:AddLine(v)
- end
- end
- return ...
-end
-
local function ParseRecipes()
local lists = GetNumRecipeLists()
for listIndex = 1, lists do
@@ -214,10 +223,11 @@ local function SousChef_Loaded(eventCode, addOnName)
--[[ Hook into the tooltip
-- This causes security errors, will have to reconsider
- local tooltip = ZO_InventorySlot_OnMouseEnter
+ SousChefTooltip = ZO_InventorySlot_OnMouseEnter
function ZO_InventorySlot_OnMouseEnter(...)
local control = ...
- AddDetails(control, tooltip(control, ...))
+ CallSecureProtected("SousChefTooltip", control, ...)
+ AddDetails(control)
end--]]
end