/*
	Wheels Of Steel
	Copyright (c) 2006, Darragh Coy.
	All rights reserved.
	Original work(s), source code & author(s) details available at: http://www.darraghcoy.com

	Redistribution and use in source and binary forms, with or without modification, are permitted 
	provided that the following conditions are met:

		* 	Redistributions of source code must retain the above copyright notice, this list of 
			conditions and the following disclaimer.
		* 	Redistributions in binary form must reproduce the above copyright notice, this list of 
			conditions and the following disclaimer in the documentation.
		* 	Neither the name of the author nor the names of contributors may be used to endorse or 
			promote products derived from this software without specific prior written permission.
		* 	The use of any third party libraries, modules or data files provided with the source 
			form of the program must follow and respect the individual licensing terms of these 
			components. You do not have permission to modify or circumvent the licensing terms for 
			provided third party components unless the third party licenses specifically allow this. 
			If you do not agree to the terms of provided third party components then you do not have 
			permission to use them in your derived work(s).
		* 	The terms of this license do not apply to separate (but related) distributions if supplied 
			by the author(s), only to the contents of this source distribution, derived works, and the 
			binaries produced by either modified or unmodified versions of the source code. The terms 
			of this license do not also apply to any third party libraries or components provided with 
			the source distribution. Such third party elements are licensed under their own separate 
			agreements.

	THIS SOFTWARE IS PROVIDED BY DARRAGH COY ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 
	BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
	ARE DISCLAIMED. IN NO EVENT SHALL DARRAGH COY BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
	EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
	OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 
	OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
	IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

//##############################################################################
//##############################################################################
//##############################################################################
//##############################################################################
//
//
// Class Name:   Menu_Main
// Purpose:      Shows the main menu. allows user to quit or start a race and
//               change race settings.
//
//##############################################################################
//##############################################################################
//##############################################################################
//##############################################################################

#include "Menu_Main.h"

//------------------------------------------------------------------------------
// Static initialisers
//------------------------------------------------------------------------------

bool                    Menu_Main::runMenu      = 0;                                    // Run the window and consequently the menu ?
Bitmap *                Menu_Main::bmpMenuBar   = 0;                                    // The menu bar horizontal rule divider
Bitmap *                Menu_Main::bmpArrow     = 0;                                    // The arrow image showing the selected menu item
BitmapFont *            Menu_Main::bitFont      = 0;                                    // Bitmap font to use for the screen
Menu_Main::MenuItem     Menu_Main::menuItem     = Menu_Main::MENU_ITEM_TRACK_LENGHT;    // Currently selected menu item

Menu_Main::TrackLenght      Menu_Main::trackLenght      = Menu_Main::TRACK_LENGHT_NORMAL;       // Various menu settings for when starting the game
Menu_Main::HillSteepness    Menu_Main::hillSteepness    = Menu_Main::HILL_STEEPNESS_NORMAL;
Menu_Main::TurnSharpness    Menu_Main::turnSharpness    = Menu_Main::TURN_SHARPNESS_NORMAL;
Menu_Main::NumCompetitors   Menu_Main::numCompetitors   = Menu_Main::NUM_COMPETITORS_16;
Menu_Main::AICarSpeed       Menu_Main::aiCarSpeed       = Menu_Main::AI_CAR_SPEED_NORMAL;
Menu_Main::GridSpacing      Menu_Main::gridSpacing      = Menu_Main::GRID_SPACING_NORMAL;

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Name:     Menu_Main::display
Purpose:  starts showing the main menu.
Params:   as commented.
Returns:  none

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

void Menu_Main::display(Window * window)
{
    //--------------------------------------------------------------------------
    // Show the menu initially: set current selected menu item
    //--------------------------------------------------------------------------

    runMenu     = true;
    menuItem    = MENU_ITEM_TRACK_LENGHT;

    //--------------------------------------------------------------------------
    // Set the default values for the menu settings
    //--------------------------------------------------------------------------

    trackLenght      = TRACK_LENGHT_NORMAL;
    hillSteepness    = HILL_STEEPNESS_NORMAL;
    turnSharpness    = TURN_SHARPNESS_NORMAL;
    numCompetitors   = NUM_COMPETITORS_16;
    aiCarSpeed       = AI_CAR_SPEED_NORMAL;
    gridSpacing      = GRID_SPACING_NORMAL;

    //--------------------------------------------------------------------------
    // Load the menu bar resource and menu arrow
    //--------------------------------------------------------------------------

    bmpMenuBar  = window->loadBitmap("gfx\\menu\\menuBar1.bmp"  ,true);
    bmpArrow    = window->loadBitmap("gfx\\menu\\arrow.bmp"     ,true);

    //--------------------------------------------------------------------------
    // Load the bitmap font used for the end of race screen
    //--------------------------------------------------------------------------

    bitFont = new BitmapFont("gfx\\font\\font1sm.bmp",window);

    //--------------------------------------------------------------------------
    // Set the paint, keydown and window closed event of the window
    //--------------------------------------------------------------------------

    window->setEvent_paint(event_draw);
    window->setEvent_closed(event_closed);
    window->setEvent_keyDown(event_keyDown);

    //--------------------------------------------------------------------------
    // Continue running the window until the 'runMenu' flag is false
    //--------------------------------------------------------------------------

    while ( runMenu )
    {
        // Request a repaint of the window.

        window->requestRepaint();

        // do message processing of the window

        window->run();
    }

    //--------------------------------------------------------------------------
    // Disengage the event handlers
    //--------------------------------------------------------------------------

    window->setEvent_paint(0);
    window->setEvent_closed(0);
    window->setEvent_keyDown(0);

    //--------------------------------------------------------------------------
    // Free all resources allocated
    //--------------------------------------------------------------------------

    delete bmpMenuBar;  bmpMenuBar  = 0;
    delete bmpArrow;    bmpArrow    = 0;
    delete bitFont;     bitFont     = 0;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Name:     Menu_Main::event_keyDown
Purpose:  Handles key down events for the window
Params:   Window, key presed
Returns:  none

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

void Menu_Main::event_keyDown ( Window & window , Window::KeyboardKey key )
{
    //--------------------------------------------------------------------------
    // See what key was pressed firstly
    //--------------------------------------------------------------------------

    switch ( key )
    {
        //----------------------------------------------------------------------
        // Up key pressed: change menu item
        //----------------------------------------------------------------------

        case Window::KEYBOARD_UP:
        {
            // Change the menu item

            switch ( menuItem )
            {
                case MENU_ITEM_TRACK_LENGHT:    /* do nothing */                        break;
                case MENU_ITEM_HILL_STEEPNESS:  menuItem = MENU_ITEM_TRACK_LENGHT;      break;
                case MENU_ITEM_TURN_SHARPNESS:  menuItem = MENU_ITEM_HILL_STEEPNESS;    break;
                case MENU_ITEM_NUM_COMPETITORS: menuItem = MENU_ITEM_TURN_SHARPNESS;    break;
                case MENU_ITEM_AI_CAR_SPEED:    menuItem = MENU_ITEM_NUM_COMPETITORS;   break;
                case MENU_ITEM_GRID_SPACING:    menuItem = MENU_ITEM_AI_CAR_SPEED;      break;
            }

        }break;

        //----------------------------------------------------------------------
        // Down key pressed: change menu item
        //----------------------------------------------------------------------

        case Window::KEYBOARD_DOWN:
        {
            // Change the menu item

            switch ( menuItem )
            {
                case MENU_ITEM_TRACK_LENGHT:    menuItem = MENU_ITEM_HILL_STEEPNESS;    break;
                case MENU_ITEM_HILL_STEEPNESS:  menuItem = MENU_ITEM_TURN_SHARPNESS;    break;
                case MENU_ITEM_TURN_SHARPNESS:  menuItem = MENU_ITEM_NUM_COMPETITORS;   break;
                case MENU_ITEM_NUM_COMPETITORS: menuItem = MENU_ITEM_AI_CAR_SPEED;      break;
                case MENU_ITEM_AI_CAR_SPEED:    menuItem = MENU_ITEM_GRID_SPACING;      break;
                case MENU_ITEM_GRID_SPACING:    /* do nothing */                        break;
            }

        }break;

        //----------------------------------------------------------------------
        // Left key pressed: change setting
        //----------------------------------------------------------------------

        case Window::KEYBOARD_LEFT:
        {
            // Change the value of the currently selected setting

            switch ( menuItem )
            {
                case MENU_ITEM_TRACK_LENGHT:
                {
                    // Change the track lenght

                    switch ( trackLenght )
                    {
                        case TRACK_LENGHT_SHORT:   /* Do nothing */                     break;
                        case TRACK_LENGHT_NORMAL:  trackLenght = TRACK_LENGHT_SHORT;    break;
                        case TRACK_LENGHT_LONG:    trackLenght = TRACK_LENGHT_NORMAL;   break;
                    }

                }break;

                case MENU_ITEM_HILL_STEEPNESS:
                {
                    // Change the hill steepness

                    switch ( hillSteepness )
                    {
                        case HILL_STEEPNESS_GENTLE:   /* Do nothing */                          break;
                        case HILL_STEEPNESS_NORMAL:   hillSteepness = HILL_STEEPNESS_GENTLE;    break;
                        case HILL_STEEPNESS_STEEP:    hillSteepness = HILL_STEEPNESS_NORMAL;    break;
                    }

                }break;

                case MENU_ITEM_TURN_SHARPNESS:
                {
                    // Change the turn sharpness

                    switch ( turnSharpness )
                    {
                        case TURN_SHARPNESS_GENTLE:   /* Do nothing */                          break;
                        case TURN_SHARPNESS_NORMAL:   turnSharpness = TURN_SHARPNESS_GENTLE;    break;
                        case TURN_SHARPNESS_SHARP:    turnSharpness = TURN_SHARPNESS_NORMAL;    break;
                    }

                }break;

                case MENU_ITEM_NUM_COMPETITORS:
                {
                    // Change the number of competitors

                    switch ( numCompetitors )
                    {
                        case NUM_COMPETITORS_8:   /* Do nothing */                        break;
                        case NUM_COMPETITORS_16:  numCompetitors = NUM_COMPETITORS_8;     break;
                        case NUM_COMPETITORS_24:  numCompetitors = NUM_COMPETITORS_16;    break;
                        case NUM_COMPETITORS_32:  numCompetitors = NUM_COMPETITORS_24;    break;
                    }

                }break;

                case MENU_ITEM_AI_CAR_SPEED:
                {
                    // Change the ai car speed

                    switch ( aiCarSpeed )
                    {
                        case AI_CAR_SPEED_SLOW:   /* Do nothing */                      break;
                        case AI_CAR_SPEED_NORMAL:   aiCarSpeed = AI_CAR_SPEED_SLOW;     break;
                        case AI_CAR_SPEED_FAST:     aiCarSpeed = AI_CAR_SPEED_NORMAL;   break;
                    }

                }break;

                case MENU_ITEM_GRID_SPACING:
                {
                    // Change the grid spacing

                    switch ( gridSpacing )
                    {
                        case GRID_SPACING_NEAR:     /* Do nothing */                     break;
                        case GRID_SPACING_NORMAL:   gridSpacing = GRID_SPACING_NEAR;     break;
                        case GRID_SPACING_FAR:      gridSpacing = GRID_SPACING_NORMAL;   break;
                    }

                }break;

            }  // end switch menu item

        }break;

        //----------------------------------------------------------------------
        // Right key pressed: change setting
        //----------------------------------------------------------------------

        case Window::KEYBOARD_RIGHT:
        {
            // Change the value of the currently selected setting

            switch ( menuItem )
            {
                case MENU_ITEM_TRACK_LENGHT:
                {
                    // Change the track lenght

                    switch ( trackLenght )
                    {
                        case TRACK_LENGHT_SHORT:   trackLenght = TRACK_LENGHT_NORMAL;   break;
                        case TRACK_LENGHT_NORMAL:  trackLenght = TRACK_LENGHT_LONG;     break;
                        case TRACK_LENGHT_LONG:    /* do nothing */                     break;
                    }

                }break;

                case MENU_ITEM_HILL_STEEPNESS:
                {
                    // Change the hill steepness

                    switch ( hillSteepness )
                    {
                        case HILL_STEEPNESS_GENTLE:   hillSteepness = HILL_STEEPNESS_NORMAL;    break;
                        case HILL_STEEPNESS_NORMAL:   hillSteepness = HILL_STEEPNESS_STEEP;     break;
                        case HILL_STEEPNESS_STEEP:    /* do nothing */                          break;
                    }

                }break;

                case MENU_ITEM_TURN_SHARPNESS:
                {
                    // Change the turn sharpness

                    switch ( turnSharpness )
                    {
                        case TURN_SHARPNESS_GENTLE:   turnSharpness = TURN_SHARPNESS_NORMAL;    break;
                        case TURN_SHARPNESS_NORMAL:   turnSharpness = TURN_SHARPNESS_SHARP;     break;
                        case TURN_SHARPNESS_SHARP:    /* do nothing */                          break;
                    }

                }break;

                case MENU_ITEM_NUM_COMPETITORS:
                {
                    // Change the number of competitors

                    switch ( numCompetitors )
                    {
                        case NUM_COMPETITORS_8:   numCompetitors = NUM_COMPETITORS_16;      break;
                        case NUM_COMPETITORS_16:  numCompetitors = NUM_COMPETITORS_24;      break;
                        case NUM_COMPETITORS_24:  numCompetitors = NUM_COMPETITORS_32;      break;
                        case NUM_COMPETITORS_32:  /* do nothing */                          break;
                    }

                }break;

                case MENU_ITEM_AI_CAR_SPEED:
                {
                    // Change the ai car speed

                    switch ( aiCarSpeed )
                    {
                        case AI_CAR_SPEED_SLOW:     aiCarSpeed = AI_CAR_SPEED_NORMAL;   break;
                        case AI_CAR_SPEED_NORMAL:   aiCarSpeed = AI_CAR_SPEED_FAST;     break;
                        case AI_CAR_SPEED_FAST:     /* do nothing */                    break;
                    }

                }break;

                case MENU_ITEM_GRID_SPACING:
                {
                    // Change the grid spacing

                    switch ( gridSpacing )
                    {
                        case GRID_SPACING_NEAR:     gridSpacing = GRID_SPACING_NORMAL;      break;
                        case GRID_SPACING_NORMAL:   gridSpacing = GRID_SPACING_FAR;         break;
                        case GRID_SPACING_FAR:      /* do nothing */                        break;
                    }

                }break;

            }  // end switch menu item

        }break;


        //----------------------------------------------------------------------
        // Escape key pressed: quit the menu
        //----------------------------------------------------------------------

        case Window::KEYBOARD_ESCAPE:
        {
            // Stop running the menu

            runMenu = false;

        } break;

        //----------------------------------------------------------------------
        // Enter key pressed: start the game
        //----------------------------------------------------------------------

        case Window::KEYBOARD_RETURN:
        {
            //------------------------------------------------------------------
            // Disengage all event handlers for the window: window will be
            // taken over by game
            //------------------------------------------------------------------

            window.setEvent_paint(0);
            window.setEvent_keyDown(0);
            window.setEvent_closed(0);

            //------------------------------------------------------------------
            // Now make up all of the values that are to be passed to the game
            // init function depending on what settings have been selected.
            // These are really the beef in the game settings. Most of the gameplay
            // tweaking is to be done here..
            //------------------------------------------------------------------

                // Decide on track lenght

                unsigned trackSections = 4096;

                switch ( Menu_Main::trackLenght )
                {
                    case TRACK_LENGHT_SHORT:    trackSections = 1024;   break;
                    case TRACK_LENGHT_NORMAL:   trackSections = 2048;   break;
                    case TRACK_LENGHT_LONG:     trackSections = 4096;   break;
                }

                // Decide on the number of comeptitors

                unsigned numCars = 8;

                switch ( Menu_Main::numCompetitors )
                {
                    case NUM_COMPETITORS_8:    numCars = 8;   break;
                    case NUM_COMPETITORS_16:   numCars = 16;  break;
                    case NUM_COMPETITORS_24:   numCars = 24;  break;
                    case NUM_COMPETITORS_32:   numCars = 32;  break;
                }

                // Decide on minimum and maximum hill heights

                float minHillHeight = 2000.0f;
                float maxHillHeight = 10000.0f;

                switch ( Menu_Main::hillSteepness )
                {
                    case HILL_STEEPNESS_GENTLE: minHillHeight = 3500.0f;    maxHillHeight = 20000.0f;   break;
                    case HILL_STEEPNESS_NORMAL: minHillHeight = 6000.0f;    maxHillHeight = 32500.0f;   break;
                    case HILL_STEEPNESS_STEEP:  minHillHeight = 8000.0f;    maxHillHeight = 35000.0f;   break;
                }

                // Decide on the minimum and maximum turn amounts

                float minTurnAmount = 2000.0f;
                float maxTurnAmount = 10000.0f;

                switch ( Menu_Main::turnSharpness )
                {
                    case TURN_SHARPNESS_GENTLE: minTurnAmount = 4500.0f;    maxTurnAmount = 25000.0f;   break;
                    case TURN_SHARPNESS_NORMAL: minTurnAmount = 6000.0f;    maxTurnAmount = 32500.0f;   break;
                    case TURN_SHARPNESS_SHARP:  minTurnAmount = 8000.0f;    maxTurnAmount = 35000.0f;   break;
                }

                // Decide on the players speed handicap and difference in ai car speed between grid positions

                float playerSpeedHandicap       = 4000.0f;
                float aiCarGridSpeedDifference  = 500.0f;

                switch ( Menu_Main::aiCarSpeed )
                {
                    case AI_CAR_SPEED_SLOW:     playerSpeedHandicap = 2000.0f;    aiCarGridSpeedDifference = 250.0f;   break;
                    case AI_CAR_SPEED_NORMAL:   playerSpeedHandicap = 1500.0f;    aiCarGridSpeedDifference = 175.0f;   break;
                    case AI_CAR_SPEED_FAST:     playerSpeedHandicap = 1000.0f;    aiCarGridSpeedDifference = 100.0f;   break;
                }

                // Decide on the grid spacing between cars at the starting grid

                float gridSpacingDistance = 2048;

                switch ( Menu_Main::gridSpacing )
                {
                    case GRID_SPACING_NEAR:     gridSpacingDistance = 2048.0f;  break;
                    case GRID_SPACING_NORMAL:   gridSpacingDistance = 4096.0f;  break;
                    case GRID_SPACING_FAR:      gridSpacingDistance = 8192.0f;  break;
                }

            //------------------------------------------------------------------
            // Start up the game using all the settings
            //------------------------------------------------------------------

            Game::initGame
            (
                &window,
                trackSections,
                numCars,
                minHillHeight,
                maxHillHeight,
                minTurnAmount,
                maxTurnAmount,
                playerSpeedHandicap,
                aiCarGridSpeedDifference,
                gridSpacingDistance
            );

            //------------------------------------------------------------------
            // If the window has been shut down then stop the run menu loop,
            // otherwise restore all over-ridden event handlers..
            //------------------------------------------------------------------

            if ( window.exists() )
            {
                //--------------------------------------------------------------
                // Rengage all event handlers for the window:
                // game has over-riden them
                //--------------------------------------------------------------

                window.setEvent_paint(event_draw);
                window.setEvent_keyDown(event_keyDown);
                window.setEvent_closed(event_closed);
            }
            else
            {
                //--------------------------------------------------------------
                // Window no longer exists. stop showing the menu.
                //--------------------------------------------------------------

                runMenu = false;
            }

        } break;

        //----------------------------------------------------------------------
        // Default case: just in to stop compiler warnings..
        //----------------------------------------------------------------------

        default: ;
    }
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Name:     Menu_Main::event_closed
Purpose:  Just stops the execution of the window after it is closed.
Params:   Window
Returns:  none

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

