Quantcast

Re-anchored ARL_ExpGeneralOptCB to MainPanel.filter_reset, from MainPanel.filter_toggle, to match its physical location.

torhal [11-28-09 - 04:16]
Re-anchored ARL_ExpGeneralOptCB to MainPanel.filter_reset, from MainPanel.filter_toggle, to match its physical location.
Moved creation of the filter toggle buttons from addon:InitializeFrame() to the main file body.
Moved CreateFilterMenuButton() to just before it's needed.
Moved CreateExpansionButton() to just after the creation of MainPanel.filter_menu, where it will be needed after further changes.
In the ToC: Moved ARLFrame.lua to load after ARLColour.lua.
Filename
ARLFrame.lua
AckisRecipeList.toc
diff --git a/ARLFrame.lua b/ARLFrame.lua
index b2e5633..2826788 100644
--- a/ARLFrame.lua
+++ b/ARLFrame.lua
@@ -1362,36 +1362,6 @@ MainPanel.filter_toggle:SetScript("OnClick",
 			   end)

 -------------------------------------------------------------------------------
--- Create MainPanel.filter_menu and set its scripts.
--------------------------------------------------------------------------------
-MainPanel.filter_menu = CreateFrame("Frame", "ARL_FilterMenu", MainPanel)
-MainPanel.filter_menu:SetWidth(FILTERMENU_DOUBLE_WIDTH)
-MainPanel.filter_menu:SetHeight(FILTERMENU_HEIGHT)
-MainPanel.filter_menu:SetPoint("TOPLEFT", MainPanel, "TOPRIGHT", -6, -102)
-MainPanel.filter_menu:EnableMouse(true)
-MainPanel.filter_menu:EnableKeyboard(true)
-MainPanel.filter_menu:SetMovable(false)
-MainPanel.filter_menu:SetHitRectInsets(5, 5, 5, 5)
-MainPanel.filter_menu:Hide()
-
--- Set all the current options in the filter menu to make sure they are consistent with the SV options.
-MainPanel.filter_menu:SetScript("OnShow",
-				function()
-					for filter, info in pairs(FilterValueMap) do
-						if info.svroot then
-							info.cb:SetChecked(info.svroot[filter])
-						end
-					end
-					-- Miscellaneous Options
-					ARL_IgnoreCB:SetChecked(addon.db.profile.ignoreexclusionlist)
-				end)
-
-MainPanel.filter_menu.texture = MainPanel.filter_menu:CreateTexture(nil, "ARTWORK")
-MainPanel.filter_menu.texture:SetTexture("Interface\\Addons\\AckisRecipeList\\img\\fly_2col")
-MainPanel.filter_menu.texture:SetAllPoints(MainPanel.filter_menu)
-MainPanel.filter_menu.texture:SetTexCoord(0, (FILTERMENU_DOUBLE_WIDTH/256), 0, (FILTERMENU_HEIGHT/512))
-
--------------------------------------------------------------------------------
 -- Create MainPanel.filter_reset and set its scripts.
 -------------------------------------------------------------------------------
 MainPanel.filter_reset = GenericCreateButton(nil, MainPanel, 25, 90, "GameFontNormalSmall", "GameFontHighlightSmall", _G.RESET, "CENTER",
@@ -1439,1268 +1409,1323 @@ do
 end	-- do

 -------------------------------------------------------------------------------
--- Create MainPanel.scrollframe and set its scripts.
+-- Create the seven buttons for opening/closing the filter menus
 -------------------------------------------------------------------------------
-MainPanel.scroll_frame = CreateFrame("ScrollFrame", "ARL_MainPanelScrollFrame", MainPanel, "FauxScrollFrameTemplate")
-MainPanel.scroll_frame:SetHeight(322)
-MainPanel.scroll_frame:SetWidth(243)
-MainPanel.scroll_frame:SetPoint("TOPLEFT", MainPanel, "TOPLEFT", 20, -97)
-MainPanel.scroll_frame:SetScript("OnVerticalScroll",
-				 function(self, arg1)
-					 self.scrolling = true
-					 FauxScrollFrame_OnVerticalScroll(self, arg1, 16, self.Update)
-					 self.scrolling = nil
-				 end)
-
-MainPanel.scroll_frame.entries = {}
-MainPanel.scroll_frame.state_buttons = {}
-MainPanel.scroll_frame.recipe_buttons = {}
-
+local CreateFilterMenuButton
 do
-	local highlight = CreateFrame("Frame", nil, UIParent)
-	highlight:SetFrameStrata("TOOLTIP")
-	highlight:Hide()
+	local ExpButtonTT = {
+		L["FILTERING_GENERAL_DESC"],	-- 1
+		L["FILTERING_OBTAIN_DESC"],	-- 2
+		L["FILTERING_BINDING_DESC"],	-- 3
+		L["FILTERING_ITEM_DESC"],	-- 4
+		L["FILTERING_PLAYERTYPE_DESC"],	-- 5
+		L["FILTERING_REP_DESC"],	-- 6
+		L["FILTERING_MISC_DESC"]	-- 7
+	}

-	highlight._texture = highlight:CreateTexture(nil, "OVERLAY")
-	highlight._texture:SetTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight")
-	highlight._texture:SetBlendMode("ADD")
-	highlight._texture:SetAllPoints(highlight)
+	local function ToggleFilterMenu(panel)
+		-- This manages the filter menu panel, as well as checking or unchecking the
+		-- buttons that got us here in the first place
+		--
+		-- our panels are:
+		-- 1	ARL_ExpGeneralOptCB			General Filters
+		-- 2	ARL_ExpObtainOptCB			Obtain Filters
+		-- 3	ARL_ExpBindingOptCB			Binding Filters
+		-- 4	ARL_ExpItemOptCB			Item Filters
+		-- 5	ARL_ExpPlayerOptCB			Role Filters
+		-- 6	ARL_ExpRepOptCB				Reputation Filters
+		-- 7	ARL_ExpMiscOptCB			Miscellaneous Filters

-	local function Button_OnEnter(self)
-		GenerateTooltipContent(self, MainPanel.scroll_frame.entries[self.string_index].recipe_id)
-	end
+		local ChangeFilters = false

-	local function Button_OnLeave()
-		QTip:Release(arlTooltip)
-		arlSpellTooltip:Hide()
-	end
+		MainPanel.filter_menu.Rep.Classic:Hide()
+		MainPanel.filter_menu.Rep.BC:Hide()
+		MainPanel.filter_menu.Rep.LK:Hide()

-	local function Bar_OnEnter(self)
-		highlight:SetParent(self)
-		highlight:SetAllPoints(self)
-		highlight:Show()
-		GenerateTooltipContent(self, MainPanel.scroll_frame.entries[self.string_index].recipe_id)
-	end
+		ARL_Rep_ClassicCB:SetChecked(false)
+		ARL_Rep_BCCB:SetChecked(false)
+		ARL_Rep_LKCB:SetChecked(false)

-	local function Bar_OnLeave()
-		highlight:Hide()
-		highlight:ClearAllPoints()
-		highlight:SetParent(nil)
-		QTip:Release(arlTooltip)
-		arlSpellTooltip:Hide()
-	end
+		if panel == 1 then
+			if ARL_ExpGeneralOptCB:GetChecked() then
+				-- uncheck all other buttons
+				HideARL_ExpOptCB("general")

-	function MainPanel.scroll_frame:Update(expand_acquires, refresh)
-		local sorted_recipes = addon.sorted_recipes
-		local recipe_list = addon.recipe_list
-		local exclusions = addon.db.profile.exclusionlist
-		local sort_type = addon.db.profile.sorting
-		local skill_sort = (sort_type == "SkillAsc" or sort_type == "SkillDesc")
-		local insert_index = 1
+				-- display the correct subframe with all the buttons and such, hide the others
+				MainPanel.filter_menu.General:Show()
+				MainPanel.filter_menu.Obtain:Hide()
+				MainPanel.filter_menu.Binding:Hide()
+				MainPanel.filter_menu.Item:Hide()
+				MainPanel.filter_menu.Player:Hide()
+				MainPanel.filter_menu.Rep:Hide()
+				MainPanel.filter_menu.Misc:Hide()

-		-- If not refreshing an existing list and not scrolling up/down, wipe and re-initialize the entries.
-		if not refresh and not self.scrolling then
-			for i = 1, #self.entries do
-				ReleaseTable(self.entries[i])
+				ChangeFilters = true
+			else
+				ARL_ExpGeneralOptCB.text:SetText(addon:Yellow(ExpButtonText[1]))
+				ChangeFilters = false
 			end
-			twipe(self.entries)
-
-			for i = 1, #sorted_recipes do
-				local recipe_index = sorted_recipes[i]
-				local recipe_entry = recipe_list[recipe_index]
+		elseif panel == 2 then
+			if ARL_ExpObtainOptCB:GetChecked() then
+				HideARL_ExpOptCB("obtain")

-				if recipe_entry["Display"] and recipe_entry["Search"] then
-					local recipe_string = recipe_entry["Name"]
+				-- display the correct subframe with all the buttons and such, hide the others
+				MainPanel.filter_menu.General:Hide()
+				MainPanel.filter_menu.Obtain:Show()
+				MainPanel.filter_menu.Binding:Hide()
+				MainPanel.filter_menu.Item:Hide()
+				MainPanel.filter_menu.Player:Hide()
+				MainPanel.filter_menu.Rep:Hide()
+				MainPanel.filter_menu.Misc:Hide()

-					if exclusions[recipe_index] then
-						recipe_string = "** " .. recipe_string .. " **"
-					end
-					local recipe_level = recipe_entry["Level"]
+				ChangeFilters = true
+			else
+				ARL_ExpObtainOptCB.text:SetText(addon:Yellow(ExpButtonText[2]))
+				ChangeFilters = false
+			end
+		elseif panel == 3 then
+			if ARL_ExpBindingOptCB:GetChecked() then
+				HideARL_ExpOptCB("binding")

-					recipe_string = skill_sort and ("[" .. recipe_level .. "] - " .. recipe_string) or (recipe_string .. " - [" .. recipe_level .. "]")
+				-- display the correct subframe with all the buttons and such, hide the others
+				MainPanel.filter_menu.General:Hide()
+				MainPanel.filter_menu.Obtain:Hide()
+				MainPanel.filter_menu.Binding:Show()
+				MainPanel.filter_menu.Item:Hide()
+				MainPanel.filter_menu.Player:Hide()
+				MainPanel.filter_menu.Rep:Hide()
+				MainPanel.filter_menu.Misc:Hide()

-					local t = AcquireTable()
-					t.text = ColourSkillLevel(recipe_entry, Player:HasProperRepLevel(recipe_index), recipe_string)
+				ChangeFilters = true
+			else
+				ARL_ExpBindingOptCB.text:SetText(addon:Yellow(ExpButtonText[3]))
+				ChangeFilters = false
+			end
+		elseif panel == 4 then
+			if ARL_ExpItemOptCB:GetChecked() then
+				HideARL_ExpOptCB("item")

-					t.recipe_id = recipe_index
-					t.is_header = true
+				-- display the correct subframe with all the buttons and such, hide the others
+				MainPanel.filter_menu.General:Hide()
+				MainPanel.filter_menu.Obtain:Hide()
+				MainPanel.filter_menu.Binding:Hide()
+				MainPanel.filter_menu.Item:Show()
+				MainPanel.filter_menu.Player:Hide()
+				MainPanel.filter_menu.Rep:Hide()
+				MainPanel.filter_menu.Misc:Hide()

-					if expand_acquires and recipe_entry["Acquire"] then
-						-- we have acquire information for this. push the title entry into the strings
-						-- and start processing the acquires
-						t.is_expanded = true
-						tinsert(self.entries, insert_index, t)
-						insert_index = self:ExpandEntry(insert_index)
-					else
-						t.is_expanded = false
-						tinsert(self.entries, insert_index, t)
-						insert_index = insert_index + 1
-					end
-				end
+				ChangeFilters = true
+			else
+				ARL_ExpItemOptCB.text:SetText(addon:Yellow(ExpButtonText[4]))
+				ChangeFilters = false
 			end
-		end
-
-		-- Reset the current buttons/lines
-		for i = 1, NUM_RECIPE_LINES do
-			local recipe = self.recipe_buttons[i]
-			local state = self.state_buttons[i]
+		elseif panel == 5 then
+			if ARL_ExpPlayerOptCB:GetChecked() then
+				HideARL_ExpOptCB("player")

-			recipe.string_index = 0
-			recipe:SetText("")
-			recipe:SetScript("OnEnter", nil)
-			recipe:SetScript("OnLeave", nil)
+				-- display the correct subframe with all the buttons and such, hide the others
+				MainPanel.filter_menu.General:Hide()
+				MainPanel.filter_menu.Obtain:Hide()
+				MainPanel.filter_menu.Binding:Hide()
+				MainPanel.filter_menu.Item:Hide()
+				MainPanel.filter_menu.Player:Show()
+				MainPanel.filter_menu.Rep:Hide()
+				MainPanel.filter_menu.Misc:Hide()

-			state.string_index = 0
-			state:Hide()
-			state:SetScript("OnEnter", nil)
-			state:SetScript("OnLeave", nil)
-		end
-		local num_entries = #self.entries
-		local display_lines = NUM_RECIPE_LINES
+				ChangeFilters = true
+			else
+				ARL_ExpPlayerOptCB.text:SetText(addon:Yellow(ExpButtonText[5]))
+				ChangeFilters = false
+			end
+		elseif panel == 6 then
+			if ARL_ExpRepOptCB:GetChecked() then
+				HideARL_ExpOptCB("rep")

-		if num_entries < display_lines then
-			display_lines = num_entries / 2
-		end
-		FauxScrollFrame_Update(self, num_entries, display_lines, 16)
-		addon:ClosePopups()
+				-- display the correct subframe with all the buttons and such, hide the others
+				MainPanel.filter_menu.General:Hide()
+				MainPanel.filter_menu.Obtain:Hide()
+				MainPanel.filter_menu.Binding:Hide()
+				MainPanel.filter_menu.Item:Hide()
+				MainPanel.filter_menu.Player:Hide()
+				MainPanel.filter_menu.Rep:Show()
+				MainPanel.filter_menu.Misc:Hide()

-		if num_entries > 0 then
-			ARL_ExpandButton:SetNormalFontObject("GameFontNormalSmall")
-			ARL_ExpandButton:Enable()
-
-			-- Populate the buttons with new values
-			local button_index = 1
-			local string_index = button_index + FauxScrollFrame_GetOffset(self)
-			local stayInLoop = true
-
-			while stayInLoop do
-				local cur_state = self.state_buttons[button_index]
-				local cur_entry = self.entries[string_index]
-
-				if cur_entry.is_header then
-					cur_state:Show()
-
-					if cur_entry.is_expanded then
-						cur_state:SetNormalTexture("Interface\\Buttons\\UI-MinusButton-Up")
-						cur_state:SetPushedTexture("Interface\\Buttons\\UI-MinusButton-Down")
-						cur_state:SetHighlightTexture("Interface\\Buttons\\UI-PlusButton-Hilight")
-						cur_state:SetDisabledTexture("Interface\\Buttons\\UI-MinusButton-Disabled")
-					else
-						cur_state:SetNormalTexture("Interface\\Buttons\\UI-PlusButton-Up")
-						cur_state:SetPushedTexture("Interface\\Buttons\\UI-PlusButton-Down")
-						cur_state:SetHighlightTexture("Interface\\Buttons\\UI-PlusButton-Hilight")
-						cur_state:SetDisabledTexture("Interface\\Buttons\\UI-PlusButton-Disabled")
-					end
-					cur_state.string_index = string_index
-					cur_state:SetScript("OnEnter", Button_OnEnter)
-					cur_state:SetScript("OnLeave", Button_OnLeave)
-				else
-					cur_state:Hide()
-				end
-				local cur_recipe = self.recipe_buttons[button_index]
-
-				cur_recipe.string_index = string_index
-				cur_recipe:SetText(cur_entry.text)
-				cur_recipe:SetScript("OnEnter", Bar_OnEnter)
-				cur_recipe:SetScript("OnLeave", Bar_OnLeave)
-
-				button_index = button_index + 1
-				string_index = string_index + 1
-
-				if (button_index > NUM_RECIPE_LINES) or (string_index > num_entries) then
-					stayInLoop = false
-				end
-			end
-		else
-			-- disable expand button, it's useless here and would spam the same error again
-			ARL_ExpandButton:SetNormalFontObject("GameFontDisableSmall")
-			ARL_ExpandButton:Disable()
-
-			local showpopup = false
-
-			if not addon.db.profile.hidepopup then
-				showpopup = true
+				ChangeFilters = true
+			else
+				ARL_ExpRepOptCB.text:SetText(addon:Yellow(ExpButtonText[6]))
+				ChangeFilters = false
 			end
+		elseif panel == 7 then
+			if ARL_ExpMiscOptCB:GetChecked() then
+				HideARL_ExpOptCB("misc")

-			-- If we haven't run this before we'll show pop-ups for the first time.
-			if addon.db.profile.addonversion ~= addon.version then
-				addon.db.profile.addonversion = addon.version
-				showpopup = true
-			end
+				-- display the correct subframe with all the buttons and such, hide the others
+				MainPanel.filter_menu.General:Hide()
+				MainPanel.filter_menu.Obtain:Hide()
+				MainPanel.filter_menu.Binding:Hide()
+				MainPanel.filter_menu.Item:Hide()
+				MainPanel.filter_menu.Player:Hide()
+				MainPanel.filter_menu.Rep:Hide()
+				MainPanel.filter_menu.Misc:Show()

-			if Player.recipes_total == 0 then
-				if showpopup then
-					StaticPopup_Show("ARL_NOTSCANNED")
-				end
-			elseif Player.recipes_known == Player.recipes_total then
-				if showpopup then
-					StaticPopup_Show("ARL_ALLKNOWN")
-				end
-			elseif (Player.recipes_total_filtered - Player.recipes_known_filtered) == 0 then
-				if showpopup then
-					StaticPopup_Show("ARL_ALLFILTERED")
-				end
-			elseif Player.excluded_recipes_unknown ~= 0 then
-				if showpopup then
-					StaticPopup_Show("ARL_ALLEXCLUDED")
-				end
-			elseif ARL_SearchText:GetText() ~= "" then
-				StaticPopup_Show("ARL_SEARCHFILTERED")
+				ChangeFilters = true
 			else
-				addon:Print(L["NO_DISPLAY"])
-				addon:Print("DEBUG: recipes_total check for 0")
-				addon:Print("DEBUG: recipes_total: " .. Player.recipes_total)
-				addon:Print("DEBUG: recipes_total check for equal to recipes_total")
-				addon:Print("DEBUG: recipes_known: " .. Player.recipes_known)
-				addon:Print("DEBUG: recipes_total: " .. Player.recipes_total)
-				addon:Print("DEBUG: recipes_total_filtered - recipes_known_filtered = 0")
-				addon:Print("DEBUG: recipes_total_filtered: " .. Player.recipes_total_filtered)
-				addon:Print("DEBUG: recipes_known_filtered: " .. Player.recipes_known_filtered)
-				addon:Print("DEBUG: excluded_recipes_unknown ~= 0")
-				addon:Print("DEBUG: excluded_recipes_unknown: " .. Player.excluded_recipes_unknown)
+				ARL_ExpMiscOptCB.text:SetText(addon:Yellow(ExpButtonText[7]))
+				ChangeFilters = false
 			end
 		end
-	end
-	local faction_strings

-	local function CheckDisplayFaction(faction)
-		if addon.db.profile.filters.general.faction then
-			return true
+		if ChangeFilters then
+			-- Depending on which panel we're showing, either display one column
+			-- or two column
+			if panel == 1 or panel == 2 or panel == 3 or panel == 4 or panel == 7 then
+				MainPanel.filter_menu.texture:ClearAllPoints()
+				MainPanel.filter_menu:SetWidth(FILTERMENU_DOUBLE_WIDTH)
+				MainPanel.filter_menu.texture:SetTexture([[Interface\Addons\AckisRecipeList\img\fly_2col]])
+				MainPanel.filter_menu.texture:SetAllPoints(MainPanel.filter_menu)
+				MainPanel.filter_menu.texture:SetTexCoord(0, (FILTERMENU_DOUBLE_WIDTH/256), 0, (FILTERMENU_HEIGHT/512))
+			elseif ((panel == 5) or (panel == 6)) then
+				MainPanel.filter_menu.texture:ClearAllPoints()
+				MainPanel.filter_menu:SetWidth(FILTERMENU_SINGLE_WIDTH)
+				MainPanel.filter_menu.texture:SetTexture([[Interface\Addons\AckisRecipeList\img\fly_1col]])
+				MainPanel.filter_menu.texture:SetAllPoints(MainPanel.filter_menu)
+				MainPanel.filter_menu.texture:SetTexCoord(0, (FILTERMENU_SINGLE_WIDTH/256), 0, (FILTERMENU_HEIGHT/512))
+			end
+			-- Change the filters to the current panel
+			MainPanel.filter_menu:Show()
+		else
+			-- We're hiding, don't bother changing anything
+			MainPanel.filter_menu:Hide()
 		end
-		return (not faction or faction == BFAC[Player["Faction"]] or faction == FACTION_NEUTRAL)
 	end

-	function MainPanel.scroll_frame:ExpandEntry(entry_index)
-		local obtain_filters = addon.db.profile.filters.obtain
-		local recipe_id = self.entries[entry_index].recipe_id
-		local pad = "  "
-
-		-- entry_index is the position in self.entries that we want
-		-- to expand. Since we are expanding the current entry, the return
-		-- value should be the index of the next button after the expansion
-		-- occurs
-		entry_index = entry_index + 1
+	function CreateFilterMenuButton(bName, bTex, panelIndex)
+		local ExpTextureSize = 34
+		local cButton = CreateFrame("CheckButton", bName, MainPanel) -- , "UICheckButtonTemplate")

