local f = InfoPanel_AddPlugin();

--------------------------------------------------------------------------------------------------------
--                                             Functions                                              --
--------------------------------------------------------------------------------------------------------

-- OnEnter
local function OnEnter(self)
	InfoPanel_MakeTip(f,"Honor Details");

	-- Today's values
	local kills, points = GetPVPSessionStats();
	GameTooltip:AddDoubleLine("Today's Kills",kills,nil,nil,nil,1,1,1);
	GameTooltip:AddDoubleLine("Today's Points",points,nil,nil,nil,1,1,1);
	GameTooltip:AddLine(" ");
	-- Yesterday's values
	kills, points = GetPVPYesterdayStats();
	GameTooltip:AddDoubleLine("Yesterday's Kills",kills,nil,nil,nil,1,1,1);
	GameTooltip:AddDoubleLine("Yesterday's Points",points,nil,nil,nil,1,1,1);
	GameTooltip:AddLine(" ");
	-- Lifetime stats
	local highestRank;
	kills, highestRank = GetPVPLifetimeStats();
	GameTooltip:AddDoubleLine("Lifetime Kills",kills,nil,nil,nil,1,1,1);
	GameTooltip:AddDoubleLine("Highest Rank",highestRank,nil,nil,nil,1,1,1);
	GameTooltip:AddLine(" ");
	-- Rank
	local rankName, rankNumber = GetPVPRankInfo(highestRank);
	if ( not rankName ) then
		rankName = NONE;
	end
	GameTooltip:AddDoubleLine("Rank Name",rankName,nil,nil,nil,1,1,1);
	GameTooltip:AddDoubleLine("Rank Number",rankNumber,nil,nil,nil,1,1,1);
	GameTooltip:AddLine(" ");
	-- Points
	GameTooltip:AddDoubleLine("Honor Points",GetHonorCurrency(),nil,nil,nil,1,1,1);
	GameTooltip:AddDoubleLine("Arena Points",GetArenaCurrency(),nil,nil,nil,1,1,1);

	GameTooltip:Show();
end

-- OnEvent
local function OnEvent(self,event,...)
	InfoPanel_SetText(f,select(2,GetPVPSessionStats()));
end

--------------------------------------------------------------------------------------------------------
--                                              Finalize                                              --
--------------------------------------------------------------------------------------------------------

f.icon:SetTexture("Interface\\TargetingFrame\\UI-PVP-"..UnitFactionGroup("player"));
f.icon:SetTexCoord(0,0.55,0,0.55);
f:SetScript("OnEnter",OnEnter);
f:SetScript("OnEvent",OnEvent);
f:RegisterEvent("PLAYER_LOGIN");
f:RegisterEvent("HONOR_CURRENCY_UPDATE");