Pokemon Trainer NG: The Pet Battle Mod

Pokemon Trainer NG: The Pet Battle Mod

33.4k Downloads

Tooltip doubles information and stays on screen

Painstormx opened this issue ยท 6 comments

commented

When I hover over a battle pet in the wild, I get a tootip showing abilities for my 3 current battle pets.
When i then move the mouse, the information is doubled and it stays on the screen (see screenshot)

Image

commented

Go to your Interface\AddOns\PokemonTrainer\Modules\WildPetTooltip.lua. Edit function module:ProcessTooltip():

function module:ProcessTooltip()
	local name, unit = _G.GameTooltip:GetUnit();
	
	local func = self.db.profile.onlywildpets and _G.UnitIsWildBattlePet or _G.UnitIsBattlePet;
	if( not unit or not func(unit) ) then
		return;
	end
        -- Remain unchaged above --

	-- Add following codes to fix duplicated tooltip--
	_G.GameTooltip:ClearLines();
	_G.GameTooltip:SetUnit(unit);
	
        -- Remain unchanged below --
	local enemyType, enemyLevel = _G.UnitBattlePetType(unit), _G.UnitBattlePetLevel(unit)

It just clears the tooltip before adding new content to avoid duplicated contents.

commented

@JireRen Thanks for the fix, it did remove the double tooltip :)
Any idea how to fix the tooltip not fading after 1-2 second, like a normal mouseover tooltip?
The battle pet tooltip just stays up permanently until you mouse over something else.

PS! For anyone trying this fix, the code is not in the TooltipCombatDisplay.lua, it's in the WildPetTooltip.lua file.

commented

Yeah I'm also annoyed the tooltip is not fading as the default ones. Try the following fix (this is what Claude told me ;p), it checks whether the tooltip has been modified or not by the addon. There are other more robust fix but guess we'll leave it to the author to decide.

function module:ProcessTooltip()
	local name, unit = _G.GameTooltip:GetUnit();
	
	local func = self.db.profile.onlywildpets and _G.UnitIsWildBattlePet or _G.UnitIsBattlePet;
	if( not unit or not func(unit) ) then
		return;
	end
        -- Remain unchanged above --

        -- Add following codes to fix duplicated tooltip --
        -- Checks if tooltip has already been modified by this addon -- 
	local numLines = _G.GameTooltip:NumLines();
	local battleLevelText = L["Battle Level"];
	
	for i = 1, numLines do
		local line = _G["GameTooltipTextLeft" .. i];
		if line and line:GetText() and line:GetText():find(battleLevelText) then
			-- Already processed, don't add again
			return;
		end
	end
	
        -- Remain unchanged below --
	local enemyType, enemyLevel = _G.UnitBattlePetType(unit), _G.UnitBattlePetLevel(unit)
commented

Great thanks, that new code both solves both problems :)

commented

Thank you - I'll see if I can get time to release an updated version with this fix soon ๐Ÿ˜Š

commented

I have pushed 11.1.7-20250714-1 with the changes provided above.
Thank you for fixing the issue - the new version should be available within a few hours.