-		for k, v in pairs(addon.recipe_list[recipe_id]["Acquire"]) do
-			-- Initialize the first line here, since every type below will have one.
-			local acquire_type = v["Type"]
-			local t = AcquireTable()
-			t.recipe_id = recipe_id
-			t.is_expanded = true
+		cButton:SetWidth(ExpTextureSize)
+		cButton:SetHeight(ExpTextureSize)
+		cButton:SetScript("OnClick",
+				  function()
+					  ToggleFilterMenu(panelIndex)
+				  end)

-			if acquire_type == A_TRAINER and obtain_filters.trainer then
-				local trainer = addon.trainer_list[v["ID"]]
+		local bgTex = cButton:CreateTexture(cButton:GetName() .. "bgTex", "BACKGROUND")
+		bgTex:SetTexture('Interface/SpellBook/UI-Spellbook-SpellBackground')
+		bgTex:SetHeight(ExpTextureSize + 6)
+		bgTex:SetWidth(ExpTextureSize + 4)
+		bgTex:SetTexCoord(0, (43/64), 0, (43/64))
+		bgTex:SetPoint("CENTER", cButton, "CENTER", 0, 0)

-				if CheckDisplayFaction(trainer["Faction"]) then
-					local nStr = ""
+		local iconTex = cButton:CreateTexture(cButton:GetName() .. "iconTex", "BORDER")
+		iconTex:SetTexture('Interface/Icons/' .. bTex)
+		iconTex:SetAllPoints(cButton)

-					if trainer["Faction"] == FACTION_HORDE then
-						nStr = addon:Horde(trainer["Name"])
-					elseif trainer["Faction"] == FACTION_ALLIANCE then
-						nStr = addon:Alliance(trainer["Name"])
-					else
-						nStr = addon:Neutral(trainer["Name"])
-					end
-					t.text = pad .. addon:Trainer(L["Trainer"] .. " : ") .. nStr
+		local pushedTexture = cButton:CreateTexture(cButton:GetName() .. "pTex", "ARTWORK")
+		pushedTexture:SetTexture('Interface/Buttons/UI-Quickslot-Depress')
+		pushedTexture:SetAllPoints(cButton)
+		cButton:SetPushedTexture(pushedTexture)

-					tinsert(self.entries, entry_index, t)
-					entry_index = entry_index + 1
+		local highlightTexture = cButton:CreateTexture()
+		highlightTexture:SetTexture('Interface/Buttons/ButtonHilight-Square')
+		highlightTexture:SetAllPoints(cButton)
+		highlightTexture:SetBlendMode('ADD')
+		cButton:SetHighlightTexture(highlightTexture)

-					local cStr = ""
+		local checkedTexture = cButton:CreateTexture()
+		checkedTexture:SetTexture('Interface/Buttons/CheckButtonHilight')
+		checkedTexture:SetAllPoints(cButton)
+		checkedTexture:SetBlendMode('ADD')
+		cButton:SetCheckedTexture(checkedTexture)

-					if trainer["Coordx"] ~= 0 and trainer["Coordy"] ~= 0 then
-						cStr = addon:Coords("(" .. trainer["Coordx"] .. ", " .. trainer["Coordy"] .. ")")
-					end
-					t = AcquireTable()
-					t.recipe_id = recipe_id
-					t.is_expanded = true
-					t.text = pad .. pad .. trainer["Location"] .. " " .. cStr
+		-- Create the text object to go along with it
+		local cbText = cButton:CreateFontString("cbText", "OVERLAY", "GameFontHighlight")
+		cbText:SetText(addon:Yellow(ExpButtonText[panelIndex]))
+		cbText:SetPoint("LEFT", cButton, "RIGHT", 5, 0)
+		cbText:SetHeight(14)
+		cbText:SetWidth(100)
+		cbText:SetJustifyH("LEFT")
+		cButton.text = cbText

-					tinsert(self.entries, entry_index, t)
-					entry_index = entry_index + 1
-				end
-				-- Right now PVP obtained items are located on vendors so they have the vendor and pvp flag.
-				-- We need to display the vendor in the drop down if we want to see vendors or if we want to see PVP
-				-- This allows us to select PVP only and to see just the PVP recipes
-			elseif acquire_type == A_VENDOR and (obtain_filters.vendor or obtain_filters.pvp) then
-				local vendor = addon.vendor_list[v["ID"]]
+		-- And throw up a tooltip
+		SetTooltipScripts(cButton, ExpButtonTT[panelIndex])
+		cButton:Hide()

-				if CheckDisplayFaction(vendor["Faction"]) then
-					local nStr = ""
+		return cButton
+	end
+end	-- do

-					if vendor["Faction"] == FACTION_HORDE then
-						nStr = addon:Horde(vendor["Name"])
-					elseif vendor["Faction"] == FACTION_ALLIANCE then
-						nStr = addon:Alliance(vendor["Name"])
-					else
-						nStr = addon:Neutral(vendor["Name"])
-					end
-					t.text = pad .. addon:Vendor(L["Vendor"] .. " : ") .. nStr
+ARL_ExpGeneralOptCB = CreateFilterMenuButton("ARL_ExpGeneralOptCB", "INV_Misc_Note_06", 1)
+ARL_ExpGeneralOptCB:SetPoint("TOPRIGHT", MainPanel.filter_reset, "BOTTOMLEFT", -7, -23)

-					tinsert(self.entries, entry_index, t)
-					entry_index = entry_index + 1
+ARL_ExpObtainOptCB = CreateFilterMenuButton("ARL_ExpObtainOptCB", "Spell_Shadow_MindRot", 2)
+ARL_ExpObtainOptCB:SetPoint("TOPLEFT", ARL_ExpGeneralOptCB, "BOTTOMLEFT", 0, -8)

-					local cStr = ""
+ARL_ExpBindingOptCB = CreateFilterMenuButton("ARL_ExpBindingOptCB", "INV_Belt_20", 3)
+ARL_ExpBindingOptCB:SetPoint("TOPLEFT", ARL_ExpObtainOptCB, "BOTTOMLEFT", -0, -8)

-					if vendor["Coordx"] ~= 0 and vendor["Coordy"] ~= 0 then
-						cStr = addon:Coords("(" .. vendor["Coordx"] .. ", " .. vendor["Coordy"] .. ")")
-					end
-					t = AcquireTable()
-					t.recipe_id = recipe_id
-					t.is_expanded = true
-					t.text = pad .. pad .. vendor["Location"] .. " " .. cStr
+ARL_ExpItemOptCB = CreateFilterMenuButton("ARL_ExpItemOptCB", "INV_Misc_EngGizmos_19", 4)
+ARL_ExpItemOptCB:SetPoint("TOPLEFT", ARL_ExpBindingOptCB, "BOTTOMLEFT", -0, -8)

