/***************************************************************************
 *   Copyright (C) 2004-2005 by                                            *
 *     Paolo Sacconier   <axa1981@tin.it>                                  *
 *     Francesco Tamagni <minchiahead@hacari.org>                          *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#ifndef GILLOMENU_H
#define GILLOMENU_H

#include "main.h"

#include "video.h"
#include "sound.h"
#include "player.h"
#include "event.h"

namespace gillo {

/**
The menu game mode.

@author $AUTHOR$
*/
class Menu{
	static const int	numElements = 3;
	static const int	numCars = 2;
	static const int	numPlayers = 2;
	static const float	elementCoord[numElements][4];
	
	enum Status {
		VISIBLE,
		INVISIBLE,
		CHANGE_VEHICLE
	};
	Video&	video;
	Sound&	sound;
	queue<Event>& equeue;
	Status	status;
	float	selectorCoord[4];
	Img*	selectorPtr;
	Img* 	carPicPtr[numPlayers][numCars];
	Img*	carTextPtr[numPlayers][numCars];
	Img*	leftButtonPtr[numPlayers];
	Img*	rightButtonPtr[numPlayers];
	Img*	okPtr[numPlayers];
	Img*	cvBackPtr;
	Img*	aImgPtr;
	int	selectedElement;
	int 	selectedCar[numPlayers];
	int	currentCar[numPlayers];
	bool	gameTriggered;
	bool 	ok[numPlayers];
	
	void handleKeyDown( SDL_keysym* keysym );
	void handleKeyUp  ( SDL_keysym* keysym );
	void showCar(int playerId, int desiredCar);
	void loadTextures();
	void unloadTextures();
public:
    Menu(Video& v, Sound& s, queue<Event>& eq);

    ~Menu();
	void update(double dt);
	void react(SDL_Event *event);
	void react(const Event::Type et);
	bool changeStatus(Status s);
};

};

#endif
