Incorporate GetItemLinkRecipeResultItemLink(), hopefully eliminating mismatched recipe/result names.

katkat42 [11-23-14 - 05:20]
Incorporate GetItemLinkRecipeResultItemLink(), hopefully eliminating mismatched recipe/result names.
Make typeIconLookup work in german and french
Put result level in recipe's tooltip
Filename
Common.lua
Inventory.lua
Provisioning.lua
SousChef.lua
Strings.lua
TradingHouse.lua
Utility.lua
diff --git a/Common.lua b/Common.lua
index 433aeb2..fd228d6 100644
--- a/Common.lua
+++ b/Common.lua
@@ -111,22 +111,31 @@ function SousChef.AddDetails(row)
 		bagId = slotIndex
 		slotIndex = nil
 	end
+	local itemLink = (slotIndex and GetItemLink(bagId, slotIndex)) or (rowInfo.lootId and GetLootItemLink(bagId)) or (GetStoreItemLink(bagId))

-	if u.MatchesRecipe(rowInfo.name and rowInfo.name or "") then
-        local gmatch = u.MatchInGlobalCookbook(rowInfo.name)
-        if gmatch then
+	-- item is a recipe
+	if GetItemLinkItemType(itemLink) == ITEMTYPE_RECIPE then
+        local knownBy = SousChef.settings.Cookbook[u.CleanString(GetItemLinkName(GetItemLinkRecipeResultItemLink(itemLink)))]
+        if knownBy then
             ZO_Tooltip_AddDivider(ItemTooltip)
+			ItemTooltip:AddLine(zo_strformat(str.TOOLTIP_CREATES, GetItemLinkRequiredLevel(GetItemLinkRecipeResultItemLink(itemLink)), GetItemLinkName(GetItemLinkRecipeResultItemLink(itemLink))), "ZoFontWinH5", 1, 1, 1, BOTTOM)
             ItemTooltip:AddLine(str.TOOLTIP_KNOWN_BY, "ZoFontWinH5", 1,1,1, BOTTOM, MODIFY_TEXT_TYPE_UPPERCASE)
-            ItemTooltip:AddLine(u.TableKeyConcat(gmatch))
+            ItemTooltip:AddLine(u.TableKeyConcat(knownBy))
             return false
         end
     end

+	-- if we're only showing items on the shopping list, and we've already hidden this item, then don't touch it!
     if SousChef.settings.onlyShowShopping and SousChef.slotLines[row:GetName()] and SousChef.slotLines[row:GetName()]:IsHidden() then return end

-	local itemId = u.GetItemID((slotIndex and GetItemLink(bagId, slotIndex)) or (rowInfo.lootId and GetLootItemLink(bagId)) or (GetStoreItemLink(bagId))) -- Get itemId of inventory or loot or store slot
-	local usableIngredient = SousChef.ReverseCookbook[itemId]
-	if SousChef.settings.showAltIngredientKnowledge then usableIngredient = SousChef.settings.ReverseCookbook[itemId] end
+	-- item is an ingredient
+	local itemId = u.GetItemID(itemLink) -- Get itemId of inventory or loot or store slot
+	local usableIngredient
+	if SousChef.settings.showAltIngredientKnowledge then
+		usableIngredient = SousChef.settings.ReverseCookbook[itemId]
+	else
+		usableIngredient = SousChef.ReverseCookbook[itemId]
+	end
 	if usableIngredient then
 		ZO_Tooltip_AddDivider(ItemTooltip)
 		ItemTooltip:AddLine(str.TOOLTIP_USED_IN, "ZoFontWinH5", 1,1,1, BOTTOM, MODIFY_TEXT_TYPE_UPPERCASE)
diff --git a/Inventory.lua b/Inventory.lua
index 57e1255..d7d6fd1 100644
--- a/Inventory.lua
+++ b/Inventory.lua
@@ -27,33 +27,40 @@ function SousChef.AddRankToSlot(row, funcs)
 	-- Are we gold or soulgem slot? Stay hidden and go away
 	if not bagId or not slot.name or slot.name == "" then return end

