Quantcast
local addon = select(2, ...)
local module = addon:CreateModule"Tooltip"
local tt = GameTooltip
local UNIT_CAPTURABLE_COLLECTED = UNIT_CAPTURABLE.." (collected)"

function module:Enable()
	self:RegisterEvent"UPDATE_MOUSEOVER_UNIT"
end

function module:UPDATE_MOUSEOVER_UNIT()
	if not UnitIsWildBattlePet"mouseover" then return end

	local guid = UnitGUID"mouseover"
	local species = select(2, addon:GetPetInfoByGUID(guid))

	if not species then return end

	local collected = addon:IsPetSpeciesOwned(species)

	if not collected then return end

	for i=1, tt:NumLines() do
		local line = _G["GameTooltipTextLeft"..i]
		local text = line:GetText()

		if text:find(UNIT_CAPTURABLE) then
			line:SetText(text:gsub(UNIT_CAPTURABLE, UNIT_CAPTURABLE_COLLECTED))
			tt:SetWidth(tt:GetWidth() + 25)
		end
	end
end