Quantcast

tracked quests level in watch frame fixed

Alex Shubert [10-16-14 - 21:23]
tracked quests level in watch frame  fixed
Filename
AutoTurnIn.lua
QuestLevel.lua
ui/main_options.lua
diff --git a/AutoTurnIn.lua b/AutoTurnIn.lua
index b90e3b5..7a9d17a 100644
--- a/AutoTurnIn.lua
+++ b/AutoTurnIn.lua
@@ -96,8 +96,8 @@ function AutoTurnIn:OnEnable()
 	if self.TOC < 60000 then
 		hooksecurefunc("QuestLog_Update", AutoTurnIn.ShowQuestLevelInLog)
 		hooksecurefunc(QuestLogScrollFrame, "update", AutoTurnIn.ShowQuestLevelInLog)
-		hooksecurefunc("WatchFrame_Update", AutoTurnIn.ShowQuestLevelInWatchFrame)
 	end
+	hooksecurefunc("ObjectiveTracker_Update", AutoTurnIn.ShowQuestLevelInWatchFrame)
 end

 function AutoTurnIn:OnDisable()
diff --git a/QuestLevel.lua b/QuestLevel.lua
index 2ee4653..d7e7eb7 100644
--- a/QuestLevel.lua
+++ b/QuestLevel.lua
@@ -44,24 +44,24 @@ function AutoTurnIn:ShowQuestLevelInWatchFrame()
 	if not AutoTurnInCharacterDB.watchlevel then
 		return
 	end
-
-	for i = 1, #WATCHFRAME_LINKBUTTONS do
-		local button = WATCHFRAME_LINKBUTTONS[i]

-		if( button.type == "QUEST" ) then
-			local questIndex = GetQuestIndexForWatch(button.index)
-			if questIndex then
-				local textLine = button.lines[button.startLine]
-				if textLine.text:GetText() and (not string.find("", "^%[.*%].*")) then
-					local title, level, _, _, _, _, _, isDaily = GetQuestLogTitle(questIndex)
-					local questTypeIndex = GetQuestLogQuestType(questIndex)
-					local tagString = AutoTurnIn.QuestTypesIndex[questTypeIndex]
-					if (not tagString) then
-						--AutoTurnIn:Print("Please, inform addon author unknown QT for: " ..title)
-						tagString = ""
-					end
-					textLine.text:SetText(AutoTurnIn.WatchFrameLevelFormat:format(level, tagString, isDaily and "\*" or "", title))
-				end
+	local tracker = ObjectiveTrackerFrame
+	if ( not tracker.initialized )then
+		return
+	end
+
+	for i = 1, #tracker.MODULES do
+		for id,block in pairs( tracker.MODULES[i].Header.module.usedBlocks) do
+			local text = block.HeaderText:GetText()
+			if text and (not string.find(text, "^%[.*%].*")) then
+				local title, level, suggestedGroup, isHeader, isCollapsed, isComplete, frequency, questID,
+					  startEvent, displayQuestID, isOnMap, hasLocalPOI, isTask, isStory = GetQuestLogTitle(block.questLogIndex)
+
+				local questTypeIndex = GetQuestLogQuestType(block.questLogIndex)
+				local tagString = AutoTurnIn.QuestTypesIndex[questTypeIndex] or ""
+				local dailyMod = (frequency == LE_QUEST_FREQUENCY_DAILY or frequency == LE_QUEST_FREQUENCY_WEEKLY) and "\*" or ""
+
+				block.HeaderText:SetText(AutoTurnIn.WatchFrameLevelFormat:format(level, tagString, dailyMod, title))
 			end
 		end
 	end
diff --git a/ui/main_options.lua b/ui/main_options.lua
index f09f03b..862999c 100644
--- a/ui/main_options.lua
+++ b/ui/main_options.lua
@@ -155,9 +155,10 @@ end
 OptionsPanel.okay = function()
 	AutoTurnInCharacterDB = CopyTable(ptable.TempConfig)
 	AutoTurnIn:SetEnabled(AutoTurnInCharacterDB.enabled)
+
+	ObjectiveTracker_Update(OBJECTIVE_TRACKER_UPDATE_ALL)
 	if AutoTurnIn.TOC < 60000 then
 		QuestLog_Update()
-		WatchFrame_Update(WatchFrame)
 	end
 end