local _, core = ...;

local fontText           = "Fonts\\FRIZQT__.TTF";
if GetLocale() == "ruRU" then fontText = "Interface\\AddOns\\WoWChallenger\\fonts\\FRIZQT__CYR.TTF"	end

-- ====== TOOLTIP ====== --
WC_Lib.OnEnterIconHelpScore = function(self, motion)
	GameTooltip:SetOwner(self, "ANCHOR_LEFT", 15, 5);
	GameTooltip:AddLine(core.L["Obtention des points"]);
	GameTooltip:AddLine(core.L["Campaigns"]);
	GameTooltip:AddLine(core.L["+5 points par niveau sur le 1er Boss (+5 points si Boss)"], 1, 1, 1);
	GameTooltip:AddLine(core.L["+15 points par niveau sur le 2ème Boss (+10 points si Boss)"], 1, 1, 1);
	GameTooltip:AddLine(core.L["+35 points par niveau sur le 3ème Boss (+20 points si Boss)"], 1, 1, 1);
	GameTooltip:AddLine(core.L["+50 points par niveau sur le 4ème Boss (+30 points si Boss)"], 1, 1, 1);
	GameTooltip:AddLine(" ");
	GameTooltip:AddLine(core.L["Challenges"]);
	GameTooltip:AddLine(core.L["+250 points par challenges Novice terminés"], 1, 1, 1);
	GameTooltip:AddLine(core.L["+500 points par challenges Intermédiaire terminés"], 1, 1, 1);
	GameTooltip:AddLine(core.L["+750 points par challenges Expert terminés"], 1, 1, 1);
	GameTooltip:AddLine(" ");
	GameTooltip:AddLine(core.L["Collections"]);
	GameTooltip:AddLine(core.L["+50 points par objet Facile obtenu"], 1, 1, 1);
	GameTooltip:AddLine(core.L["+100 points par objet Moyen obtenu"], 1, 1, 1);
	GameTooltip:AddLine(core.L["+150 points par objet Difficile obtenu"], 1, 1, 1);
	GameTooltip:Show();
end

WC_Lib.OnEnterRankingPlayer = function(self, motion)
	GameTooltip:SetOwner(self, "ANCHOR_LEFT", 5, -7);
	GameTooltip:AddLine(self.name.." ("..self.score..")", 1, 1, 1);
	GameTooltip:AddLine(core.L["Campaigns"]..core.L["2points"].."|cffffffff"..self.donePart[1].."|r");
	GameTooltip:AddLine(core.L["Challenges"]..core.L["2points"].."|cffffffff"..self.donePart[2].."|r");
	GameTooltip:AddLine(core.L["Collections"]..core.L["2points"].."|cffffffff"..self.donePart[3].."|r");
	
	-- PATREON PART --
	if (self.supportRank > 0) then
		GameTooltip:AddLine(" ");
		GameTooltip:AddLine(core.L["Soutien"]..core.L["2points"]..core.L["SupportList"][self.supportRank].."|r");
	end
	GameTooltip:AddLine(" ");
	GameTooltip:AddLine(core.L["Cliquer pour voir la progression"], 0.5, 0.5, 0.5);
	GameTooltip:Show();
	
	if (self.chat == "GUILD") then
		self.portrait.delBtn:Show();
	end
end

WC_Lib.OnEnterCompare = function(self, motion)
	GameTooltip:SetOwner(self, "ANCHOR_RIGHT", 0, 0);
	GameTooltip:AddLine(self.title, 1, 1, 1);
	GameTooltip:AddDoubleLine(self.category, self.faction, 1, 1, 1, 1, 1, 1);
	GameTooltip:AddLine(" ");
	GameTooltip:AddDoubleLine(self.comparedName, core.L["Vous"]);
	if self.comparedValue[1] then
		for i = 1, #self.comparedValue do
			GameTooltip:AddDoubleLine(self.comparedValue[i], self.yourValue[i]);
		end
	else
		GameTooltip:AddDoubleLine(self.comparedValue, self.yourValue, 1, 1, 1, 1, 1, 1);
	end
	GameTooltip:Show();
