Jaliborc / PetTracker

Tracks pets, alerts for upgrades and helps you in pet battles.
47 stars 25 forks source link

Fix issue with overlapping tooltip text #309

Closed GurliGebis closed 1 year ago

GurliGebis commented 1 year ago

This fixes the tooltip issue where text is overlapping when hovering over a pet or when using the auction house.

Based on code by plusmouse.

This fixes #197

Jaliborc commented 1 year ago

This is throwing a lot of functionality away

GurliGebis commented 1 year ago

@Jaliborc it might, but it solves the problem. Can you please take a look at it, and see if it can be solved? (Right now the tooltip in the auction house is useless)

eTzmNcbkrng commented 1 year ago

I've been working on this problem but been unable to solve it, mostly because my Lua is completely rubbish. The approach I was attempting was to see how many lines of text were returned in tip.source and then for each line longer than 240 pixels, increase the tip.Source:GetHeight() by an additional line height.

So something like:

local lineHeight = tip.Source:GetLineHeight()
local extraTipHeight = 0
for line = 1,tip.source:GetNumLines() do
    if string.len(line) > tip.Source:GetWidth() then -- tip.Source:GetWidth() returns 240 for me and this appearts to be the maximum number of pixels displayed before wrapping
        extraTipHeight = extraTipHeight + lineHeight
    end
end
...

tip:SetHeight(tip:GetHeight() + tip.Source:GetHeight() + extraTipHeight)

Where I'm getting hung up is that tip.Source:GetText() returns a multi line string (not a table) and I have no clue how to iterate over each line (even though tip.Source:GetNumLines() does correctly return the number of lines in the formatted text)

Hopefully someone who's better at string manipulation can see if my logic makes sense and help towards fixing this nuisance bug.