diff --git a/Common.lua b/Common.lua
new file mode 100644
index 0000000..2b64d26
--- /dev/null
+++ b/Common.lua
@@ -0,0 +1,111 @@
+local SousChef = SousChef
+local u = SousChef.Utility
+local m = SousChef.Media
+
+local BACKPACK = ZO_PlayerInventoryBackpack
+local BANK = ZO_PlayerBankBackpack
+local GUILD_BANK = ZO_GuildBankBackpack
+
+local COOKING_RANK_2 = [[SousChef\media\Two.dds]]
+local COOKING_RANK_3 = [[SousChef\media\Three.dds]]
+local COOKING_RANK_4 = [[SousChef\media\Four.dds]]
+local COOKING_RANK_5 = [[SousChef\media\Five.dds]]
+local COOKING_RANK_6 = [[SousChef\media\Six.dds]]
+local COOKING_FLAVOUR = [[SousChef\media\Flavour.dds]]
+local COOKING_SPICE = [[SousChef\media\Spice.dds]]
+local COOKING_SPICEB = [[SousChef\media\Spice_Flat.dds]]
+local COOKING_RANK_1B = [[SousChef\media\One_flat.dds]]
+local COOKING_RANK_2B = [[SousChef\media\Two_flat.dds]]
+local COOKING_RANK_3B = [[SousChef\media\Three_flat.dds]]
+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_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 }
+
+m.CANLEARN = [[/esoui/art/loot/loot_finesseitem.dds]]
+
+local rowClicked = {}
+
+function SousChef.HookInventory()
+ for _,v in pairs(PLAYER_INVENTORY.inventories) do
+ local listView = v.listView
+ if listView and listView.dataTypes and listView.dataTypes[1] then
+ SousChef.hookedFunctions = listView.dataTypes[1].setupCallback
+
+ listView.dataTypes[1].setupCallback =
+ function(rowControl, slot)
+ SousChef.hookedFunctions(rowControl, slot)
+ SousChef.AddRankToSlot(rowControl)
+ end
+ end
+ end
+
+ ZO_ScrollList_RefreshVisible(BACKPACK)
+ ZO_ScrollList_RefreshVisible(BANK)
+ ZO_ScrollList_RefreshVisible(GUILD_BANK)
+end
+
+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 )
+ end
+ return rankIcon
+end
+
+function SousChef.AddDetails(row)
+ if not row.dataEntry or not row.dataEntry.data or rowClicked[row] then return false end
+ local rowInfo = row.dataEntry.data
+ local bagId = rowInfo.bagId
+ local slotIndex = rowInfo.slotIndex
+
+ if u.MatchesRecipe(rowInfo.name) then
+ local gmatch = u.MatchInGlobalCookbook(rowInfo.name)
+ if gmatch then
+ ItemTooltip:AddLine("")
+ ItemTooltip:AddLine("Known by ", "ZoFontWinH5", 1,1,1, BOTTOM, MODIFY_TEXT_TYPE_UPPERCASE)
+ ItemTooltip:AddLine(u.TableKeyConcat(gmatch))
+ rowClicked[row] = true
+ return
+ end
+ end
+
+ if ((GetItemCraftingInfo(bagId, slotIndex)) ~= CRAFTING_TYPE_PROVISIONING) then return false end
+
+ 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
+ ItemTooltip:AddLine("Used in:", "ZoFontWinH5", 1,1,1, BOTTOM, MODIFY_TEXT_TYPE_UPPERCASE)
+ ItemTooltip:AddLine(table.concat(usableIngredient, ", "))
+ rowClicked[row] = true
+ end
+ return false
+end
+
+function SousChef.AddRecipeToIgnoreList(link)
+ if GetItemLinkInfo(link) ~= "" then link = string.match(link, "([ %a]+)%]") 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 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")
+end
+
+function SousChef.ListIgnoredRecipes()
+ d("Ignoring:")
+ for recipe in pairs(SousChef.settings.ignoredRecipes) do
+ d(recipe)
+ end
+end
\ No newline at end of file
diff --git a/Inventory.lua b/Inventory.lua
new file mode 100644
index 0000000..2906835
--- /dev/null
+++ b/Inventory.lua
@@ -0,0 +1,54 @@
+local SousChef = SousChef
+local u = SousChef.Utility
+local m = SousChef.Media
+
+function SousChef.AddRankToSlot(row)
+ local slot = row.dataEntry.data
+ local bagId = slot.bagId
+ local slotIndex = slot.slotIndex
+ local rankIcon = SousChef.getIcon(row)
+
+ -- Allow for ingeniousclown's Inventory Grid View
+ if row:GetWidth() - row:GetHeight() < 5 then -- if we're mostly square
+ rankIcon:SetDimensions(20,20)
+ rankIcon:SetAnchor(TOPLEFT, row, TOPLEFT, 2)
+ else
+ rankIcon:SetDimensions(30, 30)
+ rankIcon:SetAnchor(CENTER, row, CENTER, 200)
+ end
+
+ rankIcon:SetHidden(true)
+
+ if ((GetItemCraftingInfo(bagId, slotIndex)) == CRAFTING_TYPE_PROVISIONING) then
+ local texture = SousChef.Pantry[u.GetItemID(GetItemLink(bagId, slotIndex))]
+ if SousChef.settings.showAltKnowledge then texture = SousChef.settings.Pantry[u.GetItemID(GetItemLink(bagId, slotIndex))] end
+ if texture then
+ rankIcon:SetColor(SousChef.settings.colour[1], SousChef.settings.colour[2], SousChef.settings.colour[3])
+ rankIcon:SetHidden(false)
+ if SousChef.settings.boldIcon then
+ rankIcon:SetTexture(m.COOKINGB[texture])
+ else
+ rankIcon:SetTexture(m.COOKING[texture])
+ end
+
+ end
+ else
+ if SousChef.settings.processRecipes then
+ if GetItemType(bagId, slotIndex) == ITEMTYPE_RECIPE then
+ if u.MatchInIgnoreList(slot.name) then return end
+ local match = u.MatchInCookbook(slot.name)
+ local gmatch = u.MatchInGlobalCookbook(slot.name)
+ if (match and SousChef.settings.checkKnown == "known") or
+ (not match and SousChef.settings.checkKnown == "unknown")then
+ rankIcon:SetTexture(m.CANLEARN)
+ rankIcon:SetHidden(false)
+ if not match and gmatch and SousChef.settings.checkKnown == "unknown" and SousChef.settings.markAlt then
+ rankIcon:SetColor(1,1,1,0.2)
+ else
+ rankIcon:SetColor(1,1,1,1)
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/Provisioning.lua b/Provisioning.lua
new file mode 100644
index 0000000..6a08d68
--- /dev/null
+++ b/Provisioning.lua
@@ -0,0 +1,23 @@
+local SousChef = SousChef
+
+function SousChef.HookRecipeTreeFunction()
+ -- Hook the provisioning panel
+ if not SousChef.hookedProvisioningFunction then
+ local ref = PROVISIONER.recipeTree.templateInfo.ZO_ProvisionerNavigationEntry
+ if ref then
+ SousChef.hookedProvisioningFunction = ref.setupFunction
+ ref.setupFunction =
+ function(...)
+ local node, control, data, open, userRequested, enabled = ...
+ SousChef.hookedProvisioningFunction(...)
+
+ end
+ end
+ end
+end
+
+function SousChef.HookRecipeTree(...)
+ local eventId, craftingTable = ...
+ if craftingTable ~= CRAFTING_TYPE_PROVISIONING then return end
+ zo_callLater(SousChef.HookRecipeTreeFunction, 1000)
+end
diff --git a/SousChef.lua b/SousChef.lua
index e86c076..a023f62 100644
--- a/SousChef.lua
+++ b/SousChef.lua
@@ -5,36 +5,16 @@
inspired by ingeniousclown's Research Assistant
------------------------------------------------------------------]]--
-SousChef = {}
-local LAM = LibStub:GetLibrary("LibAddonMenu-1.0")
-local BACKPACK = ZO_PlayerInventoryBackpack
-local BANK = ZO_PlayerBankBackpack
-local GUILD_BANK = ZO_GuildBankBackpack
+SousChef = {}
+SousChef.Utility = {}
+SousChef.Media = {}
-local COOKING_RANK_1 = [[SousChef\media\One.dds]]
-local COOKING_RANK_2 = [[SousChef\media\Two.dds]]
-local COOKING_RANK_3 = [[SousChef\media\Three.dds]]
-local COOKING_RANK_4 = [[SousChef\media\Four.dds]]
-local COOKING_RANK_5 = [[SousChef\media\Five.dds]]
-local COOKING_RANK_6 = [[SousChef\media\Six.dds]]
-local COOKING_FLAVOUR = [[SousChef\media\Flavour.dds]]
-local COOKING_SPICE = [[SousChef\media\Spice.dds]]
-local COOKING_RANK_1B = [[SousChef\media\One_flat.dds]]
-local COOKING_RANK_2B = [[SousChef\media\Two_flat.dds]]
-local COOKING_RANK_3B = [[SousChef\media\Three_flat.dds]]
-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_FLAVOURB = [[SousChef\media\flavour_flat.dds]]
-local COOKING_SPICEB = [[SousChef\media\Spice_Flat.dds]]
+local SousChef = SousChef
+local u = SousChef.Utility
-local COOKING = { COOKING_RANK_1, COOKING_RANK_2, COOKING_RANK_3, COOKING_RANK_4, COOKING_RANK_5, COOKING_RANK_6, COOKING_FLAVOUR, COOKING_SPICE }
-local COOKINGB = { COOKING_RANK_1B, COOKING_RANK_2B, COOKING_RANK_3B, COOKING_RANK_4B, COOKING_RANK_5B, COOKING_RANK_6B, COOKING_FLAVOURB, COOKING_SPICEB }
+local LAM = LibStub:GetLibrary("LibAddonMenu-1.0")
-local CANLEARN = [[/esoui/art/loot/loot_finesseitem.dds]]
-local containerHooks = { INVENTORY_BACKPACK, INVENTORY_BANK, INVENTORY_GUILD_BANK }
-local itemQuality = { ITEM_QUALITY_MAGIC = { 0, 0, 1 }, ITEM_QUALITY_NORMAL = {1,1,1}, ITEM_QUALITY_ARCANE = {1, 0, 1}}
SousChef.Pantry = {}
SousChef.Cookbook = {}
SousChef.ReverseCookbook = {}
@@ -43,196 +23,8 @@ SousChef.slotLines = {}
SousChef.hookedFunctions = {}
SousChef.hookedDataFunction = nil
-local function GetItemID(link)
- return tonumber(string.match(string.match(link, "%d+:"), "%d+"))
-end
-
-function EndsWith(String,End)
- return End=='' or string.sub(String,-string.len(End))==End
-end
-
-function StartsWith(String,Start)
- return Start=='' or string.sub(String, 1, string.len(Start))==Start
-end
-
-local languageElements = {"de ", "à ", "la ", }
-local separators = {"%^(%a+)", "-", " " }
-
-local function StripLanguageIdentifiers(entry)
- for _,v in pairs(languageElements) do
- entry = entry:gsub(v, "")
- end
- return entry
-end
-
-local function Compress(entry)
- for _,v in pairs(separators) do
- entry = entry:gsub(v, "")
- end
- return entry
-end
-
-local function CleanString(entry)
- if SousChef.settings.experimentalMatch then
- entry = StripLanguageIdentifiers(entry)
- end
- return Compress(entry):lower()
-end
-
-local function MatchesRecipe(entry)
- return CleanString(entry):find(CleanString(GetString(SI_ITEMTYPE29)))
-end
-
-local function TableKeyConcat(t)
- local tt = {}
- for k in pairs(t) do tt[#tt+1]=k end
- return table.concat(tt, ", ")
-end
-
-local function MatchInCookbook(name)
- name = CleanString(name)
- for recipe,known in pairs(SousChef.Cookbook) do
- if StartsWith(name,recipe) or EndsWith(name, recipe) then
- local difference = (#recipe + #CleanString(GetString(SI_ITEMTYPE29)) - #name)
- if difference < 3 and difference > -3 then
- return known
- end
- end
- end
- return nil
-end
-
-local function MatchInGlobalCookbook(name)
- name = CleanString(name)
- for recipe,known in pairs(SousChef.settings.Cookbook) do
- if StartsWith(name,recipe) or EndsWith(name, recipe) then
- local difference = (#recipe + #CleanString(GetString(SI_ITEMTYPE29)) - #name)
- if difference < 3 and difference > - 3 then
- return known
- end
- end
- end
- return nil
-end
-
- rowClicked = {}
-
-local function AddDetails(row)
- if not row.dataEntry or not row.dataEntry.data or rowClicked[row] then return false end
- local rowInfo = row.dataEntry.data
- local bagId = rowInfo.bagId
- local slotIndex = rowInfo.slotIndex
-
- if MatchesRecipe(rowInfo.name) then
- local gmatch = MatchInGlobalCookbook(rowInfo.name)
- if gmatch then
- ItemTooltip:AddLine("")
- ItemTooltip:AddLine("Known by ", "ZoFontWinH5", 1,1,1, BOTTOM, MODIFY_TEXT_TYPE_UPPERCASE)
- ItemTooltip:AddLine(TableKeyConcat(gmatch))
- rowClicked[row] = true
- return
- end
- end
-
- if ((GetItemCraftingInfo(bagId, slotIndex)) ~= CRAFTING_TYPE_PROVISIONING) then return false end
-
- local usableIngredient = SousChef.ReverseCookbook[GetItemID(GetItemLink(bagId, slotIndex))]
- if SousChef.settings.showAltKnowledge then usableIngredient = SousChef.settings.ReverseCookbook[GetItemID(GetItemLink(bagId, slotIndex))] end
- if usableIngredient then
- ItemTooltip:AddLine("Used in:", "ZoFontWinH5", 1,1,1, BOTTOM, MODIFY_TEXT_TYPE_UPPERCASE)
- ItemTooltip:AddLine(table.concat(usableIngredient, ", "))
- rowClicked[row] = true
- end
- return false
-end
-
-local function 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", AddDetails)
- ZO_PreHookHandler(row, "OnMouseExit", function(self) rowClicked[self] = nil return false end )
- end
- return rankIcon
-end
-
local rowHandler = {}
-local function AddRankToSlot(row)
- local slot = row.dataEntry.data
- local bagId = slot.bagId
- local slotIndex = slot.slotIndex
- local rankIcon = getIcon(row)
-
- -- Allow for ingeniousclown's Inventory Grid View
- if row:GetWidth() - row:GetHeight() < 5 then -- if we're mostly square
- rankIcon:SetDimensions(20,20)
- rankIcon:SetAnchor(TOPLEFT, row, TOPLEFT, 2)
- else
- rankIcon:SetDimensions(30, 30)
- rankIcon:SetAnchor(CENTER, row, CENTER, 200)
- end
-
- rankIcon:SetHidden(true)
-
- if ((GetItemCraftingInfo(bagId, slotIndex)) == CRAFTING_TYPE_PROVISIONING) then
- local texture = SousChef.Pantry[GetItemID(GetItemLink(bagId, slotIndex))]
- if SousChef.settings.showAltKnowledge then texture = SousChef.settings.Pantry[GetItemID(GetItemLink(bagId, slotIndex))] end
- if texture then
- rankIcon:SetColor(SousChef.settings.colour[1], SousChef.settings.colour[2], SousChef.settings.colour[3])
- rankIcon:SetHidden(false)
- if SousChef.settings.boldIcon then
- rankIcon:SetTexture(COOKINGB[texture])
- else
- rankIcon:SetTexture(COOKING[texture])
- end
-
- end
- else
- if SousChef.settings.processRecipes then
- if GetItemType(bagId, slotIndex) == ITEMTYPE_RECIPE then
- local match = MatchInCookbook(slot.name)
- local gmatch = MatchInGlobalCookbook(slot.name)
- if (match and SousChef.settings.checkKnown == "known") or
- (not match and SousChef.settings.checkKnown == "unknown")then
- rankIcon:SetTexture(CANLEARN)
- rankIcon:SetHidden(false)
- if not match and gmatch and SousChef.settings.checkKnown == "unknown" and SousChef.settings.markAlt then
- rankIcon:SetColor(1,1,1,0.2)
- else
- rankIcon:SetColor(1,1,1,1)
- end
- end
- end
- end
- end
-end
-
-local function AddTradingSlot(row, result)
- local rankIcon = getIcon(row)
-
- rankIcon:SetHidden(true)
- if SousChef.settings.processRecipes then
- if MatchesRecipe(result.name) then
- local match = MatchInCookbook(result.name)
- local gmatch = MatchInGlobalCookbook(result.name)
- if (match and SousChef.settings.checkKnown == "known") or
- (not match and SousChef.settings.checkKnown == "unknown")then
- rankIcon:SetDimensions(30, 30)
- rankIcon:SetAnchor(CENTER, row, CENTER, 230)
- rankIcon:SetTexture(CANLEARN)
- rankIcon:SetHidden(false)
- if not match and gmatch and SousChef.settings.checkKnown == "unknown" and SousChef.settings.markAlt then
- rankIcon:SetColor(1,1,1,0.2)
- else
- rankIcon:SetColor(1,1,1,1)
- end
- end
- end
- end
-end
-
local function AddRecipe(Cookbook, link)
for _,v in pairs(Cookbook) do
if v == link then return end
@@ -240,14 +32,14 @@ local function AddRecipe(Cookbook, link)
table.insert(Cookbook, link)
end
-local function ParseRecipes()
+function SousChef.ParseRecipes()
local lists = GetNumRecipeLists()
for listIndex = 1, lists do
local name, count = GetRecipeListInfo(listIndex)
for recipeIndex = 1, count do
if GetRecipeInfo(listIndex, recipeIndex) then
-- Store the recipes known
- local recipeName = CleanString((GetRecipeResultItemInfo(listIndex, recipeIndex)))
+ local recipeName = u.CleanString((GetRecipeResultItemInfo(listIndex, recipeIndex)))
SousChef.Cookbook[recipeName] = true
if not SousChef.settings.Cookbook[recipeName] then
SousChef.settings.Cookbook[recipeName] = {}
@@ -255,7 +47,7 @@ local function ParseRecipes()
SousChef.settings.Cookbook[recipeName][GetUnitName("player")] = true
local _, _, ingredientCount, level, _, specialType = GetRecipeInfo(listIndex, recipeIndex)
for ingredientIndex = 1, ingredientCount do
- local link = GetItemID(GetRecipeIngredientItemLink(listIndex, recipeIndex, ingredientIndex, LINK_STYLE_NORMAL))
+ local link = u.GetItemID(GetRecipeIngredientItemLink(listIndex, recipeIndex, ingredientIndex, LINK_STYLE_NORMAL))
-- Store the fact that the ingredient is used
if ingredientIndex < 3 then
SousChef.Pantry[link] = math.max(level, SousChef.Pantry[link] or 0)
@@ -320,38 +112,7 @@ local function SousChefCreateSettings()
end
-local function HookRecipeTreeFunction()
- -- Hook the provisioning panel
- if not SousChef.hookedProvisioningFunction then
- local ref = PROVISIONER.recipeTree.templateInfo.ZO_ProvisionerNavigationEntry
- if ref then
- SousChef.hookedProvisioningFunction = ref.setupFunction
- ref.setupFunction =
- function(...)
- local node, control, data, open, userRequested, enabled = ...
- SousChef.hookedProvisioningFunction(...)
- end
- end
- 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
- ZO_TradingHouseItemPaneSearchResults.dataTypes[1].setupCallback = function(...)
- local row, data = ...
- SousChef.hookedDataFunction(...)
- AddTradingSlot(row, data)
- end
-end
local function SousChef_Loaded(eventCode, addOnName)
if(addOnName ~= "SousChef") then
@@ -369,7 +130,8 @@ local function SousChef_Loaded(eventCode, addOnName)
showAltKnowledge = false,
boldIcon = false,
experimentalMatch = false,
- processRecipes = true
+ processRecipes = true,
+ ignoredRecipes = {}
}
SousChef.settings = ZO_SavedVars:NewAccountWide("SousChef_Settings", 8, nil, defaults)
@@ -387,39 +149,22 @@ local function SousChef_Loaded(eventCode, addOnName)
SousChefCreateSettings()
- ParseRecipes()
-
+ zo_callLater(SousChef.ParseRecipes, 1000)
+ SLASH_COMMANDS['/sciadd'] = SousChef.AddRecipeToIgnoreList
+ SLASH_COMMANDS['/sciremove'] = SousChef.RemoveRecipeFromIgnoreList
+ SLASH_COMMANDS['/scilist'] = SousChef.ListIgnoredRecipes
-- Now we want to hook into the function that sets the details on the inventory slot
- for _,v in pairs(PLAYER_INVENTORY.inventories) do
- local listView = v.listView
- if listView and listView.dataTypes and listView.dataTypes[1] then
- SousChef.hookedFunctions = listView.dataTypes[1].setupCallback
-
- listView.dataTypes[1].setupCallback =
- function(rowControl, slot)
- SousChef.hookedFunctions(rowControl, slot)
- AddRankToSlot(rowControl)
- 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("SousChefLearnt", EVENT_RECIPE_LEARNED, ParseRecipes)
-
- EVENT_MANAGER:RegisterForEvent("SousChefProvi", EVENT_CRAFTING_STATION_INTERACT, HookRecipeTree)
-
-end
-
-local function SousChef_Initialized()
- EVENT_MANAGER:RegisterForEvent("SousChefLoaded", EVENT_ADD_ON_LOADED, SousChef_Loaded)
+ zo_callLater(SousChef.HookEvents, 3000)
end
+function SousChef.HookEvents()
+ EVENT_MANAGER:RegisterForEvent("SousChefTrading", EVENT_TRADING_HOUSE_RESPONSE_RECEIVED, SousChef.HookTrading)
+ EVENT_MANAGER:RegisterForEvent("SousChefLearnt", EVENT_RECIPE_LEARNED, SousChef.ParseRecipes)
+ EVENT_MANAGER:RegisterForEvent("SousChefProvi", EVENT_CRAFTING_STATION_INTERACT, SousChef.HookRecipeTree)
+ SousChef.HookInventory()
+end
-SousChef_Initialized()
+EVENT_MANAGER:RegisterForEvent("SousChefLoaded", EVENT_ADD_ON_LOADED, SousChef_Loaded)
\ No newline at end of file
diff --git a/SousChef.txt b/SousChef.txt
index 02fe969..9d96a13 100644
--- a/SousChef.txt
+++ b/SousChef.txt
@@ -8,4 +8,9 @@ libs\LibStub\LibStub.lua
libs\LibAddonMenu-1.0\LibAddonMenu-1.0.lua
SousChef.lua
+Utility.lua
+Common.lua
+Inventory.lua
+TradingHouse.lua
+Provisioning.lua
SousChef.xml
\ No newline at end of file
diff --git a/TradingHouse.lua b/TradingHouse.lua
new file mode 100644
index 0000000..30e7125
--- /dev/null
+++ b/TradingHouse.lua
@@ -0,0 +1,38 @@
+local SousChef = SousChef
+local u = SousChef.Utility
+
+function SousChef.AddTradingSlot(row, result)
+ local rankIcon = SousChef.getIcon(row)
+
+ rankIcon:SetHidden(true)
+ if SousChef.settings.processRecipes then
+ if u.MatchesRecipe(result.name) then
+ local match = u.MatchInCookbook(result.name)
+ local gmatch = u.MatchInGlobalCookbook(result.name)
+ if (match and SousChef.settings.checkKnown == "known") or
+ (not match and SousChef.settings.checkKnown == "unknown")then
+ rankIcon:SetDimensions(30, 30)
+ rankIcon:SetAnchor(CENTER, row, CENTER, 230)
+ rankIcon:SetTexture(CANLEARN)
+ rankIcon:SetHidden(false)
+ if not match and gmatch and SousChef.settings.checkKnown == "unknown" and SousChef.settings.markAlt then
+ rankIcon:SetColor(1,1,1,0.2)
+ else
+ rankIcon:SetColor(1,1,1,1)
+ end
+ end
+ end
+ end
+end
+
+
+
+function SousChef.HookTrading(...)
+ if SousChef.hookedDataFunction then return end
+ SousChef.hookedDataFunction = ZO_TradingHouseItemPaneSearchResults.dataTypes[1].setupCallback
+ ZO_TradingHouseItemPaneSearchResults.dataTypes[1].setupCallback = function(...)
+ local row, data = ...
+ SousChef.hookedDataFunction(...)
+ AddTradingSlot(row, data)
+ end
+end
\ No newline at end of file
diff --git a/Utility.lua b/Utility.lua
new file mode 100644
index 0000000..b958f39
--- /dev/null
+++ b/Utility.lua
@@ -0,0 +1,84 @@
+
+local SousChef = SousChef
+
+local u = SousChef.Utility
+
+function u.GetItemID(link)
+ return tonumber(string.match(string.match(link, "%d+:"), "%d+"))
+end
+
+function u.EndsWith(String,End)
+ return End=='' or string.sub(String,-string.len(End))==End
+end
+
+function u.StartsWith(String,Start)
+ return Start=='' or string.sub(String, 1, string.len(Start))==Start
+end
+
+local languageElements = {"de ", "à ", "la ", }
+local separators = {"%^[%a:]+", "-", " " }
+
+function u.StripLanguageIdentifiers(entry)
+ for _,v in pairs(languageElements) do
+ entry = entry:gsub(v, "")
+ end
+ return entry
+end
+
+function u.Compress(entry)
+ for _,v in pairs(separators) do
+ entry = entry:gsub(v, "")
+ end
+ return entry
+end
+
+function u.CleanString(entry)
+ if SousChef.settings.experimentalMatch then
+ entry = u.StripLanguageIdentifiers(entry)
+ end
+ return u.Compress(entry):lower()
+end
+
+function u.MatchesRecipe(entry)
+ return u.CleanString(entry):find(u.CleanString(GetString(SI_ITEMTYPE29)))
+end
+
+function u.TableKeyConcat(t)
+ local tt = {}
+ for k in pairs(t) do tt[#tt+1]=k end
+ return table.concat(tt, ", ")
+end
+
+function u.MatchInCookbook(name)
+ name = u.CleanString(name)
+ for recipe,known in pairs(SousChef.Cookbook) do
+ if u.StartsWith(name,recipe) or u.EndsWith(name, recipe) then
+ local difference = (#recipe + #u.CleanString(GetString(SI_ITEMTYPE29)) - #name)
+ if difference < 3 and difference > -3 then
+ return known
+ end
+ end
+ end
+ return nil
+end
+
+function u.MatchInGlobalCookbook(name)
+ name = u.CleanString(name)
+ for recipe,known in pairs(SousChef.settings.Cookbook) do
+ if u.StartsWith(name,recipe) or u.EndsWith(name, recipe) then
+ local difference = (#recipe + #u.CleanString(GetString(SI_ITEMTYPE29)) - #name)
+ if difference < 3 and difference > - 3 then
+ return known
+ end
+ end
+ end
+ return nil
+end
+
+function u.MatchInIgnoreList(name)
+ name = u.CleanString(name)
+ for recipe in pairs(SousChef.settings.ignoredRecipes) do
+ if u.CleanString(recipe) == name then return true end
+ end
+ return false
+end
\ No newline at end of file