From 24d47cc08f60e981c75e97c7733d2b74177900b5 Mon Sep 17 00:00:00 2001 From: "James D. Callahan III" Date: Fri, 2 Jul 2010 02:11:56 -0400 Subject: [PATCH] More fine-tuning for waypoints so clicking on specific vendors or trainers will yield expected results. --- Frame.lua | 16 +++++++++++++++- Waypoint.lua | 32 +++++++++++++++++--------------- 2 files changed, 32 insertions(+), 16 deletions(-) diff --git a/Frame.lua b/Frame.lua index e3e2911..8cad5e2 100644 --- a/Frame.lua +++ b/Frame.lua @@ -2247,7 +2247,7 @@ do -- First, check if this is a "modified" click, and react appropriately if clicked_line.recipe_id and _G.IsModifierKeyDown() then if _G.IsControlKeyDown() and _G.IsShiftKeyDown() then - addon:AddWaypoint(clicked_line.recipe_id, clicked_line.acquire_id, clicked_line.location_id) + addon:AddWaypoint(clicked_line.recipe_id, clicked_line.acquire_id, clicked_line.location_id, clicked_line.npc_id) elseif _G.IsShiftKeyDown() then local itemID = private.recipe_list[clicked_line.recipe_id].item_id @@ -2397,6 +2397,7 @@ do local recipe_id = parent_entry.recipe_id local acquire_id = parent_entry.acquire_id local location_id = parent_entry.location_id + local npc_id = parent_entry.npc_id if recipe_id then entry.recipe_id = recipe_id @@ -2409,6 +2410,10 @@ do if location_id then entry.location_id = location_id end + + if npc_id then + entry.npc_id = npc_id + end else addon:Debug("Attempting to parent an entry to itself.") end @@ -2730,6 +2735,7 @@ do t.text = string.format("%s%s %s", PADDING, hide_type and "" or SetTextColor(CATEGORY_COLORS["trainer"], L["Trainer"])..":", name) t.recipe_id = recipe_id + t.npc_id = id_num entry_index = ListFrame:InsertEntry(t, parent_entry, entry_index, entry_type, true) @@ -2739,6 +2745,7 @@ do t = AcquireTable() t.text = string.format("%s%s%s %s", PADDING, PADDING, hide_location and "" or SetTextColor(CATEGORY_COLORS["location"], trainer.location), coord_text) t.recipe_id = recipe_id + t.npc_id = id_num return ListFrame:InsertEntry(t, parent_entry, entry_index, entry_type, true) end @@ -2766,6 +2773,7 @@ do hide_type and "" or SetTextColor(CATEGORY_COLORS["vendor"], L["Vendor"])..":", name, type(quantity) == "number" and SetTextColor(BASIC_COLORS["white"], string.format(" (%d)", quantity)) or "") t.recipe_id = recipe_id + t.npc_id = id_num entry_index = ListFrame:InsertEntry(t, parent_entry, entry_index, entry_type, true) @@ -2775,6 +2783,7 @@ do t = AcquireTable() t.text = string.format("%s%s%s %s", PADDING, PADDING, hide_location and "" or SetTextColor(CATEGORY_COLORS["location"], vendor.location), coord_text) t.recipe_id = recipe_id + t.npc_id = id_num return ListFrame:InsertEntry(t, parent_entry, entry_index, entry_type, true) end @@ -2791,6 +2800,7 @@ do t.text = string.format("%s%s %s", PADDING, hide_type and "" or SetTextColor(CATEGORY_COLORS["mobdrop"], L["Mob Drop"])..":", SetTextColor(private.reputation_colors["hostile"], mob.name)) t.recipe_id = recipe_id + t.npc_id = id_num entry_index = ListFrame:InsertEntry(t, parent_entry, entry_index, entry_type, true) @@ -2800,6 +2810,7 @@ do t = AcquireTable() t.text = string.format("%s%s%s %s", PADDING, PADDING, hide_location and "" or SetTextColor(CATEGORY_COLORS["location"], mob.location), coord_text) t.recipe_id = recipe_id + t.npc_id = id_num return ListFrame:InsertEntry(t, parent_entry, entry_index, entry_type, true) end @@ -2869,12 +2880,14 @@ do t.text = string.format("%s%s %s", PADDING, hide_type and "" or SetTextColor(CATEGORY_COLORS["reputation"], _G.REPUTATION)..":", SetTextColor(CATEGORY_COLORS["repname"], private.reputation_list[rep_id].name)) t.recipe_id = recipe_id + t.npc_id = vendor_id entry_index = ListFrame:InsertEntry(t, parent_entry, entry_index, entry_type, true) t = AcquireTable() t.text = PADDING .. PADDING .. faction_strings[rep_level] .. name t.recipe_id = recipe_id + t.npc_id = vendor_id entry_index = ListFrame:InsertEntry(t, parent_entry, entry_index, entry_type, true) @@ -2890,6 +2903,7 @@ do t = AcquireTable() t.text = string.format("%s%s%s%s %s", PADDING, PADDING, PADDING, hide_location and "" or SetTextColor(CATEGORY_COLORS["location"], rep_vendor.location), coord_text) t.recipe_id = recipe_id + t.npc_id = vendor_id return ListFrame:InsertEntry(t, parent_entry, entry_index, entry_type, true) end diff --git a/Waypoint.lua b/Waypoint.lua index f378e7e..b5ca25e 100644 --- a/Waypoint.lua +++ b/Waypoint.lua @@ -380,7 +380,7 @@ local maplist = {} -- Expected result: Icons are added to the world map and mini-map. -- Input: An optional recipe ID, acquire ID, and location ID. -- Output: Points are added to the maps -function addon:AddWaypoint(recipe_id, acquire_id, location_id) +function addon:AddWaypoint(recipe_id, acquire_id, location_id, npc_id) if not _G.TomTom and not _G.Cartographer_Waypoints then return end @@ -408,23 +408,25 @@ function addon:AddWaypoint(recipe_id, acquire_id, location_id) local recipe = recipe_list[recipe_id] for acquire_type, acquire_info in pairs(recipe.acquire_data) do - for id_num, id_info in pairs(acquire_info) do - if not acquire_id or acquire_type == acquire_id then - if acquire_type == A.REPUTATION then - for rep_level, level_info in pairs(id_info) do - for vendor_id in pairs(level_info) do - local waypoint = GetWaypoint(acquire_type, vendor_id, recipe) - - if waypoint and (not location_id or waypoint.location == location_id) then - maplist[waypoint] = recipe_id + if not acquire_id or acquire_type == acquire_id then + for id_num, id_info in pairs(acquire_info) do + if not npc_id or id_num == npc_id then + if acquire_type == A.REPUTATION then + for rep_level, level_info in pairs(id_info) do + for vendor_id in pairs(level_info) do + local waypoint = GetWaypoint(acquire_type, vendor_id, recipe) + + if waypoint and (not location_id or waypoint.location == location_id) then + maplist[waypoint] = recipe_id + end end end - end - else - local waypoint = GetWaypoint(acquire_type, id_num, recipe) + else + local waypoint = GetWaypoint(acquire_type, id_num, recipe) - if waypoint and (not location_id or waypoint.location == location_id) then - maplist[waypoint] = recipe_id + if waypoint and (not location_id or waypoint.location == location_id) then + maplist[waypoint] = recipe_id + end end end end -- 1.7.9.5