-	local id = u.GetItemID(idFunc(bagId, slotIndex))
+	local itemLink = idFunc(bagId, slotIndex)
+	local itemType = GetItemLinkItemType(itemLink)
+	-- let's try for a performance gain here: if it's not our type of item, go away now
+	if (itemType ~= ITEMTYPE_FLAVORING) and (itemType ~= ITEMTYPE_INGREDIENT) and (itemType ~= ITEMTYPE_RECIPE) and (itemType ~= ITEMTYPE_SPICE) then
+		return
+	end
+	local id = u.GetItemID(itemLink)
 	local texture = SousChef.Pantry[id]
 	if SousChef.settings.showAltIngredientKnowledge then texture = SousChef.settings.Pantry[id] end
-	if texture then
-
-		rankIcon:SetHidden(false)
+	if texture then
+		-- we're an ingredient
+		rankIcon:SetHidden(false)

 		if SousChef.settings.boldIcon then
 			rankIcon:SetTexture(m.COOKINGB[texture])
 		else
 			rankIcon:SetTexture(m.COOKING[texture])
-		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
+		end
 		return
 	end

+	-- are we a recipe?
     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 GetItemLinkItemType(itemLink) == ITEMTYPE_RECIPE then
+	        local match = SousChef.Cookbook[u.CleanString(GetItemLinkName(GetItemLinkRecipeResultItemLink(itemLink)))]
+	        local gmatch = SousChef.settings.Cookbook[u.CleanString(GetItemLinkName(GetItemLinkRecipeResultItemLink(itemLink)))]
 	        if (match and SousChef.settings.checkKnown == "known") or
 	           (not match and SousChef.settings.checkKnown == "unknown")then
 	            rankIcon:SetTexture(m.CANLEARN)
diff --git a/Provisioning.lua b/Provisioning.lua
index 59d0639..d1979dd 100644
--- a/Provisioning.lua
+++ b/Provisioning.lua
@@ -67,7 +67,7 @@ function SousChef:HookRecipeTreeFunction()
             function(...)
                 local node, control, data, open, userRequested, enabled = ...
                 SousChef.hookedProvisioningFunction(...)
-                local link = zo_strformat(SI_TOOLTIP_ITEM_NAME, GetRecipeResultItemLink(data.recipeListIndex, data.recipeIndex, LINK_STYLE_BRACKETS))
+                local link = GetItemLinkName(GetRecipeResultItemLink(data.recipeListIndex, data.recipeIndex, LINK_STYLE_BRACKETS)))
                 if link then
                     SousChef:AddNotifier(control, type(SousChef.settings.shoppingList[link]) == "table" and u.TableKeyConcat(SousChef.settings.shoppingList[link]))
                 end
@@ -125,7 +125,7 @@ function SousChef:IsOnShoppingList(id)
 end

 function SousChef:MarkRecipe()
-    local link = zo_strformat(SI_TOOLTIP_ITEM_NAME, GetRecipeResultItemLink(PROVISIONER:GetSelectedRecipeListIndex(), PROVISIONER:GetSelectedRecipeIndex(), LINK_STYLE_BRACKETS))
+    local link = GetItemLinkName(GetRecipeResultItemLink(PROVISIONER:GetSelectedRecipeListIndex(), PROVISIONER:GetSelectedRecipeIndex(), LINK_STYLE_BRACKETS)))

     if type(SousChef.settings.shoppingList[link]) ~= "table" then SousChef.settings.shoppingList[link]  = {} end

@@ -211,7 +211,6 @@ local function CalculateHowManyCouldBeCreated(recipeListIndex, recipeIndex, numI
     return minCount or 0
 end

--- XXX FIXME
 -- This is an almost direct clone of the existing function
 -- Except for two parts.
 -- 1) Storing the parent in the data (for each category of recipe)
@@ -270,7 +269,7 @@ function SousChef:RefreshRecipeList()
 	ZO_CheckButton_SetEnableState(self.haveSkillsCheckBox, hasAnyRecipesInTab)
 	ZO_CheckButton_SetEnableState(SousChef.qualityCheckBox, hasAnyRecipesInTab)
     if not hasRecipesWithFilter then
-		if knowAnyRecipesInTab then
+		if hasAnyRecipesInTab then
 			self.noRecipesLabel:SetText(GetString(SI_PROVISIONER_NO_MATCHING_RECIPES))
 		else
 			self.noRecipesLabel:SetText(GetString(self.filterType == PROVISIONER_SPECIAL_INGREDIENT_TYPE_SPICES and SI_PROVISIONER_NO_COOKING_RECIPES or SI_PROVISIONER_NO_BREWING_RECIPES))
