Changed to offer mouseover tooltip

Wobin [05-04-14 - 16:32]
Changed to offer mouseover tooltip
Filename
Common.lua
SousChef.lua
diff --git a/Common.lua b/Common.lua
index dad482b..5d8fda4 100644
--- a/Common.lua
+++ b/Common.lua
@@ -56,15 +56,21 @@ function SousChef.getIcon(row)
 	local rankIcon = SousChef.slotLines[row:GetName()]
 	if(not rankIcon) then
 		rankIcon =  WINDOW_MANAGER:CreateControl(row:GetName() .. "SousChef", row, CT_TEXTURE)
-        SousChef.slotLines[row:GetName()] = rankIcon
-		ZO_PreHookHandler(row, "OnMouseDown", SousChef.AddDetails)
-		ZO_PreHookHandler(row, "OnMouseExit", function(self) rowClicked[self] = nil return false end )
+        SousChef.slotLines[row:GetName()] = rankIcon
+        if SousChef.settings.showOnClick then
+        	ZO_PreHookHandler(row, "OnMouseDown", SousChef.AddDetails)
+        	ZO_PreHookHandler(row, "OnMouseExit", function(self) rowClicked = nil return false end )
+        else
+			ZO_PreHookHandler(ItemTooltip, "OnUpdate", function() return SousChef.AddDetails(moc()) end)
+			ZO_PreHookHandler(ItemTooltip, "OnHide", function() rowClicked = nil return false end )
+		end
 	end
 	return rankIcon
 end

 function SousChef.AddDetails(row)
-	if not row.dataEntry or not row.dataEntry.data or rowClicked[row] then return false end
+	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 slotIndex = rowInfo.slotIndex
@@ -72,11 +78,10 @@ function SousChef.AddDetails(row)
 	if u.MatchesRecipe(rowInfo.name) then
         local gmatch = u.MatchInGlobalCookbook(rowInfo.name)
         if gmatch then
-            ItemTooltip:AddLine("")
+            ZO_Tooltip_AddDivider(ItemTooltip)
             ItemTooltip:AddLine("Known by ", "ZoFontWinH5", 1,1,1, BOTTOM, MODIFY_TEXT_TYPE_UPPERCASE)
             ItemTooltip:AddLine(u.TableKeyConcat(gmatch))
-            rowClicked[row] = true
-            return
+            return false
         end
     end

@@ -84,25 +89,25 @@ function SousChef.AddDetails(row)

 	local usableIngredient = SousChef.ReverseCookbook[u.GetItemID(GetItemLink(bagId, slotIndex))]
 	if SousChef.settings.showAltKnowledge then usableIngredient = SousChef.settings.ReverseCookbook[u.GetItemID(GetItemLink(bagId, slotIndex))] end
-	if usableIngredient then
+	if usableIngredient then
+		ZO_Tooltip_AddDivider(ItemTooltip)
 		ItemTooltip:AddLine("Used in:", "ZoFontWinH5", 1,1,1, BOTTOM, MODIFY_TEXT_TYPE_UPPERCASE)
 	    for i,v in ipairs(usableIngredient) do
 	    	ItemTooltip:AddLine(v)
-	    end
-		rowClicked[row] = true
-	end
+	    end
+	end
 	return false
 end

 function SousChef.AddRecipeToIgnoreList(link)
-	if GetItemLinkInfo(link) ~= "" then link = string.match(link, "([ %a]+)%]") end
+	if GetItemLinkInfo(link) ~= "" then link = string.match(link, "([%w\128-\244 ]+)%]") end
 	SousChef.settings.ignoredRecipes[link] = true
 	d("Adding " .. link .. " to ignored recipes")

 end

 function SousChef.RemoveRecipeFromIgnoreList(link)
-	if GetItemLinkInfo(link) ~= "" then link = string.match(link, "([ %a]+)%]") end
+	if GetItemLinkInfo(link) ~= "" then link = string.match(link, "([%w\128-\244 ]+)%]") end
 	if not SousChef.settings.ignoredRecipes[link] then d(link .. " not found in ignore list") return end
 	SousChef.settings.ignoredRecipes[link] = nil
 	d("Removed " .. link .. " from ignored recipes")
diff --git a/SousChef.lua b/SousChef.lua
index 31e880c..760bb0d 100644
--- a/SousChef.lua
+++ b/SousChef.lua
@@ -87,7 +87,7 @@ local function SousChefCreateSettings()
                         function() return SousChef.settings.processRecipes end,
                         function(value)
                             SousChef.settings.processRecipes = not SousChef.settings.processRecipes
-                            if SousChef.settings.processRecipes then
+                            if not SousChef.settings.processRecipes then
                                 ZO_Options_SetOptionInactive(markLearnt)
                                 ZO_Options_SetOptionInactive(markAltKnows)
                             else
@@ -105,6 +105,9 @@ local function SousChefCreateSettings()
 	LAM:AddCheckbox(panel, "showAltKnows", "Alternate Character Recipe Knowledge", "Show rank indicators on alts for all recipe knowledge of all alternate characters",
 						function() return SousChef.settings.showAltKnowledge end,
 						function(value) SousChef.settings.showAltKnowledge = not SousChef.settings.showAltKnowledge end)
+	LAM:AddCheckbox(panel, "showOnClickOnly", "Show in Tooltip only on click", "Only show details on a left click to save space (requires /reloadui)",
+						function() return SousChef.settings.showOnClick end,
+						function(value) SousChef.settings.showOnClick = not SousChef.settings.showOnClick end)
 	LAM:AddCheckbox(panel, "useBold", "Use bolder icons", "Swap out rank icon to a more flat display",
 						function() return SousChef.settings.boldIcon end,
 						function(value) SousChef.settings.boldIcon = not SousChef.settings.boldIcon end)
@@ -117,9 +120,17 @@ local function SousChefCreateSettings()
 						function(r,g,b) SousChef.settings.colour[1] = r; SousChef.settings.colour[2] = g; SousChef.settings.colour[3] = b end)
     LAM:AddCheckbox(panel, "experimental", "Use the experimental recipe matcher", [[Currently Sous Chef cannot match reliably in other languages. This will attempt to match as best it can by stripping out common prepositions so that the recipe and result match better.

-    (NOTE: please file a bug report if you find recipes that don't match the results exactly, with the recipe/result names and/or screenshots so I can update this dictionary)]],
+    (NOTE: please file a typo bug report with Zenimax if you find recipes that don't match the results exactly, with the recipe/result names)]],
                         function() return SousChef.settings.experimentalMatch end,
                         function(value) SousChef.settings.experimentalMatch = not SousChef.settings.experimentalMatch end)
+
+      if not SousChef.settings.processRecipes then
+        ZO_Options_SetOptionInactive(markLearnt)
+        ZO_Options_SetOptionInactive(markAltKnows)
+    else
+        ZO_Options_SetOptionActive(markLearnt)
+        ZO_Options_SetOptionActive(markAltKnows)
+    end
 end


@@ -143,7 +154,8 @@ local function SousChef_Loaded(eventCode, addOnName)
         experimentalMatch = false,
         processRecipes = true,
         showSpecialIngredients = false,
-        ignoredRecipes = {}
+        ignoredRecipes = {},
+        showOnClick = false
 	}

     SousChef.settings = ZO_SavedVars:NewAccountWide("SousChef_Settings", 8, nil, defaults)