Thread Tools Display Modes
04-23-10, 06:06 PM   #1
lilgulps
A Theradrim Guardian
 
lilgulps's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 62
Repeating Target Line Error, Please Help Me Figure Out Why (Tooltip Mod)

Disclaimer
Let me first start by saying this is not my code, but the author of Ranttooltip

Why am I seeking help? Cause I am using an older version of the addon before he switched to his new layout system. The bug I am trying to fix has been around for quite a long time and it has become something of a challenge for me to try and just figure out what it was that caused it.

Needless to say... I haven't figured it out yet.

EDIT, I UPLOADED THE ADDON FILES IF ANYONE IS WILLING TO TAKE A LOOK

The Problem

Target line bug, causes the target line to continuously generate until the entire screen is filled up. Only exists if target changes targets while you are mousing over it. In other words, i mouse over subject a, subject a targets subject b, tooltip updates showing this. I am still moused over target a but target a now targets target c, tooltip goes berserk.

Examples
This is normal when you first mouse over a target, no target line created yet just the unit frame.
Screen 1:

Now I press f1 to select a unit, target line is created, still looking good!
Screen 1:

Now I press escape so that i am no longer targetting anything, tooltip updates but now the mana bar and health bars are skewed?
Screen 1:

I now retarget myself and the bug occurs at full force until i un mousover
Screen 1:

I don't exactly want to post a wall of text so i'll only post a small portion of the code here, if you would like the rest of the files emailed to you, to take a look, ask me and I will glady send the rest of the code over. Thank you



Code

Code:
GameTooltip["DeleteLine"] = function(self, line, exact)
	if not line then return end
	local numLines = self:NumLines()
	if type(line) == "number" then
		line = _G["GameTooltipTextLeft"..line]
	elseif type(line) == "string" then
		line = self:FindLine(line, exact)
	end
	local originalNum = self:GetLine(line)
	if line then
		if line ~= _G["GameTooltipTextLeft"..numLines] then
			local number = self:GetLine(line)
			local tbl = {}
			for i = number+1, numLines do
				tbl[i-1] = _G["GameTooltipTextLeft"..i]
			end
			for k, v in pairs(tbl) do
				local newLine = _G["GameTooltipTextLeft"..k]
				newLine.deleted = v.deleted
				local strHeight, strSize = v:GetStringHeight(), select(2,v:GetFont())
				if strHeight > strSize then
					local numberLines = math.round(strHeight / strSize)
					local totalLines, lastEnd, lettersPerLine = "", 0
					lettersPerLine = math.round(v:GetStringWidth() / (strSize+2))
					for i = 1, numberLines do
						local str = string.sub(v:GetText(), lastEnd+1, i*lettersPerLine)
						lastEnd = i*lettersPerLine
						str = string.trim(str)
						if i ~= numberLines then
							str = str.."\n"
						end
						totalLines = totalLines..str
					end
					newLine:SetText(totalLines)
				else
					newLine:SetText(v:GetText())
				end
				newLine:SetTextColor(v:GetTextColor())
			end
			line = _G["GameTooltipTextLeft"..numLines]
			if not line then return end
		end
		line.deleted = true
		line:SetText("")
		line:Hide()
		if GameTooltip.AdjustStatusBars then
			local _, barNum = GameTooltip:FindLine(" ", true)
			if barNum and originalNum <= barNum then
				GameTooltip:AdjustStatusBars(-1)
			end
		end
		self:Show()
	end
end
Code:
RantTooltip["UpdateTooltip"] = function(self)
	local unit = GameTooltip.unit
	if not UnitExists(unit) then 
		return 
	end
	if options.layout.showTalents then
		if UnitIsPlayer(unit) and not UnitCanAttack("player", unit) then
			if treeTotal == 0 then
				local specTab, tree
				if CheckInteractDistance(unit, 1) and (not UnitIsUnit("player", unit)) and ((not InspectFrame) or (InspectFrame and (not InspectFrame:IsVisible()))) then
					NotifyInspect(unit)
					talentSpec = ""
					tree = { select(3, GetTalentTabInfo(1, true)), select(3, GetTalentTabInfo(2, true)), select(3, GetTalentTabInfo(3, true)) }
					treeTotal = tree[1] + tree[2] + tree[3]
					for i = 1, #tree do
						if tree[i] >= tree[1] and tree[i] >= tree[2] and tree[i] >= tree[3] then
							specTab = i
							break
						end
					end
					if options.layout.showTrees then
						talentSpec = "["..tree[1].."/"..tree[2].."/"..tree[3].."] " 
					end
					if options.layout.showSpecTab then
						talentSpec = talentSpec.."("..GetTalentTabInfo(specTab, true)..")"
					end
				end
			else
				local line = GameTooltip:FindLine(TALENTS)
				if line then
					line:SetText(TALENTS..talentSpec, 1, 1, 1)
					GameTooltip:Show()
				end
			end
		end
	end
	if UnitAffectingCombat(unit) and options.layout.showCombat and (not self.icons.combat:IsVisible()) then
		self.icons.combat:Show()
	elseif (not UnitAffectingCombat(unit)) and self.icons.combat:IsVisible() then
		self.icons.combat:Hide()
	end
	if options.layout.showTarget then
		local tar = unit.."target"
		local line = GameTooltip:FindLine(TARGET)
		local _, sbarLine = GameTooltip:FindLine(" ", true)
		if UnitExists(tar) then
			local name = UnitIsUnit(tar, "player") and "|cffffffff[YOU]|r"
			if not name then
				name = GameTooltip_UnitColor(tar, true)..UnitName(tar).."|r"
			end
			if line then
				if line:GetText() ~= TARGET..name then
					line:SetText(TARGET..name)
					GameTooltip:Show()
				end
			else
				if sbarLine then
					GameTooltip:InsertLine(sbarLine, TARGET..name)
				else
					GameTooltip:AddLine(TARGET..name)
				end
				GameTooltip:Show()
			end
		else
			if line then
				GameTooltip:DeleteLine(line)
			end
		end
	end
end
Attached Files
File Type: lua RantTooltip.lua (28.7 KB, 602 views)
File Type: txt API.txt (1.9 KB, 612 views)
File Type: lua RantCore.lua (10.4 KB, 601 views)
File Type: lua RantTooltipAPI.lua (5.6 KB, 598 views)
File Type: lua RantFrames.lua (4.0 KB, 594 views)

Last edited by lilgulps : 04-23-10 at 06:27 PM. Reason: Added file from addon as attachments
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Please Help Me Figure out what is wrong with this code? (Tooltip Mod)


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off