Quantcast
local addon = select(2, ...)
local module = addon:CreateModule"UniqueCount"


function module:Enable()
	if IsAddOnLoaded"Blizzard_PetJournal" then
		self:Hook()
	else
		self:RegisterEvent"ADDON_LOADED"
	end
end

function module:Hook()
	local petcount = PetJournal.PetCount
	local label = petcount.Count

	petcount:SetWidth(petcount:GetWidth() + 25)

	hooksecurefunc("PetJournal_UpdatePetList", function()
		local count = addon:GetNumUniquePets()
		local text = label:GetText()

		label:SetText(text..(" (%d)"):format(count))
	end)

	PetJournal.listScroll.update = PetJournal_UpdatePetList
end

function module:ADDON_LOADED(name)
	if name == "Blizzard_PetJournal" then
		self:Hook()
		self:UnregisterEvent"ADDON_LOADED"
	end
end