Dry code commit to show details on unknown recipes for alts.

Wobin [04-11-14 - 06:13]
Dry code commit to show details on unknown recipes for alts.
TODO: Storage of alt recipes
Filename
SousChef.lua
diff --git a/SousChef.lua b/SousChef.lua
index 31815d8..0ad5e85 100644
--- a/SousChef.lua
+++ b/SousChef.lua
@@ -28,6 +28,13 @@ local function GetItemID(link)
 	return tonumber(string.match(string.match(link, "%d+:"), "%d+"))
 end

+local function MatchInCookbook(bag, slot)
+	return Cookbook[GetItemName(bag, slot):lower():gsub(" ","")]
+end
+
+local function MatchInGlobalCookbook(bag, slot)
+	return settings.Cookbook[GetItemName(bag,slot):lower():gsub(" ", "")]
+
 local function AddRankToSlot(row, isGrid)
 	local bagId = row.dataEntry.data.bagId
 	local slotIndex = row.dataEntry.data.slotIndex
@@ -58,11 +65,17 @@ local function AddRankToSlot(row, isGrid)
 		end
 	else
 		if GetItemType(bagId, slotIndex) == ITEMTYPE_RECIPE then
-			if (Cookbook[GetItemName(bagId, slotIndex):lower():gsub(" ","")] and settings.checkKnown == "known") or
-			   (not Cookbook[GetItemName(bagId, slotIndex):lower():gsub(" ","")] and settings.checkKnown == "unknown")then
-				rankIcon:SetColor(1,1,1)
+			local match = MatchInCookbook(bagId, slotIndex)
+			local gmatch = MatchInGlobalCookbook(bagId, slotIndex)
+			if (match and settings.checkKnown == "known") or
+			   (not match and settings.checkKnown == "unknown")then
 				rankIcon:SetTexture(CANLEARN)
 				rankIcon:SetHidden(false)
+				if not match and gmatch and settings.checkKnown == "unknown" then
+					rankIcon:SetColor(1,1,1,0.5)
+				else
+					rankIcon:SetColor(1,1,1,1)
+				end
 			end
 		end

@@ -137,18 +150,22 @@ local function ParseRecipes()
 end

 local function SousChefCreateSettings()
-  local panel = LAM:CreateControlPanel("SousChef", "Sous Chef")
+	local panel = LAM:CreateControlPanel("SousChef", "Sous Chef")

-  LAM:AddHeader(panel, "SousChef_General", "Settings")
+	LAM:AddHeader(panel, "SousChef_General", "Settings")

-  LAM:AddDropdown(panel, "markLearnt", "Mark if recipes are ",
+  	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 settings.checkKnown end,
 						function(self,valueString) settings.checkKnown = valueString end)
-  LAM:AddColorPicker(panel, "setColour", "Indicator colour",
+	LAM:AddCheckBox(panel, "markAltKnows", "Indicate if an alt knows the recipe on unknown recipes. Will only work if the above setting is set to 'unknown'",
+						function() return settings.markAlt end,
+						function() settings.markAlt = not settings.markAlt end)
+	LAM:AddColorPicker(panel, "setColour", "Indicator colour",
 						"Allows you to set the colour of the indicator",
 						function() return settings.colour[1], settings.colour[2], settings.colour[3] end,
-						function(r,g,b) settings.colour[1] = r; settings.colour[2] = g; settings.colour[3] = b end)
+						function(r,g,b) settings.colour[1] = r; settings.colour[2] = g; settings.colour[3] = b end)
+
 end


@@ -161,6 +178,7 @@ local function SousChef_Loaded(eventCode, addOnName)
 	local defaults = {
 		watching = true,
 		checkKnown = "unknown",
+		markAlt = false,
 		colour = {1, 1, 1}
 	}

@@ -209,4 +227,4 @@ end



-SousChef_Initialized()
\ No newline at end of file
+SousChef_Initialized()