Quantcast

Make the ARLFrame lower the search string first. Also check to see if we have speciality info before searching that field.

Ackis [11-25-08 - 19:58]
Make the ARLFrame lower the search string first.  Also check to see if we have speciality info before searching that field.
Filename
ARLFrame.lua
AckisRecipeList.lua
diff --git a/ARLFrame.lua b/ARLFrame.lua
index 4a228eb..b66335a 100644
--- a/ARLFrame.lua
+++ b/ARLFrame.lua
@@ -390,6 +390,122 @@ local function initDisplayStrings()

 end

+-- Description:
+-- Expected result:
+-- Input:
+-- Output:
+-- Scrollframe update stuff
+
+local function RecipeList_Update()
+
+	-- Clear out the current buttons
+	for i = 1, maxVisibleRecipes do
+
+		addon.RecipeListButton[i]:SetText("")
+		addon.RecipeListButton[i].sI = 0
+		addon.PlusListButton[i]:Hide()
+		ClearRecipeButtonTooltip(i)
+
+	end
+
+	local entries = #DisplayStrings
+
+	FauxScrollFrame_Update(ARL_RecipeScrollFrame, entries, maxVisibleRecipes, 16)
+
+	if (entries > 0) then
+
+		-- now fill in our buttons
+		local listOffset = FauxScrollFrame_GetOffset(ARL_RecipeScrollFrame)
+		local buttonIndex = 1
+		local stringsIndex = buttonIndex + listOffset
+
+		local stayInLoop = true
+
+		while (stayInLoop == true) do
+
+			if (DisplayStrings[stringsIndex].IsRecipe) then
+
+				-- display the + symbol
+				addon.PlusListButton[buttonIndex]:Show()
+
+				-- Is it expanded or not?
+				if (DisplayStrings[stringsIndex].IsExpanded) then
+
+					addon.PlusListButton[buttonIndex]:SetNormalTexture("Interface\\Buttons\\UI-MinusButton-Up")
+					addon.PlusListButton[buttonIndex]:SetPushedTexture("Interface\\Buttons\\UI-MinusButton-Down")
+					addon.PlusListButton[buttonIndex]:SetHighlightTexture("Interface\\Buttons\\UI-PlusButton-Hilight")
+					addon.PlusListButton[buttonIndex]:SetDisabledTexture("Interface\\Buttons\\UI-MinusButton-Disabled")
+
+				else
+
+					addon.PlusListButton[buttonIndex]:SetNormalTexture("Interface\\Buttons\\UI-PlusButton-Up")
+					addon.PlusListButton[buttonIndex]:SetPushedTexture("Interface\\Buttons\\UI-PlusButton-Down")
+					addon.PlusListButton[buttonIndex]:SetHighlightTexture("Interface\\Buttons\\UI-PlusButton-Hilight")
+					addon.PlusListButton[buttonIndex]:SetDisabledTexture("Interface\\Buttons\\UI-PlusButton-Disabled")
+
+				end
+
+			else
+
+				addon.PlusListButton[buttonIndex]:Hide()
+
+			end
+
+			addon.RecipeListButton[buttonIndex]:SetText(DisplayStrings[stringsIndex].String)
+			addon.RecipeListButton[buttonIndex].sI = stringsIndex
+
+			-- Set the tooltip on the button
+			SetRecipeButtonTooltip(buttonIndex)
+
+			buttonIndex = buttonIndex + 1
+			stringsIndex = stringsIndex + 1
+
+			if ((buttonIndex > maxVisibleRecipes) or (stringsIndex > entries)) then
+
+				stayInLoop = false
+
+			end
+
+		end
+
+	-- Entries are 0 here, so we have 0 to display
+	else
+
+		-- If the recipe total is at 0, it means we have not scanned the profession yet
+		if (playerData.recipes_total == 0) then
+
+			StaticPopup_Show("ARL_NOTSCANNED")
+
+		-- We know all the recipes
+		elseif (playerData.recipes_known == playerData.recipes_total) then
+
+			StaticPopup_Show("ARL_ALLKNOWN")
+
+		-- Our filters are actually filtering something
+		elseif ((playerData.recipes_total_filtered - playerData.recipes_known_filtered) ~= 0) then
+
+			StaticPopup_Show("ARL_ALLFILTERED")
+
+		-- Our exclusion list is preventing something from being displayed
+		elseif (playerData.excluded_recipes_unknown ~= 0) then
+
+			StaticPopup_Show("ARL_ALLEXCLUDED")
+
+		else
+
+			addon:Print(L["NO_DISPLAY"])
+
+		end
+
+	end
+
+	-- Make sure our apply button gets disabled
+	ApplyFilterState = nil
+	ARL_ApplyButton:SetNormalFontObject("GameFontDisableSmall")
+	ARL_ApplyButton:Disable()
+
+end
+
 -- Under various conditions, I'm going to have to redisplay my recipe list
 -- This could happen because a filter changes, a new profession is chosen, or
 -- a new search occurred. Use this function to do all the dirty work