-					tinsert(self.entries, entry_index, t)
-					entry_index = entry_index + 1
-				end
-				-- Mobs can be in instances, raids, or specific mob related drops.
-			elseif acquire_type == A_MOB and (obtain_filters.mobdrop or obtain_filters.instance or obtain_filters.raid) then
-				local mob = addon.mob_list[v["ID"]]
-				t.text = pad .. addon:MobDrop(L["Mob Drop"] .. " : ") .. addon:Red(mob["Name"])
+ARL_ExpPlayerOptCB = CreateFilterMenuButton("ARL_ExpPlayerOptCB", "INV_Misc_GroupLooking", 5)
+ARL_ExpPlayerOptCB:SetPoint("TOPLEFT", ARL_ExpItemOptCB, "BOTTOMLEFT", -0, -8)

-				tinsert(self.entries, entry_index, t)
-				entry_index = entry_index + 1
+ARL_ExpRepOptCB = CreateFilterMenuButton("ARL_ExpRepOptCB", "INV_Scroll_05", 6)
+ARL_ExpRepOptCB:SetPoint("TOPLEFT", ARL_ExpPlayerOptCB, "BOTTOMLEFT", -0, -8)

-				local cStr = ""
+ARL_ExpMiscOptCB = CreateFilterMenuButton("ARL_ExpMiscOptCB", "Trade_Engineering", 7)
+ARL_ExpMiscOptCB:SetPoint("TOPLEFT", ARL_ExpRepOptCB, "BOTTOMLEFT", -0, -8)

-				if mob["Coordx"] ~= 0 and mob["Coordy"] ~= 0 then
-					cStr = addon:Coords("(" .. mob["Coordx"] .. ", " .. mob["Coordy"] .. ")")
-				end
-				t = AcquireTable()
-				t.recipe_id = recipe_id
-				t.is_expanded = true
-				t.text = pad .. pad .. mob["Location"] .. " " .. cStr
+-------------------------------------------------------------------------------
+-- Create MainPanel.filter_menu and set its scripts.
+-------------------------------------------------------------------------------
+MainPanel.filter_menu = CreateFrame("Frame", "ARL_FilterMenu", MainPanel)
+MainPanel.filter_menu:SetWidth(FILTERMENU_DOUBLE_WIDTH)
+MainPanel.filter_menu:SetHeight(FILTERMENU_HEIGHT)
+MainPanel.filter_menu:SetPoint("TOPLEFT", MainPanel, "TOPRIGHT", -6, -102)
+MainPanel.filter_menu:EnableMouse(true)
+MainPanel.filter_menu:EnableKeyboard(true)
+MainPanel.filter_menu:SetMovable(false)
+MainPanel.filter_menu:SetHitRectInsets(5, 5, 5, 5)
+MainPanel.filter_menu:Hide()

-				tinsert(self.entries, entry_index, t)
-				entry_index = entry_index + 1
-			elseif acquire_type == A_QUEST and obtain_filters.quest then
-				local quest = addon.quest_list[v["ID"]]
+-- Set all the current options in the filter menu to make sure they are consistent with the SV options.
+MainPanel.filter_menu:SetScript("OnShow",
+				function()
+					for filter, info in pairs(FilterValueMap) do
+						if info.svroot then
+							info.cb:SetChecked(info.svroot[filter])
+						end
+					end
+					-- Miscellaneous Options
+					ARL_IgnoreCB:SetChecked(addon.db.profile.ignoreexclusionlist)
+				end)

-				if CheckDisplayFaction(quest["Faction"]) then
-					local nStr = ""
+MainPanel.filter_menu.texture = MainPanel.filter_menu:CreateTexture(nil, "ARTWORK")
+MainPanel.filter_menu.texture:SetTexture("Interface\\Addons\\AckisRecipeList\\img\\fly_2col")
+MainPanel.filter_menu.texture:SetAllPoints(MainPanel.filter_menu)
+MainPanel.filter_menu.texture:SetTexCoord(0, (FILTERMENU_DOUBLE_WIDTH/256), 0, (FILTERMENU_HEIGHT/512))

-					if quest["Faction"] == FACTION_HORDE then
-						nStr = addon:Horde(quest["Name"])
-					elseif quest["Faction"] == FACTION_ALLIANCE then
-						nStr = addon:Alliance(quest["Name"])
-					else
-						nStr = addon:Neutral(quest["Name"])
-					end
-					t.text = pad .. addon:Quest(L["Quest"] .. " : ") .. nStr
+-------------------------------------------------------------------------------
+-- Generic function to create expansion buttons in MainPanel.filter_menu.Rep
+-------------------------------------------------------------------------------
+local function CreateExpansionButton(bName, bTex)
+	local cButton = CreateFrame("CheckButton", bName, MainPanel.filter_menu.Rep)
+	cButton:SetWidth(100)
+	cButton:SetHeight(46)
+	cButton:SetChecked(false)
+
+	local iconTex = cButton:CreateTexture(cButton:GetName() .. "buttonTex", "BORDER")

-					tinsert(self.entries, entry_index, t)
-					entry_index = entry_index + 1
+	if bName == "ARL_Rep_LKCB" then
+		iconTex:SetTexture("Interface\\Addons\\AckisRecipeList\\img\\" .. bTex)
+	else
+		iconTex:SetTexture('Interface/Glues/Common/' .. bTex)
+	end
+	iconTex:SetWidth(100)
+	iconTex:SetHeight(46)
+	iconTex:SetAllPoints(cButton)
+
+	local pushedTexture = cButton:CreateTexture(cButton:GetName() .. "pTex", "ARTWORK")
+	pushedTexture:SetTexture('Interface/Buttons/UI-Quickslot-Depress')
+	pushedTexture:SetAllPoints(cButton)
+	cButton:SetPushedTexture(pushedTexture)
+
+	local highlightTexture = cButton:CreateTexture()
+	highlightTexture:SetTexture('Interface/Buttons/ButtonHilight-Square')
+	highlightTexture:SetAllPoints(cButton)
+	highlightTexture:SetBlendMode('ADD')
+	cButton:SetHighlightTexture(highlightTexture)
+
+	local checkedTexture = cButton:CreateTexture()
+	checkedTexture:SetTexture('Interface/Buttons/CheckButtonHilight')
+	checkedTexture:SetAllPoints(cButton)
+	checkedTexture:SetBlendMode('ADD')
+	cButton:SetCheckedTexture(checkedTexture)
+
+	-- And throw up a tooltip
+	if bName == "ARL_Rep_ClassicCB" then
+		SetTooltipScripts(cButton, L["FILTERING_OLDWORLD_DESC"])
+	elseif bName == "ARL_Rep_BCCB" then
+		SetTooltipScripts(cButton, L["FILTERING_BC_DESC"])
+	else
+		SetTooltipScripts(cButton, L["FILTERING_WOTLK_DESC"])
+	end
+	return cButton
+end

-					local cStr = ""
+-------------------------------------------------------------------------------
+-- Create MainPanel.scrollframe and set its scripts.
+-------------------------------------------------------------------------------
+MainPanel.scroll_frame = CreateFrame("ScrollFrame", "ARL_MainPanelScrollFrame", MainPanel, "FauxScrollFrameTemplate")
+MainPanel.scroll_frame:SetHeight(322)
+MainPanel.scroll_frame:SetWidth(243)
+MainPanel.scroll_frame:SetPoint("TOPLEFT", MainPanel, "TOPLEFT", 20, -97)
+MainPanel.scroll_frame:SetScript("OnVerticalScroll",
+				 function(self, arg1)
+					 self.scrolling = true
+					 FauxScrollFrame_OnVerticalScroll(self, arg1, 16, self.Update)
+					 self.scrolling = nil
+				 end)

-					if quest["Coordx"] ~= 0 and quest["Coordy"] ~= 0 then
-						cStr = addon:Coords("(" .. quest["Coordx"] .. ", " .. quest["Coordy"] .. ")")
-					end
-					t = AcquireTable()
-					t.recipe_id = recipe_id
-					t.is_expanded = true
-					t.text = pad .. pad .. quest["Location"] .. " " .. cStr
+MainPanel.scroll_frame.entries = {}
+MainPanel.scroll_frame.state_buttons = {}
+MainPanel.scroll_frame.recipe_buttons = {}

-					tinsert(self.entries, entry_index, t)
-					entry_index = entry_index + 1
-				end
-			elseif acquire_type == A_SEASONAL and obtain_filters.seasonal then
-				t.text = pad .. addon:Season(SEASONAL_CATEGORY .. " : " .. addon.seasonal_list[v["ID"]]["Name"])
-				tinsert(self.entries, entry_index, t)
-				entry_index = entry_index + 1
-			elseif acquire_type == A_REPUTATION then -- Need to check if we're displaying the currently id'd rep or not as well
-				-- Reputation Obtain
-				-- Rep: ID, Faction
-				-- RepLevel = 0 (Neutral), 1 (Friendly), 2 (Honored), 3 (Revered), 4 (Exalted)
-				-- RepVendor - VendorID
-				local rep_vendor = addon.vendor_list[v["RepVendor"]]
+do
+	local highlight = CreateFrame("Frame", nil, UIParent)
+	highlight:SetFrameStrata("TOOLTIP")
+	highlight:Hide()

-				if CheckDisplayFaction(rep_vendor["Faction"]) then
-					t.text = pad .. addon:Rep(_G.REPUTATION .. " : ") .. addon.reputation_list[v["ID"]]["Name"]
-					tinsert(self.entries, entry_index, t)
-					entry_index = entry_index + 1
+	highlight._texture = highlight:CreateTexture(nil, "OVERLAY")
+	highlight._texture:SetTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight")
+	highlight._texture:SetBlendMode("ADD")
+	highlight._texture:SetAllPoints(highlight)

-					if not faction_strings then
-						faction_strings = {
-							[0] = addon:Neutral(FACTION_NEUTRAL .. " : "),
-							[1] = addon:Friendly(BFAC["Friendly"] .. " : "),
-							[2] = addon:Honored(BFAC["Honored"] .. " : "),
-							[3] = addon:Revered(BFAC["Revered"] .. " : "),
-							[4] = addon:Exalted(BFAC["Exalted"] .. " : ")
-						}
-					end
-					local nStr = ""
+	local function Button_OnEnter(self)
+		GenerateTooltipContent(self, MainPanel.scroll_frame.entries[self.string_index].recipe_id)
+	end

-					if rep_vendor["Faction"] == FACTION_HORDE then
-						nStr = addon:Horde(rep_vendor["Name"])
-					elseif rep_vendor["Faction"] == FACTION_ALLIANCE then
-						nStr = addon:Alliance(rep_vendor["Name"])
-					else
-						nStr = addon:Neutral(rep_vendor["Name"])
-					end
-					t = AcquireTable()
-					t.recipe_id = recipe_id
-					t.is_expanded = true
+	local function Button_OnLeave()
+		QTip:Release(arlTooltip)
+		arlSpellTooltip:Hide()
+	end

-					t.text = pad .. pad .. faction_strings[v["RepLevel"]] .. nStr
+	local function Bar_OnEnter(self)
+		highlight:SetParent(self)
+		highlight:SetAllPoints(self)
+		highlight:Show()
+		GenerateTooltipContent(self, MainPanel.scroll_frame.entries[self.string_index].recipe_id)
+	end

-					tinsert(self.entries, entry_index, t)
-					entry_index = entry_index + 1
+	local function Bar_OnLeave()
+		highlight:Hide()
+		highlight:ClearAllPoints()
+		highlight:SetParent(nil)
+		QTip:Release(arlTooltip)
+		arlSpellTooltip:Hide()
+	end

-					local cStr = ""
+	function MainPanel.scroll_frame:Update(expand_acquires, refresh)
+		local sorted_recipes = addon.sorted_recipes
+		local recipe_list = addon.recipe_list
+		local exclusions = addon.db.profile.exclusionlist
+		local sort_type = addon.db.profile.sorting
+		local skill_sort = (sort_type == "SkillAsc" or sort_type == "SkillDesc")
+		local insert_index = 1

-					if rep_vendor["Coordx"] ~= 0 and rep_vendor["Coordy"] ~= 0 then
-						cStr = addon:Coords("(" .. rep_vendor["Coordx"] .. ", " .. rep_vendor["Coordy"] .. ")")
-					end
-					t = AcquireTable()
-					t.recipe_id = recipe_id
-					t.is_expanded = true
-					t.text = pad .. pad .. pad .. rep_vendor["Location"] .. " " .. cStr
+		-- If not refreshing an existing list and not scrolling up/down, wipe and re-initialize the entries.
+		if not refresh and not self.scrolling then
+			for i = 1, #self.entries do
+				ReleaseTable(self.entries[i])
+			end
+			twipe(self.entries)

-					tinsert(self.entries, entry_index, t)
-					entry_index = entry_index + 1
-				end
-			elseif acquire_type == A_WORLD_DROP and obtain_filters.worlddrop then
-				t.text = pad .. addon:RarityColor(v["ID"] + 1, L["World Drop"])
-				tinsert(self.entries, entry_index, t)
-				entry_index = entry_index + 1
-			elseif acquire_type == A_CUSTOM then
-				t.text = pad .. addon:Normal(addon.custom_list[v["ID"]]["Name"])
-				tinsert(self.entries, entry_index, t)
-				entry_index = entry_index + 1
-			elseif acquire_type == A_PVP and obtain_filters.pvp then
-				local vendor = addon.vendor_list[v["ID"]]
+			for i = 1, #sorted_recipes do
+				local recipe_index = sorted_recipes[i]
+				local recipe_entry = recipe_list[recipe_index]

-				if CheckDisplayFaction(vendor["Faction"]) then
-					local cStr = ""
+				if recipe_entry["Display"] and recipe_entry["Search"] then
+					local recipe_string = recipe_entry["Name"]

-					if vendor["Coordx"] ~= 0 and vendor["Coordy"] ~= 0 then
-						cStr = addon:Coords("(" .. vendor["Coordx"] .. ", " .. vendor["Coordy"] .. ")")
+					if exclusions[recipe_index] then
+						recipe_string = "** " .. recipe_string .. " **"
 					end
-					local nStr = ""
+					local recipe_level = recipe_entry["Level"]

-					if vendor["Faction"] == FACTION_HORDE then
-						nStr = addon:Horde(vendor["Name"])
-					elseif vendor["Faction"] == FACTION_ALLIANCE then
-						nStr = addon:Alliance(vendor["Name"])
-					else
-						nStr = addon:Neutral(vendor["Name"])
-					end
-					t.text = pad .. addon:Vendor(L["Vendor"] .. " : ") .. nStr
+					recipe_string = skill_sort and ("[" .. recipe_level .. "] - " .. recipe_string) or (recipe_string .. " - [" .. recipe_level .. "]")

