Quantcast
local IsCataclysmWorld = select("#", GetMapContinents()) > 4

local MAX_COMPANIONS = {
	CRITTER = IsCataclysmWorld and 190 or 160,
	MOUNT = IsCataclysmWorld and 290 or 263
}

do
	local progress = CreateFrame("StatusBar", "CompanionCountProgress", SpellBookCompanionsFrame, "ProfessionStatusBarTemplate")
	progress:SetPoint("CENTER", 0, -220)

	hooksecurefunc("SpellBookFrame_UpdatePages", function()
		local mode = SpellBookCompanionsFrame.mode

		if mode then
			local cur, max = GetNumCompanions(mode), MAX_COMPANIONS[mode]
			progress:SetMinMaxValues(1, max)
			progress:SetValue(cur)
			progress.rankText:SetFormattedText("%d/%d", cur, max)
		end
	end)
end