end

-- ====== END TOOLTIP ====== --

function WC_Lib.CreateProgressBar(parent, width, title, name)
	local progressBarFrame = CreateFrame("Frame", name, parent, BackdropTemplateMixin and "BackdropTemplate");
	progressBarFrame:SetSize(width, 28);
	
	progressBarFrame.blackBg = CreateFrame("Frame", nil, progressBarFrame, BackdropTemplateMixin and "BackdropTemplate");
	progressBarFrame.blackBg:SetSize(progressBarFrame:GetWidth(),progressBarFrame:GetHeight());
	progressBarFrame.blackBg:SetPoint("CENTER");
	progressBarFrame.blackBg:SetBackdrop({bgFile = "Interface/Tooltips/UI-Tooltip-Background",
										insets = { left = 5, right = 5, top = 0, bottom = 0 }})
	progressBarFrame.blackBg:SetBackdropColor(0, 0, 0, 1);
	
	progressBarFrame.bg = CreateFrame("Frame", nil, progressBarFrame.blackBg, BackdropTemplateMixin and "BackdropTemplate");
	progressBarFrame.bg:SetSize(progressBarFrame:GetWidth(),progressBarFrame:GetHeight());
	progressBarFrame.bg:SetPoint("CENTER");
	progressBarFrame.bg:SetBackdrop({bgFile = "",
										edgeFile = "Interface\\GLUES\\COMMON\\TextPanel-Border",
										tile = true,
										tileSize = 22,
										edgeSize = 22,
										insets = { left = 5, right = 5, top = 0, bottom = 0 }})
	progressBarFrame.bg:SetBackdropColor(0, 0, 0, 1);
										
	progressBarFrame.progressBg = CreateFrame("Frame", nil, progressBarFrame.blackBg, BackdropTemplateMixin and "BackdropTemplate");
	progressBarFrame.progressBg:SetSize(0,progressBarFrame:GetHeight() - 7);
	progressBarFrame.progressBg:SetPoint("LEFT", progressBarFrame.bg, "LEFT", 6, 1);
	progressBarFrame.progressBg:SetBackdrop({bgFile = "Interface\\TARGETINGFRAME\\UI-StatusBar",
										insets = { left = 0, right = 9, top = 0, bottom = 0}})
	progressBarFrame.progressBg:SetBackdropColor(0.10, 0.65, 0.10, 1);
	
	progressBarFrame.title = progressBarFrame.bg:CreateFontString(nil, "OVERLAY", progressBarFrame);
	progressBarFrame.title:SetFontObject("GameFontNormal");
	progressBarFrame.title:SetPoint("LEFT", progressBarFrame, "LEFT", 11, 0);
	progressBarFrame.title:SetText(title);
	
	progressBarFrame.progressText = progressBarFrame.bg:CreateFontString(nil, "OVERLAY", progressBarFrame);
	progressBarFrame.progressText:SetFontObject("GameFontHighlight");
	progressBarFrame.progressText:SetPoint("RIGHT", progressBarFrame, "RIGHT", -11, 0);
	progressBarFrame.progressText:SetText("0/0");
	
	return progressBarFrame;
end


local function CreateCampaignsContentPart(parent)
	for i = 1, #core.DBcampaign do
		local mainFrame = CreateFrame("Frame", "WC_RankingIconBoss"..i, parent, BackdropTemplateMixin and "BackdropTemplate");
		mainFrame:SetSize(100, 75);
		mainFrame:SetBackdrop({bgFile = "Interface/AddOns/WoWChallenger/images/campaign/design_campaign/icon_zone"..i,
							insets = {left = -15, right = -15, top = -25, bottom = -25}})
		mainFrame:SetScript("OnEnter", WC_Lib.OnEnterCompare);
		mainFrame:SetScript("OnLeave", WC_Lib.OnLeave);
		mainFrame.title         = core.DBcampaign[i].title;
		mainFrame.comparedName  = "";
		mainFrame.comparedValue = {};
		mainFrame.yourValue     = {};
		if (i == 1) then
			mainFrame:SetPoint("TOPLEFT", parent, "TOPLEFT", 11, 0);
		elseif (i == 2) then
			mainFrame:SetPoint("TOPRIGHT", parent, "TOPRIGHT", -11, 0);
		else
			mainFrame:SetPoint("TOP", _G["WC_RankingIconBoss"..i - 2], "BOTTOM", 0, -2);
		end
	end