-					tinsert(self.entries, entry_index, t)
-					entry_index = entry_index + 1
+					local t = AcquireTable()
+					t.text = ColourSkillLevel(recipe_entry, Player:HasProperRepLevel(recipe_index), recipe_string)

-					t = AcquireTable()
-					t.recipe_id = recipe_id
-					t.is_expanded = true
-					t.text = pad .. pad .. vendor["Location"] .. " " .. cStr
+					t.recipe_id = recipe_index
+					t.is_header = true

-					tinsert(self.entries, entry_index, t)
-					entry_index = entry_index + 1
+					if expand_acquires and recipe_entry["Acquire"] then
+						-- we have acquire information for this. push the title entry into the strings
+						-- and start processing the acquires
+						t.is_expanded = true
+						tinsert(self.entries, insert_index, t)
+						insert_index = self:ExpandEntry(insert_index)
+					else
+						t.is_expanded = false
+						tinsert(self.entries, insert_index, t)
+						insert_index = insert_index + 1
+					end
 				end
-				--@alpha@
-			elseif acquire_type > A_MAX then
-				t.text = "Unhandled Acquire Case - Type: " .. acquire_type
-				tinsert(self.entries, entry_index, t)
-				entry_index = entry_index + 1
-				--@end-alpha@
 			end
 		end
-		return entry_index
-	end
-end	-- do

--------------------------------------------------------------------------------
--- Create MainPanel.progress_bar and set its scripts
--------------------------------------------------------------------------------
-do
-	-- Default values for the progressbar
-	local pbMin = 0
-	local pbMax = 100
-	local pbCur = 50
+		-- Reset the current buttons/lines
+		for i = 1, NUM_RECIPE_LINES do
+			local recipe = self.recipe_buttons[i]
+			local state = self.state_buttons[i]

-	MainPanel.progress_bar = CreateFrame("StatusBar", nil, MainPanel)
-	MainPanel.progress_bar:SetWidth(195)
-	MainPanel.progress_bar:SetHeight(14)
+			recipe.string_index = 0
+			recipe:SetText("")
+			recipe:SetScript("OnEnter", nil)
+			recipe:SetScript("OnLeave", nil)

-	MainPanel.progress_bar:ClearAllPoints()
-	MainPanel.progress_bar:SetPoint("BOTTOMLEFT", MainPanel, 17, 7)
-
-	MainPanel.progress_bar:SetStatusBarTexture("Interface\\Addons\\AckisRecipeList\\img\\progressbar")
-	MainPanel.progress_bar:SetOrientation("HORIZONTAL")
-	MainPanel.progress_bar:SetStatusBarColor(0.25, 0.25, 0.75)
-	MainPanel.progress_bar:SetMinMaxValues(pbMin, pbMax)
-	MainPanel.progress_bar:SetValue(pbCur)
+			state.string_index = 0
+			state:Hide()
+			state:SetScript("OnEnter", nil)
+			state:SetScript("OnLeave", nil)
+		end
+		local num_entries = #self.entries
+		local display_lines = NUM_RECIPE_LINES

-	MainPanel.progress_bar.text = MainPanel.progress_bar:CreateFontString(nil, "ARTWORK")
-	MainPanel.progress_bar.text:SetWidth(195)
-	MainPanel.progress_bar.text:SetHeight(14)
-	MainPanel.progress_bar.text:SetFontObject("GameFontHighlightSmall")
+		if num_entries < display_lines then
+			display_lines = num_entries / 2
+		end
+		FauxScrollFrame_Update(self, num_entries, display_lines, 16)
+		addon:ClosePopups()

-	MainPanel.progress_bar.text:ClearAllPoints()
-	MainPanel.progress_bar.text:SetPoint("CENTER", MainPanel.progress_bar, "CENTER", 0, 0)
-	MainPanel.progress_bar.text:SetJustifyH("CENTER")
-	MainPanel.progress_bar.text:SetFormattedText("%d / %d - %d%%", pbCur, pbMax, floor(pbCur / pbMax * 100))
-end	-- do
+		if num_entries > 0 then
+			ARL_ExpandButton:SetNormalFontObject("GameFontNormalSmall")
+			ARL_ExpandButton:Enable()

-function MainPanel.progress_bar:Update()
-	local pbCur, pbMax
-	local settings = addon.db.profile
+			-- Populate the buttons with new values
+			local button_index = 1
+			local string_index = button_index + FauxScrollFrame_GetOffset(self)
+			local stayInLoop = true

-	if settings.includefiltered then
-		pbCur = Player.recipes_known
-		pbMax = Player.recipes_total
-	else
-		-- We're removing filtered recipes from the final count
-		pbCur = Player.recipes_known_filtered
-		pbMax = Player.recipes_total_filtered
-	end
+			while stayInLoop do
+				local cur_state = self.state_buttons[button_index]
+				local cur_entry = self.entries[string_index]

-	if not settings.includeexcluded and not settings.ignoreexclusionlist then
-		pbCur = pbCur - Player.excluded_recipes_unknown
-		pbMax = pbMax - Player.excluded_recipes_known
-	end
-	self:SetMinMaxValues(0, pbMax)
-	self:SetValue(pbCur)
+				if cur_entry.is_header then
+					cur_state:Show()

-	if (floor(pbCur / pbMax * 100) < 101) and pbCur >= 0 and pbMax >= 0 then
-		self.text:SetFormattedText("%d / %d - %d%%", pbCur, pbMax, floor(pbCur / pbMax * 100))
-	else
-		self.text:SetFormattedText("0 / 0 - %s", L["NOT_YET_SCANNED"])
-	end
-end
+					if cur_entry.is_expanded then
+						cur_state:SetNormalTexture("Interface\\Buttons\\UI-MinusButton-Up")
+						cur_state:SetPushedTexture("Interface\\Buttons\\UI-MinusButton-Down")
+						cur_state:SetHighlightTexture("Interface\\Buttons\\UI-PlusButton-Hilight")
+						cur_state:SetDisabledTexture("Interface\\Buttons\\UI-MinusButton-Disabled")
+					else
+						cur_state:SetNormalTexture("Interface\\Buttons\\UI-PlusButton-Up")
+						cur_state:SetPushedTexture("Interface\\Buttons\\UI-PlusButton-Down")
+						cur_state:SetHighlightTexture("Interface\\Buttons\\UI-PlusButton-Hilight")
+						cur_state:SetDisabledTexture("Interface\\Buttons\\UI-PlusButton-Disabled")
+					end
+					cur_state.string_index = string_index
+					cur_state:SetScript("OnEnter", Button_OnEnter)
+					cur_state:SetScript("OnLeave", Button_OnLeave)
+				else
+					cur_state:Hide()
+				end
+				local cur_recipe = self.recipe_buttons[button_index]

--------------------------------------------------------------------------------
--- Create the close button, and set its scripts.
--------------------------------------------------------------------------------
-MainPanel.close_button = GenericCreateButton(nil, MainPanel, 22, 69, "GameFontNormalSmall", "GameFontHighlightSmall", L["Close"], "CENTER", L["CLOSE_DESC"], 1)
-MainPanel.close_button:SetPoint("BOTTOMRIGHT", MainPanel, "BOTTOMRIGHT", -4, 3)
+				cur_recipe.string_index = string_index
+				cur_recipe:SetText(cur_entry.text)
+				cur_recipe:SetScript("OnEnter", Bar_OnEnter)
+				cur_recipe:SetScript("OnLeave", Bar_OnLeave)

-MainPanel.close_button:SetScript("OnClick",
-				 function(self, button, down)
-					 MainPanel:Hide()
-				 end)
+				button_index = button_index + 1
+				string_index = string_index + 1

--------------------------------------------------------------------------------
--- Map waypoint code.
--------------------------------------------------------------------------------
-do
-	local function LoadZones(c, y, ...)
-		-- Fill up the list for normal lookup
-		for i = 1, select('#', ...),1 do
-			c[i] = select(i,...)
-		end
-		-- Reverse lookup to make work easier later on
-		for i in pairs(c) do
-			y[c[i]] = i
-		end
-	end
+				if (button_index > NUM_RECIPE_LINES) or (string_index > num_entries) then
+					stayInLoop = false
+				end
+			end
+		else
+			-- disable expand button, it's useless here and would spam the same error again
+			ARL_ExpandButton:SetNormalFontObject("GameFontDisableSmall")
+			ARL_ExpandButton:Disable()

-	local C1 = {}
-	local C2 = {}
-	local C3 = {}
-	local C4 = {}
-	local c1 = {}
-	local c2 = {}
-	local c3 = {}
-	local c4 = {}
+			local showpopup = false

-	LoadZones(C1, c1, GetMapZones(1))
-	LoadZones(C2, c2, GetMapZones(2))
-	LoadZones(C3, c3, GetMapZones(3))
-	LoadZones(C4, c4, GetMapZones(4))
+			if not addon.db.profile.hidepopup then
+				showpopup = true
+			end

-	local iconlist = {}
+			-- If we haven't run this before we'll show pop-ups for the first time.
+			if addon.db.profile.addonversion ~= addon.version then
+				addon.db.profile.addonversion = addon.version
+				showpopup = true
+			end

-	-- Clears all the icons from the world map and the mini-map
-	function addon:ClearMap()
-		if TomTom then
-			for i in pairs(iconlist) do
-				TomTom:RemoveWaypoint(iconlist[i])
+			if Player.recipes_total == 0 then
+				if showpopup then
+					StaticPopup_Show("ARL_NOTSCANNED")
+				end
+			elseif Player.recipes_known == Player.recipes_total then
+				if showpopup then
+					StaticPopup_Show("ARL_ALLKNOWN")
+				end
+			elseif (Player.recipes_total_filtered - Player.recipes_known_filtered) == 0 then
+				if showpopup then
+					StaticPopup_Show("ARL_ALLFILTERED")
+				end
+			elseif Player.excluded_recipes_unknown ~= 0 then
+				if showpopup then
+					StaticPopup_Show("ARL_ALLEXCLUDED")
+				end
+			elseif ARL_SearchText:GetText() ~= "" then
+				StaticPopup_Show("ARL_SEARCHFILTERED")
+			else
+				addon:Print(L["NO_DISPLAY"])
+				addon:Print("DEBUG: recipes_total check for 0")
+				addon:Print("DEBUG: recipes_total: " .. Player.recipes_total)
+				addon:Print("DEBUG: recipes_total check for equal to recipes_total")
+				addon:Print("DEBUG: recipes_known: " .. Player.recipes_known)
+				addon:Print("DEBUG: recipes_total: " .. Player.recipes_total)
+				addon:Print("DEBUG: recipes_total_filtered - recipes_known_filtered = 0")
+				addon:Print("DEBUG: recipes_total_filtered: " .. Player.recipes_total_filtered)
+				addon:Print("DEBUG: recipes_known_filtered: " .. Player.recipes_known_filtered)
+				addon:Print("DEBUG: excluded_recipes_unknown ~= 0")
+				addon:Print("DEBUG: excluded_recipes_unknown: " .. Player.excluded_recipes_unknown)
 			end
-			iconlist = twipe(iconlist)
 		end
+	end
+	local faction_strings

+	local function CheckDisplayFaction(faction)
+		if addon.db.profile.filters.general.faction then
+			return true
+		end
+		return (not faction or faction == BFAC[Player["Faction"]] or faction == FACTION_NEUTRAL)
 	end

-	local function CheckMapDisplay(acquire_entry, flags)
-		local maptrainer = addon.db.profile.maptrainer
-		local mapquest = addon.db.profile.mapquest
-		local mapvendor = addon.db.profile.mapvendor
-		local mapmob = addon.db.profile.mapmob
-		local player_faction = Player["Faction"]
-		local acquire_type = acquire_entry["Type"]
-		local acquire_id = acquire_entry["ID"]
-		local display = false
+	function MainPanel.scroll_frame:ExpandEntry(entry_index)
+		local obtain_filters = addon.db.profile.filters.obtain
+		local recipe_id = self.entries[entry_index].recipe_id
+		local pad = "  "

-		-- Trainers - Display if it's your faction or neutral.
-		if maptrainer then
-			if acquire_type == A_TRAINER then
-				local trainer = addon.trainer_list[acquire_id]
+		-- entry_index is the position in self.entries that we want
+		-- to expand. Since we are expanding the current entry, the return
+		-- value should be the index of the next button after the expansion
+		-- occurs
+		entry_index = entry_index + 1

-				display = (trainer["Faction"] == BFAC[player_faction] or trainer["Faction"] == FACTION_NEUTRAL)
-			elseif acquire_type == A_CUSTOM and flags[3] then
-				return true
-			end
-			-- Vendors - Display if it's your faction or neutral
-		elseif mapvendor then
-			if acquire_type == A_VENDOR then
-				local vendor = addon.vendor_list[acquire_id]
+		for k, v in pairs(addon.recipe_list[recipe_id]["Acquire"]) do
+			-- Initialize the first line here, since every type below will have one.
+			local acquire_type = v["Type"]
+			local t = AcquireTable()
+			t.recipe_id = recipe_id
+			t.is_expanded = true

-				display = (vendor["Faction"] == BFAC[player_faction] or vendor["Faction"] == FACTION_NEUTRAL)
-			elseif acquire_type == A_CUSTOM and flags[4] then
-				return true
-			end
-			-- Always display mobs
-		elseif (acquire_type == A_MOB and mapmob) or
-			(acquire_type == A_CUSTOM and (flags[5] or flags[6] or flags[10] or flags[11])) then
-			return true
-		-- Quests
-		elseif mapquest then
-			if acquire_type == A_QUEST then
-				local quest = addon.quest_list[acquire_id]
-				display = (quest["Faction"] == BFAC[player_faction] or quest["Faction"] == FACTION_NEUTRAL)
-			elseif acquire_type == A_CUSTOM and flags[8] then
-				return true
-			end
-		end
-		return display
-	end
+			if acquire_type == A_TRAINER and obtain_filters.trainer then
+				local trainer = addon.trainer_list[v["ID"]]

-	local BZ = LibStub("LibBabble-Zone-3.0"):GetLookupTable()
+				if CheckDisplayFaction(trainer["Faction"]) then
+					local nStr = ""