// No unreferenced param warning

#pragma warning(disable:4100)

void Menu_Main::event_closed ( Window & window )
{
    // Stop running the menu

    runMenu = false;
}

// Restore this warning to normal

#pragma warning(default:4100)

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Name:     Menu_Main::event_draw
Purpose:  Draws the menu screen.
Params:   Window to paint to.
Returns:  none

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

void Menu_Main::event_draw( Window & window )
{
    // Clear the screen to black

    window.clear(0,0,0);

    // Draw the title of the screen centered

    bitFont->drawText
    (
        "WHEELS OF STEEL",
        Game::RESOLUTION_X / 2 - ( strlen("WHEELS OF STEEL") * bitFont->getWidth() ) / 2,
        bitFont->getHeight(),
        &window
    );

    // Draw a the menu bar under the title

    window.drawBitmap
    (
        bmpMenuBar,
        0,
        bitFont->getHeight() * 3
    );

    // Decide what height to draw the menu arrow at depending on which item is selected

    int arrowY = 0;

    switch ( menuItem )
    {
        case MENU_ITEM_TRACK_LENGHT:    arrowY = int(bitFont->getHeight() * 4.5);   break;
        case MENU_ITEM_HILL_STEEPNESS:  arrowY = int(bitFont->getHeight() * 6.0);   break;
        case MENU_ITEM_TURN_SHARPNESS:  arrowY = int(bitFont->getHeight() * 7.5);   break;
        case MENU_ITEM_NUM_COMPETITORS: arrowY = int(bitFont->getHeight() * 9.0);   break;
        case MENU_ITEM_AI_CAR_SPEED:    arrowY = int(bitFont->getHeight() * 10.5);  break;
        case MENU_ITEM_GRID_SPACING:    arrowY = int(bitFont->getHeight() * 12.0);  break;
    }

    // Draw the menu arrow showing which menu item is selected

    window.drawBitmap
    (
        bmpArrow,
        10,
        arrowY
    );

    // This setting holds the x coordinate for the menu settings display: i.e where 'hard, normal, short' etc are drawn

    int settingsX = 475;

    // Draw a the menu bar above the 'ENTER TO SELECT ITEM' hint

    window.drawBitmap
    (
        bmpMenuBar,
        0,
        Game::RESOLUTION_Y - bitFont->getHeight() * 5
    );

    // Draw the 'TRACK LENGHT' MENU ITEM

    bitFont->drawText
    (
        "TRACK LENGHT ",
        bitFont->getWidth () * 2,
        int(bitFont->getHeight() * 4.5),
        &window
    );

    // Draw the track lenght current setting

    switch ( trackLenght )
    {
        case TRACK_LENGHT_SHORT:    bitFont->drawText( "SHORT ", settingsX, int(bitFont->getHeight() * 4.5), &window);   break;
        case TRACK_LENGHT_NORMAL:   bitFont->drawText( "NORMAL", settingsX, int(bitFont->getHeight() * 4.5), &window);   break;
        case TRACK_LENGHT_LONG:     bitFont->drawText( "LONG  ", settingsX, int(bitFont->getHeight() * 4.5), &window);   break;
    }

    // Draw the 'HILL STEEPNESS' MENU ITEM

    bitFont->drawText
    (
        "HILL STEEPNESS",
        bitFont->getWidth () * 2,
        bitFont->getHeight() * 6,
        &window
    );

    // Draw the hill steepness current setting

    switch ( hillSteepness )
    {
        case HILL_STEEPNESS_GENTLE: bitFont->drawText( "GENTLE", settingsX, int(bitFont->getHeight() * 6), &window);   break;
        case HILL_STEEPNESS_NORMAL: bitFont->drawText( "NORMAL", settingsX, int(bitFont->getHeight() * 6), &window);   break;
        case HILL_STEEPNESS_STEEP:  bitFont->drawText( "STEEP ", settingsX, int(bitFont->getHeight() * 6), &window);   break;
    }

    // Draw the 'TURN SHARPNESS ' MENU ITEM

    bitFont->drawText
    (
        "TURN SHARPNESS",
        bitFont->getWidth () * 2,
        int(bitFont->getHeight() * 7.5),
        &window
    );

    // Draw the turn sharpness current setting

    switch ( turnSharpness )
    {
        case TURN_SHARPNESS_GENTLE: bitFont->drawText( "GENTLE", settingsX, int(bitFont->getHeight() * 7.5), &window);   break;
        case TURN_SHARPNESS_NORMAL: bitFont->drawText( "NORMAL", settingsX, int(bitFont->getHeight() * 7.5), &window);   break;
        case TURN_SHARPNESS_SHARP:  bitFont->drawText( "SHARP ", settingsX, int(bitFont->getHeight() * 7.5), &window);   break;
    }

    // Draw the 'NUM COMPETITORS' MENU ITEM

    bitFont->drawText
    (
        "NUM COMPETITORS ",
        bitFont->getWidth () * 2,
        bitFont->getHeight() * 9,
        &window
    );

    // Draw the num competitors setting

    switch ( numCompetitors )
    {
        case NUM_COMPETITORS_8:     bitFont->drawText( "8 ", settingsX, int(bitFont->getHeight() * 9), &window);   break;
        case NUM_COMPETITORS_16:    bitFont->drawText( "16", settingsX, int(bitFont->getHeight() * 9), &window);   break;
        case NUM_COMPETITORS_24:    bitFont->drawText( "24", settingsX, int(bitFont->getHeight() * 9), &window);   break;
        case NUM_COMPETITORS_32:    bitFont->drawText( "32", settingsX, int(bitFont->getHeight() * 9), &window);   break;
    }

    // Draw the 'AI CAR SPEED' MENU ITEM

    bitFont->drawText
    (
        "AI CAR SPEED ",
        bitFont->getWidth () * 2,
        int(bitFont->getHeight() * 10.5),
        &window
    );

    // Draw the ai car speed setting

    switch ( aiCarSpeed )
    {
        case AI_CAR_SPEED_SLOW:     bitFont->drawText( "SLOW"   , settingsX, int(bitFont->getHeight() * 10.5), &window);   break;
        case AI_CAR_SPEED_NORMAL:   bitFont->drawText( "NORMAL" , settingsX, int(bitFont->getHeight() * 10.5), &window);   break;
        case AI_CAR_SPEED_FAST:     bitFont->drawText( "FAST"   , settingsX, int(bitFont->getHeight() * 10.5), &window);   break;
    }

    // Draw the 'GRID SPACING ' MENU ITEM

    bitFont->drawText
    (
        "GRID SPACING ",
        bitFont->getWidth () * 2,
        bitFont->getHeight() * 12,
        &window
    );

    // Draw the grid spacing setting

    switch ( gridSpacing )
    {
        case GRID_SPACING_NEAR:     bitFont->drawText( "NEAR"   , settingsX, int(bitFont->getHeight() * 12), &window);   break;
        case GRID_SPACING_NORMAL:   bitFont->drawText( "NORMAL" , settingsX, int(bitFont->getHeight() * 12), &window);   break;
        case GRID_SPACING_FAR:      bitFont->drawText( "FAR"    , settingsX, int(bitFont->getHeight() * 12), &window);   break;
    }

    // Draw the 'USE ARROW KEYS TO MODIFY' hint

    bitFont->drawText
    (
        "USE ARROW KEYS TO MODIFY",
        Game::RESOLUTION_X / 2 - ( strlen("USE ARROW KEYS TO MODIFY") * bitFont->getWidth() ) / 2,
        Game::RESOLUTION_Y - bitFont->getHeight() * 3,
        &window
    );

    // Draw the 'ENTER BEGINS. ESC QUITS.' hint

    bitFont->drawText
    (
        "ENTER BEGINS, ESC QUITS.",
        Game::RESOLUTION_X / 2 - ( strlen("ENTER BEGINS, ESC QUITS.") * bitFont->getWidth() ) / 2,
        Game::RESOLUTION_Y - bitFont->getHeight() * 1,
        &window
    );

}