end

local function CreateChallengesContentPart(parent)
	local k = 0;
	for i = 1, #core.DBchallenge.data do
		for j = 1, #core.DBchallenge.data[i] do
			local title     = core.DBchallenge.data[i][j].title;
			local mainFrame = WC_Lib.CreateProgressBar(parent, parent:GetWidth() - 25, title, "WC_RankingProgressBarChallenges"..k + 1);			
			mainFrame:SetScript("OnEnter", WC_Lib.OnEnterCompare);
			mainFrame:SetScript("OnLeave", WC_Lib.OnLeave);
			mainFrame.title         = title;
			mainFrame.comparedName  = "";
			mainFrame.comparedValue = "";
			mainFrame.yourValue     = "";
			if (i == 1 and j == 1) then
				mainFrame:SetPoint("TOP", parent, "TOP", 0, 0);
			else
				mainFrame:SetPoint("TOP", parent, "TOP", 0, -k * 30);
			end
			k = k + 1;
		end
	end
end

local function CreateCollectionsContentPart(parent)
	local guidesByWC = WC_Lib.GetGuidesByWoWChallengerByLocal();
	for i = 0, #guidesByWC - 1 do
		local infoCollection = guidesByWC[i + 1];
		local icon = CreateFrame("Frame", "WC_RankingIconCollections"..i, parent, BackdropTemplateMixin and "BackdropTemplate");
		icon:SetSize(44, 44);
		icon:SetBackdrop({bgFile = infoCollection.icon});
		icon:SetScript("OnEnter", WC_Lib.OnEnterCompare);
		icon:SetScript("OnLeave", WC_Lib.OnLeave);
		icon.category      = "";
		icon.faction       = "";
		icon.comparedName  = "";
		icon.comparedValue = "";
		icon.yourValue     = "";
		icon.title = infoCollection.info[1];
		if (infoCollection.faction == 1) then
			icon.faction = core.L["Alliance"];
		elseif (infoCollection.faction == 2) then
			icon.faction = core.L["Horde"];			
		end
		if (infoCollection.category == "hf") then
			icon.category = core.L["Hauts-faits"];
		elseif (infoCollection.category == "mounts") then
			icon.category = core.L["Mounts"];
		elseif (infoCollection.category == "pets") then
			icon.category = core.L["Pets"];
		elseif (infoCollection.category == "transmogs") then
			icon.category = core.L["Transmog"];		
		end
		
		icon.greenCheck = CreateFrame("Frame", nil, icon, BackdropTemplateMixin and "BackdropTemplate");
		icon.greenCheck:SetSize(32, 32);
		icon.greenCheck:SetPoint("BOTTOMRIGHT", icon, "BOTTOMRIGHT", 5, -5);
		icon.greenCheck:SetBackdrop({bgFile = "Interface/AddOns/WoWChallenger/images/collections/greenCheck"});
		icon.greenCheck:Hide();
		if (i == 0) then
			icon:SetPoint("TOPLEFT", parent, "TOPLEFT", 11, 0);
		elseif (i % 10 == 0) then
			icon:SetPoint("TOP", _G["WC_RankingIconCollections"..i - 10], "BOTTOM", 0, 0);
		else
			icon:SetPoint("LEFT", _G["WC_RankingIconCollections"..i - 1], "RIGHT", 0, 0);
		end
	end
end

