--------------------------------------------------------------------------
-- BetterItemCount.lua 
--------------------------------------------------------------------------
--[[
Better Item Count 

author: AnduinLothar    <karlkfi@cosmosui.org>

Replaces some old Cosmos FrameXML Hacks.
-Better Item Count displays #.#k instead of * for counts > 999

]]--

function BetterItemCount_SetItemButtonCount(button, count)
	-- orig by Miyke
	if ( not button ) then return end
	if ( not count ) then
		count = 0
	end

	button.count = count
	local countText = getglobal(button:GetName().."Count")
	if count > 1 or (button.isBag and count > 0) then
		if count > 999 then 
			local fixedCount = count+50
			count = floor((fixedCount)/1000).."."..floor(((mod(fixedCount, 1000))/100)).."k"
		end 
		countText:SetText(count)
		countText:Show()
	else
		countText:Hide()
	end
end

hooksecurefunc("SetItemButtonCount", BetterItemCount_SetItemButtonCount)
