Added in option to show Flavourings and Spices by the type of food they're for, eg Grilled, or Wine

Wobin [05-08-14 - 11:53]
Added in option to show Flavourings and Spices by the type of food they're for, eg Grilled, or Wine
Filename
Common.lua
Inventory.lua
SousChef.lua
Utility.lua
diff --git a/Common.lua b/Common.lua
index f1e83bd..2dbdd7e 100644
--- a/Common.lua
+++ b/Common.lua
@@ -23,8 +23,15 @@ local COOKING_RANK_6B = [[SousChef\media\Six_flat.dds]]
 local COOKING_FLAVOURB = [[SousChef\media\flavour_flat.dds]]
 local COOKING_RANK_1 = [[SousChef\media\One.dds]]

-m.COOKING = { COOKING_RANK_1, COOKING_RANK_2, COOKING_RANK_3, COOKING_RANK_4, COOKING_RANK_5, COOKING_RANK_6, COOKING_FLAVOUR, COOKING_SPICE }
-m.COOKINGB = { COOKING_RANK_1B, COOKING_RANK_2B, COOKING_RANK_3B, COOKING_RANK_4B, COOKING_RANK_5B, COOKING_RANK_6B, COOKING_FLAVOURB, COOKING_SPICEB }
+local GRILLED  = [[/esoui/art/treeicons/provisioner_indexicon_meat_down.dds]]
+local BREADPIE  = [[/esoui/art/treeicons/provisioner_indexicon_baked_down.dds]]
+local SOUPSTEW  = [[/esoui/art/treeicons/provisioner_indexicon_stew_down.dds]]
+local BEER  = [[/esoui/art/treeicons/provisioner_indexicon_beer_down.dds]]
+local SPIRITS  = [[/esoui/art/treeicons/provisioner_indexicon_spirits_down.dds]]
+local WINE  = [[/esoui/art/treeicons/provisioner_indexicon_wine_down.dds]]
+
+m.COOKING = { COOKING_RANK_1, COOKING_RANK_2, COOKING_RANK_3, COOKING_RANK_4, COOKING_RANK_5, COOKING_RANK_6, COOKING_FLAVOUR, COOKING_SPICE, GRILLED, BREADPIE, SOUPSTEW, BEER, SPIRITS, WINE}
+m.COOKINGB = { COOKING_RANK_1B, COOKING_RANK_2B, COOKING_RANK_3B, COOKING_RANK_4B, COOKING_RANK_5B, COOKING_RANK_6B, COOKING_FLAVOURB, COOKING_SPICEB, GRILLED, BREADPIE, SOUPSTEW, BEER, SPIRITS, WINE}

 m.CANLEARN = [[/esoui/art/loot/loot_finesseitem.dds]]

diff --git a/Inventory.lua b/Inventory.lua
index 1e89ef5..0ff6de1 100644
--- a/Inventory.lua
+++ b/Inventory.lua
@@ -8,7 +8,7 @@ function SousChef.AddRankToSlot(row, funcs)
     local bagId = slot[funcs[2]]
     local slotIndex = funcs[3] and slot[funcs[3]] or nil

-    if not bagId or not slot.name or slot.name == "" then return end
+    if not slot.name or slot.name == "" then return end

 	local rankIcon = SousChef.getIcon(row)

@@ -25,6 +25,8 @@ function SousChef.AddRankToSlot(row, funcs)

 	rankIcon:SetHidden(true)

+	if not bagId then return end
+
 	local id = u.GetItemID(idFunc(bagId, slotIndex))
 	local texture = SousChef.Pantry[id]
 	if SousChef.settings.showAltKnowledge then texture = SousChef.settings.Pantry[id] end
diff --git a/SousChef.lua b/SousChef.lua
index 045f7d1..c220e51 100644
--- a/SousChef.lua
+++ b/SousChef.lua
@@ -36,6 +36,15 @@ local function AddRecipe(Cookbook, link)
 	table.insert(Cookbook, link)
 end

+local typeIconLookup = {
+	["Grilled"] = 9,
+	["Bread and Pies"] = 10,
+	["Soup and Stew"] = 11,
+	["Beer"] = 12,
+	["Spirits"] = 13,
+	["Wine"] = 14
+}
+
 function SousChef:ParseRecipes()
 	local lists = GetNumRecipeLists()
 	for listIndex = 1, lists do
@@ -57,8 +66,8 @@ function SousChef:ParseRecipes()
                         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
+                        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
 					if not SousChef.ReverseCookbook[link] then SousChef.ReverseCookbook[link] = {} end
@@ -113,7 +122,18 @@ local function SousChefCreateSettings()
 						function(value) SousChef.settings.boldIcon = not SousChef.settings.boldIcon end)
 	LAM:AddCheckbox(panel, "specialIngredients", "Show special ingredients", "Indicate if an ingredient is considered a Spice/Flavour rather than the tier of the max ranked recipe you have that uses it",
 						function() return SousChef.settings.showSpecialIngredients end,
-						function(value) SousChef.settings.showSpecialIngredients = not SousChef.settings.showSpecialIngredients SousChef.ParseRecipes() end)
+						function(value)
+							SousChef.settings.showSpecialIngredients = not SousChef.settings.showSpecialIngredients
+							if SousChef.settings.showSpecialIngredients then
+								ZO_Options_SetOptionActive(typeIcons)
+							else
+								ZO_Options_SetOptionInactive(typeIcons)
+							end
+							SousChef.ParseRecipes()
+						end)
+	LAM:AddCheckbox(panel, "typeIcons", "Show special ingredients as types", "Use the icon for the type of food it's a special ingredient for, eg Grilled",
+						function() return SousChef.settings.typeIcon end,
+						function(value) SousChef.settings.typeIcon = not SousChef.settings.typeIcon SousChef.ParseRecipes() end)
 	LAM:AddColorPicker(panel, "setColour", "Indicator colour",
 						"Allows you to set the colour of the indicator",
 						function() return SousChef.settings.colour[1], SousChef.settings.colour[2], SousChef.settings.colour[3] end,
@@ -140,6 +160,12 @@ local function SousChefCreateSettings()
         ZO_Options_SetOptionActive(markLearnt)
         ZO_Options_SetOptionActive(markAltKnows)
     end
+
+    if SousChef.settings.showSpecialIngredients then
+		ZO_Options_SetOptionActive(typeIcons)
+	else
+		ZO_Options_SetOptionInactive(typeIcons)
+	end
 end


@@ -161,6 +187,7 @@ local function SousChef_Loaded(eventCode, addOnName)
 		ReverseCookbook = {},
 		showAltKnowledge = false,
 		boldIcon = false,
+		typeIcon = true,
         experimentalMatch = false,
         processRecipes = true,
         showSpecialIngredients = false,
diff --git a/Utility.lua b/Utility.lua
index 1370209..e2d9467 100644
--- a/Utility.lua
+++ b/Utility.lua
@@ -27,6 +27,7 @@ function u.StripLanguageIdentifiers(entry)
 end

 function u.Compress(entry)
+    if not entry or entry == "" then return "" end
     for _,v in pairs(separators) do
         entry = entry:gsub(v, "")
     end