James D. Callahan III [07-12-10 - 21:50]
diff --git a/Interface/List.lua b/Interface/List.lua
index e0ed9a2..bd74806 100644
--- a/Interface/List.lua
+++ b/Interface/List.lua
@@ -38,7 +38,7 @@ local CATEGORY_COLORS = private.category_colors
local BASIC_COLORS = private.basic_colors
local SF = private.recipe_state_flags
-local COMMON_FLAGS_1 = private.common_flags_word1
+local COMMON1 = private.common_flags_word1
local A = private.acquire_types
local A_MAX = 9
@@ -410,76 +410,437 @@ function private.InitializeListFrame()
return insert_index
end
- function ListFrame:Initialize(expand_mode)
- for i = 1, #self.entries do
- ReleaseTable(self.entries[i])
- end
- table.wipe(self.entries)
-
- addon:UpdateFilters(MainPanel.is_linked)
-
+ do
-------------------------------------------------------------------------------
- -- Mark all exclusions in the recipe database to not be displayed, and update
- -- the player's known and unknown counts.
+ -- Filter flag data and functions for ListFrame:Initialize()
-------------------------------------------------------------------------------
- local exclusion_list = addon.db.profile.exclusionlist
- local ignored = not addon.db.profile.ignoreexclusionlist
- local recipe_list = private.recipe_list
- local current_prof = private.ordered_professions[MainPanel.profession]
- local known_count = 0
- local unknown_count = 0
-
- for spell_id in pairs(exclusion_list) do
- local recipe = recipe_list[spell_id]
-
- if recipe then
- if recipe:HasState("KNOWN") and recipe.profession == current_prof then
- known_count = known_count + 1
- elseif recipe_profession == current_prof then
- unknown_count = unknown_count + 1
+ local CLASS1 = private.class_flags_word1
+ local REP1 = private.rep_flags_word1
+ local REP2 = private.rep_flags_word2
+ local ITEM1 = private.item_flags_word1
+
+ -- HardFilterFlags and SoftFilterFlags are used to determine if a recipe should be shown based on the value of the key compared to the value of its saved_var.
+ -- Its keys and values are populated the first time CanDisplayRecipe() is called.
+ local HardFilterFlags, SoftFilterFlags, RepFilterFlags, RepFilterFlags2
+
+ local ClassFilterFlags = {
+ ["deathknight"] = CLASS1.DK,
+ ["druid"] = CLASS1.DRUID,
+ ["hunter"] = CLASS1.HUNTER,
+ ["mage"] = CLASS1.MAGE,
+ ["paladin"] = CLASS1.PALADIN,
+ ["priest"] = CLASS1.PRIEST,
+ ["shaman"] = CLASS1.SHAMAN,
+ ["rogue"] = CLASS1.ROGUE,
+ ["warlock"] = CLASS1.WARLOCK,
+ ["warrior"] = CLASS1.WARRIOR,
+ }
+
+ ---Scans a specific recipe to determine if it is to be displayed or not.
+ -- For flag info see comments at start of file in comments
+ local function CanDisplayRecipe(recipe)
+ if addon.db.profile.exclusionlist[recipe.spell_id] and not addon.db.profile.ignoreexclusionlist then
+ return false
+ end
+ local filter_db = addon.db.profile.filters
+ local general_filters = filter_db.general
+
+ -- See Documentation file for logic explanation
+ -------------------------------------------------------------------------------
+ -- Stage 1
+ -- Loop through exclusive flags (hard filters)
+ -- If one of these does not pass we do not display the recipe
+ -- So to be more efficient we'll just leave this function if there's a false
+ -------------------------------------------------------------------------------
+
+ -- Display both horde and alliance factions?
+ if not general_filters.faction and not Player:HasRecipeFaction(recipe) then
+ return false
+ end
+
+ -- Display all skill levels?
+ if not general_filters.skill and recipe.skill_level > Player["ProfessionLevel"] then
+ return false
+ end
+
+ -- Display all specialities?
+ if not general_filters.specialty then
+ local specialty = recipe.specialty
+
+ if specialty and specialty ~= Player["Specialty"] then
+ return false
end
end
- end
- Player.excluded_recipes_known = known_count
- Player.excluded_recipes_unknown = unknown_count
- -------------------------------------------------------------------------------
- -- Initialize the expand button and entries for the current tab.
- -------------------------------------------------------------------------------
- local current_tab = MainPanel.tabs[addon.db.profile.current_tab]
- local expanded_button = current_tab["expand_button_"..MainPanel.profession]
+ -- Display retired recipes?
+ if not general_filters.retired and bit.band(recipe.flags.common1, COMMON1.RETIRED) == COMMON1.RETIRED then
+ return false
+ end
+ local obtain_filters = filter_db.obtain
+ local game_version = private.game_versions[recipe.genesis]
+ local V = private.game_versions
- if expanded_button then
- MainPanel.expand_button:Expand(current_tab)
- else
- MainPanel.expand_button:Contract(current_tab)
- end
- local recipe_count = current_tab:Initialize(expand_mode)
+ -- Filter out game recipes
+ if not obtain_filters.expansion0 and game_version == V.ORIG then
+ return false
+ end
- -------------------------------------------------------------------------------
- -- Update the progress bar display.
- -------------------------------------------------------------------------------
- local profile = addon.db.profile
- local max_value = profile.includefiltered and Player.recipes_total or Player.recipes_total_filtered
- local cur_value = profile.includefiltered and Player.recipes_known or Player.recipes_known_filtered
+ if not obtain_filters.expansion1 and game_version == V.TBC then
+ return false
+ end
+
+ if not obtain_filters.expansion2 and game_version == V.WOTLK then
+ return false
+ end
+ local quality_filters = filter_db.quality
+ local recipe_quality = recipe.quality
+ local Q = private.item_qualities
+
+ -- Filter out certain recipe quality types.
+ if not quality_filters.common and recipe_quality == Q.COMMON then
+ return false
+ end
+
+ if not quality_filters.uncommon and recipe_quality == Q.UNCOMMON then
+ return false
+ end
+
+ if not quality_filters.rare and recipe_quality == Q.RARE then
+ return false
+ end
+
+ if not quality_filters.epic and recipe_quality == Q.EPIC then
+ return false
+ end
+
+ -------------------------------------------------------------------------------
+ -- Check the hard filter flags
+ -------------------------------------------------------------------------------
+ if not HardFilterFlags then
+ local binding_filters = filter_db.binding
+ local player_filters = filter_db.player
+ local armor_filters = filter_db.item.armor
+ local weapon_filters = filter_db.item.weapon
+
+ HardFilterFlags = {
+ ------------------------------------------------------------------------------------------------
+ -- Binding flags.
+ ------------------------------------------------------------------------------------------------
+ ["itemboe"] = { flag = COMMON1.IBOE, index = 1, sv_root = binding_filters },
+ ["itembop"] = { flag = COMMON1.IBOP, index = 1, sv_root = binding_filters },
+ ["itemboa"] = { flag = COMMON1.IBOA, index = 1, sv_root = binding_filters },
+ ["recipeboe"] = { flag = COMMON1.RBOE, index = 1, sv_root = binding_filters },
+ ["recipebop"] = { flag = COMMON1.RBOP, index = 1, sv_root = binding_filters },
+ ["recipeboa"] = { flag = COMMON1.RBOA, index = 1, sv_root = binding_filters },
+ ------------------------------------------------------------------------------------------------
+ -- Player Type flags.
+ ------------------------------------------------------------------------------------------------
+ ["melee"] = { flag = COMMON1.DPS, index = 1, sv_root = player_filters },
+ ["tank"] = { flag = COMMON1.TANK, index = 1, sv_root = player_filters },
+ ["healer"] = { flag = COMMON1.HEALER, index = 1, sv_root = player_filters },
+ ["caster"] = { flag = COMMON1.CASTER, index = 1, sv_root = player_filters },
+ ------------------------------------------------------------------------------------------------
+ -- Armor flags.
+ ------------------------------------------------------------------------------------------------
+ ["cloth"] = { flag = ITEM1.CLOTH, index = 5, sv_root = armor_filters },
+ ["leather"] = { flag = ITEM1.LEATHER, index = 5, sv_root = armor_filters },
+ ["mail"] = { flag = ITEM1.MAIL, index = 5, sv_root = armor_filters },
+ ["plate"] = { flag = ITEM1.PLATE, index = 5, sv_root = armor_filters },
+ ["trinket"] = { flag = ITEM1.TRINKET, index = 5, sv_root = armor_filters },
+ ["cloak"] = { flag = ITEM1.CLOAK, index = 5, sv_root = armor_filters },
+ ["ring"] = { flag = ITEM1.RING, index = 5, sv_root = armor_filters },
+ ["necklace"] = { flag = ITEM1.NECK, index = 5, sv_root = armor_filters },
+ ["shield"] = { flag = ITEM1.SHIELD, index = 5, sv_root = armor_filters },
+ ------------------------------------------------------------------------------------------------
+ -- Weapon flags.
+ ------------------------------------------------------------------------------------------------
+ ["onehand"] = { flag = ITEM1.ONE_HAND, index = 5, sv_root = weapon_filters },
+ ["twohand"] = { flag = ITEM1.TWO_HAND, index = 5, sv_root = weapon_filters },
+ ["axe"] = { flag = ITEM1.AXE, index = 5, sv_root = weapon_filters },
+ ["sword"] = { flag = ITEM1.SWORD, index = 5, sv_root = weapon_filters },
+ ["mace"] = { flag = ITEM1.MACE, index = 5, sv_root = weapon_filters },
+ ["polearm"] = { flag = ITEM1.POLEARM, index = 5, sv_root = weapon_filters },
+ ["dagger"] = { flag = ITEM1.DAGGER, index = 5, sv_root = weapon_filters },
+ ["fist"] = { flag = ITEM1.FIST, index = 5, sv_root = weapon_filters },
+ ["gun"] = { flag = ITEM1.GUN, index = 5, sv_root = weapon_filters },
+ ["staff"] = { flag = ITEM1.STAFF, index = 5, sv_root = weapon_filters },
+ ["wand"] = { flag = ITEM1.WAND, index = 5, sv_root = weapon_filters },
+ ["thrown"] = { flag = ITEM1.THROWN, index = 5, sv_root = weapon_filters },
+ ["bow"] = { flag = ITEM1.BOW, index = 5, sv_root = weapon_filters },
+ ["crossbow"] = { flag = ITEM1.XBOW, index = 5, sv_root = weapon_filters },
+ ["ammo"] = { flag = ITEM1.AMMO, index = 5, sv_root = weapon_filters },
+ }
+ end
+
+ for filter, data in pairs(HardFilterFlags) do
+ local bitfield = recipe.flags[private.flag_members[data.index]]
+
+ if bitfield and bit.band(bitfield, data.flag) == data.flag and not data.sv_root[filter] then
+ return false
+ end
+ end
+
+ -------------------------------------------------------------------------------
+ -- Check the reputation filter flags
+ -------------------------------------------------------------------------------
+ if not RepFilterFlags then
+ RepFilterFlags = {
+ [REP1.ARGENTDAWN] = "argentdawn",
+ [REP1.CENARION_CIRCLE] = "cenarioncircle",
+ [REP1.THORIUM_BROTHERHOOD] = "thoriumbrotherhood",
+ [REP1.TIMBERMAW_HOLD] = "timbermaw",
+ [REP1.ZANDALAR] = "zandalar",
+ [REP1.ALDOR] = "aldor",
+ [REP1.ASHTONGUE] = "ashtonguedeathsworn",
+ [REP1.CENARION_EXPEDITION] = "cenarionexpedition",
+ [REP1.HELLFIRE] = "hellfire",
+ [REP1.CONSORTIUM] = "consortium",
+ [REP1.KOT] = "keepersoftime",
+ [REP1.LOWERCITY] = "lowercity",
+ [REP1.NAGRAND] = "nagrand",
+ [REP1.SCALE_SANDS] = "scaleofthesands",
+ [REP1.SCRYER] = "scryer",
+ [REP1.SHATAR] = "shatar",
+ [REP1.SHATTEREDSUN] = "shatteredsun",
+ [REP1.SPOREGGAR] = "sporeggar",
+ [REP1.VIOLETEYE] = "violeteye",
+ [REP1.ARGENTCRUSADE] = "argentcrusade",
+ [REP1.FRENZYHEART] = "frenzyheart",
+ [REP1.EBONBLADE] = "ebonblade",
+ [REP1.KIRINTOR] = "kirintor",
+ [REP1.HODIR] = "sonsofhodir",
+ [REP1.KALUAK] = "kaluak",
+ [REP1.ORACLES] = "oracles",
+ [REP1.WYRMREST] = "wyrmrest",
+ [REP1.WRATHCOMMON1] = "wrathcommon1",
+ [REP1.WRATHCOMMON2] = "wrathcommon2",
+ [REP1.WRATHCOMMON3] = "wrathcommon3",
+ [REP1.WRATHCOMMON4] = "wrathcommon4",
+ [REP1.WRATHCOMMON5] = "wrathcommon5",
+ }
+ end
+
+ if not RepFilterFlags2 then
+ RepFilterFlags2 = {
+ [REP2.ASHEN_VERDICT] = "ashenverdict",
+ }
+ end
+
+ -- Now we check to see if _all_ of the pertinent reputation or class flags are toggled off. If even one is toggled on, we still show the recipe.
+ local toggled_off, toggled_on = 0, 0
+
+ for flag, name in pairs(RepFilterFlags) do
+ local bitfield = recipe.flags.reputation1
+
+ if bitfield and bit.band(bitfield, flag) == flag then
+ if filter_db.rep[name] then
+ toggled_on = toggled_on + 1
+ else
+ toggled_off = toggled_off + 1
+ end
+ end
+ end
+
+ if toggled_off > 0 and toggled_on == 0 then
+ return false
+ end
+
+ toggled_off, toggled_on = 0, 0
+
+ for flag, name in pairs(RepFilterFlags2) do
+ local bitfield = recipe.flags.reputation2
+
+ if bitfield and bit.band(bitfield, flag) == flag then
+ if filter_db.rep[name] then
+ toggled_on = toggled_on + 1
+ else
+ toggled_off = toggled_off + 1
+ end
+ end
+ end
- if not profile.includeexcluded and not profile.ignoreexclusionlist then
- max_value = max_value - Player.excluded_recipes_known
+ if toggled_off > 0 and toggled_on == 0 then
+ return false
+ end
+
+ -------------------------------------------------------------------------------
+ -- Check the class filter flags
+ -------------------------------------------------------------------------------
+ local class_filters = filter_db.classes
+
+ toggled_off, toggled_on = 0, 0
+
+ for class, flag in pairs(ClassFilterFlags) do
+ local bitfield = recipe.flags.class1
+
+ if bitfield and bit.band(bitfield, flag) == flag then
+ if class_filters[class] then
+ toggled_on = toggled_on + 1
+ else
+ toggled_off = toggled_off + 1
+ end
+ end
+ end
+
+ if toggled_off > 0 and toggled_on == 0 then
+ return false
+ end
+
+ ------------------------------------------------------------------------------------------------
+ -- Stage 2
+ -- loop through nonexclusive (soft filters) flags until one is true
+ -- If one of these is true (ie: we want to see trainers and there is a trainer flag) we display the recipe
+ ------------------------------------------------------------------------------------------------
+ if not SoftFilterFlags then
+ SoftFilterFlags = {
+ ["trainer"] = { flag = COMMON1.TRAINER, index = 1, sv_root = obtain_filters },
+ ["vendor"] = { flag = COMMON1.VENDOR, index = 1, sv_root = obtain_filters },
+ ["instance"] = { flag = COMMON1.INSTANCE, index = 1, sv_root = obtain_filters },
+ ["raid"] = { flag = COMMON1.RAID, index = 1, sv_root = obtain_filters },
+ ["seasonal"] = { flag = COMMON1.SEASONAL, index = 1, sv_root = obtain_filters },
+ ["quest"] = { flag = COMMON1.QUEST, index = 1, sv_root = obtain_filters },
+ ["pvp"] = { flag = COMMON1.PVP, index = 1, sv_root = obtain_filters },
+ ["worlddrop"] = { flag = COMMON1.WORLD_DROP, index = 1, sv_root = obtain_filters },
+ ["mobdrop"] = { flag = COMMON1.MOB_DROP, index = 1, sv_root = obtain_filters },
+ ["discovery"] = { flag = COMMON1.DISC, index = 1, sv_root = obtain_filters },
+ }
+ end
+
+ for filter, data in pairs(SoftFilterFlags) do
+ local bitfield = recipe.flags[private.flag_members[data.index]]
+
+ if bitfield and bit.band(bitfield, data.flag) == data.flag and data.sv_root[filter] then
+ return true
+ end
+ end
+
+ -- If we get here it means that no flags matched our values
+ return false
end
- local progress_bar = MainPanel.progress_bar
- progress_bar:SetMinMaxValues(0, max_value)
- progress_bar:SetValue(cur_value)
+ function ListFrame:Initialize(expand_mode)
+ for i = 1, #self.entries do
+ ReleaseTable(self.entries[i])
+ end
+ table.wipe(self.entries)
- local percentage = cur_value / max_value * 100
+ -------------------------------------------------------------------------------
+ -- Update recipe filters.
+ -------------------------------------------------------------------------------
+ local general_filters = addon.db.profile.filters.general
- if (math.floor(percentage) < 101) and cur_value >= 0 and max_value >= 0 then
- local results = string.format(_G.SINGLE_PAGE_RESULTS_TEMPLATE, recipe_count)
- progress_bar.text:SetFormattedText("%d/%d - %1.2f%% (%s)", cur_value, max_value, percentage, results)
- else
- progress_bar.text:SetFormattedText("%s", L["NOT_YET_SCANNED"])
+ local recipes_total = 0
+ local recipes_known = 0
+
+ local recipes_total_filtered = 0
+ local recipes_known_filtered = 0
+
+ local recipe_list = private.recipe_list
+ local current_prof = MainPanel.prof_name or private.ordered_professions[MainPanel.profession]
+ local can_display = false
+
+ for recipe_id, recipe in pairs(recipe_list) do
+ recipe:RemoveState("VISIBLE")
+
+ if recipe.profession == current_prof then
+ local is_known
+
+ if MainPanel.is_linked then
+ is_known = recipe:HasState("LINKED")
+ else
+ is_known = recipe:HasState("KNOWN")
+ end
+
+ can_display = CanDisplayRecipe(recipe)
+ recipes_total = recipes_total + 1
+ recipes_known = recipes_known + (is_known and 1 or 0)
+
+ if can_display then
+ recipes_total_filtered = recipes_total_filtered + 1
+ recipes_known_filtered = recipes_known_filtered + (is_known and 1 or 0)
+
+ if not general_filters.known and is_known then
+ can_display = false
+ end
+
+ if not general_filters.unknown and not is_known then
+ can_display = false
+ end
+ end
+ else
+ can_display = false
+ end
+
+ if can_display then
+ recipe:AddState("VISIBLE")
+ end
+ end
+ Player.recipes_total = recipes_total
+ Player.recipes_known = recipes_known
+ Player.recipes_total_filtered = recipes_total_filtered
+ Player.recipes_known_filtered = recipes_known_filtered
+
+ -------------------------------------------------------------------------------
+ -- Mark all exclusions in the recipe database to not be displayed, and update
+ -- the player's known and unknown counts.
+ -------------------------------------------------------------------------------
+ local exclusion_list = addon.db.profile.exclusionlist
+ local ignored = not addon.db.profile.ignoreexclusionlist
+ local known_count = 0
+ local unknown_count = 0
+
+ for spell_id in pairs(exclusion_list) do
+ local recipe = recipe_list[spell_id]
+
+ if recipe then
+ if recipe:HasState("KNOWN") and recipe.profession == current_prof then
+ known_count = known_count + 1
+ elseif recipe_profession == current_prof then
+ unknown_count = unknown_count + 1
+ end
+ end
+ end
+ Player.excluded_recipes_known = known_count
+ Player.excluded_recipes_unknown = unknown_count
+
+ -------------------------------------------------------------------------------
+ -- Initialize the expand button and entries for the current tab.
+ -------------------------------------------------------------------------------
+ local current_tab = MainPanel.tabs[addon.db.profile.current_tab]
+ local expanded_button = current_tab["expand_button_"..MainPanel.profession]
+
+ if expanded_button then
+ MainPanel.expand_button:Expand(current_tab)
+ else
+ MainPanel.expand_button:Contract(current_tab)
+ end
+ local recipe_count = current_tab:Initialize(expand_mode)
+
+ -------------------------------------------------------------------------------
+ -- Update the progress bar display.
+ -------------------------------------------------------------------------------
+ local profile = addon.db.profile
+ local max_value = profile.includefiltered and Player.recipes_total or Player.recipes_total_filtered
+ local cur_value = profile.includefiltered and Player.recipes_known or Player.recipes_known_filtered
+
+ if not profile.includeexcluded and not profile.ignoreexclusionlist then
+ max_value = max_value - Player.excluded_recipes_known
+ end
+ local progress_bar = MainPanel.progress_bar
+
+ progress_bar:SetMinMaxValues(0, max_value)
+ progress_bar:SetValue(cur_value)
+
+ local percentage = cur_value / max_value * 100
+
+ if (math.floor(percentage) < 101) and cur_value >= 0 and max_value >= 0 then
+ local results = string.format(_G.SINGLE_PAGE_RESULTS_TEMPLATE, recipe_count)
+ progress_bar.text:SetFormattedText("%d/%d - %1.2f%% (%s)", cur_value, max_value, percentage, results)
+ else
+ progress_bar.text:SetFormattedText("%s", L["NOT_YET_SCANNED"])
+ end
end
- end
+ end -- do-block
-- Reset the current buttons/lines
function ListFrame:ClearLines()
@@ -1419,12 +1780,12 @@ do
-- Main tooltip-generating function.
-------------------------------------------------------------------------------
local BINDING_FLAGS = {
- [COMMON_FLAGS_1.IBOE] = L["BOEFilter"],
- [COMMON_FLAGS_1.IBOP] = L["BOPFilter"],
- [COMMON_FLAGS_1.IBOA] = L["BOAFilter"],
- [COMMON_FLAGS_1.RBOE] = L["RecipeBOEFilter"],
- [COMMON_FLAGS_1.RBOP] = L["RecipeBOPFilter"],
- [COMMON_FLAGS_1.RBOA] = L["RecipeBOAFilter"]
+ [COMMON1.IBOE] = L["BOEFilter"],
+ [COMMON1.IBOP] = L["BOPFilter"],
+ [COMMON1.IBOA] = L["BOAFilter"],
+ [COMMON1.RBOE] = L["RecipeBOEFilter"],
+ [COMMON1.RBOP] = L["RecipeBOPFilter"],
+ [COMMON1.RBOA] = L["RecipeBOAFilter"]
}
function ListItem_ShowTooltip(owner, list_entry)
diff --git a/core.lua b/core.lua
index 01ee658..8a62c07 100644
--- a/core.lua
+++ b/core.lua
@@ -1386,370 +1386,6 @@ do
end -- do
-------------------------------------------------------------------------------
--- Filter flag functions
--------------------------------------------------------------------------------
-do
- local COMMON1 = private.common_flags_word1
- local CLASS1 = private.class_flags_word1
- local REP1 = private.rep_flags_word1
- local REP2 = private.rep_flags_word2
- local ITEM1 = private.item_flags_word1
-
- -- HardFilterFlags and SoftFilterFlags are used to determine if a recipe should be shown based on the value of the key compared to the value of its saved_var.
- -- Its keys and values are populated the first time CanDisplayRecipe() is called.
- local HardFilterFlags, SoftFilterFlags, RepFilterFlags, RepFilterFlags2
-
- local ClassFilterFlags = {
- ["deathknight"] = CLASS1.DK,
- ["druid"] = CLASS1.DRUID,
- ["hunter"] = CLASS1.HUNTER,
- ["mage"] = CLASS1.MAGE,
- ["paladin"] = CLASS1.PALADIN,
- ["priest"] = CLASS1.PRIEST,
- ["shaman"] = CLASS1.SHAMAN,
- ["rogue"] = CLASS1.ROGUE,
- ["warlock"] = CLASS1.WARLOCK,
- ["warrior"] = CLASS1.WARRIOR,
- }
-
- ---Scans a specific recipe to determine if it is to be displayed or not.
- -- For flag info see comments at start of file in comments
- local function CanDisplayRecipe(recipe)
- if addon.db.profile.exclusionlist[recipe.spell_id] and not addon.db.profile.ignoreexclusionlist then
- return false
- end
- local filter_db = addon.db.profile.filters
- local general_filters = filter_db.general
-
- -- See Documentation file for logic explanation
- -------------------------------------------------------------------------------
- -- Stage 1
- -- Loop through exclusive flags (hard filters)
- -- If one of these does not pass we do not display the recipe
- -- So to be more efficient we'll just leave this function if there's a false
- -------------------------------------------------------------------------------
-
- -- Display both horde and alliance factions?
- if not general_filters.faction and not Player:HasRecipeFaction(recipe) then
- return false
- end
-
- -- Display all skill levels?
- if not general_filters.skill and recipe.skill_level > Player["ProfessionLevel"] then
- return false
- end
-
- -- Display all specialities?
- if not general_filters.specialty then
- local specialty = recipe.specialty
-
- if specialty and specialty ~= Player["Specialty"] then
- return false
- end
- end
-
- -- Display retired recipes?
- if not general_filters.retired and bit.band(recipe.flags.common1, COMMON1.RETIRED) == COMMON1.RETIRED then
- return false
- end
- local obtain_filters = filter_db.obtain
- local game_version = private.game_versions[recipe.genesis]
- local V = private.game_versions
-
- -- Filter out game recipes
- if not obtain_filters.expansion0 and game_version == V.ORIG then
- return false
- end
-
- if not obtain_filters.expansion1 and game_version == V.TBC then
- return false
- end
-
- if not obtain_filters.expansion2 and game_version == V.WOTLK then
- return false
- end
- local quality_filters = filter_db.quality
- local recipe_quality = recipe.quality
- local Q = private.item_qualities
-
- -- Filter out certain recipe quality types.
- if not quality_filters.common and recipe_quality == Q.COMMON then
- return false
- end
-
- if not quality_filters.uncommon and recipe_quality == Q.UNCOMMON then
- return false
- end
-
- if not quality_filters.rare and recipe_quality == Q.RARE then
- return false
- end
-
- if not quality_filters.epic and recipe_quality == Q.EPIC then
- return false
- end
-
- -------------------------------------------------------------------------------
- -- Check the hard filter flags
- -------------------------------------------------------------------------------
- if not HardFilterFlags then
- local binding_filters = filter_db.binding
- local player_filters = filter_db.player
- local armor_filters = filter_db.item.armor
- local weapon_filters = filter_db.item.weapon
-
- HardFilterFlags = {
- ------------------------------------------------------------------------------------------------
- -- Binding flags.
- ------------------------------------------------------------------------------------------------
- ["itemboe"] = { flag = COMMON1.IBOE, index = 1, sv_root = binding_filters },
- ["itembop"] = { flag = COMMON1.IBOP, index = 1, sv_root = binding_filters },
- ["itemboa"] = { flag = COMMON1.IBOA, index = 1, sv_root = binding_filters },
- ["recipeboe"] = { flag = COMMON1.RBOE, index = 1, sv_root = binding_filters },
- ["recipebop"] = { flag = COMMON1.RBOP, index = 1, sv_root = binding_filters },
- ["recipeboa"] = { flag = COMMON1.RBOA, index = 1, sv_root = binding_filters },
- ------------------------------------------------------------------------------------------------
- -- Player Type flags.
- ------------------------------------------------------------------------------------------------
- ["melee"] = { flag = COMMON1.DPS, index = 1, sv_root = player_filters },
- ["tank"] = { flag = COMMON1.TANK, index = 1, sv_root = player_filters },
- ["healer"] = { flag = COMMON1.HEALER, index = 1, sv_root = player_filters },
- ["caster"] = { flag = COMMON1.CASTER, index = 1, sv_root = player_filters },
- ------------------------------------------------------------------------------------------------
- -- Armor flags.
- ------------------------------------------------------------------------------------------------
- ["cloth"] = { flag = ITEM1.CLOTH, index = 5, sv_root = armor_filters },
- ["leather"] = { flag = ITEM1.LEATHER, index = 5, sv_root = armor_filters },
- ["mail"] = { flag = ITEM1.MAIL, index = 5, sv_root = armor_filters },
- ["plate"] = { flag = ITEM1.PLATE, index = 5, sv_root = armor_filters },
- ["trinket"] = { flag = ITEM1.TRINKET, index = 5, sv_root = armor_filters },
- ["cloak"] = { flag = ITEM1.CLOAK, index = 5, sv_root = armor_filters },
- ["ring"] = { flag = ITEM1.RING, index = 5, sv_root = armor_filters },
- ["necklace"] = { flag = ITEM1.NECK, index = 5, sv_root = armor_filters },
- ["shield"] = { flag = ITEM1.SHIELD, index = 5, sv_root = armor_filters },
- ------------------------------------------------------------------------------------------------
- -- Weapon flags.
- ------------------------------------------------------------------------------------------------
- ["onehand"] = { flag = ITEM1.ONE_HAND, index = 5, sv_root = weapon_filters },
- ["twohand"] = { flag = ITEM1.TWO_HAND, index = 5, sv_root = weapon_filters },
- ["axe"] = { flag = ITEM1.AXE, index = 5, sv_root = weapon_filters },
- ["sword"] = { flag = ITEM1.SWORD, index = 5, sv_root = weapon_filters },
- ["mace"] = { flag = ITEM1.MACE, index = 5, sv_root = weapon_filters },
- ["polearm"] = { flag = ITEM1.POLEARM, index = 5, sv_root = weapon_filters },
- ["dagger"] = { flag = ITEM1.DAGGER, index = 5, sv_root = weapon_filters },
- ["fist"] = { flag = ITEM1.FIST, index = 5, sv_root = weapon_filters },
- ["gun"] = { flag = ITEM1.GUN, index = 5, sv_root = weapon_filters },
- ["staff"] = { flag = ITEM1.STAFF, index = 5, sv_root = weapon_filters },
- ["wand"] = { flag = ITEM1.WAND, index = 5, sv_root = weapon_filters },
- ["thrown"] = { flag = ITEM1.THROWN, index = 5, sv_root = weapon_filters },
- ["bow"] = { flag = ITEM1.BOW, index = 5, sv_root = weapon_filters },
- ["crossbow"] = { flag = ITEM1.XBOW, index = 5, sv_root = weapon_filters },
- ["ammo"] = { flag = ITEM1.AMMO, index = 5, sv_root = weapon_filters },
- }
- end
-
- for filter, data in pairs(HardFilterFlags) do
- local bitfield = recipe.flags[private.flag_members[data.index]]
-
- if bitfield and bit.band(bitfield, data.flag) == data.flag and not data.sv_root[filter] then
- return false
- end
- end
-
- -------------------------------------------------------------------------------
- -- Check the reputation filter flags
- -------------------------------------------------------------------------------
- if not RepFilterFlags then
- RepFilterFlags = {
- [REP1.ARGENTDAWN] = "argentdawn",
- [REP1.CENARION_CIRCLE] = "cenarioncircle",
- [REP1.THORIUM_BROTHERHOOD] = "thoriumbrotherhood",
- [REP1.TIMBERMAW_HOLD] = "timbermaw",
- [REP1.ZANDALAR] = "zandalar",
- [REP1.ALDOR] = "aldor",
- [REP1.ASHTONGUE] = "ashtonguedeathsworn",
- [REP1.CENARION_EXPEDITION] = "cenarionexpedition",
- [REP1.HELLFIRE] = "hellfire",
- [REP1.CONSORTIUM] = "consortium",
- [REP1.KOT] = "keepersoftime",
- [REP1.LOWERCITY] = "lowercity",
- [REP1.NAGRAND] = "nagrand",
- [REP1.SCALE_SANDS] = "scaleofthesands",
- [REP1.SCRYER] = "scryer",
- [REP1.SHATAR] = "shatar",
- [REP1.SHATTEREDSUN] = "shatteredsun",
- [REP1.SPOREGGAR] = "sporeggar",
- [REP1.VIOLETEYE] = "violeteye",
- [REP1.ARGENTCRUSADE] = "argentcrusade",
- [REP1.FRENZYHEART] = "frenzyheart",
- [REP1.EBONBLADE] = "ebonblade",
- [REP1.KIRINTOR] = "kirintor",
- [REP1.HODIR] = "sonsofhodir",
- [REP1.KALUAK] = "kaluak",
- [REP1.ORACLES] = "oracles",
- [REP1.WYRMREST] = "wyrmrest",
- [REP1.WRATHCOMMON1] = "wrathcommon1",
- [REP1.WRATHCOMMON2] = "wrathcommon2",
- [REP1.WRATHCOMMON3] = "wrathcommon3",
- [REP1.WRATHCOMMON4] = "wrathcommon4",
- [REP1.WRATHCOMMON5] = "wrathcommon5",
- }
- end
-
- if not RepFilterFlags2 then
- RepFilterFlags2 = {
- [REP2.ASHEN_VERDICT] = "ashenverdict",
- }
- end
- -- Now we check to see if _all_ of the pertinent reputation or class flags are toggled off. If even one is toggled on, we still show the recipe.
- local toggled_off, toggled_on = 0, 0
-
- for flag, name in pairs(RepFilterFlags) do
- local bitfield = recipe.flags.reputation1
-
- if bitfield and bit.band(bitfield, flag) == flag then
- if filter_db.rep[name] then
- toggled_on = toggled_on + 1
- else
- toggled_off = toggled_off + 1
- end
- end
- end
-
- if toggled_off > 0 and toggled_on == 0 then
- return false
- end
-
- toggled_off, toggled_on = 0, 0
-
- for flag, name in pairs(RepFilterFlags2) do
- local bitfield = recipe.flags.reputation2
-
- if bitfield and bit.band(bitfield, flag) == flag then
- if filter_db.rep[name] then
- toggled_on = toggled_on + 1
- else
- toggled_off = toggled_off + 1
- end
- end
- end
-
- if toggled_off > 0 and toggled_on == 0 then
- return false
- end
-
- -------------------------------------------------------------------------------
- -- Check the class filter flags
- -------------------------------------------------------------------------------
- local class_filters = filter_db.classes
-
- toggled_off, toggled_on = 0, 0
-
- for class, flag in pairs(ClassFilterFlags) do
- local bitfield = recipe.flags.class1
-
- if bitfield and bit.band(bitfield, flag) == flag then
- if class_filters[class] then
- toggled_on = toggled_on + 1
- else
- toggled_off = toggled_off + 1
- end
- end
- end
-
- if toggled_off > 0 and toggled_on == 0 then
- return false
- end
-
- ------------------------------------------------------------------------------------------------
- -- Stage 2
- -- loop through nonexclusive (soft filters) flags until one is true
- -- If one of these is true (ie: we want to see trainers and there is a trainer flag) we display the recipe
- ------------------------------------------------------------------------------------------------
- if not SoftFilterFlags then
- SoftFilterFlags = {
- ["trainer"] = { flag = COMMON1.TRAINER, index = 1, sv_root = obtain_filters },
- ["vendor"] = { flag = COMMON1.VENDOR, index = 1, sv_root = obtain_filters },
- ["instance"] = { flag = COMMON1.INSTANCE, index = 1, sv_root = obtain_filters },
- ["raid"] = { flag = COMMON1.RAID, index = 1, sv_root = obtain_filters },
- ["seasonal"] = { flag = COMMON1.SEASONAL, index = 1, sv_root = obtain_filters },
- ["quest"] = { flag = COMMON1.QUEST, index = 1, sv_root = obtain_filters },
- ["pvp"] = { flag = COMMON1.PVP, index = 1, sv_root = obtain_filters },
- ["worlddrop"] = { flag = COMMON1.WORLD_DROP, index = 1, sv_root = obtain_filters },
- ["mobdrop"] = { flag = COMMON1.MOB_DROP, index = 1, sv_root = obtain_filters },
- ["discovery"] = { flag = COMMON1.DISC, index = 1, sv_root = obtain_filters },
- }
- end
-
- for filter, data in pairs(SoftFilterFlags) do
- local bitfield = recipe.flags[private.flag_members[data.index]]
-
- if bitfield and bit.band(bitfield, data.flag) == data.flag and data.sv_root[filter] then
- return true
- end
- end
-
- -- If we get here it means that no flags matched our values
- return false
- end
-
- ---Scans the recipe listing and updates the filters according to user preferences
- function addon:UpdateFilters(is_linked)
- local general_filters = addon.db.profile.filters.general
- local recipes_total = 0
- local recipes_known = 0
- local recipes_total_filtered = 0
- local recipes_known_filtered = 0
- local can_display = false
- local current_profession = self.Frame.prof_name or private.ordered_professions[self.Frame.profession]
- local recipe_list = private.recipe_list
- local SF = private.recipe_state_flags
-
- for recipe_id, recipe in pairs(recipe_list) do
- recipe:RemoveState("VISIBLE")
-
- if recipe.profession == current_profession then
- local is_known
-
- if is_linked then
- is_known = recipe:HasState("LINKED")
- else
- is_known = recipe:HasState("KNOWN")
- end
-
- can_display = CanDisplayRecipe(recipe)
- recipes_total = recipes_total + 1
- recipes_known = recipes_known + (is_known and 1 or 0)
-
- if can_display then
- recipes_total_filtered = recipes_total_filtered + 1
- recipes_known_filtered = recipes_known_filtered + (is_known and 1 or 0)
-
- if not general_filters.known and is_known then
- can_display = false
- end
-
- if not general_filters.unknown and not is_known then
- can_display = false
- end
- end
- else
- can_display = false
- end
-
- if can_display then
- recipe:AddState("VISIBLE")
- end
- end
- Player.recipes_total = recipes_total
- Player.recipes_known = recipes_known
- Player.recipes_total_filtered = recipes_total_filtered
- Player.recipes_known_filtered = recipes_known_filtered
- end
-
-end -- do
-
--------------------------------------------------------------------------------
-- ARL Logic Functions
-------------------------------------------------------------------------------
function addon:InitializeProfession(profession)