-	local INSTANCE_LOCATIONS = {
-		[BZ["Ahn'kahet: The Old Kingdom"]] = {
-			["loc"] = c1[BZ["Dragonblight"]],
-			["c"] = 4,
-		},
-		[BZ["Auchenai Crypts"]] = {
-			["loc"] = c1[BZ["Terokkar Forest"]],
-			["c"] = 3,
-		},
-		[BZ["Azjol-Nerub"]] = {
-			["loc"] = c1[BZ["Dragonblight"]],
-			["c"] = 4,
-		},
-		[BZ["Blackrock Depths"]] = {
-			["loc"] = c1[BZ["Searing Gorge"]],
-			["c"] = 2,
-		},
-		[BZ["Blackrock Spire"]] = {
-			["loc"] = c1[BZ["Searing Gorge"]],
-			["c"] = 2,
-		},
-		[BZ["Blackwing Lair"]] = {
-			["loc"] = c1[BZ["Searing Gorge"]],
-			["c"] = 2,
-		},
-		[BZ["Dire Maul"]] = {
-			["loc"] = c1[BZ["Feralas"]],
-			["c"] = 1,
-		},
-		[BZ["Drak'Tharon Keep"]] = {
-			["loc"] = c1[BZ["Zul'Drak"]],
-			["c"] = 4,
-		},
-		[BZ["Gnomeregan"]] = {
-			["loc"] = c1[BZ["Dun Morogh"]],
-			["c"] = 2,
-		},
-		[BZ["Halls of Lightning"]] = {
-			["loc"] = c1[BZ["The Storm Peaks"]],
-			["c"] = 4,
-		},
-		[BZ["Halls of Stone"]] = {
-			["loc"] = c1[BZ["The Storm Peaks"]],
-			["c"] = 4,
-		},
-		[BZ["Karazhan"]] = {
-			["loc"] = c1[BZ["Deadwind Pass"]],
-			["c"] = 2,
-		},
-		[BZ["Magisters' Terrace"]] = {
-			["loc"] = c1[BZ["Isle of Quel'Danas"]],
-			["c"] = 3,
-		},
-		[BZ["Mana-Tombs"]] = {
-			["loc"] = c1[BZ["Terokkar Forest"]],
-			["c"] = 3,
-		},
-		[BZ["The Oculus"]] = {
-			["loc"] = c1[BZ["Borean Tundra"]],
-			["c"] = 4,
-		},
-		[BZ["Old Hillsbrad Foothills"]] = {
-			["loc"] = c1[BZ["Tanaris"]],
-			["c"] = 1,
-		},
-		[BZ["Onyxia's Lair"]] = {
-			["loc"] = c1[BZ["Dustwallow Marsh"]],
-			["c"] = 1,
-		},
-		[BZ["Ruins of Ahn'Qiraj"]] = {
-			["loc"] = c1[BZ["Tanaris"]],
-			["c"] = 1,
-		},
-		[BZ["Scholomance"]] = {
-			["loc"] = c1[BZ["Western Plaguelands"]],
-			["c"] = 2,
-		},
-		[BZ["Sethekk Halls"]] = {
-			["loc"] = c1[BZ["Terokkar Forest"]],
-			["c"] = 3,
-		},
-		[BZ["Shadow Labyrinth"]] = {
-			["loc"] = c1[BZ["Terokkar Forest"]],
-			["c"] = 3,
-		},
-		[BZ["Stratholme"]] = {
-			["loc"] = c1[BZ["Eastern Plaguelands"]],
-			["c"] = 2,
-		},
-		[BZ["Temple of Ahn'Qiraj"]] = {
-			["loc"] = c1[BZ["Tanaris"]],
-			["c"] = 1,
-		},
-		[BZ["The Arcatraz"]] = {
-			["loc"] = c1[BZ["Netherstorm"]],
-			["c"] = 3,
-		},
-		[BZ["The Black Morass"]] = {
-			["loc"] = c1[BZ["Tanaris"]],
-			["c"] = 1,
-		},
-		[BZ["The Botanica"]] = {
-			["loc"] = c1[BZ["Netherstorm"]],
-			["c"] = 3,
-		},
-		[BZ["The Deadmines"]] = {
-			["loc"] = c1[BZ["Westfall"]],
-			["c"] = 2,
-		},
-		[BZ["The Mechanar"]] = {
-			["loc"] = c1[BZ["Netherstorm"]],
-			["c"] = 3,
-		},
-		[BZ["The Nexus"]] = {
-			["loc"] = c1[BZ["Borean Tundra"]],
-			["c"] = 4,
-		},
-		[BZ["The Shattered Halls"]] = {
-			["loc"] = c1[BZ["Hellfire Peninsula"]],
-			["c"] = 3,
-		},
-		[BZ["The Slave Pens"]] = {
-			["loc"] = c1[BZ["Zangarmarsh"]],
-			["c"] = 3,
-		},
-		[BZ["The Steamvault"]] = {
-			["loc"] = c1[BZ["Zangarmarsh"]],
-			["c"] = 3,
-		},
-		[BZ["The Temple of Atal'Hakkar"]] = {
-			["loc"] = c1[BZ["Swamp of Sorrows"]],
-			["c"] = 2,
-		},
-		[BZ["The Violet Hold"]] = {
-			["loc"] = c1[BZ["Dalaran"]],
-			["c"] = 4,
-		},
-		[BZ["Utgarde Keep"]] = {
-			["loc"] = c1[BZ["Howling Fjord"]],
-			["c"] = 4,
-		},
-		[BZ["Utgarde Pinnacle"]] = {
-			["loc"] = c1[BZ["Howling Fjord"]],
-			["c"] = 4,
-		},
-		[BZ["Zul'Gurub"]] = {
-			["loc"] = c1[BZ["Stranglethorn Vale"]],
-			["c"] = 2,
-		},
-	}
+					if trainer["Faction"] == FACTION_HORDE then
+						nStr = addon:Horde(trainer["Name"])
+					elseif trainer["Faction"] == FACTION_ALLIANCE then
+						nStr = addon:Alliance(trainer["Name"])
+					else
+						nStr = addon:Neutral(trainer["Name"])
+					end
+					t.text = pad .. addon:Trainer(L["Trainer"] .. " : ") .. nStr

-	local maplist = {}
+					tinsert(self.entries, entry_index, t)
+					entry_index = entry_index + 1

-	-- Description: Adds mini-map and world map icons with tomtom.
-	-- Expected result: Icons are added to the world map and mini-map.
-	-- Input: An optional recipe ID
-	-- Output: Points are added to the maps
-	function addon:SetupMap(single_recipe)
-		if not TomTom then
-			return
-		end
+					local cStr = ""

-		local worldmap = addon.db.profile.worldmap
-		local minimap = addon.db.profile.minimap
+					if trainer["Coordx"] ~= 0 and trainer["Coordy"] ~= 0 then
+						cStr = addon:Coords("(" .. trainer["Coordx"] .. ", " .. trainer["Coordy"] .. ")")
+					end
+					t = AcquireTable()
+					t.recipe_id = recipe_id
+					t.is_expanded = true
+					t.text = pad .. pad .. trainer["Location"] .. " " .. cStr

-		if not (worldmap or minimap) then
-			return
-		end
+					tinsert(self.entries, entry_index, t)
+					entry_index = entry_index + 1
+				end
+				-- Right now PVP obtained items are located on vendors so they have the vendor and pvp flag.
+				-- We need to display the vendor in the drop down if we want to see vendors or if we want to see PVP
+				-- This allows us to select PVP only and to see just the PVP recipes
+			elseif acquire_type == A_VENDOR and (obtain_filters.vendor or obtain_filters.pvp) then
+				local vendor = addon.vendor_list[v["ID"]]

-		local icontext = "Interface\\AddOns\\AckisRecipeList\\img\\enchant_up"
+				if CheckDisplayFaction(vendor["Faction"]) then
+					local nStr = ""

-		-- Get the proper icon to put on the mini-map
-		--		for i, k in pairs(SortedProfessions) do
-		--			if (k["name"] == Player["Profession"]) then
-		--				icontext = "Interface\\AddOns\\AckisRecipeList\\img\\" .. k["texture"] .. "_up"
-		--				break
-		--			end
-		--		end
+					if vendor["Faction"] == FACTION_HORDE then
+						nStr = addon:Horde(vendor["Name"])
+					elseif vendor["Faction"] == FACTION_ALLIANCE then
+						nStr = addon:Alliance(vendor["Name"])
+					else
+						nStr = addon:Neutral(vendor["Name"])
+					end
+					t.text = pad .. addon:Vendor(L["Vendor"] .. " : ") .. nStr

-		twipe(maplist)
+					tinsert(self.entries, entry_index, t)
+					entry_index = entry_index + 1

-		local recipe_list = addon.recipe_list
+					local cStr = ""

-		-- We're only getting a single recipe, not a bunch
-		if single_recipe then
-			-- loop through acquire methods, display each
-			for k, v in pairs(recipe_list[single_recipe]["Acquire"]) do
-				if CheckMapDisplay(v, recipe_list[single_recipe]["Flags"]) then
-					maplist[v["ID"]] = v["Type"]
+					if vendor["Coordx"] ~= 0 and vendor["Coordy"] ~= 0 then
+						cStr = addon:Coords("(" .. vendor["Coordx"] .. ", " .. vendor["Coordy"] .. ")")
+					end
+					t = AcquireTable()
+					t.recipe_id = recipe_id
+					t.is_expanded = true
+					t.text = pad .. pad .. vendor["Location"] .. " " .. cStr
+
+					tinsert(self.entries, entry_index, t)
+					entry_index = entry_index + 1
 				end
-			end
-		elseif addon.db.profile.autoscanmap then
-			local sorted_recipes = addon.sorted_recipes
+				-- Mobs can be in instances, raids, or specific mob related drops.
+			elseif acquire_type == A_MOB and (obtain_filters.mobdrop or obtain_filters.instance or obtain_filters.raid) then
+				local mob = addon.mob_list[v["ID"]]
+				t.text = pad .. addon:MobDrop(L["Mob Drop"] .. " : ") .. addon:Red(mob["Name"])

-			-- Scan through all recipes to display, and add the vendors to a list to get their acquire info
-			for i = 1, #sorted_recipes do
-				local recipe_index = sorted_recipes[i]
+				tinsert(self.entries, entry_index, t)
+				entry_index = entry_index + 1

-				if recipe_list[recipe_index]["Display"] and recipe_list[recipe_index]["Search"] then
-					-- loop through acquire methods, display each
-					for k, v in pairs(recipe_list[recipe_index]["Acquire"]) do
-						if CheckMapDisplay(v, recipe_list[recipe_index]["Flags"]) then
-							maplist[v["ID"]] = v["Type"]
-						end
-					end
+				local cStr = ""
+
+				if mob["Coordx"] ~= 0 and mob["Coordy"] ~= 0 then
+					cStr = addon:Coords("(" .. mob["Coordx"] .. ", " .. mob["Coordy"] .. ")")
 				end
-			end
-		end
+				t = AcquireTable()
+				t.recipe_id = recipe_id
+				t.is_expanded = true
+				t.text = pad .. pad .. mob["Location"] .. " " .. cStr

-		--		local ARLWorldMap = CreateFrame("Button","ARLWorldMap",WorldMapDetailFrame)
-		--		ARLWorldMap:ClearAllPoints()
-		--		ARLWorldMap:SetWidth(8)
-		--		ARLWorldMap:SetHeight(8)
-		--		ARLWorldMap.icon = ARLWorldMap:CreateTexture("ARTWORK")
-		--		ARLWorldMap.icon:SetTexture(icontext)
-		--		ARLWorldMap.icon:SetAllPoints()
+				tinsert(self.entries, entry_index, t)
+				entry_index = entry_index + 1
+			elseif acquire_type == A_QUEST and obtain_filters.quest then
+				local quest = addon.quest_list[v["ID"]]

-		--		local ARLMiniMap = CreateFrame("Button","ARLMiniMap",MiniMap)
-		--		ARLMiniMap:ClearAllPoints()
-		--		ARLMiniMap:SetWidth(8)
-		--		ARLMiniMap:SetHeight(8)
-		--		ARLMiniMap.icon = ARLMiniMap:CreateTexture("ARTWORK")
-		--		ARLMiniMap.icon:SetTexture(icontext)
-		--		ARLMiniMap.icon:SetAllPoints()
-
-		for k, j in pairs(maplist) do
-			local loc
-			local custom = false
+				if CheckDisplayFaction(quest["Faction"]) then
+					local nStr = ""

-			-- Get the entries location
-			if maplist[k] == A_TRAINER then
-				loc = addon.trainer_list[k]
-			elseif maplist[k] == A_VENDOR then
-				loc = addon.vendor_list[k]
-			elseif maplist[k] == A_MOB then
-				loc = addon.mob_list[k]
-			elseif maplist[k] == A_QUEST then
-				loc = addon.quest_list[k]
-			elseif maplist[k] == A_CUSTOM then
-				loc = addon.custom_list[k]
-				custom = true
-			end
+					if quest["Faction"] == FACTION_HORDE then
+						nStr = addon:Horde(quest["Name"])
+					elseif quest["Faction"] == FACTION_ALLIANCE then
+						nStr = addon:Alliance(quest["Name"])
+					else
+						nStr = addon:Neutral(quest["Name"])
+					end
+					t.text = pad .. addon:Quest(L["Quest"] .. " : ") .. nStr

-			local name = loc["Name"]
-			local x = loc["Coordx"]
-			local y = loc["Coordy"]
-			local location = loc["Location"]
-			local continent, zone
+					tinsert(self.entries, entry_index, t)
+					entry_index = entry_index + 1

-			if not loc then
-				--@alpha@
-				addon:Print("DEBUG: No continent/zone map match for ID " .. k .. " - loc is nil.")
-				--@end-alpha@
-			elseif c1[location] then
-				continent = 1
-				zone = c1[location]
-			elseif c2[location] then
-				continent = 2
-				zone = c2[location]
-			elseif c3[location] then
-				continent = 3
-				zone = c3[location]
-			elseif c4[location] then
-				continent = 4
-				zone = c4[location]
-			elseif INSTANCE_LOCATIONS[location] then
-				continent = INSTANCE_LOCATIONS[location]["c"]
-				zone = INSTANCE_LOCATIONS[location]["loc"]
-				name = name .. " (" .. location .. ")"
-			else
-				--@alpha@
-				addon:Print("DEBUG: No continent/zone map match for ID " .. k .. " Location: " .. location)
-				--@end-alpha@
-			end
+					local cStr = ""

-			--@alpha@
-			if (x < -100) or (x > 100) or (y < -100) or (y > 100) then
-				addon:Print("DEBUG: Invalid location coordinates for ID " .. k .. " Location: " .. location)
-			end
-			--@end-alpha@
+					if quest["Coordx"] ~= 0 and quest["Coordy"] ~= 0 then
+						cStr = addon:Coords("(" .. quest["Coordx"] .. ", " .. quest["Coordy"] .. ")")
+					end
+					t = AcquireTable()
+					t.recipe_id = recipe_id
+					t.is_expanded = true
+					t.text = pad .. pad .. quest["Location"] .. " " .. cStr