local function CreateCorpsPartRanking(parent, part)
	local title = "Title";	
	local mainFrame = CreateFrame("Frame", nil, parent);
	
	if (part == 1) then
		title = core.L["Campaigns"];
		mainFrame:SetSize(parent:GetWidth()/2 - 25, 190);
	elseif (part == 2) then
		title = core.L["Challenges"];
		mainFrame:SetSize(parent:GetWidth()/2 - 25, 190);
	elseif (part == 3) then
		title = core.L["Collections"];
		mainFrame:SetSize(parent:GetWidth() - 40, 170);
	end	
	
	mainFrame.header = WC_Lib.CreateProgressBar(mainFrame, mainFrame:GetWidth(), title);
	mainFrame.header:SetPoint("TOP", mainFrame, "TOP", 0, 0);
	
	mainFrame.body = CreateFrame("Frame", nil, mainFrame, BackdropTemplateMixin and "BackdropTemplate");
	mainFrame.body:SetSize(mainFrame:GetWidth(), mainFrame:GetHeight());
	mainFrame.body:SetPoint("BOTTOM", mainFrame, "BOTTOM");
	mainFrame.body:SetBackdrop({
		bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background", 
		edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border",
		tile = true,
		tileSize = 32,
		edgeSize = 32,
		insets = {left = 12, right = 12, top = 12, bottom = 11},
	})	
	
	mainFrame.body.content = CreateFrame("ScrollFrame", nil, mainFrame.body, "UIPanelScrollFrameTemplate");
	mainFrame.body.content:SetPoint("TOPLEFT", mainFrame.body, "TOPLEFT", 0, -28);
	mainFrame.body.content:SetPoint("BOTTOMRIGHT", mainFrame.body, "BOTTOMRIGHT", 0, 10);	
	mainFrame.body.content:SetClipsChildren(true);
	mainFrame.body.content.child = CreateFrame("Frame", nil, mainFrame.body.content, BackdropTemplateMixin and "BackdropTemplate");
	mainFrame.body.content.child:SetSize(mainFrame.body:GetWidth(), mainFrame.body:GetHeight());
	
	mainFrame.body.content:SetScrollChild(mainFrame.body.content.child);
	mainFrame.body.content:SetScript("OnMouseWheel", WC_Lib.ScrollFrame_OnMouseWheel);
	
	if (part == 1) then
		CreateCampaignsContentPart(mainFrame.body.content);
	elseif (part == 2) then
		mainFrame.body.content.wheelSpeed  = 30;
		mainFrame.body.content.scrollRange = 60;
		mainFrame.body.content:SetPoint("TOPLEFT", mainFrame.body, "TOPLEFT", 0, -30);
		CreateChallengesContentPart(mainFrame.body.content.child);
	elseif (part == 3) then
		mainFrame.body.content.wheelSpeed  = 44;
		mainFrame.body.content.scrollRange = 132;
		CreateCollectionsContentPart(mainFrame.body.content.child);
	end	
	return mainFrame;
end



