From da7484e764dde605e47c0b723f2ffb8066656789 Mon Sep 17 00:00:00 2001 From: Ackis Date: Tue, 25 Nov 2008 19:51:53 +0000 Subject: [PATCH] Another fix for local functions, and when searching, only do the search if we have a value to serach for --- ARLFrame.lua | 183 ++++++++++++++++++++++++++------------------------- AckisRecipeList.lua | 48 +++++++------- 2 files changed, 118 insertions(+), 113 deletions(-) diff --git a/ARLFrame.lua b/ARLFrame.lua index de01c0d..4a228eb 100644 --- a/ARLFrame.lua +++ b/ARLFrame.lua @@ -234,97 +234,6 @@ end -- Expected result: -- Input: -- Output: --- This does the initial fillup of the DisplayStrings structure. --- This won't run if all we're doing is expanding/contracting a recipe - -local function initDisplayStrings() - - local exclude = addon.db.profile.exclusionlist - - DisplayStrings = nil - DisplayStrings = {} - - local insertIndex = 1 - - for i = 1, #sortedRecipeIndex do - - local recipeIndex = sortedRecipeIndex[i] - - if ((recipeDB[recipeIndex]["Display"] == true) and (recipeDB[recipeIndex]["Search"] == true)) then - - local t = {} - - -- add in recipe difficulty coloring - local recStr = "" - - if (exclude[recipeIndex] == true) then - - recStr = "** " .. recipeDB[recipeIndex]["Name"] .. " **" - - else - - recStr = recipeDB[recipeIndex]["Name"] - - end - - local recipeSkill = recipeDB[recipeIndex]["Level"] - local playerSkill = playerData.playerProfessionLevel - - recStr = SetSortString(recipeSkill, recStr) - - local hasFaction = checkFactions(recipeDB, recipeIndex, playerData.playerFaction, playerData["Reputation"]) - - t.String = ColourSkillLevel(recipeSkill, playerSkill, hasFaction, recStr) - - t.sID = recipeIndex - t.IsRecipe = true - t.IsExpanded = false - tinsert(DisplayStrings, insertIndex, t) - insertIndex = insertIndex + 1 - - end - - end - -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 - --- Description: --- Expected result: --- Input: --- Output: - -local function ReDisplay() - - addon:UpdateFilters(recipeDB, allSpecTable, playerData) - sortedRecipeIndex = addon:SortMissingRecipes(recipeDB) - - if (not addon.db.profile.ignoreexclusionlist) then - - addon:GetExclusions(recipeDB) - - end - - initDisplayStrings() - - SetProgressBar(playerData) - - -- Make sure our expand all button is set to expandall - ARL_ExpandButton:SetText(L["EXPANDALL"]) - addon:TooltipDisplay(ARL_ExpandButton, L["EXPANDALL_DESC"]) - - -- And update our scrollframe - RecipeList_Update() - -end - --- Description: --- Expected result: --- Input: --- Output: local function checkFactions(DB, recipeIndex, playerFaction, playerRep) @@ -422,6 +331,98 @@ local function ColourSkillLevel(recipeSkill, playerSkill, hasFaction, recStr) end + +-- Description: +-- Expected result: +-- Input: +-- Output: +-- This does the initial fillup of the DisplayStrings structure. +-- This won't run if all we're doing is expanding/contracting a recipe + +local function initDisplayStrings() + + local exclude = addon.db.profile.exclusionlist + + DisplayStrings = nil + DisplayStrings = {} + + local insertIndex = 1 + + for i = 1, #sortedRecipeIndex do + + local recipeIndex = sortedRecipeIndex[i] + + if ((recipeDB[recipeIndex]["Display"] == true) and (recipeDB[recipeIndex]["Search"] == true)) then + + local t = {} + + -- add in recipe difficulty coloring + local recStr = "" + + if (exclude[recipeIndex] == true) then + + recStr = "** " .. recipeDB[recipeIndex]["Name"] .. " **" + + else + + recStr = recipeDB[recipeIndex]["Name"] + + end + + local recipeSkill = recipeDB[recipeIndex]["Level"] + local playerSkill = playerData.playerProfessionLevel + + recStr = SetSortString(recipeSkill, recStr) + + local hasFaction = checkFactions(recipeDB, recipeIndex, playerData.playerFaction, playerData["Reputation"]) + + t.String = ColourSkillLevel(recipeSkill, playerSkill, hasFaction, recStr) + + t.sID = recipeIndex + t.IsRecipe = true + t.IsExpanded = false + tinsert(DisplayStrings, insertIndex, t) + insertIndex = insertIndex + 1 + + end + + end + +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 + +-- Description: +-- Expected result: +-- Input: +-- Output: + +local function ReDisplay() + + addon:UpdateFilters(recipeDB, allSpecTable, playerData) + sortedRecipeIndex = addon:SortMissingRecipes(recipeDB) + + if (not addon.db.profile.ignoreexclusionlist) then + + addon:GetExclusions(recipeDB) + + end + + initDisplayStrings() + + SetProgressBar(playerData) + + -- Make sure our expand all button is set to expandall + ARL_ExpandButton:SetText(L["EXPANDALL"]) + addon:TooltipDisplay(ARL_ExpandButton, L["EXPANDALL_DESC"]) + + -- And update our scrollframe + RecipeList_Update() + +end + -- Description: -- Expected result: -- Input: diff --git a/AckisRecipeList.lua b/AckisRecipeList.lua index eab13f0..fe3deaf 100644 --- a/AckisRecipeList.lua +++ b/AckisRecipeList.lua @@ -2065,37 +2065,41 @@ function addon:SearchRecipeDB(RecipeDB, searchstring) local lowerstring = tolower(searchstring) - -- Go through the entire database - for SpellID in pairs(RecipeDB) do + if (lowerstring) then + + -- Go through the entire database + for SpellID in pairs(RecipeDB) do - -- Get the Spell object - local recipe = RecipeDB[SpellID] + -- Get the Spell object + local recipe = RecipeDB[SpellID] - -- Set the search as false automatically - recipe["Search"] = false + -- Set the search as false automatically + recipe["Search"] = false - -- Allow us to search by spell ID - if sfind(tolower(SpellID),lowerstring) or + -- Allow us to search by spell ID + if sfind(tolower(SpellID),lowerstring) or - -- Allow us to search byitem ID - sfind(tolower(recipe["ItemID"]),lowerstring) or + -- Allow us to search byitem ID + sfind(tolower(recipe["ItemID"]),lowerstring) or - -- Allow us to search by name - sfind(tolower(recipe["Name"]),lowerstring) or + -- Allow us to search by name + sfind(tolower(recipe["Name"]),lowerstring) or - -- Allow us to search by locations - sfind(recipe["Locations"],lowerstring) or + -- Allow us to search by locations + sfind(recipe["Locations"],lowerstring) or - -- Allow us to search by specialty - sfind(recipe["Specialty"],lowerstring) or - - -- Allow us to search by skill level - sfind(recipe["Level"],lowerstring) or + -- Allow us to search by specialty + sfind(recipe["Specialty"],lowerstring) or + + -- Allow us to search by skill level + sfind(recipe["Level"],lowerstring) or - -- Allow us to search by Rarity - sfind(recipe["Rarity"],lowerstring) then + -- Allow us to search by Rarity + sfind(recipe["Rarity"],lowerstring) then - recipe["Search"] = true + recipe["Search"] = true + + end end -- 1.7.9.5