-			if zone and continent then
-				--@alpha@
-				if (x == 0) and (y == 0) then
-					addon:Print("DEBUG: Location is 0,0 for ID " .. k .. " Location: " .. location)
+					tinsert(self.entries, entry_index, t)
+					entry_index = entry_index + 1
 				end
-				--@end-alpha@
-				local iconuid = TomTom:AddZWaypoint(continent, zone, x, y, nil, false, minimap, worldmap)
-
-				tinsert(iconlist, iconuid)
-			end
+			elseif acquire_type == A_SEASONAL and obtain_filters.seasonal then
+				t.text = pad .. addon:Season(SEASONAL_CATEGORY .. " : " .. addon.seasonal_list[v["ID"]]["Name"])
+				tinsert(self.entries, entry_index, t)
+				entry_index = entry_index + 1
+			elseif acquire_type == A_REPUTATION then -- Need to check if we're displaying the currently id'd rep or not as well
+				-- Reputation Obtain
+				-- Rep: ID, Faction
+				-- RepLevel = 0 (Neutral), 1 (Friendly), 2 (Honored), 3 (Revered), 4 (Exalted)
+				-- RepVendor - VendorID
+				local rep_vendor = addon.vendor_list[v["RepVendor"]]

-		end
-	end
-end -- do block
+				if CheckDisplayFaction(rep_vendor["Faction"]) then
+					t.text = pad .. addon:Rep(_G.REPUTATION .. " : ") .. addon.reputation_list[v["ID"]]["Name"]
+					tinsert(self.entries, entry_index, t)
+					entry_index = entry_index + 1

--- Description: Converting from hex to rgb (Thanks Maldivia)
-local function toRGB(hex)
-	local r, g, b = hex:match("(..)(..)(..)")
+					if not faction_strings then
+						faction_strings = {
+							[0] = addon:Neutral(FACTION_NEUTRAL .. " : "),
+							[1] = addon:Friendly(BFAC["Friendly"] .. " : "),
+							[2] = addon:Honored(BFAC["Honored"] .. " : "),
+							[3] = addon:Revered(BFAC["Revered"] .. " : "),
+							[4] = addon:Exalted(BFAC["Exalted"] .. " : ")
+						}
+					end
+					local nStr = ""

-	return (tonumber(r, 16) / 256), (tonumber(g,16) / 256), (tonumber(b, 16) / 256)
-end
+					if rep_vendor["Faction"] == FACTION_HORDE then
+						nStr = addon:Horde(rep_vendor["Name"])
+					elseif rep_vendor["Faction"] == FACTION_ALLIANCE then
+						nStr = addon:Alliance(rep_vendor["Name"])
+					else
+						nStr = addon:Neutral(rep_vendor["Name"])
+					end
+					t = AcquireTable()
+					t.recipe_id = recipe_id
+					t.is_expanded = true

-local Generic_MakeCheckButton
-do
-	local PUSHDOWN = {
-		["cloak"]	= true,
-		["necklace"]	= true,
-		["ring"]	= true,
-		["trinket"]	= true,
-		["shield"]	= true,
-	}
-	function Generic_MakeCheckButton(cButton, anchorFrame, ttText, scriptVal, row, col, misc)
-		-- set the position of the new checkbox
-		local xPos = 2 + ((col - 1) * 100)
-		local yPos = -3 - ((row - 1) * 17)
+					t.text = pad .. pad .. faction_strings[v["RepLevel"]] .. nStr

-		if PUSHDOWN[scriptVal] then
-			yPos = yPos - 5
-		end
-		cButton:SetPoint("TOPLEFT", anchorFrame, "TOPLEFT", xPos, yPos)
-		cButton:SetHeight(24)
-		cButton:SetWidth(24)
+					tinsert(self.entries, entry_index, t)
+					entry_index = entry_index + 1

-		-- depending if we're on the misc panel or not, set an alternative OnClick method
-		if misc == 0 then
-			cButton:SetScript("OnClick",
-					  function()
-						  FilterValueMap[scriptVal].svroot[scriptVal] = FilterValueMap[scriptVal].cb:GetChecked() and true or false
-						  MainPanel:UpdateTitle()
-						  ReDisplay()
-					  end)
-		else
-			cButton:SetScript("OnClick",
-					  function()
-						  addon.db.profile.ignoreexclusionlist = not addon.db.profile.ignoreexclusionlist
-						  ReDisplay()
-					  end)
-		end
-		SetTooltipScripts(cButton, ttText, 1)
-	end
-end	-- do
+					local cStr = ""

--- Generic function for creating the expanded panel buttons
-local CreateFilterMenuButton
-do
-	local ExpButtonTT = {
-		L["FILTERING_GENERAL_DESC"],	-- 1
-		L["FILTERING_OBTAIN_DESC"],	-- 2
-		L["FILTERING_BINDING_DESC"],	-- 3
-		L["FILTERING_ITEM_DESC"],	-- 4
-		L["FILTERING_PLAYERTYPE_DESC"],	-- 5
-		L["FILTERING_REP_DESC"],	-- 6
-		L["FILTERING_MISC_DESC"]	-- 7
-	}
+					if rep_vendor["Coordx"] ~= 0 and rep_vendor["Coordy"] ~= 0 then
+						cStr = addon:Coords("(" .. rep_vendor["Coordx"] .. ", " .. rep_vendor["Coordy"] .. ")")
+					end
+					t = AcquireTable()
+					t.recipe_id = recipe_id
+					t.is_expanded = true
+					t.text = pad .. pad .. pad .. rep_vendor["Location"] .. " " .. cStr

-	local function ToggleFilterMenu(panel)
-		-- This manages the filter menu panel, as well as checking or unchecking the
-		-- buttons that got us here in the first place
-		--
-		-- our panels are:
-		-- 1	ARL_ExpGeneralOptCB			General Filters
-		-- 2	ARL_ExpObtainOptCB			Obtain Filters
-		-- 3	ARL_ExpBindingOptCB			Binding Filters
-		-- 4	ARL_ExpItemOptCB			Item Filters
-		-- 5	ARL_ExpPlayerOptCB			Role Filters
-		-- 6	ARL_ExpRepOptCB				Reputation Filters
-		-- 7	ARL_ExpMiscOptCB			Miscellaneous Filters
+					tinsert(self.entries, entry_index, t)
+					entry_index = entry_index + 1
+				end
+			elseif acquire_type == A_WORLD_DROP and obtain_filters.worlddrop then
+				t.text = pad .. addon:RarityColor(v["ID"] + 1, L["World Drop"])
+				tinsert(self.entries, entry_index, t)
+				entry_index = entry_index + 1
+			elseif acquire_type == A_CUSTOM then
+				t.text = pad .. addon:Normal(addon.custom_list[v["ID"]]["Name"])
+				tinsert(self.entries, entry_index, t)
+				entry_index = entry_index + 1
+			elseif acquire_type == A_PVP and obtain_filters.pvp then
+				local vendor = addon.vendor_list[v["ID"]]

-		local ChangeFilters = false
+				if CheckDisplayFaction(vendor["Faction"]) then
+					local cStr = ""

-		MainPanel.filter_menu.Rep.Classic:Hide()
-		MainPanel.filter_menu.Rep.BC:Hide()
-		MainPanel.filter_menu.Rep.LK:Hide()
+					if vendor["Coordx"] ~= 0 and vendor["Coordy"] ~= 0 then
+						cStr = addon:Coords("(" .. vendor["Coordx"] .. ", " .. vendor["Coordy"] .. ")")
+					end
+					local nStr = ""

-		ARL_Rep_ClassicCB:SetChecked(false)
-		ARL_Rep_BCCB:SetChecked(false)
-		ARL_Rep_LKCB:SetChecked(false)
+					if vendor["Faction"] == FACTION_HORDE then
+						nStr = addon:Horde(vendor["Name"])
+					elseif vendor["Faction"] == FACTION_ALLIANCE then
+						nStr = addon:Alliance(vendor["Name"])
+					else
+						nStr = addon:Neutral(vendor["Name"])
+					end
+					t.text = pad .. addon:Vendor(L["Vendor"] .. " : ") .. nStr

-		if panel == 1 then
-			if ARL_ExpGeneralOptCB:GetChecked() then
-				-- uncheck all other buttons
-				HideARL_ExpOptCB("general")
+					tinsert(self.entries, entry_index, t)
+					entry_index = entry_index + 1

-				-- display the correct subframe with all the buttons and such, hide the others
-				MainPanel.filter_menu.General:Show()
-				MainPanel.filter_menu.Obtain:Hide()
-				MainPanel.filter_menu.Binding:Hide()
-				MainPanel.filter_menu.Item:Hide()
-				MainPanel.filter_menu.Player:Hide()
-				MainPanel.filter_menu.Rep:Hide()
-				MainPanel.filter_menu.Misc:Hide()
+					t = AcquireTable()
+					t.recipe_id = recipe_id
+					t.is_expanded = true
+					t.text = pad .. pad .. vendor["Location"] .. " " .. cStr

-				ChangeFilters = true
-			else
-				ARL_ExpGeneralOptCB.text:SetText(addon:Yellow(ExpButtonText[1]))
-				ChangeFilters = false
+					tinsert(self.entries, entry_index, t)
+					entry_index = entry_index + 1
+				end
+				--@alpha@
+			elseif acquire_type > A_MAX then
+				t.text = "Unhandled Acquire Case - Type: " .. acquire_type
+				tinsert(self.entries, entry_index, t)
+				entry_index = entry_index + 1
+				--@end-alpha@
 			end
-		elseif panel == 2 then
-			if ARL_ExpObtainOptCB:GetChecked() then
-				HideARL_ExpOptCB("obtain")
+		end
+		return entry_index
+	end
+end	-- do

-				-- display the correct subframe with all the buttons and such, hide the others
-				MainPanel.filter_menu.General:Hide()
-				MainPanel.filter_menu.Obtain:Show()
-				MainPanel.filter_menu.Binding:Hide()
-				MainPanel.filter_menu.Item:Hide()
-				MainPanel.filter_menu.Player:Hide()
-				MainPanel.filter_menu.Rep:Hide()
-				MainPanel.filter_menu.Misc:Hide()
+-------------------------------------------------------------------------------
+-- Create MainPanel.progress_bar and set its scripts
+-------------------------------------------------------------------------------
+do
+	-- Default values for the progressbar
+	local pbMin = 0
+	local pbMax = 100
+	local pbCur = 50

-				ChangeFilters = true
-			else
-				ARL_ExpObtainOptCB.text:SetText(addon:Yellow(ExpButtonText[2]))
-				ChangeFilters = false
-			end
-		elseif panel == 3 then
-			if ARL_ExpBindingOptCB:GetChecked() then
-				HideARL_ExpOptCB("binding")
+	MainPanel.progress_bar = CreateFrame("StatusBar", nil, MainPanel)
+	MainPanel.progress_bar:SetWidth(195)
+	MainPanel.progress_bar:SetHeight(14)

-				-- display the correct subframe with all the buttons and such, hide the others
-				MainPanel.filter_menu.General:Hide()
-				MainPanel.filter_menu.Obtain:Hide()
-				MainPanel.filter_menu.Binding:Show()
-				MainPanel.filter_menu.Item:Hide()
-				MainPanel.filter_menu.Player:Hide()
-				MainPanel.filter_menu.Rep:Hide()
-				MainPanel.filter_menu.Misc:Hide()
+	MainPanel.progress_bar:ClearAllPoints()
+	MainPanel.progress_bar:SetPoint("BOTTOMLEFT", MainPanel, 17, 7)

-				ChangeFilters = true
-			else
-				ARL_ExpBindingOptCB.text:SetText(addon:Yellow(ExpButtonText[3]))
-				ChangeFilters = false
-			end
-		elseif panel == 4 then
-			if ARL_ExpItemOptCB:GetChecked() then
-				HideARL_ExpOptCB("item")
+	MainPanel.progress_bar:SetStatusBarTexture("Interface\\Addons\\AckisRecipeList\\img\\progressbar")
+	MainPanel.progress_bar:SetOrientation("HORIZONTAL")
+	MainPanel.progress_bar:SetStatusBarColor(0.25, 0.25, 0.75)
+	MainPanel.progress_bar:SetMinMaxValues(pbMin, pbMax)
+	MainPanel.progress_bar:SetValue(pbCur)

-				-- display the correct subframe with all the buttons and such, hide the others
-				MainPanel.filter_menu.General:Hide()
-				MainPanel.filter_menu.Obtain:Hide()
-				MainPanel.filter_menu.Binding:Hide()
-				MainPanel.filter_menu.Item:Show()
-				MainPanel.filter_menu.Player:Hide()
-				MainPanel.filter_menu.Rep:Hide()
-				MainPanel.filter_menu.Misc:Hide()
+	MainPanel.progress_bar.text = MainPanel.progress_bar:CreateFontString(nil, "ARTWORK")
+	MainPanel.progress_bar.text:SetWidth(195)
+	MainPanel.progress_bar.text:SetHeight(14)
+	MainPanel.progress_bar.text:SetFontObject("GameFontHighlightSmall")

-				ChangeFilters = true
-			else
-				ARL_ExpItemOptCB.text:SetText(addon:Yellow(ExpButtonText[4]))
-				ChangeFilters = false
-			end
-		elseif panel == 5 then
-			if ARL_ExpPlayerOptCB:GetChecked() then
-				HideARL_ExpOptCB("player")
+	MainPanel.progress_bar.text:ClearAllPoints()
+	MainPanel.progress_bar.text:SetPoint("CENTER", MainPanel.progress_bar, "CENTER", 0, 0)
+	MainPanel.progress_bar.text:SetJustifyH("CENTER")
+	MainPanel.progress_bar.text:SetFormattedText("%d / %d - %d%%", pbCur, pbMax, floor(pbCur / pbMax * 100))
+end	-- do

-				-- display the correct subframe with all the buttons and such, hide the others
-				MainPanel.filter_menu.General:Hide()
-				MainPanel.filter_menu.Obtain:Hide()
-				MainPanel.filter_menu.Binding:Hide()
-				MainPanel.filter_menu.Item:Hide()
-				MainPanel.filter_menu.Player:Show()
-				MainPanel.filter_menu.Rep:Hide()
-				MainPanel.filter_menu.Misc:Hide()
+function MainPanel.progress_bar:Update()
+	local pbCur, pbMax
+	local settings = addon.db.profile