@@ -1868,121 +1984,6 @@ local function SetRecipeButtonTooltip(bIndex)

 end

--- Description:
--- Expected result:
--- Input:
--- Output:
--- Scrollframe update stuff
-
-local function RecipeList_Update()
-
-	-- Clear out the current buttons
-	for i = 1, maxVisibleRecipes do
-
-		addon.RecipeListButton[i]:SetText("")
-		addon.RecipeListButton[i].sI = 0
-		addon.PlusListButton[i]:Hide()
-		ClearRecipeButtonTooltip(i)
-
-	end
-
-	local entries = #DisplayStrings
-
-	FauxScrollFrame_Update(ARL_RecipeScrollFrame, entries, maxVisibleRecipes, 16)
-
-	if (entries > 0) then
-
-		-- now fill in our buttons
-		local listOffset = FauxScrollFrame_GetOffset(ARL_RecipeScrollFrame)
-		local buttonIndex = 1
-		local stringsIndex = buttonIndex + listOffset
-
-		local stayInLoop = true
-
-		while (stayInLoop == true) do
-
-			if (DisplayStrings[stringsIndex].IsRecipe) then
-
-				-- display the + symbol
-				addon.PlusListButton[buttonIndex]:Show()
-
-				-- Is it expanded or not?
-				if (DisplayStrings[stringsIndex].IsExpanded) then
-
-					addon.PlusListButton[buttonIndex]:SetNormalTexture("Interface\\Buttons\\UI-MinusButton-Up")
-					addon.PlusListButton[buttonIndex]:SetPushedTexture("Interface\\Buttons\\UI-MinusButton-Down")
-					addon.PlusListButton[buttonIndex]:SetHighlightTexture("Interface\\Buttons\\UI-PlusButton-Hilight")
-					addon.PlusListButton[buttonIndex]:SetDisabledTexture("Interface\\Buttons\\UI-MinusButton-Disabled")
-
-				else
-
-					addon.PlusListButton[buttonIndex]:SetNormalTexture("Interface\\Buttons\\UI-PlusButton-Up")
-					addon.PlusListButton[buttonIndex]:SetPushedTexture("Interface\\Buttons\\UI-PlusButton-Down")
-					addon.PlusListButton[buttonIndex]:SetHighlightTexture("Interface\\Buttons\\UI-PlusButton-Hilight")
-					addon.PlusListButton[buttonIndex]:SetDisabledTexture("Interface\\Buttons\\UI-PlusButton-Disabled")
-
-				end
-
-			else
-
-				addon.PlusListButton[buttonIndex]:Hide()
-
-			end
-
-			addon.RecipeListButton[buttonIndex]:SetText(DisplayStrings[stringsIndex].String)
-			addon.RecipeListButton[buttonIndex].sI = stringsIndex
-
-			-- Set the tooltip on the button
-			SetRecipeButtonTooltip(buttonIndex)
-
-			buttonIndex = buttonIndex + 1
-			stringsIndex = stringsIndex + 1
-
-			if ((buttonIndex > maxVisibleRecipes) or (stringsIndex > entries)) then
-
-				stayInLoop = false
-
-			end
-
-		end
-
-	-- Entries are 0 here, so we have 0 to display
-	else
-
-		-- If the recipe total is at 0, it means we have not scanned the profession yet
-		if (playerData.recipes_total == 0) then
-
-			StaticPopup_Show("ARL_NOTSCANNED")
-
-		-- We know all the recipes
-		elseif (playerData.recipes_known == playerData.recipes_total) then
-
-			StaticPopup_Show("ARL_ALLKNOWN")
-
-		-- Our filters are actually filtering something
-		elseif ((playerData.recipes_total_filtered - playerData.recipes_known_filtered) ~= 0) then
-
-			StaticPopup_Show("ARL_ALLFILTERED")
-
-		-- Our exclusion list is preventing something from being displayed
-		elseif (playerData.excluded_recipes_unknown ~= 0) then
-
-			StaticPopup_Show("ARL_ALLEXCLUDED")
-
-		else
-
-			addon:Print(L["NO_DISPLAY"])
-
-		end
-
-	end
-
-	-- Make sure our apply button gets disabled
-	ApplyFilterState = nil
-	ARL_ApplyButton:SetNormalFontObject("GameFontDisableSmall")
-	ARL_ApplyButton:Disable()
-
-end

 -- Description:
 -- Expected result:
@@ -3358,10 +3359,11 @@ function addon:CreateFrame(

 					local searchtext = ARL_SearchText:GetText()
 					searchtext = searchtext:trim()
-
+
 					if (searchtext ~= "") then

 						ARL_LastSearchedText = searchtext
+						searchtext = tolower(searchtext)

 						addon:SearchRecipeDB(recipeDB, searchtext)
 						initDisplayStrings()
diff --git a/AckisRecipeList.lua b/AckisRecipeList.lua
index fe3deaf..2599395 100644
--- a/AckisRecipeList.lua
+++ b/AckisRecipeList.lua
@@ -2063,9 +2063,7 @@ end

 function addon:SearchRecipeDB(RecipeDB, searchstring)

-	local lowerstring = tolower(searchstring)
-
-	if (lowerstring) then
+	if (searchstring) then

 		-- Go through the entire database
 		for SpellID in pairs(RecipeDB) do
@@ -2077,25 +2075,25 @@ function addon:SearchRecipeDB(RecipeDB, searchstring)
 			recipe["Search"] = false

 			-- Allow us to search by spell ID
-			if sfind(tolower(SpellID),lowerstring) or
+			if sfind(tolower(SpellID),searchstring) or

 				-- Allow us to search byitem ID
-				sfind(tolower(recipe["ItemID"]),lowerstring) or
+				sfind(tolower(recipe["ItemID"]),searchstring) or

 				-- Allow us to search by name
-				sfind(tolower(recipe["Name"]),lowerstring) or
+				sfind(tolower(recipe["Name"]),searchstring) or

 				-- Allow us to search by locations
-				sfind(recipe["Locations"],lowerstring) or
+				sfind(recipe["Locations"],searchstring) or

 				-- Allow us to search by specialty
-				sfind(recipe["Specialty"],lowerstring) or
+				(recipe["Specialty"] and sfind(recipe["Specialty"],searchstring)) or

 				-- Allow us to search by skill level
-				sfind(recipe["Level"],lowerstring) or
+				sfind(recipe["Level"],searchstring) or

 				-- Allow us to search by Rarity
-				sfind(recipe["Rarity"],lowerstring) then
+				sfind(recipe["Rarity"],searchstring) then

 					recipe["Search"] = true