-- wndhighscores.lua

require("scripts/style.lua");
require("scripts/styles/mainmenustyle.lua");

posX = 400;
posY = (height - 100);
offsetX = 185;

titleOffsetX = 112;
titleOffsetY = 45;

lblPosX = 100.0
playerNamePosX = 150.0
playerScorePosX = 360.0
entriesInitialPosY = 150.0
spaceBetweenEntries = 50.0
numberEntries = 5

-- Define a function to create a given number of labels (the ones that 
-- will hold the numbers)
function CreateLabelEntries(number)

	t = {SetStyle(CreditsHighScoreNumberStyle),};
	for i = 0, number - 1 do
		table.insert(t,
		Text
		{
			-- Common properties
			x = lblPosX, 
			w = kMax, h = kMax,
			
			-- Individual properties
			y = entriesInitialPosY + (spaceBetweenEntries * i),
			label = "#<outline color='000000' size='2'>"..(i + 1)..".</outline>",
		}
		);	
	end
	
	return Group(t)
end

-- Define a function to create a given number of texts (the ones that
-- will hold the names of the players)
function CreatePlayerNamesTexts(number)

	t = {SetStyle(CreditsHighScoreNumberStyle),};
	for i = 0, number - 1 do
		table.insert(t,
		Text
		{
			-- Common properties
			x = playerNamePosX, 
			w = kMax, h = kMax,
			
			-- Individual properties
			y = entriesInitialPosY + (spaceBetweenEntries * i),
			label = "<outline color='000000' size='2'>#Player"..i.."</outline>",
			name = "txtPlayerName"..i
		}
		);	
	end
	
	return Group(t)
end

-- Define a function to create a given number of texts (the ones that
-- will hold the scores of the players)
function CreatePlayerScoresTexts(number)

	t = {SetStyle(CreditsHighScoreStyle),};
	for i = 0, number - 1 do
		table.insert(t,
		Text
		{
			-- Common properties
			x = playerScorePosX, 
			w = kMax, h = kMax,
			
			-- Individual properties
			y = entriesInitialPosY + (spaceBetweenEntries * i) + 5,
			label = "0",
			name = "txtPlayerScore"..i
		}
		);	
	end
	
	return Group(t)
end

MakeDialog
{
	-- Set the background image
	BlgBitmap
	{
		image = "common/screens/basics_credits/basics_background",
		x = kCenter, y = kCenter,
			
		-- Create our main credits window
		WndHighScores
		{
			fit = true,
			x = kCenter,
			y = kCenter,
			w = kMax, h = kMax,
		
			Bitmap
			{
				image = "common/screens/basics_credits/basics_box",
				x = kCenter + 10,
				y = kCenter,
				
				SetStyle(CreditsTitleStyle),
	
				Text
				{
					label = "menu_highscores_title",
					x = titleOffsetX, y = titleOffsetY,
					w = 390, h = 75,
					--font = BasicsTitleFont,
					flags = kHAlignCenter + kVAlignCenter,
				},
				
				SetStyle(CreditsContentStyle),
				
				-- Create the labels and texts for the high scores entries
				CreateLabelEntries(numberEntries),
				CreatePlayerNamesTexts(numberEntries),
				CreatePlayerScoresTexts(numberEntries),
				
				
			},
			
			SetStyle(InternalButtonStyle),
			
			BlgButton
			{
				--x = (posX + offsetX), y = posY-height,
				x = 440, y = 550,
	           	label = "backtogame",
	           	width = 400, height = 200,
				positionMatrix = { x = 10, y = 10},
				graphics = {
					"common/screens/button/basic_button",
					"",
					"",
					"",
				},
	           	command =
			        function()
			        	SwapToModalWithTransition("wndmainmenu.lua")
			        end
			},
		}
	}
}