diff --git a/SousChef.lua b/SousChef.lua
index d1fac24..9ba493d 100644
--- a/SousChef.lua
+++ b/SousChef.lua
@@ -34,12 +34,27 @@ if SousChef.lang ~= "en" and SousChef.lang ~= "de" and SousChef.lang ~= "fr" the
 local rowHandler = {}

 local typeIconLookup = {
+	-- en
 	["Grilled"] = 9,
 	["Bread and Pies"] = 10,
 	["Soup and Stew"] = 11,
 	["Beer"] = 12,
 	["Spirits"] = 13,
-	["Wine"] = 14
+	["Wine"] = 14,
+	-- de
+	["Gegrillt"] = 9,
+	["Brot und Kuchen"] = 10,
+	["Suppen und Eintöpfe"] = 11,
+	["Bier"] = 12,
+	["Getränke"] = 13,
+	["Wein"] = 14,
+	-- fr
+	["Grillades"] = 9,
+	["Pain et Tartes"] = 10,
+	["Soupe et Ragoût"] = 11,
+	["Bi\195\169re"] = 12,
+	["Spiritueux"] = 13,
+	["Vin"] = 14,
 }


@@ -81,7 +96,7 @@ function SousChef:ParseRecipes()
 				local _, _, ingredientCount, level, _, specialType = GetRecipeInfo(listIndex, recipeIndex)
 				-- store the recipe's index numbers and number of ingredients
 				-- XXX: why does this table get indexed with the formatted item name, but the Pantry table uses the whole link?
-				SousChef.CookbookIndex[zo_strformat(SI_TOOLTIP_ITEM_NAME, GetRecipeResultItemLink(listIndex, recipeIndex, LINK_STYLE_BRACKETS))] =
+				SousChef.CookbookIndex[GetItemLinkName(GetRecipeResultItemLink(listIndex, recipeIndex, LINK_STYLE_BRACKETS))] =
 					{listIndex = listIndex, recipeIndex = recipeIndex, numIngredients = ingredientCount}
 				-- now, for every ingredient in the current recipe...
 				for ingredientIndex = 1, ingredientCount do
@@ -95,16 +110,16 @@ function SousChef:ParseRecipes()
                         SousChef.settings.Pantry[link] = math.max(level, SousChef.Pantry[link] or 0)
                     else
 						-- if this is a special ingredient, record:
-						-- 						type icon number if user wants type icons,								7 if ingredient is a flavoring,																8 otherwise (ie, ingredient is a spice)
+						-- 						type icon number if user wants type icons,								7 if ingredient is a flavoring,						8 otherwise (ie, ingredient is a spice)
                         SousChef.Pantry[link] = SousChef.settings.typeIcon and typeIconLookup[name] or specialType == PROVISIONER_SPECIAL_INGREDIENT_TYPE_FLAVORING and 7 or 8
                         SousChef.settings.Pantry[link] = SousChef.settings.typeIcon and typeIconLookup[name] or specialType == PROVISIONER_SPECIAL_INGREDIENT_TYPE_FLAVORING and 7 or 8
                     end
 					-- Store the recipe it's used in to the character reverseCookbook
 					if not SousChef.ReverseCookbook[link] then SousChef.ReverseCookbook[link] = {} end
-					AddRecipe(SousChef.ReverseCookbook[link], zo_strformat(SI_TOOLTIP_ITEM_NAME, GetRecipeResultItemLink(listIndex, recipeIndex, LINK_STYLE_BRACKETS)))
+					AddRecipe(SousChef.ReverseCookbook[link], GetItemLinkName(GetRecipeResultItemLink(listIndex, recipeIndex, LINK_STYLE_BRACKETS)))
 					-- ...and to the account-wide reverseCookbook
 					if not SousChef.settings.ReverseCookbook[link] then SousChef.settings.ReverseCookbook[link] = {} end
-					AddRecipe(SousChef.settings.ReverseCookbook[link], zo_strformat(SI_TOOLTIP_ITEM_NAME, GetRecipeResultItemLink(listIndex, recipeIndex, LINK_STYLE_BRACKETS)))
+					AddRecipe(SousChef.settings.ReverseCookbook[link], GetItemLinkName(GetRecipeResultItemLink(listIndex, recipeIndex, LINK_STYLE_BRACKETS)))
 				end
 			end
 		end
@@ -369,13 +384,22 @@ local function SousChef_Loaded(eventCode, addOnName)
 	-- Fetch the saved variables
     SousChef.settings = ZO_SavedVars:NewAccountWide("SousChef_Settings", 9, SousChef.lang, defaults)

