Partial adjustments to spice/flavouring and attempt at hooking into the provisioning panel

Wobin [04-28-14 - 18:12]
Partial adjustments to spice/flavouring and attempt at hooking into the provisioning panel
Filename
SousChef.lua
diff --git a/SousChef.lua b/SousChef.lua
index 16573de..94ba325 100644
--- a/SousChef.lua
+++ b/SousChef.lua
@@ -25,8 +25,8 @@ local COOKING_RANK_4B = [[SousChef\media\Four_flat.dds]]
 local COOKING_RANK_5B = [[SousChef\media\Five_flat.dds]]
 local COOKING_RANK_6B = [[SousChef\media\Six_flat.dds]]

-local COOKING = { COOKING_RANK_1, COOKING_RANK_2, COOKING_RANK_3, COOKING_RANK_4, COOKING_RANK_5, COOKING_RANK_6 }
-local COOKINGB = { COOKING_RANK_1B, COOKING_RANK_2B, COOKING_RANK_3B, COOKING_RANK_4B, COOKING_RANK_5B, COOKING_RANK_6B }
+local COOKING = { COOKING_RANK_1, COOKING_RANK_2, COOKING_RANK_3, COOKING_RANK_4, COOKING_RANK_5, COOKING_RANK_6, COOKING_RANK_5B, COOKING_RANK_6B }
+local COOKINGB = { COOKING_RANK_1B, COOKING_RANK_2B, COOKING_RANK_3B, COOKING_RANK_4B, COOKING_RANK_5B, COOKING_RANK_6B, COOKING_RANK_5, COOKING_RANK_6 }

 local CANLEARN = [[/esoui/art/loot/loot_finesseitem.dds]]
 local containerHooks = { INVENTORY_BACKPACK, INVENTORY_BANK, INVENTORY_GUILD_BANK }
@@ -249,12 +249,17 @@ local function ParseRecipes()
                     SousChef.settings.Cookbook[recipeName] = {}
 				end
                 SousChef.settings.Cookbook[recipeName][GetUnitName("player")] = true
-				local _, _, ingredientCount, level = GetRecipeInfo(listIndex, recipeIndex)
+				local _, _, ingredientCount, level, _, specialType = GetRecipeInfo(listIndex, recipeIndex)
 				for ingredientIndex = 1, ingredientCount do
 					local link = GetItemID(GetRecipeIngredientItemLink(listIndex, recipeIndex, ingredientIndex, LINK_STYLE_NORMAL))
 					-- Store the fact that the ingredient is used
-                    SousChef.Pantry[link] = math.max(level, SousChef.Pantry[link] or 0)
-                    SousChef.settings.Pantry[link] = math.max(level, SousChef.Pantry[link] or 0)
+                    if ingredientIndex < 3 then
+                        SousChef.Pantry[link] = math.max(level, SousChef.Pantry[link] or 0)
+                        SousChef.settings.Pantry[link] = math.max(level, SousChef.Pantry[link] or 0)
+                    else
+                        SousChef.Pantry[link] = specialType == PROVISIONER_SPECIAL_INGREDIENT_TYPE_FLAVORING and 7 or 8
+                        SousChef.settings.Pantry[link] = specialType == PROVISIONER_SPECIAL_INGREDIENT_TYPE_FLAVORING and 7 or 8
+                    end
 					-- Store the recipe it's used in
 					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)))
@@ -310,6 +315,35 @@ local function SousChefCreateSettings()
                         function(value) SousChef.settings.experimentalMatch = not SousChef.settings.experimentalMatch end)
 end

+
+function HookRecipeTreeFunction()
+    -- Hook the provisioning panel
+    if not SousChef.hookedProvisioningFunction then
+        local count = 1
+        local ref = _G["ZO_ProvisionerTopLevelNavigationContainerScrollChildZO_ProvisionerNavigationEntry" .. count]
+        while ref do
+            SousChef.hookedProvisioningFunction = ref.node.setupFunction
+            ref.node.setupFunction =
+            function(...)
+                local node, control, data, open, userRequested, enabled = ...
+                d("setup " .. data.name)
+                SousChef.hookedProvisioningFunction(...)
+            end
+        count = count + 1
+        ref = _G["ZO_ProvisionerTopLevelNavigationContainerScrollChildZO_ProvisionerNavigationEntry" .. count]
+        end
+        d(count)
+        ZO_ProvisionerTopLevelNavigationContainerScrollChildZO_ProvisionerNavigationEntry1.node.parentNode.parentNode:RefreshVisible(true)
+    end
+end
+
+local function HookRecipeTree(...)
+    local eventId, craftingTable = ...
+    if craftingTable ~= CRAFTING_TYPE_PROVISIONING then return end
+    zo_callLater(HookRecipeTreeFunction, 1000)
+end
+
+
 local function HookTrading(...)
 	if SousChef.hookedDataFunction then return end
     SousChef.hookedDataFunction = ZO_TradingHouseItemPaneSearchResults.dataTypes[1].setupCallback
@@ -370,14 +404,17 @@ local function SousChef_Loaded(eventCode, addOnName)
 					AddRankToSlot(rowControl)
 				end
 		end
-	end
+    end
+
 	ZO_ScrollList_RefreshVisible(BACKPACK)
 	ZO_ScrollList_RefreshVisible(BANK)
 	ZO_ScrollList_RefreshVisible(GUILD_BANK)

-	EVENT_MANAGER:RegisterForEvent("SousChefTRading", EVENT_TRADING_HOUSE_RESPONSE_RECEIVED, HookTrading)
+	EVENT_MANAGER:RegisterForEvent("SousChefTrading", EVENT_TRADING_HOUSE_RESPONSE_RECEIVED, HookTrading)
 	EVENT_MANAGER:RegisterForEvent("SousChefLearnt", EVENT_RECIPE_LEARNED, ParseRecipes)
-
+
+    EVENT_MANAGER:RegisterForEvent("SousChefProvi", EVENT_CRAFTING_STATION_INTERACT, HookRecipeTree)
+
 end

 local function SousChef_Initialized()