From 0cc312aab6d46637c2ec914a5a95915ed5fc055b Mon Sep 17 00:00:00 2001 From: "James D. Callahan III" Date: Sat, 11 Dec 2010 19:16:05 -0500 Subject: [PATCH] Added support for recipes which are obtained via achievements. --- Constants.lua | 15 ++++++++++----- Interface/FilterMenus.lua | 10 ++++++---- Interface/List.lua | 32 ++++++++++++++++++++++++++++++-- Locales/devel-enUS.lua | 1 + core.lua | 13 +++++++++++-- 5 files changed, 58 insertions(+), 13 deletions(-) diff --git a/Constants.lua b/Constants.lua index 7dc7d48..057929d 100644 --- a/Constants.lua +++ b/Constants.lua @@ -121,7 +121,7 @@ private.filter_flags = { ["ALLIANCE"] = 1, ["HORDE"] = 2, ["TRAINER"] = 3, ["VENDOR"] = 4, ["INSTANCE"] = 5, ["RAID"] = 6, ["SEASONAL"] = 7, ["QUEST"] = 8, ["PVP"] = 9, ["WORLD_DROP"] = 10, ["MOB_DROP"] = 11, ["DISC"] = 12, - ["RETIRED"] = 13, ["RESERVED_14"] = 14, ["RESERVED_15"] = 15, ["RESERVED_16"] = 16, + ["RETIRED"] = 13, ["ACHIEVEMENT"] = 14, ["RESERVED_15"] = 15, ["RESERVED_16"] = 16, ["RESERVED_17"] = 17, ["RESERVED_18"] = 18, ["RESERVED_19"] = 19, ["RESERVED_20"] = 20, ["DK"] = 21, ["DRUID"] = 22, ["HUNTER"] = 23, ["MAGE"] = 24, ["PALADIN"] = 25, ["PRIEST"] = 26, ["SHAMAN"] = 27, ["ROGUE"] = 28, @@ -158,7 +158,7 @@ private.filter_strings = { [1] = "ALLIANCE", [2] = "HORDE", [3] = "TRAINER", [4] = "VENDOR", [5] = "INSTANCE", [6] = "RAID", [7] = "SEASONAL", [8] = "QUEST", [9] = "PVP", [10] = "WORLD_DROP", [11] = "MOB_DROP", [12] = "DISC", - [13] = "RETIRED", [14] = "RESERVED_14", [15] = "RESERVED_15", [16] = "RESERVED_16", + [13] = "RETIRED", [14] = "ACHIEVEMENT", [15] = "RESERVED_15", [16] = "RESERVED_16", [17] = "RESERVED_17", [18] = "RESERVED_18", [19] = "RESERVED_19", [20] = "RESERVED_20", [21] = "DK", [22] = "DRUID", [23] = "HUNTER", [24] = "MAGE", [25] = "PALADIN", [26] = "PRIEST", [27] = "SHAMAN", [28] = "ROGUE", @@ -218,6 +218,7 @@ private.common_flags_word1 = { TANK = 0x00100000, -- 21 HEALER = 0x00200000, -- 22 CASTER = 0x00400000, -- 23 + ACHIEVEMENT = 0x00800000, -- 24 } ------------------------------------------------------------------------------- @@ -358,7 +359,8 @@ private.acquire_types = { ["SEASONAL"] = 5, ["REPUTATION"] = 6, ["WORLD_DROP"] = 7, - ["CUSTOM"] = 8, + ["ACHIEVEMENT"] = 8, + ["CUSTOM"] = 9, } private.acquire_strings = { @@ -369,7 +371,8 @@ private.acquire_strings = { [5] = "SEASONAL", [6] = "REPUTATION", [7] = "WORLD_DROP", - [8] = "CUSTOM", + [8] = "ACHIEVEMENT", + [9] = "CUSTOM", } private.acquire_names = { @@ -380,7 +383,8 @@ private.acquire_names = { [5] = _G.GetCategoryInfo(155), [6] = _G.REPUTATION, [7] = L["World Drop"], - [8] = _G.MISCELLANEOUS, + [8] = _G.ACHIEVEMENTS, + [9] = _G.MISCELLANEOUS, } ------------------------------------------------------------------------------- @@ -532,6 +536,7 @@ private.basic_colors = { -- Colors used in tooltips and the recipe list. private.category_colors = { -- Acquire type colors + ["achievement"] = "faeb98", ["custom"] = "73b7ff", ["mobdrop"] = "962626", ["quest"] = "dbdb2c", diff --git a/Interface/FilterMenus.lua b/Interface/FilterMenus.lua index 4718c20..749385e 100644 --- a/Interface/FilterMenus.lua +++ b/Interface/FilterMenus.lua @@ -444,10 +444,11 @@ function private.InitializeFilterPanel() ["discovery"] = { tt = L["DISCOVERY_DESC"], text = L["Discovery"], row = 4, col = 2 }, ["worlddrop"] = { tt = L["WORLD_DROP_DESC"], text = L["World Drop"], row = 5, col = 1 }, ["mobdrop"] = { tt = L["MOB_DROP_DESC"], text = L["Mob Drop"], row = 5, col = 2 }, - ["expansion0"] = { tt = L["ORIGINAL_WOW_DESC"], text = _G.EXPANSION_NAME0, row = 7, col = 1 }, - ["expansion1"] = { tt = L["BC_WOW_DESC"], text = _G.EXPANSION_NAME1, row = 8, col = 1 }, - ["expansion2"] = { tt = L["LK_WOW_DESC"], text = _G.EXPANSION_NAME2, row = 9, col = 1 }, - ["expansion3"] = { tt = L["CATA_WOW_DESC"], text = _G.EXPANSION_NAME3, row = 10, col = 1 }, + ["achievement"] = { tt = L["ACHIEVEMENT_DESC"], text = _G.ACHIEVEMENTS, row = 6, col = 1 }, + ["expansion0"] = { tt = L["ORIGINAL_WOW_DESC"], text = _G.EXPANSION_NAME0, row = 8, col = 1 }, + ["expansion1"] = { tt = L["BC_WOW_DESC"], text = _G.EXPANSION_NAME1, row = 9, col = 1 }, + ["expansion2"] = { tt = L["LK_WOW_DESC"], text = _G.EXPANSION_NAME2, row = 10, col = 1 }, + ["expansion3"] = { tt = L["CATA_WOW_DESC"], text = _G.EXPANSION_NAME3, row = 11, col = 1 }, } GenerateCheckBoxes(obtain_frame, obtain_buttons) obtain_buttons = nil @@ -1277,6 +1278,7 @@ function private.InitializeFilterPanel() ["discovery"] = { cb = FilterPanel.obtain.discovery, svroot = filterdb.obtain }, ["worlddrop"] = { cb = FilterPanel.obtain.worlddrop, svroot = filterdb.obtain }, ["mobdrop"] = { cb = FilterPanel.obtain.mobdrop, svroot = filterdb.obtain }, + ["achievement"] = { cb = FilterPanel.obtain.achievement, svroot = filterdb.obtain }, ["expansion0"] = { cb = FilterPanel.obtain.expansion0, svroot = filterdb.obtain }, ["expansion1"] = { cb = FilterPanel.obtain.expansion1, svroot = filterdb.obtain }, ["expansion2"] = { cb = FilterPanel.obtain.expansion2, svroot = filterdb.obtain }, diff --git a/Interface/List.lua b/Interface/List.lua index 413c345..09f0b4e 100644 --- a/Interface/List.lua +++ b/Interface/List.lua @@ -503,6 +503,7 @@ function private.InitializeListFrame() ["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 }, + ["achievement"] = { flag = COMMON1.ACHIEVEMENT, index = 1, sv_root = obtain_filters }, } local REP1 = private.rep_flags_word1 @@ -1263,6 +1264,18 @@ function private.InitializeListFrame() return ListFrame:InsertEntry(t, parent_entry, entry_index, entry_type, true) end + local function ExpandAchievementData(entry_index, entry_type, parent_entry, id_num, recipe_id, hide_location, hide_type) + local _, achievement_name = GetAchievementInfo(id_num) + local t = AcquireTable() + + t.text = string.format("%s%s %s", PADDING, + hide_type and "" or SetTextColor(CATEGORY_COLORS["achievement"], _G.ACHIEVEMENTS)..":", + SetTextColor(BASIC_COLORS["normal"], achievement_name)) + t.recipe_id = recipe_id + + return ListFrame:InsertEntry(t, parent_entry, entry_index, entry_type, true) + end + local function ExpandAcquireData(entry_index, entry_type, parent_entry, acquire_type, acquire_data, recipe_id, hide_location, hide_type) local obtain_filters = addon.db.profile.filters.obtain @@ -1295,6 +1308,8 @@ function private.InitializeListFrame() func = ExpandCustomData end --@alpha@ + elseif acquire_type == A.ACHIEVEMENT and obtain_filters.achievement then + func = ExpandAchievementData elseif acquire_type > A_MAX then local t = AcquireTable() @@ -1346,7 +1361,7 @@ function private.InitializeListFrame() local expand = false local type = "subheader" - if acquire_id == A.WORLD_DROP or acquire_id == A.CUSTOM then + if acquire_id == A.WORLD_DROP or acquire_id == A.CUSTOM or acquire_id == A.ACHIEVEMENT then expand = true type = "entry" end @@ -1736,6 +1751,17 @@ do end end + local function Tooltip_AddAchievement(recipe_id, id_num, addline_func) + local recipe = private.recipe_list[recipe_id] + local _, achievement_name, _, _, _, _, _, achievement_desc = GetAchievementInfo(id_num) + + -- The recipe is an actual reward from an achievement if flagged - else we're just using the text to describe how to get it. + if recipe:IsFlagged("common1", "ACHIEVEMENT") then + addline_func(0, -1, false, _G.ACHIEVEMENTS, CATEGORY_COLORS["achievement"], achievement_name, BASIC_COLORS["normal"]) + end + addline_func(0, -1, false, achievement_desc, CATEGORY_COLORS["custom"]) + end + ------------------------------------------------------------------------------- -- Public API function for displaying a recipe's acquire data. -- * The addline_func paramater must be a function which accepts the same @@ -1775,6 +1801,8 @@ do elseif acquire_type == A.CUSTOM then addline_func(0, -1, false, private.custom_list[id_num].name, CATEGORY_COLORS["custom"]) --@alpha@ + elseif acquire_type == A.ACHIEVEMENT then + Tooltip_AddAchievement(recipe_id, id_num, addline_func) elseif can_display then -- Unhandled addline_func(0, -1, 0, L["Unhandled Recipe"], BASIC_COLORS["normal"]) @@ -1923,7 +1951,7 @@ do ttAdd(0, -1, 0, L["CTRL_CLICK"], color_1) ttAdd(0, -1, 0, L["SHIFT_CLICK"], color_1) - if acquire_id ~= A.WORLD_DROP and acquire_id ~= A.CUSTOM and (_G.TomTom or _G.Cartographer_Waypoints) and (addon.db.profile.worldmap or addon.db.profile.minimap) then + if acquire_id ~= A.WORLD_DROP and acquire_id ~= A.CUSTOM and acquire_id ~= A.ACHIEVEMENT and (_G.TomTom or _G.Cartographer_Waypoints) and (addon.db.profile.worldmap or addon.db.profile.minimap) then ttAdd(0, -1, 0, L["CTRL_SHIFT_CLICK"], color_1) end end diff --git a/Locales/devel-enUS.lua b/Locales/devel-enUS.lua index aa48be1..8aad49c 100644 --- a/Locales/devel-enUS.lua +++ b/Locales/devel-enUS.lua @@ -269,6 +269,7 @@ L["World Drop"] = true L["WORLD_DROP_DESC"] = "Recipes that are World Drops should be included in the scan." L["Mob Drop"] = true L["MOB_DROP_DESC"] = "Recipes that are Mob Drops should be included in the scan." +L["ACHIEVEMENT_DESC"] = "Recipes obtained via Achievements should be included in the scan." ------------------------------------------------------------------------------- -- Binding Filter UI Elements and their associated descriptions diff --git a/core.lua b/core.lua index 96df8a6..92a4eb4 100644 --- a/core.lua +++ b/core.lua @@ -352,6 +352,7 @@ function addon:OnInitialize() discovery = true, worlddrop = true, mobdrop = true, + achievement = true, expansion0 = true, expansion1 = true, expansion2 = true, @@ -1285,12 +1286,16 @@ do addon:Debug("Spell ID %d: %s ID %d does not exist in the database.", spell_id, type_string, id_num) else if not unit_list then - location = type(id_num) == "string" and BZ[id_num] or nil + local id_type = type(id_num) + + location = id_type == "string" and BZ[id_num] or nil if location then affiliation = "world_drop" else - addon:Debug("WORLD_DROP with no location: %d %s", spell_id, private.recipe_list[spell_id].name) + if id_type == "string" then + addon:Debug("WORLD_DROP with no location: %d %s", spell_id, private.recipe_list[spell_id].name) + end end else local unit = unit_list[id_num] @@ -1342,6 +1347,10 @@ do GenericAddRecipeAcquire(spell_id, A.QUEST, "Quest", private.quest_list, ...) end + function addon:AddRecipeAchievement(spell_id, ...) + GenericAddRecipeAcquire(spell_id, A.ACHIEVEMENT, "Achievement", nil, ...) + end + -- This function can NOT use GenericAddRecipeAcquire() - reputation vendors are more complicated than the other acquire types. function addon:AddRecipeRepVendor(spell_id, faction_id, rep_level, ...) local num_vars = select('#', ...) -- 1.7.9.5