function WC_Lib.CreateDetailsProfilePlayer()
	local frameParent = _G["WoWChallengerFrameRanking"];
	
	local bgDetails = CreateFrame("Frame", "WC_RankingDetailsProfile", frameParent, BackdropTemplateMixin and "BackdropTemplate");
	bgDetails:SetSize(frameParent:GetWidth(), frameParent:GetHeight());
	bgDetails:SetPoint("CENTER", frameParent, "CENTER");
	bgDetails:SetFrameLevel(frameParent:GetFrameLevel() + 4);	
	bgDetails:EnableMouse(true);
	bgDetails:SetBackdrop({bgFile = "Interface/AddOns/WoWChallenger/images/challenges/bg_step_challenge",
						insets = { left = 3, right = 0, top = 0, bottom = 0 }});
			
	bgDetails.close = CreateFrame("Button", nil, bgDetails, "UIPanelCloseButton");
	bgDetails.close:SetSize(32, 32);
	bgDetails.close:SetPoint("TOPRIGHT", bgDetails, "TOPRIGHT", -20, -10);
	bgDetails.close:SetScript("OnClick", function(self)
		PlaySound("879", "sfx");
		bgDetails:Hide();
	end);
	
	bgDetails.title = bgDetails:CreateFontString(nil, "OVERLAY", bgDetails);
	bgDetails.title:SetFont(fontText, 20, "OUTLINE");
	bgDetails.title:SetPoint("TOP", bgDetails, "TOP", 0, -15);
	bgDetails.title:SetSize(bgDetails:GetWidth(), 0);	

	bgDetails.scoreText = bgDetails:CreateFontString(nil, "OVERLAY", bgDetails);
	bgDetails.scoreText:SetFontObject("GameFontNormalLarge");
	bgDetails.scoreText:SetPoint("TOP", bgDetails, "TOP", 0, -50);
	bgDetails.scoreText:SetText(core.L["Score"]..core.L["2points"].."|cffffffff0|r");
	
	-- === COLLECTIONS PART === -	
	bgDetails.CollectionsFrames = CreateCorpsPartRanking(bgDetails, 3);
	bgDetails.CollectionsFrames:SetPoint("BOTTOM", bgDetails, "BOTTOM", -8, 15);
	
	-- === CAMPAIGNS PART === --
	bgDetails.CampaignsFrames = CreateCorpsPartRanking(bgDetails, 1);
	bgDetails.CampaignsFrames:SetPoint("BOTTOMLEFT", bgDetails.CollectionsFrames, "TOPLEFT", 0, 5);
	
	-- === CHALLENGES PART === --	
	bgDetails.ChallengesFrames = CreateCorpsPartRanking(bgDetails, 2);
	bgDetails.ChallengesFrames:SetPoint("BOTTOMRIGHT", bgDetails.CollectionsFrames, "TOPRIGHT", 0, 5);
	
	bgDetails:Hide();
end