-				ChangeFilters = true
-			else
-				ARL_ExpPlayerOptCB.text:SetText(addon:Yellow(ExpButtonText[5]))
-				ChangeFilters = false
+	if settings.includefiltered then
+		pbCur = Player.recipes_known
+		pbMax = Player.recipes_total
+	else
+		-- We're removing filtered recipes from the final count
+		pbCur = Player.recipes_known_filtered
+		pbMax = Player.recipes_total_filtered
+	end
+
+	if not settings.includeexcluded and not settings.ignoreexclusionlist then
+		pbCur = pbCur - Player.excluded_recipes_unknown
+		pbMax = pbMax - Player.excluded_recipes_known
+	end
+	self:SetMinMaxValues(0, pbMax)
+	self:SetValue(pbCur)
+
+	if (floor(pbCur / pbMax * 100) < 101) and pbCur >= 0 and pbMax >= 0 then
+		self.text:SetFormattedText("%d / %d - %d%%", pbCur, pbMax, floor(pbCur / pbMax * 100))
+	else
+		self.text:SetFormattedText("0 / 0 - %s", L["NOT_YET_SCANNED"])
+	end
+end
+
+-------------------------------------------------------------------------------
+-- Create the close button, and set its scripts.
+-------------------------------------------------------------------------------
+MainPanel.close_button = GenericCreateButton(nil, MainPanel, 22, 69, "GameFontNormalSmall", "GameFontHighlightSmall", L["Close"], "CENTER", L["CLOSE_DESC"], 1)
+MainPanel.close_button:SetPoint("BOTTOMRIGHT", MainPanel, "BOTTOMRIGHT", -4, 3)
+
+MainPanel.close_button:SetScript("OnClick",
+				 function(self, button, down)
+					 MainPanel:Hide()
+				 end)
+
+-------------------------------------------------------------------------------
+-- Map waypoint code.
+-------------------------------------------------------------------------------
+do
+	local function LoadZones(c, y, ...)
+		-- Fill up the list for normal lookup
+		for i = 1, select('#', ...),1 do
+			c[i] = select(i,...)
+		end
+		-- Reverse lookup to make work easier later on
+		for i in pairs(c) do
+			y[c[i]] = i
+		end
+	end
+
+	local C1 = {}
+	local C2 = {}
+	local C3 = {}
+	local C4 = {}
+	local c1 = {}
+	local c2 = {}
+	local c3 = {}
+	local c4 = {}
+
+	LoadZones(C1, c1, GetMapZones(1))
+	LoadZones(C2, c2, GetMapZones(2))
+	LoadZones(C3, c3, GetMapZones(3))
+	LoadZones(C4, c4, GetMapZones(4))
+
+	local iconlist = {}
+
+	-- Clears all the icons from the world map and the mini-map
+	function addon:ClearMap()
+		if TomTom then
+			for i in pairs(iconlist) do
+				TomTom:RemoveWaypoint(iconlist[i])
 			end
-		elseif panel == 6 then
-			if ARL_ExpRepOptCB:GetChecked() then
-				HideARL_ExpOptCB("rep")
+			iconlist = twipe(iconlist)
+		end

-				-- display the correct subframe with all the buttons and such, hide the others
-				MainPanel.filter_menu.General:Hide()
-				MainPanel.filter_menu.Obtain:Hide()
-				MainPanel.filter_menu.Binding:Hide()
-				MainPanel.filter_menu.Item:Hide()
-				MainPanel.filter_menu.Player:Hide()
-				MainPanel.filter_menu.Rep:Show()
-				MainPanel.filter_menu.Misc:Hide()
+	end

-				ChangeFilters = true
-			else
-				ARL_ExpRepOptCB.text:SetText(addon:Yellow(ExpButtonText[6]))
-				ChangeFilters = false
+	local function CheckMapDisplay(acquire_entry, flags)
+		local maptrainer = addon.db.profile.maptrainer
+		local mapquest = addon.db.profile.mapquest
+		local mapvendor = addon.db.profile.mapvendor
+		local mapmob = addon.db.profile.mapmob
+		local player_faction = Player["Faction"]
+		local acquire_type = acquire_entry["Type"]
+		local acquire_id = acquire_entry["ID"]
+		local display = false
+
+		-- Trainers - Display if it's your faction or neutral.
+		if maptrainer then
+			if acquire_type == A_TRAINER then
+				local trainer = addon.trainer_list[acquire_id]
+
+				display = (trainer["Faction"] == BFAC[player_faction] or trainer["Faction"] == FACTION_NEUTRAL)
+			elseif acquire_type == A_CUSTOM and flags[3] then
+				return true
 			end
-		elseif panel == 7 then
-			if ARL_ExpMiscOptCB:GetChecked() then
-				HideARL_ExpOptCB("misc")
+			-- Vendors - Display if it's your faction or neutral
+		elseif mapvendor then
+			if acquire_type == A_VENDOR then
+				local vendor = addon.vendor_list[acquire_id]

-				-- display the correct subframe with all the buttons and such, hide the others
-				MainPanel.filter_menu.General:Hide()
-				MainPanel.filter_menu.Obtain:Hide()
-				MainPanel.filter_menu.Binding:Hide()
-				MainPanel.filter_menu.Item:Hide()
-				MainPanel.filter_menu.Player:Hide()
-				MainPanel.filter_menu.Rep:Hide()
-				MainPanel.filter_menu.Misc:Show()
+				display = (vendor["Faction"] == BFAC[player_faction] or vendor["Faction"] == FACTION_NEUTRAL)
+			elseif acquire_type == A_CUSTOM and flags[4] then
+				return true
+			end
+			-- Always display mobs
+		elseif (acquire_type == A_MOB and mapmob) or
+			(acquire_type == A_CUSTOM and (flags[5] or flags[6] or flags[10] or flags[11])) then
+			return true
+		-- Quests
+		elseif mapquest then
+			if acquire_type == A_QUEST then
+				local quest = addon.quest_list[acquire_id]
+				display = (quest["Faction"] == BFAC[player_faction] or quest["Faction"] == FACTION_NEUTRAL)
+			elseif acquire_type == A_CUSTOM and flags[8] then
+				return true
+			end
+		end
+		return display
+	end
+
+	local BZ = LibStub("LibBabble-Zone-3.0"):GetLookupTable()
+
+	local INSTANCE_LOCATIONS = {
+		[BZ["Ahn'kahet: The Old Kingdom"]] = {
+			["loc"] = c1[BZ["Dragonblight"]],
+			["c"] = 4,
+		},
+		[BZ["Auchenai Crypts"]] = {
+			["loc"] = c1[BZ["Terokkar Forest"]],
+			["c"] = 3,
+		},
+		[BZ["Azjol-Nerub"]] = {
+			["loc"] = c1[BZ["Dragonblight"]],
+			["c"] = 4,
+		},
+		[BZ["Blackrock Depths"]] = {
+			["loc"] = c1[BZ["Searing Gorge"]],
+			["c"] = 2,
+		},
+		[BZ["Blackrock Spire"]] = {
+			["loc"] = c1[BZ["Searing Gorge"]],
+			["c"] = 2,
+		},
+		[BZ["Blackwing Lair"]] = {
+			["loc"] = c1[BZ["Searing Gorge"]],
+			["c"] = 2,
+		},
+		[BZ["Dire Maul"]] = {
+			["loc"] = c1[BZ["Feralas"]],
+			["c"] = 1,
+		},
+		[BZ["Drak'Tharon Keep"]] = {
+			["loc"] = c1[BZ["Zul'Drak"]],
+			["c"] = 4,
+		},
+		[BZ["Gnomeregan"]] = {
+			["loc"] = c1[BZ["Dun Morogh"]],
+			["c"] = 2,
+		},
+		[BZ["Halls of Lightning"]] = {
+			["loc"] = c1[BZ["The Storm Peaks"]],
+			["c"] = 4,
+		},
+		[BZ["Halls of Stone"]] = {
+			["loc"] = c1[BZ["The Storm Peaks"]],
+			["c"] = 4,
+		},
+		[BZ["Karazhan"]] = {
+			["loc"] = c1[BZ["Deadwind Pass"]],
+			["c"] = 2,
+		},
+		[BZ["Magisters' Terrace"]] = {
+			["loc"] = c1[BZ["Isle of Quel'Danas"]],
+			["c"] = 3,
+		},
+		[BZ["Mana-Tombs"]] = {
+			["loc"] = c1[BZ["Terokkar Forest"]],
+			["c"] = 3,
+		},
+		[BZ["The Oculus"]] = {
+			["loc"] = c1[BZ["Borean Tundra"]],
+			["c"] = 4,
+		},
+		[BZ["Old Hillsbrad Foothills"]] = {
+			["loc"] = c1[BZ["Tanaris"]],
+			["c"] = 1,
+		},
+		[BZ["Onyxia's Lair"]] = {
+			["loc"] = c1[BZ["Dustwallow Marsh"]],
+			["c"] = 1,
+		},
+		[BZ["Ruins of Ahn'Qiraj"]] = {
+			["loc"] = c1[BZ["Tanaris"]],
+			["c"] = 1,
+		},
+		[BZ["Scholomance"]] = {
+			["loc"] = c1[BZ["Western Plaguelands"]],
+			["c"] = 2,
+		},
+		[BZ["Sethekk Halls"]] = {
+			["loc"] = c1[BZ["Terokkar Forest"]],
+			["c"] = 3,
+		},
+		[BZ["Shadow Labyrinth"]] = {
+			["loc"] = c1[BZ["Terokkar Forest"]],
+			["c"] = 3,
+		},
+		[BZ["Stratholme"]] = {
+			["loc"] = c1[BZ["Eastern Plaguelands"]],
+			["c"] = 2,
+		},
+		[BZ["Temple of Ahn'Qiraj"]] = {
+			["loc"] = c1[BZ["Tanaris"]],
+			["c"] = 1,
+		},
+		[BZ["The Arcatraz"]] = {
+			["loc"] = c1[BZ["Netherstorm"]],
+			["c"] = 3,
+		},
+		[BZ["The Black Morass"]] = {
+			["loc"] = c1[BZ["Tanaris"]],
+			["c"] = 1,
+		},
+		[BZ["The Botanica"]] = {
+			["loc"] = c1[BZ["Netherstorm"]],
+			["c"] = 3,
+		},
+		[BZ["The Deadmines"]] = {
+			["loc"] = c1[BZ["Westfall"]],
+			["c"] = 2,
+		},
+		[BZ["The Mechanar"]] = {
+			["loc"] = c1[BZ["Netherstorm"]],
+			["c"] = 3,
+		},
+		[BZ["The Nexus"]] = {
+			["loc"] = c1[BZ["Borean Tundra"]],
+			["c"] = 4,
+		},
+		[BZ["The Shattered Halls"]] = {
+			["loc"] = c1[BZ["Hellfire Peninsula"]],
+			["c"] = 3,
+		},
+		[BZ["The Slave Pens"]] = {
+			["loc"] = c1[BZ["Zangarmarsh"]],
+			["c"] = 3,
+		},
+		[BZ["The Steamvault"]] = {
+			["loc"] = c1[BZ["Zangarmarsh"]],
+			["c"] = 3,
+		},
+		[BZ["The Temple of Atal'Hakkar"]] = {
+			["loc"] = c1[BZ["Swamp of Sorrows"]],
+			["c"] = 2,
+		},
+		[BZ["The Violet Hold"]] = {
+			["loc"] = c1[BZ["Dalaran"]],
+			["c"] = 4,
+		},
+		[BZ["Utgarde Keep"]] = {
+			["loc"] = c1[BZ["Howling Fjord"]],
+			["c"] = 4,
+		},
+		[BZ["Utgarde Pinnacle"]] = {
+			["loc"] = c1[BZ["Howling Fjord"]],
+			["c"] = 4,
+		},
+		[BZ["Zul'Gurub"]] = {
+			["loc"] = c1[BZ["Stranglethorn Vale"]],
+			["c"] = 2,
+		},
+	}
+
+	local maplist = {}
+
+	-- Description: Adds mini-map and world map icons with tomtom.
+	-- Expected result: Icons are added to the world map and mini-map.
+	-- Input: An optional recipe ID
+	-- Output: Points are added to the maps
+	function addon:SetupMap(single_recipe)
+		if not TomTom then
+			return
+		end
+
+		local worldmap = addon.db.profile.worldmap
+		local minimap = addon.db.profile.minimap

-				ChangeFilters = true
-			else
-				ARL_ExpMiscOptCB.text:SetText(addon:Yellow(ExpButtonText[7]))
-				ChangeFilters = false
-			end
+		if not (worldmap or minimap) then
+			return
 		end

-		if ChangeFilters then
-			-- Depending on which panel we're showing, either display one column
-			-- or two column
-			if panel == 1 or panel == 2 or panel == 3 or panel == 4 or panel == 7 then
-				MainPanel.filter_menu.texture:ClearAllPoints()
-				MainPanel.filter_menu:SetWidth(FILTERMENU_DOUBLE_WIDTH)
-				MainPanel.filter_menu.texture:SetTexture([[Interface\Addons\AckisRecipeList\img\fly_2col]])
-				MainPanel.filter_menu.texture:SetAllPoints(MainPanel.filter_menu)
-				MainPanel.filter_menu.texture:SetTexCoord(0, (FILTERMENU_DOUBLE_WIDTH/256), 0, (FILTERMENU_HEIGHT/512))
-			elseif ((panel == 5) or (panel == 6)) then
-				MainPanel.filter_menu.texture:ClearAllPoints()
-				MainPanel.filter_menu:SetWidth(FILTERMENU_SINGLE_WIDTH)
-				MainPanel.filter_menu.texture:SetTexture([[Interface\Addons\AckisRecipeList\img\fly_1col]])
-				MainPanel.filter_menu.texture:SetAllPoints(MainPanel.filter_menu)
-				MainPanel.filter_menu.texture:SetTexCoord(0, (FILTERMENU_SINGLE_WIDTH/256), 0, (FILTERMENU_HEIGHT/512))
+		local icontext = "Interface\\AddOns\\AckisRecipeList\\img\\enchant_up"
+
+		-- Get the proper icon to put on the mini-map
+		--		for i, k in pairs(SortedProfessions) do
+		--			if (k["name"] == Player["Profession"]) then
+		--				icontext = "Interface\\AddOns\\AckisRecipeList\\img\\" .. k["texture"] .. "_up"
+		--				break
+		--			end
+		--		end
+
+		twipe(maplist)
+
+		local recipe_list = addon.recipe_list
+
+		-- We're only getting a single recipe, not a bunch
+		if single_recipe then
+			-- loop through acquire methods, display each
+			for k, v in pairs(recipe_list[single_recipe]["Acquire"]) do
+				if CheckMapDisplay(v, recipe_list[single_recipe]["Flags"]) then
+					maplist[v["ID"]] = v["Type"]
+				end
 			end
