diff --git a/SousChef.lua b/SousChef.lua
index 5d3cf49..064472e 100644
--- a/SousChef.lua
+++ b/SousChef.lua
@@ -51,19 +51,46 @@ local function StartsWith(String,Start)
return Start=='' or string.sub(String, 1, string.len(Start))==Start
end
+local languageElements = {"de ", "à ", "la ", }
+local separators = {"%^(%a+)", ":(%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)
- return entry:gsub("%^(%a+)", ""):gsub(" ",""):gsub("-",""):lower()
+ 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
- if (#recipe + #CleanString(GetString(SI_ITEMTYPE29)) - #name) < 3 then
+ local difference = (#recipe + #CleanString(GetString(SI_ITEMTYPE29)) - #name)
+ if difference < 3 and difference >= 0 then
return known
end
end
@@ -75,7 +102,8 @@ 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
- if (#recipe + #CleanString(GetString(SI_ITEMTYPE29)) - #name) < 3 then
+ local difference = (#recipe + #CleanString(GetString(SI_ITEMTYPE29)) - #name)
+ if difference < 3 and difference >= 0 then
return known
end
end
@@ -96,9 +124,7 @@ local function AddDetails(row)
if gmatch then
ItemTooltip:AddLine("")
ItemTooltip:AddLine("Known by ", "ZoFontWinH5", 1,1,1, BOTTOM, MODIFY_TEXT_TYPE_UPPERCASE)
- for i,v in pairs(gmatch) do
- ItemTooltip:AddLine(i)
- end
+ ItemTooltip:AddLine(TableKeyConcat(gmatch))
rowClicked[row] = true
return
end
@@ -110,9 +136,7 @@ local function AddDetails(row)
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)
- for i,v in ipairs(usableIngredient) do
- ItemTooltip:AddLine(v)
- end
+ ItemTooltip:AddLine(table.concat(usableIngredient, ", "))
rowClicked[row] = true
end
return false
@@ -161,22 +185,23 @@ local function AddRankToSlot(row)
end
end
- else
- 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
-
+ 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
@@ -184,23 +209,24 @@ local function AddTradingSlot(row, result)
local rankIcon = getIcon(row)
rankIcon:SetHidden(true)
-
- 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
+ if SousChef.settings.parseRecipes 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)
@@ -247,7 +273,19 @@ local function SousChefCreateSettings()
local panel = LAM:CreateControlPanel("SousChefMenu", "Sous Chef")
LAM:AddHeader(panel, "SousChef_General", "Settings")
-
+
+ LAM:AddCheckbox(panel, "processRecipes", "Have Sous Chef check for recipes", "Non English clients may want to untick this if the experimental matching isn't sufficient",
+ function() return SousChef.settings.processRecipes end,
+ function(value)
+ SousChef.settings.processRecipes = not SousChef.settings.processRecipes
+ if SousChef.settings.processRecipes then
+ ZO_Options_SetOptionInactive(markLearnt)
+ ZO_Options_SetOptionInactive(markAltKnows)
+ else
+ ZO_Options_SetOptionActive(markLearnt)
+ ZO_Options_SetOptionActive(markAltKnows)
+ end
+ end)
LAM:AddDropdown(panel, "markLearnt", "Mark if recipes are ",
"How do you want Sous Chef to indicate your knowledge of a recipe?",
{"known", "unknown"}, function() return SousChef.settings.checkKnown end,
@@ -265,7 +303,11 @@ local function SousChefCreateSettings()
"Allows you to set the colour of the indicator",
function() return SousChef.settings.colour[1], SousChef.settings.colour[2], SousChef.settings.colour[3] end,
function(r,g,b) SousChef.settings.colour[1] = r; SousChef.settings.colour[2] = g; SousChef.settings.colour[3] = b end)
-
+ LAM:AddCheckbox(panel, "experimental", "Use the experimental recipe matcher", [[Currently Sous Chef cannot match reliably in other languages. This will attempt to match as best it can by stripping out common prepositions so that the recipe and result match better.
+
+ (NOTE: please file a bug report if you find recipes that don't match the results exactly, with the recipe/result names and/or screenshots so I can update this dictionary)]],
+ function() return SousChef.settings.experimentalMatch end,
+ function(value) SousChef.settings.experimentalMatch = not SousChef.settings.experimentalMatch end)
end
local function HookTrading(...)
@@ -292,7 +334,9 @@ local function SousChef_Loaded(eventCode, addOnName)
Pantry = {},
ReverseCookbook = {},
showAltKnowledge = false,
- boldIcon = false
+ boldIcon = false,
+ experimentalMatch = false,
+ processRecipes = true
}
SousChef.settings = ZO_SavedVars:NewAccountWide("SousChef_Settings", 8, nil, defaults)