Thread Tools Display Modes
09-12-08, 12:39 AM   #1
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Hrmm... Getting a line added to tooltip twice

I've been through my code over and over, and I can't seem to find what is causing this. With my tooltip mod, TipTop, I add a line for Target and I am currently working on a line for Talents. But, since adding in the code for talents, I have been getting the target line (and sometimes the talents, too) added twice. The second target line appears when the tooltip updates with the talent info (from the talent ready event). The target line worked perfectly until adding the talent stuff.

Here's the kicker - my code is set up to only add the target line if it is not present already (and if a target exists, of course).


Here's my code: http://wowuidev.pastey.net/95882 The new talent stuff I've added is towards the bottom, highlighted. It seems that only registering for INSPECT_TALENT_READY when sending a query and then unregistering it after adding info to the tooltip remedied multiple talent lines (unless I'm just getting lucky). But I'm still seeing this:

Unit Name
level
etc.
Target: blah
Talents: blah
Target: blah
I haven't tried adding the talents line from the get-go and then parsing the tooltip to update it yet - was hoping there was something I was overlooking before I resorted to that. Though that would get rid of the tooltip resize when receiving the talent build... Anyway, just hoping someone smarter than me could give it a look over.

Thanks!
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
09-12-08, 02:43 AM   #2
Ravendwyr
A Flamescale Wyrmkin
 
Ravendwyr's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2005
Posts: 139
Are you testing this on beta? Because that could be the problem.

The globals "event", "arg1", "arg2" etc no longer exist in 3.0.

Try changing line 270 to
Code:
tt:SetScript("OnEvent", function(self, event)
and see if that helps

It could be because "event" no longer exists, local function TargetTextUpdate() could be firing twice as a result (as you have two events registered).

I can't go on beta anymore due to lack of hard-drive space, so I can't test this myself


If you're not testing this on beta, then I can't say what else it could be.
__________________
Twitter | GitHub
  Reply With Quote
09-12-08, 06:39 AM   #3
xConStruct
A Chromatic Dragonspawn
 
xConStruct's Avatar
AddOn Author - Click to view addons
Join Date: May 2008
Posts: 199
Your function TargetTextUpdate() goes on every update through all of the lines and checks for "Target:" to update the values - and after that, it checks whether the last leftText has "Target:" (which is of course the last line after going through all of them).
So, as soon as the talent info line is added as the last line, the function can't find "Target:" in the last line and adds another target-line to it.

A variable which stores whether a previous target-text has been found should solve this problem:

Code:
local function TargetTextUpdate()
    local hasTargetLine
    target = UnitName("mouseovertarget")  
    _,tclass = UnitClass("mouseovertarget")  
    if target and target ~= "Unknown" then  
        for i=1, GameTooltip:NumLines() do  
            left = getglobal(GameTooltip:GetName().."TextLeft"..i)  
            leftText = left:GetText()  
            right = getglobal(GameTooltip:GetName().."TextRight"..i)  
            rightText= right:GetText()  
            if leftText == "Target:" then
                hasTargetLine = true 
                if target == player then  
                    right:SetText("<<YOU>>")  
                    right:SetTextColor(.9, 0, .1)  
                else  
                    right:SetText(target)  
                    right:SetTextColor(color[tclass].r,color[tclass].g,color[tclass].b)
                end  
                MinWidth()  
            end  
        end  
        if not hasTargetLine then  
            TargetTextLine()  
        end  
    end  
end
I hope, this was your problem
__________________
« Website | GitHub »

Oh hai!
  Reply With Quote
09-12-08, 10:06 AM   #4
Tristanian
Andúril
Premium Member
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 279
Originally Posted by Ethan Centaurai View Post
Are you testing this on beta? Because that could be the problem.

The globals "event", "arg1", "arg2" etc no longer exist in 3.0.

Try changing line 270 to
Code:
tt:SetScript("OnEvent", function(self, event)
and see if that helps

It could be because "event" no longer exists, local function TargetTextUpdate() could be firing twice as a result (as you have two events registered).

I can't go on beta anymore due to lack of hard-drive space, so I can't test this myself


If you're not testing this on beta, then I can't say what else it could be.
Can people stop spreading this kind of misinformation already ? The globals work fine in the current beta build, yes Blizzard has stated that they are removing them, they have removed them from their own modules (default UI) at around 98% but there are still in the client. Whether they are being completely removed in a future build remains to be seen.

As far as your problem goes Seerah, I concur with Cargor's assessment. You need to store if the "Target:" string has been located and possibly add an additional check not to do anything if you have already "taken action".
  Reply With Quote
09-12-08, 11:31 AM   #5
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Oh, you're right, Cargor - I am doing that leftText check outside of the tooltip scanning block. /facepalm I put it there because I didn't want it adding it for each line that didn't start with Target, but wasn't thinking clearly enough, I guess about what it was looking for outside of the loop. Shame on me for coding so often after my bedtime.

Thank you, and I'll change that.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Hrmm... Getting a line added to tooltip twice


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