diff --git a/Provisioning.lua b/Provisioning.lua
index 386cef0..59d0639 100644
--- a/Provisioning.lua
+++ b/Provisioning.lua
@@ -7,7 +7,7 @@ local str = SousChef.Strings[SousChef.lang]
function SousChef:UpdateProvisioningTable()
local function OnFilterChanged()
self.settings.qualityChecked = ZO_CheckButton_IsChecked(self.qualityCheckBox)
- PROVISIONER:DirtyRecipeTree()
+ PROVISIONER:DirtyRecipeList()
end
-- set up the quality checkbox
self.qualityCheckBox = SousChef_ControllerOnlyQuality
@@ -20,9 +20,6 @@ function SousChef:UpdateProvisioningTable()
-- make room for the checkbox
if SousChef.lang == "fr" then
-- the french strings are really long and need extra room
- --ZO_ProvisionerTopLevelHaveIngredients:ClearAnchors()
- --ZO_ProvisionerTopLevelHaveIngredients:SetAnchor(TOPLEFT, ZO_ProvisionerTopLevelMenuBarDivider, TOPLEFT, -20, 16)
- --ZO_ProvisionerTopLevelHaveSkills:SetAnchor(LEFT, ZO_ProvisionerTopLevelHaveIngredientsLabel, RIGHT, 20)
ZO_ProvisionerTopLevelNavigationDivider:ClearAnchors()
ZO_ProvisionerTopLevelNavigationDivider:SetAnchor(TOPLEFT, ZO_ProvisionerTopLevelMenuBarDivider, BOTTOMLEFT, 0, 62)
self.qualityCheckBox:ClearAnchors()
@@ -33,11 +30,11 @@ function SousChef:UpdateProvisioningTable()
end
-- incorporate new checkbox into the filter
- SousChef.filter = PROVISIONER.DoesRecipePassFilter
- PROVISIONER.DoesRecipePassFilter = function(control, specialIngredientType, numCreatable, provisionerLevelReq, qualityReq)
+ SousChef.filter = ZO_SharedProvisioner.DoesRecipePassFilter
+ ZO_SharedProvisioner.DoesRecipePassFilter = function(control, specialIngredientType, checkNumCreatable, numCreatable, checkSkills, provisionerLevelReq, qualityReq)
if ZO_CheckButton_IsChecked(self.qualityCheckBox) and qualityReq < 2 then return false end
- return SousChef.filter(control, specialIngredientType, numCreatable, provisionerLevelReq, qualityReq)
- end
+ return SousChef.filter(control, specialIngredientType, checkNumCreatable, numCreatable, checkSkills, provisionerLevelReq, qualityReq)
+ end
end
-- this is our "Mark Recipe" button definition
@@ -52,15 +49,16 @@ SousChef.ProvisioningButton=
}}
local bGroup = SousChef.ProvisioningButton
--- SousChef:HookRecipeTreeFunction() adds the "Mark Recipe" button to the keybind bar, and set the provisioning window to display checkmarks by marked recipes
+-- SousChef:HookRecipeTreeFunction() adds the "Mark Recipe" button to the keybind bar, and sets the provisioning window to display checkmarks by marked recipes
function SousChef:HookRecipeTreeFunction()
+ -- now the keybind button
if not KEYBIND_STRIP:HasKeybindButtonGroup(bGroup) then
KEYBIND_STRIP:AddKeybindButtonGroup(bGroup)
else
KEYBIND_STRIP:UpdateKeybindButtonGroup(bGroup)
end
- -- Hook the provisioning panel
+ -- add a space for the checkmark, and hook the entry function to show/hide the checkmark as needed
if not SousChef.hookedProvisioningFunction then
local ref = PROVISIONER.recipeTree.templateInfo.ZO_ProvisionerNavigationEntry
if ref then
@@ -76,7 +74,7 @@ function SousChef:HookRecipeTreeFunction()
end
end
end
- PROVISIONER:DirtyRecipeTree()
+ PROVISIONER:DirtyRecipeList()
end
-- SousChef:getMarkedIcon(row, marked) adds the checkmark next to each marked line in the provisioning window
@@ -141,7 +139,7 @@ function SousChef:MarkRecipe()
end
end
- PROVISIONER:DirtyRecipeTree()
+ PROVISIONER:DirtyRecipeList()
end
function SousChef:HookRecipeTree(...)
@@ -157,15 +155,27 @@ function SousChef:UnhookRecipeTree()
end
function SousChef:HookGetRecipeInfo()
+ -- first, add the pretty colors to the recipe tree if they aren't there already
+ if SousChef.OldZO_ProvisionerRow_GetTextColor == nil then
+ SousChef.OldZO_ProvisionerRow_GetTextColor = ZO_ProvisionerRow_GetTextColor
+ ZO_ProvisionerRow_GetTextColor = function(self)
+ return SousChef.ZO_ProvisionerRow_GetTextColor(self)
+ end
+ end
+
if SousChef.settings.sortProvisioningTable then
- SousChef.OldRefreshRecipeTree = ZO_Provisioner.RefreshRecipeTree
- ZO_Provisioner.RefreshRecipeTree = function()
- return SousChef.RefreshRecipeTree(PROVISIONER)
+ SousChef.OldRefreshRecipeList = ZO_Provisioner.RefreshRecipeList
+ ZO_Provisioner.RefreshRecipeList = function()
+ return SousChef.RefreshRecipeList(PROVISIONER)
end
end
- SousChef.OldZO_ProvisionerRow_GetTextColor = ZO_ProvisionerRow_GetTextColor
- ZO_ProvisionerRow_GetTextColor = function(self)
- return SousChef.ZO_ProvisionerRow_GetTextColor(self)
+end
+
+function SousChef:UnhookGetRecipeInfo()
+ if not SousChef.settings.sortProvisioningTable then
+ if SousChef.OldRefreshRecipeList ~= nil then
+ ZO_Provisioner.RefreshRecipeList = SousChef.OldRefreshRecipeList
+ end
end
end
@@ -201,16 +211,20 @@ 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)
-- 2) Putting them all in a table first, then sorting, then adding them to the tree
-function SousChef:RefreshRecipeTree()
+function SousChef:RefreshRecipeList()
self.dirty = false
self.recipeTree:Reset()
- local hasAnyRecipes = false
+ local hasAnyRecipesInTab = false
+ local hasRecipesWithFilter = false
+ local checkNumCreatable = ZO_CheckButton_IsChecked(self.haveIngredientsCheckBox)
+ local checkSkills = ZO_CheckButton_IsChecked(self.haveSkillsCheckBox)
local RecipeLines = {}
for recipeListIndex = 1, GetNumRecipeLists() do
local recipeListName, numRecipes, upIcon, downIcon, overIcon, disabledIcon, createSound = GetRecipeListInfo(recipeListIndex)
@@ -219,9 +233,9 @@ function SousChef:RefreshRecipeTree()
for recipeIndex = 1, numRecipes do
local known, recipeName, numIngredients, provisionerLevelReq, qualityReq, specialIngredientType = GetRecipeInfo(recipeListIndex, recipeIndex)
local useLevelReq = GetItemLinkRequiredLevel(GetRecipeResultItemLink(recipeListIndex, recipeIndex))
- if known then
- local numCreatable = CalculateHowManyCouldBeCreated(recipeListIndex, recipeIndex, numIngredients)
- if self:DoesRecipePassFilter(specialIngredientType, numCreatable, provisionerLevelReq, qualityReq) then
+ if known and self.filterType == specialIngredientType then
+ local numCreatable = self:CalculateHowManyCouldBeCreated(recipeListIndex, recipeIndex, numIngredients)
+ if self:DoesRecipePassFilter(specialIngredientType, checkNumCreatable, numCreatable, checkSkills, provisionerLevelReq, qualityReq) then
parent = parent or self.recipeTree:AddNode("ZO_IconHeader", { recipeListIndex = recipeListIndex, name = recipeListName, upIcon = upIcon, downIcon = downIcon, overIcon = overIcon, disabledIcon = disabledIcon }, nil, SOUNDS.PROVISIONING_BLADE_SELECTED)
local data = {
recipeListIndex = recipeListIndex,
@@ -234,12 +248,13 @@ function SousChef:RefreshRecipeTree()
numIngredients = numIngredients,
numCreatable = numCreatable,
createSound = createSound,
- parent = parent
+ parent = parent,
}
table.insert(RecipeLines, data)
- hasAnyRecipes = true
+ hasRecipesWithFilter = true
end
+ hasAnyRecipesInTab = true
end
end
end
@@ -248,11 +263,21 @@ function SousChef:RefreshRecipeTree()
for i,data in ipairs(RecipeLines) do
self.recipeTree:AddNode("ZO_ProvisionerNavigationEntry", data, data.parent, SOUNDS.PROVISIONING_ENTRY_SELECTED)
end
-
self.recipeTree:Commit()
- self.noRecipesLabel:SetHidden(hasAnyRecipes)
- if not hasAnyRecipes then
+ self.noRecipesLabel:SetHidden(hasRecipesWithFilter)
+ ZO_CheckButton_SetEnableState(self.haveIngredientsCheckBox, hasAnyRecipesInTab)
+ ZO_CheckButton_SetEnableState(self.haveSkillsCheckBox, hasAnyRecipesInTab)
+ ZO_CheckButton_SetEnableState(SousChef.qualityCheckBox, hasAnyRecipesInTab)
+ if not hasRecipesWithFilter then
+ if knowAnyRecipesInTab 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))
+ ZO_CheckButton_SetChecked(self.haveIngredientsCheckBox)
+ ZO_CheckButton_SetChecked(self.haveSkillsCheckBox)
+ ZO_CheckButton_SetUnchecked(SousChef.qualityCheckBox)
+ end
self:RefreshRecipeDetails()
end
end
diff --git a/SousChef.lua b/SousChef.lua
index 4c83b06..d1fac24 100644
--- a/SousChef.lua
+++ b/SousChef.lua
@@ -205,7 +205,14 @@ local function SousChefCreateSettings()
name = str.MENU_SORT_PROVISIONING,
tooltip = str.MENU_SORT_PROVISIONING_TOOLTIP,
getFunc = function() return SousChef.settings.sortProvisioningTable end,
- setFunc = function(value) SousChef.settings.sortProvisioningTable = value end,
+ setFunc = function(value)
+ SousChef.settings.sortProvisioningTable = value
+ if value then
+ SousChef:HookGetRecipeInfo()
+ else
+ SousChef:UnhookGetRecipeInfo()
+ end
+ end,
},
[8] = {