require "StandardMouseButton"
require "CDialog"
		
-- reserve constructor
Menu_HighScoresDialog = 
{
	name = "Menu_HighScoresDialog"
}

function Menu_HighScoresDialog:Create(  )
	
	-- The main screen container
	local instance = root.dialogs[ self.name ];
	instance:SetPosition( 139, 99 )
	CDialog:Attach( instance )
	
	-- The ok button
	local okButton = instance.button
	
	function instance:OnUpdate( )
		self:OnUpdateDialog()
	end
	
	-- The main init function
	function instance:Init( )

		instance.name1:SetText( instance:GetEntryName( 0 ) );
		instance.name2:SetText( instance:GetEntryName( 1 ) );
		instance.name3:SetText( instance:GetEntryName( 2 ) );
		instance.name4:SetText( instance:GetEntryName( 3 ) );
		instance.name5:SetText( instance:GetEntryName( 4 ) );
		instance.name6:SetText( instance:GetEntryName( 5 ) );
		instance.name7:SetText( instance:GetEntryName( 6 ) );
		instance.name8:SetText( instance:GetEntryName( 7 ) );

		instance.score1:SetText( instance:GetEntryTime( 0 ) );
		instance.score2:SetText( instance:GetEntryTime( 1 ) );
		instance.score3:SetText( instance:GetEntryTime( 2 ) );
		instance.score4:SetText( instance:GetEntryTime( 3 ) );
		instance.score5:SetText( instance:GetEntryTime( 4 ) );
		instance.score6:SetText( instance:GetEntryTime( 5 ) );
		instance.score7:SetText( instance:GetEntryTime( 6 ) );
		instance.score8:SetText( instance:GetEntryTime( 7 ) );
		
		StandardMouseButton( okButton );
		okButton:Init( )
	end

	-- Handle keyboard input for the dialog
	function instance:CharDown( i_Key )
		log( "On Key Down" .. i_Key )
	end

	-- The ok button
	function okButton:Init( )
		
		function okButton:Pressed( )
			instance:CloseAndSave( )
		end
		self:AddAsGlobalHandler()
		function okButton:OnKeyDown( i_Key )
			-- press ok on pressing return button
			if ( i_Key == 13 ) then
				okButton:Pressed()
			end
		end
	end
end

Menu_HighScoresDialog:Create( )
