diff --git a/Provisioning.lua b/Provisioning.lua
index 44df00a..f6000a2 100644
--- a/Provisioning.lua
+++ b/Provisioning.lua
@@ -119,7 +119,15 @@ end
function SousChef:IsOnShoppingList(id)
for i,v in ipairs(SousChef.settings.ReverseCookbook[id]) do
- if type(SousChef.settings.shoppingList[v]) == "table" and next(SousChef.settings.shoppingList[v]) then return SousChef.settings.shoppingList[v] end
+ if type(SousChef.settings.shoppingList[v]) == "table" and next(SousChef.settings.shoppingList[v]) then
+ if SousChef.settings.showAltShopping then
+ return true
+ else
+ if SousChef.settings.shoppingList[v][SousChef.settings.mainChar] then
+ return true
+ end
+ end
+ end
end
return false
end
diff --git a/SousChef.lua b/SousChef.lua
index 4c2ab89..88582b5 100644
--- a/SousChef.lua
+++ b/SousChef.lua
@@ -10,7 +10,7 @@ Thanks to Ayantir for the French translations, and sirinsidiator for the German
SousChef = {}
SousChef.Utility = {}
SousChef.Media = {}
-SousChef.version = "2.16"
+SousChef.version = "2.17"
local SousChef = SousChef
local u = SousChef.Utility
@@ -74,8 +74,31 @@ function SousChef:RefreshViews()
ZO_ScrollList_RefreshVisible(GUILD_BANK)
end
+-- every time you change the main character in the settings menu, you need to update the "player" cookbook, cookbook index, pantry, and reverse cookbook with the new character's data
+local function ChangeMainChar()
+ SousChef.CookbookIndex = SousChef.settings.CookbookIndex[SousChef.settings.mainChar]
+
+ SousChef.Cookbook = {}
+ SousChef.Pantry = {}
+ SousChef.ReverseCookbook = {}
+ for name, data in pairs(SousChef.CookbookIndex) do
+ SousChef.Cookbook[u.CleanString((GetRecipeResultItemInfo(data.listIndex, data.recipeIndex)))] = true
+ local _, _, _, level, _, specialType = GetRecipeInfo(listIndex, recipeIndex)
+ for ingredient = 1, data.numIngredients do
+ local ingredientID = u.GetItemID(GetRecipeIngredientItemLink(data.listIndex, data.recipeIndex, ingredient))
+ if ingredient < 3 or not SousChef.settings.showSpecialIngredients then
+ SousChef.Pantry[ingredientID] = math.max(level, SousChef.Pantry[ingredientID] or 0)
+ else
+ SousChef.Pantry[ingredientID] = SousChef.settings.typeIcon and typeIconLookup[name] or specialType == PROVISIONER_SPECIAL_INGREDIENT_TYPE_FLAVORING and 7 or 8
+ end
+ if not SousChef.ReverseCookbook[ingredientID] then SousChef.ReverseCookbook[ingredientID] = {} end
+ AddRecipe(SousChef.ReverseCookbook[ingredientID], name)
+ end
+ end
+end
+
-- ParseRecipes() goes through the player's known recipes and records their info.
-function SousChef:ParseRecipes()
+function SousChef:ParseRecipes()
local lists = GetNumRecipeLists()
for listIndex = 1, lists do
@@ -85,11 +108,9 @@ function SousChef:ParseRecipes()
-- Store the recipes known:
local recipeName = u.CleanString((GetRecipeResultItemInfo(listIndex, recipeIndex)))
-- in this character's cookbook
- SousChef.Cookbook[recipeName] = true
+ --SousChef.Cookbook[recipeName] = true
-- and in the settings, so other characters can see what recipes this character knows
- if not SousChef.settings.Cookbook[recipeName] then
- SousChef.settings.Cookbook[recipeName] = {}
- end
+ if not SousChef.settings.Cookbook[recipeName] then SousChef.settings.Cookbook[recipeName] = {} end
SousChef.settings.Cookbook[recipeName][GetUnitName("player")] = true
-- now record information about the recipe's ingregients
@@ -97,7 +118,8 @@ function SousChef:ParseRecipes()
-- store the recipe's index numbers and number of ingredients
local resultLink = GetRecipeResultItemLink(listIndex, recipeIndex)
local coloredName = u.GetColoredLinkName(resultLink)
- SousChef.CookbookIndex[coloredName] = {listIndex = listIndex, recipeIndex = recipeIndex, numIngredients = ingredientCount}
+ if not SousChef.settings.CookbookIndex[GetUnitName("player")] then SousChef.settings.CookbookIndex[GetUnitName("player")] = {} end
+ SousChef.settings.CookbookIndex[GetUnitName("player")][coloredName] = {listIndex = listIndex, recipeIndex = recipeIndex, numIngredients = ingredientCount}
-- now, for every ingredient in the current recipe...
for ingredientIndex = 1, ingredientCount do
local link = u.GetItemID(GetRecipeIngredientItemLink(listIndex, recipeIndex, ingredientIndex, LINK_STYLE_DEFAULT))
@@ -105,18 +127,18 @@ function SousChef:ParseRecipes()
if ingredientIndex < 3 or not SousChef.settings.showSpecialIngredients then
-- if this isn't a special ingredient, or if the user doesn't want special ingredients marked as special, just record the highest-tier recipe this ingredient appears in
-- for this character,
- SousChef.Pantry[link] = math.max(level, SousChef.Pantry[link] or 0)
+ --SousChef.Pantry[link] = math.max(level, SousChef.Pantry[link] or 0)
-- and across characters
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)
- SousChef.Pantry[link] = SousChef.settings.typeIcon and typeIconLookup[name] or 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 to the character reverseCookbook
- if not SousChef.ReverseCookbook[link] then SousChef.ReverseCookbook[link] = {} end
- AddRecipe(SousChef.ReverseCookbook[link], coloredName)
+ --if not SousChef.ReverseCookbook[link] then SousChef.ReverseCookbook[link] = {} end
+ --AddRecipe(SousChef.ReverseCookbook[link], coloredName)
-- ...and to the account-wide reverseCookbook
if not SousChef.settings.ReverseCookbook[link] then SousChef.settings.ReverseCookbook[link] = {} end
AddRecipe(SousChef.settings.ReverseCookbook[link], coloredName)
@@ -124,9 +146,27 @@ function SousChef:ParseRecipes()
end
end
end
+
+ ChangeMainChar()
SousChef:RefreshViews()
end
+-- auto-junk ingredients if they're not in the shopping list
+local function AutoJunker()
+ local bagSize = GetBagSize(BAG_BACKPACK)
+ for i = 0, bagSize do
+ local itemLink = GetItemLink(BAG_BACKPACK, i)
+ if itemLink ~= "" then
+ local itemType = GetItemLinkItemType(itemLink)
+ if itemType == ITEMTYPE_FLAVORING or itemType == ITEMTYPE_SPICE or itemType == ITEMTYPE_INGREDIENT then
+ if not SousChef:IsOnShoppingList(u.GetItemID(itemLink)) then
+ SetItemIsJunk(BAG_BACKPACK, i, true)
+ end
+ end
+ end
+ end
+end
+
-- SousChefCreateSettings() creates the configuration menu for the add-on
local function SousChefCreateSettings()
local str = SousChef.Strings[SousChef.lang]
@@ -158,6 +198,18 @@ local function SousChefCreateSettings()
},
[3] = {
type = "dropdown",
+ name = str.MENU_MAIN_CHAR,
+ tooltip = str.MENU_MAIN_CHAR_TOOLTIP,
+ choices = SousChef.settings.knownChars,
+ getFunc = function() return SousChef.settings.mainChar end,
+ setFunc = function(value)
+ SousChef.settings.mainChar = value
+ ChangeMainChar()
+ end,
+ disabled = function() return not SousChef.settings.processRecipes end,
+ },
+ [4] = {
+ type = "dropdown",
name = str.MENU_MARK_IF_KNOWN,
tooltip = str.MENU_MARK_IF_KNOWN_TOOLTIP,
choices = {str.MENU_KNOWN, str.MENU_UNKNOWN},
@@ -185,7 +237,7 @@ local function SousChefCreateSettings()
end,
disabled = function() return not SousChef.settings.processRecipes end,
},
- [4] = {
+ [5] = {
type = "checkbox",
name = str.MENU_MARK_IF_ALT_KNOWS,
tooltip = str.MENU_MARK_IF_ALT_KNOWS_TOOLTIP,
@@ -193,7 +245,7 @@ local function SousChefCreateSettings()
setFunc = function(value) SousChef.settings.markAlt = value SousChef:RefreshViews() end,
disabled = function() return (not SousChef.settings.processRecipes) or (SousChef.settings.checkKnown == "known") end,
},
- [5] = {
+ [6] = {
type = "checkbox",
name = str.MENU_TOOLTIP_IF_ALT_KNOWS,
tooltip = str.MENU_TOOLTIP_IF_ALT_KNOWS_TOOLTIP,
@@ -201,7 +253,7 @@ local function SousChefCreateSettings()
setFunc = function(value) SousChef.settings.showAltKnowledge = value SousChef:RefreshViews() end,
disabled = function() return not SousChef.settings.processRecipes end,
},
- [6] = {
+ [7] = {
type = "checkbox",
name = str.MENU_MATCHER,
tooltip = str.MENU_MATCHER_TOOLTIP,
@@ -209,7 +261,7 @@ local function SousChefCreateSettings()
setFunc = function(value) SousChef.settings.experimentalMatch = value end,
disabled = function() return not SousChef.settings.processRecipes end,
},
- [7] = {
+ [8] = {
type = "checkbox",
name = str.MENU_SORT_PROVISIONING,
tooltip = str.MENU_SORT_PROVISIONING_TOOLTIP,
@@ -224,12 +276,12 @@ local function SousChefCreateSettings()
end,
},
- [8] = {
+ [9] = {
type = "header",
name = str.MENU_TOOLTIP_HEADER,
width = "full",
},
- [9] = {
+ [10] = {
type = "checkbox",
name = str.MENU_TOOLTIP_CLICK,
tooltip = str.MENU_TOOLTIP_CLICK_TOOLTIP,
@@ -237,14 +289,14 @@ local function SousChefCreateSettings()
getFunc = function() return SousChef.settings.showOnClick end,
setFunc = function(value) SousChef.settings.showOnClick = value end,
},
- [10] = {
+ [11] = {
type = "checkbox",
name = str.MENU_RESULT_COUNTS,
tooltip = str.MENU_RESULT_COUNTS_TOOLTIP,
getFunc = function() return SousChef.settings.showCounts end,
setFunc = function(value) SousChef.settings.showCounts = value end,
},
- [11] = {
+ [12] = {
type = "checkbox",
name = str.MENU_ALT_USE,
tooltip = str.MENU_ALT_USE_TOOLTIP,
@@ -252,19 +304,19 @@ local function SousChefCreateSettings()
setFunc = function(value) SousChef.settings.showAltIngredientKnowledge = value SousChef:RefreshViews() end,
},
- [12] = {
+ [13] = {
type = "header",
name = str.MENU_INDICATOR_HEADER,
width = "full",
},
- [13] = {
+ [14] = {
type = "checkbox",
name = str.MENU_ICON_SET,
tooltip = str.MENU_ICON_SET_TOOLTIP,
getFunc = function() return SousChef.settings.boldIcon end,
setFunc = function(value) SousChef.settings.boldIcon = value SousChef:RefreshViews() end,
},
- [14] = {
+ [15] = {
type = "checkbox",
name = str.MENU_SPECIAL_ICONS,
tooltip = str.MENU_SPECIAL_ICONS_TOOLTIP,
@@ -274,7 +326,7 @@ local function SousChefCreateSettings()
SousChef.ParseRecipes()
end,
},
- [15] = {
+ [16] = {
type = "checkbox",
name = str.MENU_SPECIAL_TYPES,
tooltip = str.MENU_SPECIAL_TYPES_TOOLTIP,
@@ -282,7 +334,7 @@ local function SousChefCreateSettings()
setFunc = function(value) SousChef.settings.typeIcon = value SousChef.ParseRecipes() SousChef:RefreshViews() end,
disabled = function() return not SousChef.settings.showSpecialIngredients end,
},
- [16] = {
+ [17] = {
type = "colorpicker",
name = str.MENU_INDICATOR_COLOR,
tooltip = str.MENU_INDICATOR_COLOR_TOOLTIP,
@@ -294,7 +346,7 @@ local function SousChefCreateSettings()
SousChef:RefreshViews()
end,
},
- [17] = {
+ [18] = {
type = "colorpicker",
name = str.MENU_SHOPPING_COLOR,
tooltip = str.MENU_SHOPPING_COLOR_TOOLTIP,
@@ -306,14 +358,37 @@ local function SousChefCreateSettings()
SousChef:RefreshViews()
end,
},
- [18] = {
+ [19] = {
+ type = "checkbox",
+ name = str.MENU_SHOW_ALT_SHOPPING,
+ tooltip = str.MENU_SHOW_ALT_SHOPPING_TOOLTIP,
+ getFunc = function() return SousChef.settings.showAltShopping end,
+ setFunc = function(value) SousChef.settings.showAltShopping = value SousChef:RefreshViews() end,
+ },
+ [20] = {
type = "checkbox",
name = str.MENU_ONLY_MARK_SHOPPING,
tooltip = str.MENU_ONLY_MARK_SHOPPING_TOOLTIP,
getFunc = function() return SousChef.settings.onlyShowShopping end,
setFunc = function(value) SousChef.settings.onlyShowShopping = value SousChef:RefreshViews() end,
},
- [19] = {
+ [21] = {
+ type = "checkbox",
+ name = str.MENU_AUTO_JUNK,
+ tooltip = str.MENU_AUTO_JUNK_TOOLTIP,
+ getFunc = function() return SousChef.settings.autoJunk end,
+ setFunc = function(value)
+ if value then
+ SousChef.settings.autoJunk = true
+ EVENT_MANAGER:RegisterForEvent("SousChefLootJunker", EVENT_LOOT_CLOSED, function(...) zo_callLater(AutoJunker, 100) end)
+ else
+ SousChef.settings.autoJunk = false
+ EVENT_MANAGER:UnregisterForEvent("SousChefLootJunker", EVENT_LOOT_CLOSED)
+ end
+ end,
+ warning = str.MENU_AUTO_JUNK_WARNING,
+ },
+ [22] = {
type = "checkbox",
name = str.MENU_SORT_INGREDIENTS,
tooltip = str.MENU_SORT_INGREDIENTS_TOOLTIP,
@@ -343,6 +418,7 @@ local function SousChef_Loaded(eventCode, addOnName)
colour = {1, 1, 1},
shoppingColour = {0,1,1},
Cookbook = {},
+ CookbookIndex = {},
Pantry = {},
ReverseCookbook = {},
showAltKnowledge = false,
@@ -359,13 +435,26 @@ local function SousChef_Loaded(eventCode, addOnName)
onlyShowShopping = false,
qualityChecked = false,
sortProvisioningTable = true,
- sortKnownIngredients = false
+ sortKnownIngredients = false,
+ mainChar = GetUnitName("player"),
+ knownChars = {},
+ autoJunk = false,
+ showAltShopping = true,
}
local localized = SousChef.Strings[SousChef.lang]
-- Fetch the saved variables
SousChef.settings = ZO_SavedVars:NewAccountWide("SousChef_Settings", 10, SousChef.lang, defaults)
+ -- if this character isn't in the list of known chars, add it
+ local addMe = true
+ for _, v in pairs(SousChef.settings.knownChars) do
+ if GetUnitName("player") == v then addMe = false break end
+ end
+ if addMe then
+ local myName = GetUnitName("player")
+ table.insert(SousChef.settings.knownChars, GetUnitName("player"))
+ end
-- define some slash commands
SLASH_COMMANDS['/scstats'] = function()
@@ -399,6 +488,10 @@ function SousChef.HookEvents()
EVENT_MANAGER:RegisterForEvent("SousChefTrading", EVENT_TRADING_HOUSE_RESPONSE_RECEIVED, SousChef.HookTrading)
-- let us know if we've learned a new recipe, so we can integrate it into our cookbook
EVENT_MANAGER:RegisterForEvent("SousChefLearnt", EVENT_RECIPE_LEARNED, SousChef.ParseRecipes)
+ -- if the user has turned on auto-junking unmarked ingredients, set that up
+ if SousChef.settings.autoJunk then
+ EVENT_MANAGER:RegisterForEvent("SousChefLootJunker", EVENT_LOOT_CLOSED, function(...) zo_callLater(AutoJunker, 100) end)
+ end
-- let us know when we open a crafting station, so we can sort the recipe tree
EVENT_MANAGER:RegisterForEvent("SousChefProvi", EVENT_CRAFTING_STATION_INTERACT, function(...) SousChef:HookRecipeTree(...) end)
EVENT_MANAGER:RegisterForEvent("SousChefProviEnd", EVENT_END_CRAFTING_STATION_INTERACT, function() SousChef:UnhookRecipeTree() end)
diff --git a/Strings.lua b/Strings.lua
index 3508a08..c5aed17 100644
--- a/Strings.lua
+++ b/Strings.lua
@@ -14,6 +14,8 @@ SousChef.Strings = {
MENU_RECIPE_HEADER = "Recipe Options",
MENU_PROCESS_RECIPES = "Have Sous Chef display info for recipes",
MENU_PROCESS_RECIPES_TOOLTIP = "Non English clients may want to untick this if the experimental matching isn't sufficient",
+ MENU_MAIN_CHAR = "Main Provisioner Character",
+ MENU_MAIN_CHAR_TOOLTIP = "Select the character whose recipe knowledge you want shown by the indicators",
MENU_MARK_IF_KNOWN = "Mark recipe if it is ",
MENU_KNOWN = "known",
MENU_UNKNOWN = "unknown",
@@ -44,8 +46,13 @@ SousChef.Strings = {
MENU_INDICATOR_COLOR_TOOLTIP = "Allows you to set the colour of the recipe indicator",
MENU_SHOPPING_COLOR = "Shopping List Indicator Colour",
MENU_SHOPPING_COLOR_TOOLTIP = "Allows you to set the colour of the indicator for ingredients in your Shopping List",
+ MENU_SHOW_ALT_SHOPPING = "Shop for Alts' Shopping Lists?",
+ MENU_SHOW_ALT_SHOPPING_TOOLTIP = "Shop for ingredients on all characters' shopping lists, or just the main character?",
MENU_ONLY_MARK_SHOPPING = "Only Mark Shopping List Ingredients",
MENU_ONLY_MARK_SHOPPING_TOOLTIP = "Only mark ingredients on your Shopping List",
+ MENU_AUTO_JUNK = "Auto-junk ingredients not on Shopping List",
+ MENU_AUTO_JUNK_TOOLTIP = "Automatically mark looted ingredients as junk if they're not on the Shopping List",
+ MENU_AUTO_JUNK_WARNING = "Caution: Auto-junking ingredients should be used with care!",
MENU_SORT_INGREDIENTS = "Sort Ingredients in Inventory",
MENU_SORT_INGREDIENTS_TOOLTIP = "Will sort known ingredients by rank",
MENU_RELOAD = "Requires UI Reload",
@@ -79,6 +86,8 @@ SousChef.Strings = {
MENU_RECIPE_HEADER = "Rezept Einstellungen",
MENU_PROCESS_RECIPES = "Rezeptsinfos anzeigen",
MENU_PROCESS_RECIPES_TOOLTIP = "Diese Option abw\195\164hlen, wenn der experimentelle Rezeptnamensvergleich nicht ausreicht",
+ MENU_MAIN_CHAR = "Main Provisioner Character",
+ MENU_MAIN_CHAR_TOOLTIP = "Select the character whose recipe knowledge you want shown by the indicators",
MENU_MARK_IF_KNOWN = "Rezept markieren wenn?",
MENU_KNOWN = "bekannt",
MENU_UNKNOWN = "unbekannt",
@@ -109,8 +118,13 @@ SousChef.Strings = {
MENU_INDICATOR_COLOR_TOOLTIP = "Erm\195\182glicht es die Farbe der Markierungen zu setzen",
MENU_SHOPPING_COLOR = "Einkauflisten Symbolfarbe",
MENU_SHOPPING_COLOR_TOOLTIP = "Erm\195\182glicht es die Farbe f\195\188ür Markierungen von Zutaten auf der Einkaufsliste zu setzen",
+ MENU_SHOW_ALT_SHOPPING = "Shop for Alts' Shopping Lists?",
+ MENU_SHOW_ALT_SHOPPING_TOOLTIP = "Shop for ingredients on all characters' shopping lists, or just the main character?",
MENU_ONLY_MARK_SHOPPING = "Nur Zutaten auf der Einkaufsliste markieren",
MENU_ONLY_MARK_SHOPPING_TOOLTIP = "Es werden nur Zutaten von Rezepten auf der Einkaufsliste markiert",
+ MENU_AUTO_JUNK = "Auto-junk ingredients not on Shopping List",
+ MENU_AUTO_JUNK_TOOLTIP = "Automatically mark looted ingredients as junk if they're not on the Shopping List",
+ MENU_AUTO_JUNK_WARNING = "Caution: Auto-junking ingredients should be used with care!",
MENU_SORT_INGREDIENTS = "Zutaten im Inventar sortieren",
MENU_SORT_INGREDIENTS_TOOLTIP = "Zutaten im Inventar werden nach Rang sortiert",
MENU_RELOAD = "Ben\195\182tigt das Neuladen der Benutzeroberfl\195\164che (/reloadui)",
@@ -144,6 +158,8 @@ SousChef.Strings = {
MENU_RECIPE_HEADER = "Recettes",
MENU_PROCESS_RECIPES = "Afficher des infos complémentaires aux recettes",
MENU_PROCESS_RECIPES_TOOLTIP = "Si votre jeu n'est pas en anglais, il faudra peut-être désactiver cette option si la reconnaissance des recettes ne fonctionne pas correctement",
+ MENU_MAIN_CHAR = "Main Provisioner Character",
+ MENU_MAIN_CHAR_TOOLTIP = "Select the character whose recipe knowledge you want shown by the indicators",
MENU_MARK_IF_KNOWN = "Indiquer si la recette est ",
MENU_KNOWN = "connue",
MENU_UNKNOWN = "inconnue",
@@ -174,8 +190,13 @@ SousChef.Strings = {
MENU_INDICATOR_COLOR_TOOLTIP = "Vous permet de modifier la couleur des marques indiquant le rang des recettes utilisant l'ingrédient",
MENU_SHOPPING_COLOR = "Couleur des ingrédients marqués",
MENU_SHOPPING_COLOR_TOOLTIP = "Vous permet de modifier la couleur des marques indiquant le rang des recettes marquées utilisant l'ingrédient",
+ MENU_SHOW_ALT_SHOPPING = "Shop for Alts' Shopping Lists?",
+ MENU_SHOW_ALT_SHOPPING_TOOLTIP = "Shop for ingredients on all characters' shopping lists, or just the main character?",
MENU_ONLY_MARK_SHOPPING = "N'afficher que les ingrédients marqués",
MENU_ONLY_MARK_SHOPPING_TOOLTIP = "N'afficher que les ingrédients marqués",
+ MENU_AUTO_JUNK = "Auto-junk ingredients not on Shopping List",
+ MENU_AUTO_JUNK_TOOLTIP = "Automatically mark looted ingredients as junk if they're not on the Shopping List",
+ MENU_AUTO_JUNK_WARNING = "Caution: Auto-junking ingredients should be used with care!",
MENU_SORT_INGREDIENTS = "Trier les ingrédients dans les sacs",
MENU_SORT_INGREDIENTS_TOOLTIP = "Cette option activée, les ingrédients seront triés par rang dans les sacs",
MENU_RELOAD = "Nécessite de recharger l'interface (ReloadUI)",