-			-- Change the filters to the current panel
-			MainPanel.filter_menu:Show()
-		else
-			-- We're hiding, don't bother changing anything
-			MainPanel.filter_menu:Hide()
-		end
-	end
+		elseif addon.db.profile.autoscanmap then
+			local sorted_recipes = addon.sorted_recipes

-	function CreateExpansionButton(bName, bTex)
-		local cButton = CreateFrame("CheckButton", bName, MainPanel.filter_menu.Rep)
-		cButton:SetWidth(100)
-		cButton:SetHeight(46)
-		cButton:SetChecked(false)
-
-		local iconTex = cButton:CreateTexture(cButton:GetName() .. "buttonTex", "BORDER")
+			-- Scan through all recipes to display, and add the vendors to a list to get their acquire info
+			for i = 1, #sorted_recipes do
+				local recipe_index = sorted_recipes[i]

-		if bName == "ARL_Rep_LKCB" then
-			iconTex:SetTexture("Interface\\Addons\\AckisRecipeList\\img\\" .. bTex)
-		else
-			iconTex:SetTexture('Interface/Glues/Common/' .. bTex)
+				if recipe_list[recipe_index]["Display"] and recipe_list[recipe_index]["Search"] then
+					-- loop through acquire methods, display each
+					for k, v in pairs(recipe_list[recipe_index]["Acquire"]) do
+						if CheckMapDisplay(v, recipe_list[recipe_index]["Flags"]) then
+							maplist[v["ID"]] = v["Type"]
+						end
+					end
+				end
+			end
 		end
-		iconTex:SetWidth(100)
-		iconTex:SetHeight(46)
-		iconTex:SetAllPoints(cButton)

-		local pushedTexture = cButton:CreateTexture(cButton:GetName() .. "pTex", "ARTWORK")
-		pushedTexture:SetTexture('Interface/Buttons/UI-Quickslot-Depress')
-		pushedTexture:SetAllPoints(cButton)
-		cButton:SetPushedTexture(pushedTexture)
+		--		local ARLWorldMap = CreateFrame("Button","ARLWorldMap",WorldMapDetailFrame)
+		--		ARLWorldMap:ClearAllPoints()
+		--		ARLWorldMap:SetWidth(8)
+		--		ARLWorldMap:SetHeight(8)
+		--		ARLWorldMap.icon = ARLWorldMap:CreateTexture("ARTWORK")
+		--		ARLWorldMap.icon:SetTexture(icontext)
+		--		ARLWorldMap.icon:SetAllPoints()

-		local highlightTexture = cButton:CreateTexture()
-		highlightTexture:SetTexture('Interface/Buttons/ButtonHilight-Square')
-		highlightTexture:SetAllPoints(cButton)
-		highlightTexture:SetBlendMode('ADD')
-		cButton:SetHighlightTexture(highlightTexture)
+		--		local ARLMiniMap = CreateFrame("Button","ARLMiniMap",MiniMap)
+		--		ARLMiniMap:ClearAllPoints()
+		--		ARLMiniMap:SetWidth(8)
+		--		ARLMiniMap:SetHeight(8)
+		--		ARLMiniMap.icon = ARLMiniMap:CreateTexture("ARTWORK")
+		--		ARLMiniMap.icon:SetTexture(icontext)
+		--		ARLMiniMap.icon:SetAllPoints()

-		local checkedTexture = cButton:CreateTexture()
-		checkedTexture:SetTexture('Interface/Buttons/CheckButtonHilight')
-		checkedTexture:SetAllPoints(cButton)
-		checkedTexture:SetBlendMode('ADD')
-		cButton:SetCheckedTexture(checkedTexture)
+		for k, j in pairs(maplist) do
+			local loc
+			local custom = false

-		-- And throw up a tooltip
-		if bName == "ARL_Rep_ClassicCB" then
-			SetTooltipScripts(cButton, L["FILTERING_OLDWORLD_DESC"])
-		elseif bName == "ARL_Rep_BCCB" then
-			SetTooltipScripts(cButton, L["FILTERING_BC_DESC"])
-		else
-			SetTooltipScripts(cButton, L["FILTERING_WOTLK_DESC"])
-		end
-		return cButton
-	end
+			-- Get the entries location
+			if maplist[k] == A_TRAINER then
+				loc = addon.trainer_list[k]
+			elseif maplist[k] == A_VENDOR then
+				loc = addon.vendor_list[k]
+			elseif maplist[k] == A_MOB then
+				loc = addon.mob_list[k]
+			elseif maplist[k] == A_QUEST then
+				loc = addon.quest_list[k]
+			elseif maplist[k] == A_CUSTOM then
+				loc = addon.custom_list[k]
+				custom = true
+			end

-	function CreateFilterMenuButton(bName, bTex, panelIndex)
-		local ExpTextureSize = 34
-		local cButton
+			local name = loc["Name"]
+			local x = loc["Coordx"]
+			local y = loc["Coordy"]
+			local location = loc["Location"]
+			local continent, zone

-		cButton = CreateFrame("CheckButton", bName, MainPanel) -- , "UICheckButtonTemplate")
-		cButton:SetWidth(ExpTextureSize)
-		cButton:SetHeight(ExpTextureSize)
-		cButton:SetScript("OnClick",
-				  function()
-					  ToggleFilterMenu(panelIndex)
-				  end)
+			if not loc then
+				--@alpha@
+				addon:Print("DEBUG: No continent/zone map match for ID " .. k .. " - loc is nil.")
+				--@end-alpha@
+			elseif c1[location] then
+				continent = 1
+				zone = c1[location]
+			elseif c2[location] then
+				continent = 2
+				zone = c2[location]
+			elseif c3[location] then
+				continent = 3
+				zone = c3[location]
+			elseif c4[location] then
+				continent = 4
+				zone = c4[location]
+			elseif INSTANCE_LOCATIONS[location] then
+				continent = INSTANCE_LOCATIONS[location]["c"]
+				zone = INSTANCE_LOCATIONS[location]["loc"]
+				name = name .. " (" .. location .. ")"
+			else
+				--@alpha@
+				addon:Print("DEBUG: No continent/zone map match for ID " .. k .. " Location: " .. location)
+				--@end-alpha@
+			end

-		local bgTex = cButton:CreateTexture(cButton:GetName() .. "bgTex", "BACKGROUND")
-		bgTex:SetTexture('Interface/SpellBook/UI-Spellbook-SpellBackground')
-		bgTex:SetHeight(ExpTextureSize + 6)
-		bgTex:SetWidth(ExpTextureSize + 4)
-		bgTex:SetTexCoord(0, (43/64), 0, (43/64))
-		bgTex:SetPoint("CENTER", cButton, "CENTER", 0, 0)
+			--@alpha@
+			if (x < -100) or (x > 100) or (y < -100) or (y > 100) then
+				addon:Print("DEBUG: Invalid location coordinates for ID " .. k .. " Location: " .. location)
+			end
+			--@end-alpha@

-		local iconTex = cButton:CreateTexture(cButton:GetName() .. "iconTex", "BORDER")
-		iconTex:SetTexture('Interface/Icons/' .. bTex)
-		iconTex:SetAllPoints(cButton)
+			if zone and continent then
+				--@alpha@
+				if (x == 0) and (y == 0) then
+					addon:Print("DEBUG: Location is 0,0 for ID " .. k .. " Location: " .. location)
+				end
+				--@end-alpha@
+				local iconuid = TomTom:AddZWaypoint(continent, zone, x, y, nil, false, minimap, worldmap)

-		local pushedTexture = cButton:CreateTexture(cButton:GetName() .. "pTex", "ARTWORK")
-		pushedTexture:SetTexture('Interface/Buttons/UI-Quickslot-Depress')
-		pushedTexture:SetAllPoints(cButton)
-		cButton:SetPushedTexture(pushedTexture)
+				tinsert(iconlist, iconuid)
+			end

-		local highlightTexture = cButton:CreateTexture()
-		highlightTexture:SetTexture('Interface/Buttons/ButtonHilight-Square')
-		highlightTexture:SetAllPoints(cButton)
-		highlightTexture:SetBlendMode('ADD')
-		cButton:SetHighlightTexture(highlightTexture)
+		end
+	end
+end -- do block

-		local checkedTexture = cButton:CreateTexture()
-		checkedTexture:SetTexture('Interface/Buttons/CheckButtonHilight')
-		checkedTexture:SetAllPoints(cButton)
-		checkedTexture:SetBlendMode('ADD')
-		cButton:SetCheckedTexture(checkedTexture)
+-- Description: Converting from hex to rgb (Thanks Maldivia)
+local function toRGB(hex)
+	local r, g, b = hex:match("(..)(..)(..)")

-		-- Create the text object to go along with it
-		local cbText = cButton:CreateFontString("cbText", "OVERLAY", "GameFontHighlight")
-		cbText:SetText(addon:Yellow(ExpButtonText[panelIndex]))
-		cbText:SetPoint("LEFT", cButton, "RIGHT", 5, 0)
-		cbText:SetHeight(14)
-		cbText:SetWidth(100)
-		cbText:SetJustifyH("LEFT")
-		cButton.text = cbText
+	return (tonumber(r, 16) / 256), (tonumber(g,16) / 256), (tonumber(b, 16) / 256)
+end

-		-- And throw up a tooltip
-		SetTooltipScripts(cButton, ExpButtonTT[panelIndex])
-		cButton:Hide()
+local Generic_MakeCheckButton
+do
+	local PUSHDOWN = {
+		["cloak"]	= true,
+		["necklace"]	= true,
+		["ring"]	= true,
+		["trinket"]	= true,
+		["shield"]	= true,
+	}
+	function Generic_MakeCheckButton(cButton, anchorFrame, ttText, scriptVal, row, col, misc)
+		-- set the position of the new checkbox
+		local xPos = 2 + ((col - 1) * 100)
+		local yPos = -3 - ((row - 1) * 17)

-		return cButton
+		if PUSHDOWN[scriptVal] then
+			yPos = yPos - 5
+		end
+		cButton:SetPoint("TOPLEFT", anchorFrame, "TOPLEFT", xPos, yPos)
+		cButton:SetHeight(24)
+		cButton:SetWidth(24)
+
+		-- depending if we're on the misc panel or not, set an alternative OnClick method
+		if misc == 0 then
+			cButton:SetScript("OnClick",
+					  function()
+						  FilterValueMap[scriptVal].svroot[scriptVal] = FilterValueMap[scriptVal].cb:GetChecked() and true or false
+						  MainPanel:UpdateTitle()
+						  ReDisplay()
+					  end)
+		else
+			cButton:SetScript("OnClick",
+					  function()
+						  addon.db.profile.ignoreexclusionlist = not addon.db.profile.ignoreexclusionlist
+						  ReDisplay()
+					  end)
+		end
+		SetTooltipScripts(cButton, ttText, 1)
 	end
 end	-- do

@@ -3221,30 +3246,6 @@ function addon:InitializeFrame()
 	end	-- do

 	-------------------------------------------------------------------------------
-	-- EXPANDED : 7 buttons for opening/closing the filter menu
-	-------------------------------------------------------------------------------
-	ARL_ExpGeneralOptCB = CreateFilterMenuButton("ARL_ExpGeneralOptCB", "INV_Misc_Note_06", 1)
-	ARL_ExpGeneralOptCB:SetPoint("TOPRIGHT", MainPanel.filter_toggle, "BOTTOMLEFT", -7, -50)
-
-	ARL_ExpObtainOptCB = CreateFilterMenuButton("ARL_ExpObtainOptCB", "Spell_Shadow_MindRot", 2)
-	ARL_ExpObtainOptCB:SetPoint("TOPLEFT", ARL_ExpGeneralOptCB, "BOTTOMLEFT", 0, -8)
-
-	ARL_ExpBindingOptCB = CreateFilterMenuButton("ARL_ExpBindingOptCB", "INV_Belt_20", 3)
-	ARL_ExpBindingOptCB:SetPoint("TOPLEFT", ARL_ExpObtainOptCB, "BOTTOMLEFT", -0, -8)
-
-	ARL_ExpItemOptCB = CreateFilterMenuButton("ARL_ExpItemOptCB", "INV_Misc_EngGizmos_19", 4)
-	ARL_ExpItemOptCB:SetPoint("TOPLEFT", ARL_ExpBindingOptCB, "BOTTOMLEFT", -0, -8)
-
-	ARL_ExpPlayerOptCB = CreateFilterMenuButton("ARL_ExpPlayerOptCB", "INV_Misc_GroupLooking", 5)
-	ARL_ExpPlayerOptCB:SetPoint("TOPLEFT", ARL_ExpItemOptCB, "BOTTOMLEFT", -0, -8)
-
-	ARL_ExpRepOptCB = CreateFilterMenuButton("ARL_ExpRepOptCB", "INV_Scroll_05", 6)
-	ARL_ExpRepOptCB:SetPoint("TOPLEFT", ARL_ExpPlayerOptCB, "BOTTOMLEFT", -0, -8)
-
-	ARL_ExpMiscOptCB = CreateFilterMenuButton("ARL_ExpMiscOptCB", "Trade_Engineering", 7)
-	ARL_ExpMiscOptCB:SetPoint("TOPLEFT", ARL_ExpRepOptCB, "BOTTOMLEFT", -0, -8)
-
-	-------------------------------------------------------------------------------
 	-- Flyaway virtual frames to group buttons/text easily (and make them easy to show/hide)
 	-------------------------------------------------------------------------------
 	MainPanel.filter_menu.General = CreateFrame("Frame", "ARL_FilterMenu_General", MainPanel.filter_menu)
diff --git a/AckisRecipeList.toc b/AckisRecipeList.toc
index 7f58cb4..7891821 100644
--- a/AckisRecipeList.toc
+++ b/AckisRecipeList.toc
@@ -64,8 +64,8 @@ local.xml

 AckisRecipeList.lua
 ARLConfig.lua
-ARLFrame.lua
 ARLColour.lua
+ARLFrame.lua
 ARLDatamine.lua
 Player.lua