function WC_Lib.CreateRankingTab(frameParent)
	local bgTab = CreateFrame("Frame", "WoWChallengerFrameRanking", frameParent);
	bgTab:SetSize(500,453);
	bgTab:SetPoint("CENTER", frameParent, "CENTER");

	-- ===== PLAYER SCORE DESIGN ====== --	
	local bgPlayerScore = CreateFrame("Frame", nil, bgTab, BackdropTemplateMixin and "BackdropTemplate");
	bgPlayerScore:SetSize(600,150);
	bgPlayerScore:SetPoint("TOP", bgTab, "TOP", 0, 10);
	bgPlayerScore:SetBackdrop({bgFile = "Interface/Addons/WoWChallenger/images/ranking/bgPlayerScore",
							insets = { left = -50, right = -50, top = 0, bottom = 0 }});
	
	local scoreTitle = bgPlayerScore:CreateFontString(nil, "OVERLAY", bgPlayerScore);
	scoreTitle:SetPoint("TOP", bgTab, "TOP", 0, -10);
	scoreTitle:SetFontObject("GameFontNormal");
	scoreTitle:SetText(core.L["Score"]);
	
	local scoreText = bgPlayerScore:CreateFontString("WC_RankingPlayerScore", "OVERLAY", bgPlayerScore);
	scoreText:SetPoint("CENTER", bgPlayerScore, "CENTER", -1, -7);
	scoreText:SetFont(fontText, 50, "OUTLINE");
	scoreText:SetText("0");
	
	local helpScore = CreateFrame("Button", nil, bgTab);
	helpScore:SetSize(64, 64);
	helpScore:SetNormalTexture("Interface/COMMON/help-i");
	helpScore:SetPoint("TOPRIGHT", bgPlayerScore, "TOPRIGHT", -75, -50);
	helpScore:SetScript("OnLeave", WC_Lib.OnLeave);
	helpScore:SetScript("OnEnter", WC_Lib.OnEnterIconHelpScore);
	
	local portraitPlayer = bgTab:CreateTexture("WC_RankingPlayerPortrait", "BACKGROUND")
	portraitPlayer:SetHeight(60)
	portraitPlayer:SetWidth(60)
	portraitPlayer:SetPoint("TOPLEFT", bgTab, "TOPLEFT", 45, -38);
	
	portraitPlayer.bg = CreateFrame("Frame", nil, bgTab, BackdropTemplateMixin and "BackdropTemplate");
	portraitPlayer.bg:SetSize(128,128);
	portraitPlayer.bg:SetPoint("CENTER", portraitPlayer, "CENTER")
	portraitPlayer.bg:SetBackdrop({bgFile = "Interface/Addons/WoWChallenger/images/ranking/portraitPlayer"});
	
	local bgIconSupport = "";
	if WC_Lib.spts[WC_Lib.fullNamePlayer] then bgIconSupport = "Interface/PVPFrame/Icons/prestige-icon-6-"..WC_Lib.spts[WC_Lib.fullNamePlayer] end
	portraitPlayer.iconSupport = CreateFrame("Frame", nil, portraitPlayer.bg, BackdropTemplateMixin and "BackdropTemplate");
	portraitPlayer.iconSupport:SetSize(42,42);
	portraitPlayer.iconSupport:SetPoint("BOTTOMLEFT", portraitPlayer.bg, "BOTTOMLEFT", 20, 23)
	portraitPlayer.iconSupport:SetBackdrop({bgFile = bgIconSupport});
	
	SetPortraitTexture(portraitPlayer, "player");
	
	-- ===== RANKING SCORE DESIGN ====== --
	local RankingTable = CreateFrame("Frame", "WC_RankingTable", bgTab, BackdropTemplateMixin and "BackdropTemplate");
	RankingTable:SetSize(bgTab:GetWidth(),300);
	RankingTable.numTabs = 2;
	RankingTable:SetPoint("BOTTOM", bgTab, "BOTTOM", 0, 0);
	RankingTable:SetBackdrop({bgFile = "Interface/ACHIEVEMENTFRAME/UI-GuildAchievement-AchievementBackground",
							edgeFile = "Interface/Tooltips/UI-Tooltip-Border", 
							tile = false, edgeSize = 16,
							insets = { left = 3, right = 0, top = 3, bottom = 3 }});
	
	
	
	-- GUILD-GROUP RANKING CONTENT --
	RankingTable.Tab = {};
	for i = 1, 2 do
		RankingTable.Tab[i] = CreateFrame("Button", "WC_RankingTableTab"..i, RankingTable, "OptionsFrameTabButtonTemplate");
		RankingTable.Tab[i]:SetID(i);
		RankingTable.Tab[i]:SetFrameLevel(RankingTable:GetFrameLevel() - 1);
		RankingTable.Tab[i]:SetScript("OnClick", function(self)
			local id = self:GetID();
			PanelTemplates_SetTab(self:GetParent(), id);
			for j = 1, #self:GetParent().Tab do
				self:GetParent().Tab[j].ScrollContent:Hide();
			end
			self.ScrollContent:Show();
		end);
		
		local title = "";
		if (i == 1) then
			title = core.L["Guilde"];
			RankingTable.Tab[i]:SetPoint("TOPLEFT", RankingTable, "TOPLEFT", 0, 22);
		else
			title = core.L["Personnes rencontrées"];
			RankingTable.Tab[i]:SetPoint("LEFT", RankingTable.Tab[i - 1], "RIGHT", 0, 0);
		end
		RankingTable.Tab[i]:SetText(title);
		
		RankingTable.Tab[i].ScrollContent = CreateFrame("ScrollFrame",  nil, RankingTable, "UIPanelScrollFrameTemplate");
		RankingTable.Tab[i].ScrollContent:SetSize(RankingTable:GetWidth(),RankingTable:GetHeight() - 8);
		RankingTable.Tab[i].ScrollContent:SetPoint("CENTER", RankingTable, "CENTER");
		RankingTable.Tab[i].ScrollContent:SetClipsChildren(true);
		RankingTable.Tab[i].ScrollContent.ScrollBar:ClearAllPoints();
		RankingTable.Tab[i].ScrollContent.ScrollBar:SetPoint("TOPRIGHT", RankingTable.Tab[i].ScrollContent, "TOPRIGHT", -4, -17);
		RankingTable.Tab[i].ScrollContent.ScrollBar:SetPoint("BOTTOMRIGHT", RankingTable.Tab[i].ScrollContent, "BOTTOMRIGHT", -4, 17);
		RankingTable.Tab[i].ScrollContent.child = CreateFrame("Frame", "WC_RankingTableTab"..i.."Content", RankingTable.Tab[i].ScrollContent);
		RankingTable.Tab[i].ScrollContent.child:SetSize(RankingTable.Tab[i].ScrollContent:GetWidth(), RankingTable.Tab[i].ScrollContent:GetHeight());
		RankingTable.Tab[i].ScrollContent:SetScrollChild(RankingTable.Tab[i].ScrollContent.child);
		RankingTable.Tab[i].ScrollContent:SetScript("OnMouseWheel", WC_Lib.ScrollFrame_OnMouseWheel);

		local NoInfoText = RankingTable.Tab[i].ScrollContent:CreateFontString("WC_RankingNoInfoText"..i, "OVERLAY", RankingTable.Tab[i].ScrollContent);
		NoInfoText:SetFontObject("GameFontHighlightLarge");
		NoInfoText:SetText(core.L["Aucune information pour l'instant"]..".");
		NoInfoText:SetPoint("CENTER");
	end
	
	-- ===== WARNING DESIGN ====== --	
	local WarningFrame = CreateFrame("Frame", "WC_RankingWarningPlayerScore", bgTab, BackdropTemplateMixin and "BackdropTemplate");
	WarningFrame:SetSize(bgTab:GetWidth(),bgTab:GetHeight());
	WarningFrame:SetPoint("CENTER");
	WarningFrame:SetFrameLevel(bgTab:GetFrameLevel() + 5);
	WarningFrame:SetBackdrop({bgFile = "Interface/Tooltips/UI-Tooltip-Background"})
	WarningFrame:SetBackdropColor(0, 0, 0, 0.75);
	WarningFrame:EnableMouse(true);

	WarningFrame.icon = CreateFrame("Button", nil, WarningFrame);
	WarningFrame.icon:SetSize(64, 64);
	WarningFrame.icon:SetNormalTexture("Interface/\DialogFrame/UI-Dialog-Icon-AlertNew");
	WarningFrame.icon:SetPoint("CENTER", WarningFrame, "CENTER", 0, 70);
	
	WarningFrame.title = WarningFrame:CreateFontString(nil, "OVERLAY", WarningFrame);
	WarningFrame.title:SetFontObject("ErrorFont");
	WarningFrame.title:SetText(core.L["Warning"]);
	WarningFrame.title:SetPoint("CENTER", WarningFrame, "CENTER", 0, 35);
	
	WarningFrame.text = WarningFrame:CreateFontString(nil, "OVERLAY", WarningFrame);
	WarningFrame.text:SetFontObject("GameFontWhite");
	WarningFrame.text:SetSize(WarningFrame:GetWidth() - 100, 30);
	WarningFrame.text:SetText(core.L["Les collections ne sont pas chargées et donc non prise en compte dans votre score"]..".");
	WarningFrame.text:SetPoint("CENTER");
	
	WarningFrame.btn = CreateFrame("Button", "BtnImportGuide", WarningFrame, "UIPanelButtonTemplate");
	WarningFrame.btn:SetSize(200, 30);
	WarningFrame.btn:SetText(core.L["Charger les guides"]);
	WarningFrame.btn:SetPoint("CENTER", WarningFrame, "CENTER", 0, -50);
	WarningFrame.btn:SetScript("OnClick", function (self) 
		self:Disable();
		_G["WC_BtnLoadGuides"]:Click();
		WC_Lib.SetPlayerScore();
	end);
	
	WarningFrame:Hide();	
	
	WC_Lib.CreateDetailsProfilePlayer();
	
	RankingTable.Tab[1]:Click();
end