Quantcast

-Added new ability to filter out Quest Objective Tooltips. Sometimes you just want to see the quest objective information on the tooltip. Example: A quest mob.

Xruptor [07-29-13 - 15:48]
-Added new ability to filter out Quest Objective Tooltips.  Sometimes you just want to see the quest objective information on the tooltip.  Example:  A quest mob.
Filename
xanTooltipHoudini.lua
xanTooltipHoudini.toc
diff --git a/xanTooltipHoudini.lua b/xanTooltipHoudini.lua
index fd303e3..13d3ddf 100644
--- a/xanTooltipHoudini.lua
+++ b/xanTooltipHoudini.lua
@@ -1,7 +1,13 @@
+--trigger quest scans
+local triggers = {
+	["QUEST_COMPLETE"] = true,
+	["UNIT_QUEST_LOG_UPDATE"] = true,
+	["QUEST_WATCH_UPDATE"] = true,
+	["QUEST_FINISHED"] = true,
+	["QUEST_LOG_UPDATE"] = true,
+}

-local f = CreateFrame("frame","xanTooltipHoudini_frame",UIParent)
-f:SetScript("OnEvent", function(self, event, ...) if self[event] then return self[event](self, event, ...) end end)
-
+local playerQuests = {}
 local auraSwitch = false

 local ignoreFrames = {
@@ -9,11 +15,26 @@ local ignoreFrames = {
 	["QuestInfoRewardsFrame"] = true,
 	["MinimapCluster"] = true,
 }
+
+local f = CreateFrame("frame","xanTooltipHoudini_frame",UIParent)
+f:SetScript("OnEvent", function(self, event, ...)
+	if self[event] then
+		return self[event](self, event, ...)
+	elseif triggers[event] and self["doQuestTitleGrab"] then
+		return self["doQuestTitleGrab"]()
+	end
+end)
+
 --add the loot frames
 for i=1, NUM_GROUP_LOOT_FRAMES do
 	ignoreFrames["GroupLootFrame" .. i] = true
 end
-
+
+local debugf = tekDebug and tekDebug:GetFrame("xanTooltipHoudini")
+local function Debug(...)
+    if debugf then debugf:AddMessage(string.join(", ", tostringall(...))) end
+end
+
 ----------------------
 --      Enable      --
 ----------------------
@@ -22,11 +43,42 @@ local function processAuraTooltip(self, unitid, index, filter)
 	auraSwitch = true
 end

+local function checkPlayerQuest()
+	for i=1,GameTooltip:NumLines() do
+		local ttText = getglobal("GameTooltipTextLeft" .. i)
+		if ttText:GetText() and playerQuests[ttText:GetText()] ~= nil then
+			return true
+		end
+	end
+	return false
+end
+
+function f:doQuestTitleGrab()
+	--we have to expand and then collaspe headers because GetQuestLogTitle won't return anything if it's closed
+	local saved_position = GetQuestLogSelection()
+	for i=1,GetNumQuestLogEntries() do
+	   local _,_,_,_,_,isCollapsed,isComplete = GetQuestLogTitle(i)
+	   if isCollapsed then
+		  local count = GetNumQuestLogEntries()
+		  ExpandQuestHeader(i)
+		  count = GetNumQuestLogEntries() - count
+		  for j=i+1,i+count do
+			 local title,_,_,_,_,_,isComplete = GetQuestLogTitle(j)
+				--store the player quest
+				playerQuests[title] = title
+		  end
+		  CollapseQuestHeader(i)
+	   end
+	end
+	SelectQuestLogEntry(saved_position)
+end
+
 function f:PLAYER_LOGIN()

 	--do DB stuff
 	if not XTH_DB then XTH_DB = {} end
 	if XTH_DB.showAuras == nil then XTH_DB.showAuras = true end
+	if XTH_DB.showQuestObj == nil then XTH_DB.showQuestObj = true end

 	SLASH_XANTOOLTIPHOUDINI1 = "/xth"
 	SlashCmdList["XANTOOLTIPHOUDINI"] = function(msg)
@@ -43,54 +95,110 @@ function f:PLAYER_LOGIN()
 					DEFAULT_CHAT_FRAME:AddMessage("xanTooltipHoudini: Aura (Buff/Debuff) toolips are now [|cFF99CC33ON|r]")
 				end
 				return true
+			elseif c and c:lower() == "quest" then
+				if XTH_DB.showQuestObj then
+					XTH_DB.showQuestObj = false
+					DEFAULT_CHAT_FRAME:AddMessage("xanTooltipHoudini: Quest toolips are now [|cFF99CC33OFF|r]")
+				else
+					XTH_DB.showQuestObj = true
+					DEFAULT_CHAT_FRAME:AddMessage("xanTooltipHoudini: Quest toolips are now [|cFF99CC33ON|r]")
+				end
+				return true
 			end
 		end

 		DEFAULT_CHAT_FRAME:AddMessage("xanTooltipHoudini")
 		DEFAULT_CHAT_FRAME:AddMessage("/xth auras - toggles Aura (Buff/Debuff) tooltips (ON/OFF)")
+		DEFAULT_CHAT_FRAME:AddMessage("/xth quest - toggles Quest objective tooltips (ON/OFF)")
 	end
-
+
 	GameTooltip:HookScript("OnShow", function(self)
-		--only use this if showAuras is false
-		if XTH_DB and not XTH_DB.showAuras then
+		local canPass = false
+		if XTH_DB and not XTH_DB.showAuras then canPass = true end
+		if XTH_DB and XTH_DB.showQuestObj and checkPlayerQuest() then canPass = true end
+
+		if XTH_DB and canPass then
 			if InCombatLockdown() then
 				local owner = self:GetOwner()
-				if owner and owner:GetParent() and owner:GetParent():GetName() and ignoreFrames[owner:GetParent():GetName()] then
+				if not XTH_DB.showAuras and owner and owner:GetParent() and owner:GetParent():GetName() and ignoreFrames[owner:GetParent():GetName()] then
 					--do nothing
 					return
 				end
-				self:Hide()
+				if XTH_DB.showQuestObj and checkPlayerQuest() then
+					--do nothing
+					return
+				end
+				if not XTH_DB.showAuras or not XTH_DB.showQuestObj then
+					self:Hide()
+				end
 				return
 			end
 		end
 	end)

-	GameTooltip:HookScript("OnHide", function(self)
-		auraSwitch = false
-	end)
-
 	GameTooltip:HookScript("OnUpdate", function(self, elapsed)
-		--check if showauras is on
-		if XTH_DB and XTH_DB.showAuras and self:IsShown() then
-			--hide everything BUT auras, and temporary weapon enchants ;P
+		local canPass = false
+		if XTH_DB and XTH_DB.showAuras then canPass = true end
+		if XTH_DB and XTH_DB.showQuestObj and checkPlayerQuest() then canPass = true end
+
+		if XTH_DB and canPass and self:IsShown() then
 			local owner = self:GetOwner()
-			if InCombatLockdown() and not auraSwitch then
+			if InCombatLockdown() then
 				--check for temporary enchant frame
-				if owner and owner:GetParent() and owner:GetParent():GetName() and ignoreFrames[owner:GetParent():GetName()] then
+				if XTH_DB.showAuras and not auraSwitch and owner and owner:GetParent() and owner:GetParent():GetName() and ignoreFrames[owner:GetParent():GetName()] then
 					--do nothing
 					return
 				end
+				if XTH_DB.showQuestObj and checkPlayerQuest() then
+					--do nothing
+					return
+				end
 				--otherwise hide it
-				self:Hide()
+				if not auraSwitch or not XTH_DB.showQuestObj then
+					self:Hide()
+				end
 			end
 		end
 	end)

+	-- GameTooltip:SetScript("OnTooltipSetQuest", function(self, ...)
+		-- if XTH_DB.showQuestObj then
+			-- checkPlayerQuest()
+		-- end
+    -- end)
+
+	-- GameTooltip:SetScript("OnTooltipSetUnit", function(self, ...)
+		-- if XTH_DB.showQuestObj then
+			-- checkPlayerQuest()
+		-- end
+    -- end)
+
+	-- GameTooltip:SetScript("OnTooltipSetItem", function(self, ...)
+		-- if XTH_DB.showQuestObj then
+			-- checkPlayerQuest()
+		-- end
+    -- end)
+
+	GameTooltip:HookScript("OnHide", function(self)
+		auraSwitch = false
+	end)
+
+
 	--decide if we want to show aura tooltips while in battle
 	hooksecurefunc(GameTooltip, "SetUnitAura", processAuraTooltip)
 	hooksecurefunc(GameTooltip, "SetUnitBuff", processAuraTooltip)
 	hooksecurefunc(GameTooltip, "SetUnitDebuff", processAuraTooltip)

+	--activate triggers
+	self:RegisterEvent("QUEST_COMPLETE")
+	self:RegisterEvent("UNIT_QUEST_LOG_UPDATE")
+	self:RegisterEvent("QUEST_WATCH_UPDATE")
+	self:RegisterEvent("QUEST_FINISHED")
+	self:RegisterEvent("QUEST_LOG_UPDATE")
+
+	--call quest scan just in case
+	self:doQuestTitleGrab()
+
 	self:UnregisterEvent("PLAYER_LOGIN")
 	self.PLAYER_LOGIN = nil
 end
diff --git a/xanTooltipHoudini.toc b/xanTooltipHoudini.toc
index ba2e0cc..99c61a9 100644
--- a/xanTooltipHoudini.toc
+++ b/xanTooltipHoudini.toc
@@ -2,7 +2,8 @@
 ## Title: xanTooltipHoudini
 ## Notes: Hides the game tooltip while in combat.
 ## Author: Xruptor
-## Version: 1.8
+## Version: 2.0
+## OptionalDeps: tekDebug
 ## SavedVariables: XTH_DB

 xanTooltipHoudini.lua