-	-- replaced with ZO's NonContiguousCount()
-	-- local function tablelength(T)
-		-- local count = 0
-		-- for _ in pairs(T) do count = count + 1 end
-		-- return count
-	-- end
+	-- redo some saved vars with the new format
+	for ingredient, recipes in pairs(SousChef.settings.ReverseCookbook) do
+		for index, linkOrName in pairs(recipes) do
+			if (string.find(linkOrName, "|H1:", 1, true) ~= nil) then
+				linkOrName = GetItemLinkName(linkOrName)
+			end
+		end
+	end

+	for recipe, chars in pairs(SousChef.settings.shoppingList) do
+		if (string.find(recipe, "|H1:", 1, true) ~= nil) then
+			SousChef.settings.shoppingList[GetItemLinkName(recipe)] = chars
+			SousChef.settings.shoppingList[recipe] = nil
+		end
+	end
+
 	-- define some slash commands
 	SLASH_COMMANDS['/scstats'] = function()
 		d(localized.SC_NUM_RECIPES_KNOWN.. NonContiguousCount(SousChef.settings.Cookbook))
diff --git a/Strings.lua b/Strings.lua
index d896308..975231a 100644
--- a/Strings.lua
+++ b/Strings.lua
@@ -60,6 +60,7 @@ SousChef.Strings = {
 		-- tooltip
 		TOOLTIP_KNOWN_BY = "Known by ",
 		TOOLTIP_USED_IN = "Used in:",
+		TOOLTIP_CREATES = "Creates a Level <<1>> <<2>>", -- where <<1>> is the level and <<2>> is the result name
 	},

 	-- Thanks to sirinsidiator for the German translations here!
@@ -124,6 +125,7 @@ SousChef.Strings = {
 		-- tooltip
 		TOOLTIP_KNOWN_BY = "Gelernt von ",
 		TOOLTIP_USED_IN = "Verwendet in:",
+		TOOLTIP_CREATES = "Creates a Level <<1>> <<2>>", -- where <<1>> is the level and <<2>> is the result name
 	},

 	--Thanks to Ayantir for the French translations here!
@@ -188,5 +190,6 @@ SousChef.Strings = {
 		-- tooltip
 		TOOLTIP_KNOWN_BY = "Connue par ",
 		TOOLTIP_USED_IN = "Utilisé par :",
+		TOOLTIP_CREATES = "Creates a Level <<1>> <<2>>", -- where <<1>> is the level and <<2>> is the result name
 	},
 }
\ No newline at end of file
diff --git a/TradingHouse.lua b/TradingHouse.lua
index a9f66d9..49a3a22 100644
--- a/TradingHouse.lua
+++ b/TradingHouse.lua
@@ -2,31 +2,6 @@ local SousChef = SousChef
 local u = SousChef.Utility
 local m = SousChef.Media

--- function SousChef.AddTradingSlot(row, result)
-	-- local rankIcon = SousChef.getIcon(row)
-
-	-- rankIcon:SetHidden(true)
-    -- if SousChef.settings.processRecipes then
-        -- if u.MatchInIgnoreList(result.name) then return end
-        -- if u.MatchesRecipe(result.name) then
-            -- local match = u.MatchInCookbook(result.name)
-            -- local gmatch = u.MatchInGlobalCookbook(result.name)
-            -- if (match and SousChef.settings.checkKnown == "known") or
-               -- (not match and SousChef.settings.checkKnown == "unknown")then
-                -- rankIcon:SetDimensions(30, 30)
-                -- rankIcon:SetAnchor(CENTER, row, CENTER, 230)
-                -- 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
-
 function SousChef.HookTrading(...)
     if SousChef.hookedDataFunction then return end
     SousChef.hookedDataFunction = TRADING_HOUSE.m_searchResultsList.dataTypes[1].setupCallback
diff --git a/Utility.lua b/Utility.lua
index 638ef5d..0222cdd 100644
--- a/Utility.lua
+++ b/Utility.lua
@@ -42,10 +42,6 @@ function u.CleanString(entry)
     return u.Compress(entry):lower()
 end

-function u.MatchesRecipe(entry)
-    return u.CleanString(entry):find(u.CleanString(GetString(SI_ITEMTYPE29)))
-end
-
 function u.TableKeyConcat(t)
     local tt = {}
     for k in pairs(t) do tt[#tt+1]=k end