// Author : Chris Tolley
// Date   : 8/26/2004
// Menu.cpp contains the class definition for a menu class to use with the
// game Survival

#include <windows.h>
#include <gl/gl.h>
#include <gl/glu.h>

#include "InputSystem.h"
#include "Menu.h"
#include "ScreenWriter.h"
#include "logger.h"

// Constructor
Menu::Menu() : m_Input( NULL )
{}


// Destructor
Menu::~Menu()
{}

// Renders the menu to the screen
void Menu::Render() const
{
	// Clear the buffers
	glClearColor( 0, 0, 0, 0 );
	glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

	// Render the options to the user
	int args = 0;
	float white[3] = { 1, 1, 1 };
	ScreenWriter::Render( 50, 180, white, "Press the button of your choice%n",
							&args );

	ScreenWriter::Render( 50, 160, white, "1. Play Survival.", &args );
	ScreenWriter::Render( 50, 140, white, "2. Observe the bugs.", &args );
	ScreenWriter::Render( 50, 120, white, "3. Exit the game.", &args );
}// End Menu::Render


// Updates the menu and returns what the user selected
MenuChoice Menu::Update() const
{
	// Update input
	m_Input->Update();

	// Get a pointer to the keyboard
	CKeyboard* board = m_Input->GetKeyboard();

	// If the "1" key is down
	if( board->KeyDown( DIK_1 ) )
	{
		// The user wants to play the game
		return GAME;
	}// End if

	// If the "2" key is down
	if( board->KeyDown( DIK_2 ) )
	{
		// The user wants to observe a game
		return SPECTATE;
	}// End if

	// If the "3" key is down
	if( board->KeyDown( DIK_3 ) )
	{
		// The user wants to exit the program
		return EXIT;
	}// End if

	// Return menu by default
	return MENU;
}// End Menu::Update