From aa8393968b6bd6b76b43344a6a108a0ab8b9f449 Mon Sep 17 00:00:00 2001 From: James Whitehead II Date: Wed, 1 Dec 2010 18:25:21 +0000 Subject: [PATCH] Much safer method of determining quest coords Now the map does not need to be opened at all, and things seem to function properly. The arrow also is capable of updating when the closest quest POI changes. --- TomTomLite.lua | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/TomTomLite.lua b/TomTomLite.lua index 52f2edf..580d179 100644 --- a/TomTomLite.lua +++ b/TomTomLite.lua @@ -19,6 +19,9 @@ function addon:Initialize() self:RegisterEvent("QUEST_POI_UPDATE", "ObjectivesChanged") self:RegisterEvent("QUEST_LOG_UPDATE", "ObjectivesChanged") self:RegisterMessage("TOMTOMLITE_WAYPOINT_ADDED") + hooksecurefunc("WatchFrame_Update", function() + addon:ObjectivesChanged() + end) end function addon:CreateCrazyArrow(name, parent) @@ -88,6 +91,11 @@ function addon:CreateCrazyArrow(name, parent) end function addon:AddWaypoint(map, floor, x, y, opt) + assert(type(map) == "number") + assert(type(floor) == "number") + assert(type(x) == "number") + assert(type(y) == "number") + local waypoint = {map, floor, x, y} if type(opt) == "table" then for k, v in pairs(opt) do @@ -104,7 +112,7 @@ end function addon:TOMTOMLITE_WAYPOINT_ADDED(msg, waypoint, ...) local zone, floor, x, y = unpack(waypoint) local lzone = self.mapdata:MapLocalize(zone) - self:Printf("Added a waypoint at (%.2f, %.2f) in %s", x * 100, y * 100, lzone) + --self:Printf("Added a waypoint at (%.2f, %.2f) in %s", x * 100, y * 100, lzone) self.arrow.waypoint = waypoint self.arrow.title:SetText(waypoint.title or L["Unknown waypoint"]) @@ -154,14 +162,18 @@ function addon:Scan() end local title = GetQuestLogTitle(questIndex) - - ShowUIPanel(WorldMapFrame) - HideUIPanel(WorldMapFrame) + local qid = select(9, GetQuestLogTitle(questIndex)) + + QuestPOIUpdateIcons() + local completed, x, y, objective = QuestPOIGetIconInfo(qid) + local map, floor = GetCurrentMapAreaID() - local frame = findQuestFrameFromQuestIndex(questIndex) - if frame then - local map, floor, x, y = POIAnchorToCoord(frame.poiIcon) + if not floor then floor = 0 end + if completed then + title = "Turn in: " .. title + end + + if x and y and map and floor then self:AddWaypoint(map, floor, x, y, {title = title}) end end - -- 1.7.9.5