
#include "ConsoleCommand.h"
#include "MemoryManager/DebugNew.h"

extern Console* console;
extern bool usingRTSCamera;
extern SimpleCamera* cam;
extern RTSCamera* rtsCam;
extern bool debugElevation;
extern int tempTime;
extern int lastTime;

int gameNumberToFound;

void r_skipFrustumUpdate(char* cmd, Console* csl)
{
	if(strcmp(cmd,"r_skipFrustumUpdate")==0)
	{
		csl->DispMsg(0,1,0,1,"Bloc l'update du frustum de vision du renderer.");
		if(Renderer::getInstance().skipFrustumUpdate)
			csl->DispMsg(0,1,0,1,"   courant 1 ; defaut 0");
		else
			csl->DispMsg(0,1,0,1,"   courant 0 ; defaut 0");
	}
	else
	{
		int rep=0;
		sscanf(cmd,"r_skipFrustumUpdate %d",&rep);
		Renderer::getInstance().skipFrustumUpdate = (rep!=0);
	}
}

void r_showQuadTree(char* cmd, Console* csl)
{
	if(strcmp(cmd,"r_showQuadTree")==0)
	{
		csl->DispMsg(0,1,0,1,"Affiche le quad-tree.");
		if(Renderer::getInstance().showQuadTree)
			csl->DispMsg(0,1,0,1,"   courant 1 ; defaut 0");
		else
			csl->DispMsg(0,1,0,1,"   courant 0 ; defaut 0");
	}
	else
	{
		int rep=0;
		sscanf(cmd,"r_showQuadTree %d",&rep);
		Renderer::getInstance().showQuadTree = (rep!=0);
	}
}

void r_showUnitLife(char* cmd, Console* csl)
{
	if(strcmp(cmd,"r_showUnitLife")==0)
	{
		csl->DispMsg(0,1,0,1,"Affiche la vie des unités.");
		if(Renderer::getInstance().showUnitLife)
			csl->DispMsg(0,1,0,1,"   courant 1 ; defaut 1");
		else
			csl->DispMsg(0,1,0,1,"   courant 0 ; defaut 1");
	}
	else
	{
		int rep=0;
		sscanf(cmd,"r_showUnitLife %d",&rep);
		Renderer::getInstance().showUnitLife = (rep!=0);
	}
}

void r_showWireGround(char* cmd, Console* csl)
{
	if(strcmp(cmd,"r_showWireGround")==0)
	{
		csl->DispMsg(0,1,0,1,"Affiche le terrain en wire-frame et avec les normals.");
		if(Renderer::getInstance().showWireGround)
			csl->DispMsg(0,1,0,1,"   courant 1 ; defaut 0");
		else
			csl->DispMsg(0,1,0,1,"   courant 0 ; defaut 0");
	}
	else
	{
		int rep=0;
		sscanf(cmd,"r_showWireGround %d",&rep);
		Renderer::getInstance().showWireGround = (rep!=0);
	}
}

void r_renderWater(char* cmd, Console* csl)
{
	if(strcmp(cmd,"r_renderWater")==0)
	{
		csl->DispMsg(0,1,0,1,"Affiche ou non l'eau sur la map.");
		if(Renderer::getInstance().renderWaterZone)
			csl->DispMsg(0,1,0,1,"   courant 1 ; defaut 1");
		else
			csl->DispMsg(0,1,0,1,"   courant 0 ; defaut 1");
	}
	else
	{
		int rep=0;
		sscanf(cmd,"r_renderWater %d",&rep);
		Renderer::getInstance().renderWaterZone = (rep!=0);
	}
}

void r_renderTreeLeaf(char* cmd, Console* csl)
{
	if(strcmp(cmd,"r_renderTreeLeaf")==0)
	{
		csl->DispMsg(0,1,0,1,"Affiche ou non les feuilles des arbres.");
		if(Renderer::getInstance().renderTreeLeaf)
			csl->DispMsg(0,1,0,1,"   courant 1 ; defaut 1");
		else
			csl->DispMsg(0,1,0,1,"   courant 0 ; defaut 1");
	}
	else
	{
		int rep=0;
		sscanf(cmd,"r_renderTreeLeaf %d",&rep);
		Renderer::getInstance().renderTreeLeaf = (rep!=0);
	}
}

void r_renderTree(char* cmd, Console* csl)
{
	if(strcmp(cmd,"r_renderTree")!=0)
	{
		csl->DispMsg(0,1,0,1,"inverse l'activation de l'affichage de tronc et feuilles des arbres.");
	}
	else
	{
		Renderer::getInstance().renderTreeLeaf = !Renderer::getInstance().renderTreeLeaf;
		Renderer::getInstance().renderTreeTrunk = !Renderer::getInstance().renderTreeTrunk;
	}
}

void r_renderTreeTrunk(char* cmd, Console* csl)
{
	if(strcmp(cmd,"r_renderTreeTrunk")==0)
	{
		csl->DispMsg(0,1,0,1,"Affiche ou non les troncs des arbres.");
		if(Renderer::getInstance().renderTreeTrunk)
			csl->DispMsg(0,1,0,1,"   courant 1 ; defaut 1");
		else
			csl->DispMsg(0,1,0,1,"   courant 0 ; defaut 1");
	}
	else
	{
		int rep=0;
		sscanf(cmd,"r_renderTreeTrunk %d",&rep);
		Renderer::getInstance().renderTreeTrunk = (rep!=0);
	}
}

void r_useGLFog(char* cmd, Console* csl)
{
	if(strcmp(cmd,"r_useGLFog")==0)
	{
		csl->DispMsg(0,1,0,1,"Affiche ou non du brouillard.");
		if(Renderer::getInstance().useGLFog)
			csl->DispMsg(0,1,0,1,"   courant 1 ; defaut 1");
		else
			csl->DispMsg(0,1,0,1,"   courant 0 ; defaut 1");
	}
	else
	{
		int rep=0;
		sscanf(cmd,"r_useGLFog %d",&rep);
		Renderer::getInstance().useGLFog = (rep!=0);
	}
}

void r_useGLlighting(char* cmd, Console* csl)
{
	if(strcmp(cmd,"r_useGLlighting")==0)
	{
		csl->DispMsg(0,1,0,1,"Utilise ou non l'eclairage OpenGL pour eclairer la map.");
		if(Renderer::getInstance().useGLlighting)
			csl->DispMsg(0,1,0,1,"   courant 1 ; defaut 1");
		else
			csl->DispMsg(0,1,0,1,"   courant 0 ; defaut 1");
	}
	else
	{
		int rep=0;
		sscanf(cmd,"r_useGLlighting %d",&rep);
		Renderer::getInstance().useGLlighting = (rep!=0);
	}
}

void r_useGroundTexture(char* cmd, Console* csl)
{
	if(strcmp(cmd,"r_useGroundTexture")==0)
	{
		csl->DispMsg(0,1,0,1,"Utilise ou non les texture pour afficher la map.");
		if(Renderer::getInstance().useGroundTexture)
			csl->DispMsg(0,1,0,1,"   courant 1 ; defaut 1");
		else
			csl->DispMsg(0,1,0,1,"   courant 0 ; defaut 1");
	}
	else
	{
		int rep=0;
		sscanf(cmd,"r_useGroundTexture %d",&rep);
		Renderer::getInstance().useGroundTexture = (rep!=0);
	}
}


void z_showDangerZoneIntensity(char* cmd, Console* csl)
{
	if(strcmp(cmd,"z_showDangerZoneIntensity")==0)
	{
		csl->DispMsg(0,1,0,1,"Affiche ou non les zone de danger sur la map.");
		if(Renderer::getInstance().showDangerZoneIntensity)
			csl->DispMsg(0,1,0,1,"   courant 1 ; defaut 0");
		else
			csl->DispMsg(0,1,0,1,"   courant 0 ; defaut 0");
	}
	else
	{
		int rep=0;
		sscanf(cmd,"z_showDangerZoneIntensity %d",&rep);
		Renderer::getInstance().showDangerZoneIntensity = (rep!=0);
	}
}

void z_showStrongZoneIntensity(char* cmd, Console* csl)
{
	if(strcmp(cmd,"z_showStrongZoneIntensity")==0)
	{
		csl->DispMsg(0,1,0,1,"Affiche ou non les zones fortes sur la map.");
		if(Renderer::getInstance().showStrongZoneIntensity)
			csl->DispMsg(0,1,0,1,"   courant 1 ; defaut 0");
		else
			csl->DispMsg(0,1,0,1,"   courant 0 ; defaut 0");
	}
	else
	{
		int rep=0;
		sscanf(cmd,"z_showStrongZoneIntensity %d",&rep);
		Renderer::getInstance().showStrongZoneIntensity = (rep!=0);
	}
}

void z_showNaturelAxeIntensity(char* cmd, Console* csl)
{
	if(strcmp(cmd,"z_showNaturelAxeIntensity")==0)
	{
		csl->DispMsg(0,1,0,1,"Affiche ou non les axes naturels sur la map.");
		if(Renderer::getInstance().showNaturelAxeIntensity)
			csl->DispMsg(0,1,0,1,"   courant 1 ; defaut 0");
		else
			csl->DispMsg(0,1,0,1,"   courant 0 ; defaut 0");
	}
	else
	{
		int rep=0;
		sscanf(cmd,"z_showNaturelAxeIntensity %d",&rep);
		Renderer::getInstance().showNaturelAxeIntensity = (rep!=0);
	}
}

void g_cameraFree(char* cmd, Console* csl)
{
	if(strcmp(cmd,"g_cameraFree")==0)
	{
		csl->DispMsg(0,1,0,1,"Permet d'utilise ou non la camera libre.");
		if(usingRTSCamera)
			csl->DispMsg(0,1,0,1,"   courant 1 ; defaut 0");
		else
			csl->DispMsg(0,1,0,1,"   courant 0 ; defaut 0");
	}
	else
	{
		int rep=0;
		sscanf(cmd,"g_cameraFree %d",&rep);
		if(usingRTSCamera) {
			cam->p.setPosition(rtsCam->p.getPosition());
			cam->p.setAlphaXZ(rtsCam->p.getAlphaXZ());
			cam->p.setAlphaZY(rtsCam->p.getAlphaZY());
			cam->p.compute();
			glutWarpPointer(400,300);
			glutSetCursor(GLUT_CURSOR_NONE);
		}
		else
			glutSetCursor(GLUT_CURSOR_RIGHT_ARROW);
		usingRTSCamera = (rep==0);
	}
}

void g_cameraSpeed(char* cmd, Console* csl)
{
	if(strcmp(cmd,"g_cameraSpeed")==0)
	{
		csl->DispMsg(0,1,0,1,"Permet de regler la vitesse de translation de la camera de vue en mode RTS.");
		csl->DispMsg(0,1,0,1,"   courant %f ; defaut 0.065",rtsCam->getMoveSpeed());
	}
	else
	{
		float rep=0;
		sscanf(cmd,"g_cameraSpeed %f",&rep);
		rtsCam->setMoveSpeed(rep);
	}
}



void r_timeFactor(char* cmd, Console* csl){
	if(strcmp(cmd,"r_timeFactor")==0)
	{
		csl->DispMsg(0,1,0,1,"Le facteur d'ecoulement du temp. Doit etre comprit entre 0 et 1.");
			csl->DispMsg(0,1,0,1,"   courant %f ; defaut 1.0",Renderer::getInstance().timeFactor);
	}
	else
	{
		float tmp;
		sscanf(cmd,"r_timeFactor %f",&tmp);
		if(tmp>=0.0f && tmp<=1.0f)
			Renderer::getInstance().timeFactor = tmp;
		else
			csl->DispMsg(1,0,0,1,"valeur invalide.");
	}
}

void who(char* cmd, Console* csl){
	csl->DispMsg(1.0f,1.0f,1.0f,1.0f,"L'equipe de developpement :");
	csl->DispMsg(1.0f,1.0f,1.0f,1.0f,"--------------------------");
	csl->DispMsg(1.0f,1.0f,1.0f,1.0f,"| Bafman");
	csl->DispMsg(0.0f,1.0f,1.0f,1.0f,"| BatroX");
	csl->DispMsg(1.0f,1.0f,1.0f,1.0f,"| BT");
	csl->DispMsg(1.0f,1.0f,1.0f,1.0f,"| Cap");
	csl->DispMsg(1.0f,1.0f,1.0f,1.0f,"| DaftDef");
	csl->DispMsg(1.0f,1.0f,1.0f,1.0f,"| D@m'S");
	csl->DispMsg(1.0f,0.5f,1.0f,1.0f,"| Lapinou");
	csl->DispMsg(1.0f,1.0f,0.0f,1.0f,"| Masa le Chinois");
	csl->DispMsg(1.0f,1.0f,1.0f,1.0f,"| Matthieu");
	csl->DispMsg(1.0f,1.0f,1.0f,1.0f,"| Patou");
	csl->DispMsg(1.0f,0.0f,0.0f,1.0f,"| SebH");
}

void cache(char* cmd, Console* csl){
	if(strcmp(cmd,"z_zette")==0)
	{
		csl->DispMsg(0,1,0,1,"amusez vous a trouver le bon parametre...");
	}
	else
	{
		char rep[256];
		sscanf(cmd,"z_zette %s",rep);
		if(strcmp(rep,"enorme")==0) {
			csl->DispMsg(1.0f,1.0f,1.0f,1.0f,"Comment c pourri :)");
			csl->DispMsg(1.0f,1.0f,1.0f,1.0f," ------");
			csl->DispMsg(1.0f,1.0f,1.0f,1.0f,"|      |");
			csl->DispMsg(1.0f,1.0f,1.0f,1.0f,"|      |");
			csl->DispMsg(1.0f,1.0f,1.0f,1.0f," ----------------|---");
			csl->DispMsg(1.0f,1.0f,1.0f,1.0f,"|                |   |");
			csl->DispMsg(1.0f,1.0f,1.0f,1.0f,"|                |   |");
			csl->DispMsg(1.0f,1.0f,1.0f,1.0f," ----------------|---");
			csl->DispMsg(1.0f,1.0f,1.0f,1.0f,"|      |");
			csl->DispMsg(1.0f,1.0f,1.0f,1.0f,"|      |");
			csl->DispMsg(1.0f,1.0f,1.0f,1.0f," ------");
		}
		else if (strcmp(rep,"Batrox")==0) {
			csl->DispMsg(1.0f,0.5f,1.0f,1.0f," -------");
			csl->DispMsg(1.0f,0.5f,1.0f,1.0f,"|       |");
			csl->DispMsg(1.0f,0.5f,1.0f,1.0f,"|       |");
			csl->DispMsg(1.0f,0.5f,1.0f,1.0f,"|       |");
			csl->DispMsg(1.0f,0.5f,1.0f,1.0f,"|       |");
			csl->DispMsg(1.0f,0.5f,1.0f,1.0f,"|       |");
			csl->DispMsg(1.0f,0.5f,1.0f,1.0f," ----------------------------|---");
			csl->DispMsg(1.0f,0.5f,1.0f,1.0f,"|                            |   |");
			csl->DispMsg(1.0f,0.5f,1.0f,1.0f,"|                            |   |");
			csl->DispMsg(1.0f,0.5f,1.0f,1.0f,"|                            |   |");
			csl->DispMsg(1.0f,0.5f,1.0f,1.0f," ----------------------------|---");
			csl->DispMsg(1.0f,0.5f,1.0f,1.0f,"|       |");
			csl->DispMsg(1.0f,0.5f,1.0f,1.0f,"|       |");
			csl->DispMsg(1.0f,0.5f,1.0f,1.0f,"|       |");
			csl->DispMsg(1.0f,0.5f,1.0f,1.0f,"|       |");
			csl->DispMsg(1.0f,0.5f,1.0f,1.0f,"|       |");
			csl->DispMsg(1.0f,0.5f,1.0f,1.0f," -------");
		}
		else if (strcmp(rep,"Bafman")==0) {
			csl->DispMsg(1.0f,0.0f,0.0f,1.0f," error... this screen resolution is not sufficient to display such a big BEEEEEP !!!");
		}
		else if (strcmp(rep,"Masa")==0) {
			csl->DispMsg(1.0f,1.0f,0.0f,1.0f," -");
			csl->DispMsg(1.0f,1.0f,0.0f,1.0f,"| |");
			csl->DispMsg(1.0f,1.0f,0.0f,1.0f," -|--");
			csl->DispMsg(1.0f,1.0f,0.0f,1.0f,"| |  |");
			csl->DispMsg(1.0f,1.0f,0.0f,1.0f," -|--");
			csl->DispMsg(1.0f,1.0f,0.0f,1.0f,"| |");	
			csl->DispMsg(1.0f,1.0f,0.0f,1.0f," -");
		}
		else {
		csl->DispMsg(0,1,0,1,"Vous n'avez pas trouve le bon parametre heu!!!.");
		}
	}
}


void z_showStrongZoneCases(char* cmd, Console* csl)
{
	if(strcmp(cmd,"z_showStrongZoneCases")==0)
	{
		csl->DispMsg(0,1,0,1,"Affiche ou non une zone forte precise.");
		csl->DispMsg(0,1,0,1,"z_showStrongrZoneCases ID_de_la_zone");
		csl->DispMsg(0,1,0,1,"   courant %d ; defaut -1(commande desactive)",Renderer::getInstance().showStrongZoneCases);
	}
	else
	{
		int rep=0;
		sscanf(cmd,"z_showStrongZoneCases %d",&rep);
		Renderer::getInstance().showStrongZoneCases = rep;
	}
}

void z_showNaturelAxeZoneCases(char* cmd, Console* csl)
{
	if(strcmp(cmd,"z_showNaturelAxeZoneCases")==0)
	{
		csl->DispMsg(0,1,0,1,"Affiche ou non un axe naturel precis.");
		csl->DispMsg(0,1,0,1,"z_showNaturelAxeZoneCases ID_de_la_zone");
		csl->DispMsg(0,1,0,1,"   courant %d ; defaut -1(commande desactive)",Renderer::getInstance().showNaturalAxeCases);
	}
	else
	{
		int rep=0;
		sscanf(cmd,"z_showNaturelAxeZoneCases %d",&rep);
		Renderer::getInstance().showNaturalAxeCases = rep;
	}
}

void z_showForestZoneCases(char* cmd, Console* csl)
{
	if(strcmp(cmd,"z_showForestZoneCases")==0)
	{
		csl->DispMsg(0,1,0,1,"Affiche ou non une foret precise.");
		csl->DispMsg(0,1,0,1,"z_showForestZoneCases ID_de_la_zone");
		csl->DispMsg(0,1,0,1,"   courant %d ; defaut -1(commande desactive)",Renderer::getInstance().showForestZoneCases);
	}
	else
	{
		int rep=0;
		sscanf(cmd,"z_showForestZoneCases %d",&rep);
		Renderer::getInstance().showForestZoneCases = rep;
	}
}

void r_changeTileSet(char* cmd, Console* csl)
{
	if(strcmp(cmd,"r_changeTileSet")==0)
	{
		csl->DispMsg(0,1,0,1,"Permet de changer le tileSet afficher. Seul les texture afficher sont en memoire video.");
	}
	else
	{
		int rep=0;
		sscanf(cmd,"r_changeTileSet %d",&rep);
		if(rep==0) {
			//
			csl->DispMsg(1.0f,0.0f,0.0f,1.0f,"Tileset changer a %s","textures/tileset/forest/");
			Renderer::getInstance().changeTileSet("textures/tileset/forest/");
			//	on ne prend pas en compte se temp de chargement(et celui d'avant) car le temp est grand
			//et les particule peuvent être propulser trop loin.
			tempTime = glutGet(GLUT_ELAPSED_TIME);
			lastTime = tempTime;
		}
		else if(rep==1) {
			//
			csl->DispMsg(1.0f,0.0f,0.0f,1.0f,"Tileset changer a %s","textures/tileset/psycho/");
			Renderer::getInstance().changeTileSet("textures/tileset/psycho/");
			//	on ne prend pas en compte se temp de chargement(et celui d'avant) car le temp est grand
			//et les particule peuvent être propulser trop loin.
			tempTime = glutGet(GLUT_ELAPSED_TIME);
			lastTime = tempTime;
		}
		else if(rep==2) {
			//
			csl->DispMsg(1.0f,0.0f,0.0f,1.0f,"Tileset changer a %s","textures/tileset/snow/");
			Renderer::getInstance().changeTileSet("textures/tileset/snow/");
			//	on ne prend pas en compte se temp de chargement(et celui d'avant) car le temp est grand
			//et les particule peuvent être propulser trop loin.
			tempTime = glutGet(GLUT_ELAPSED_TIME);
			lastTime = tempTime;
		}
		else
			csl->DispMsg(1.0f,0.0f,0.0f,1.0f,"Tileset non existant!");
	}
}

void r_debugElevation(char* cmd, Console* csl)
{
	if(strcmp(cmd,"r_debugElevation")==0)
	{
		csl->DispMsg(0,1,0,1,"Permet de debuguer la calcul de la hauteur du terrain pour un point donne.");
		if(debugElevation)
			csl->DispMsg(0,1,0,1,"   courant 1 ; defaut 0");
		else
			csl->DispMsg(0,1,0,1,"   courant 0 ; defaut 0");
	}
	else
	{
		int rep=0;
		sscanf(cmd,"r_debugElevation %d",&rep);
		debugElevation = (rep!=0);
	}
}

void showBlockCases(char* cmd, Console* csl)
{
	if(strcmp(cmd,"showBlockCases")==0)
	{
		csl->DispMsg(0,1,0,1,"Permet d'afficher les cases non franchissables.");
		if(debugElevation)
			csl->DispMsg(0,1,0,1,"   courant 1 ; defaut 0");
		else
			csl->DispMsg(0,1,0,1,"   courant 0 ; defaut 0");
	}
	else
	{
		int rep=0;
		sscanf(cmd,"showBlockCases %d",&rep);
		Renderer::getInstance().showBlockCase = (rep!=0);
	}
}


/*void loadMap(char* cmd, Console* csl) {
	if(strcmp(cmd,"loadMap")==0)
	{
		csl->DispMsg(0,1,0,1,"Permet charger une map contenue dans un seul bmp.");
		csl->DispMsg(0,1,0,1,"loadMap <chemin de la map relatif au .exe>");
	}
	else
	{
		char rep[256];
		FILE* f;
		sscanf(cmd,"loadMap %s",rep);
		f = fopen(rep,"rb");
		if(f!=NULL) {
			ground::GroundMap::getInstance().loadMap(rep);
			Renderer::getInstance().loadGroundMap(ground::GroundMap::getInstance(),"textures/tileset/forest/");
		}
		else {
			csl->DispMsg(1.0f,0.0f,0.0f,1.0f,"La map n'a pas ete trouvee.");
		}
	}
}*/

void r_showParticleAABB(char* cmd, Console* csl)
{
	if(strcmp(cmd,"r_showParticleAABB")==0)
	{
		csl->DispMsg(0,1,0,1,"Permet d'afficher la AABB des particules.");
		if(Renderer::getInstance().showParticleAABB)
			csl->DispMsg(0,1,0,1,"   courant 1 ; defaut 0");
		else
			csl->DispMsg(0,1,0,1,"   courant 0 ; defaut 0");
	}
	else
	{
		int rep=0;
		sscanf(cmd,"r_showParticleAABB %d",&rep);
		Renderer::getInstance().showParticleAABB = (rep!=0);
	}
}


void r_showModeleLocalAABB(char* cmd, Console* csl)
{
	if(strcmp(cmd,"r_showModeleLocalAABB")==0)
	{
		csl->DispMsg(0,1,0,1,"Permet d'afficher la AABB des modeles dans leur repere local.");
		if(Renderer::getInstance().showModeleLocalAABB)
			csl->DispMsg(0,1,0,1,"   courant 1 ; defaut 0");
		else
			csl->DispMsg(0,1,0,1,"   courant 0 ; defaut 0");
	}
	else
	{
		int rep=0;
		sscanf(cmd,"r_showModeleLocalAABB %d",&rep);
		Renderer::getInstance().showModeleLocalAABB = (rep!=0);
	}
}
void r_showModeleWorldAABB(char* cmd, Console* csl)
{
	if(strcmp(cmd,"r_showModeleWorldAABB")==0)
	{
		csl->DispMsg(0,1,0,1,"Permet d'afficher la AABB des modeles dans le repere globale.");
		if(Renderer::getInstance().showModeleWorldAABB)
			csl->DispMsg(0,1,0,1,"   courant 1 ; defaut 0");
		else
			csl->DispMsg(0,1,0,1,"   courant 0 ; defaut 0");
	}
	else
	{
		int rep=0;
		sscanf(cmd,"r_showModeleWorldAABB %d",&rep);
		Renderer::getInstance().showModeleWorldAABB = (rep!=0);
	}
}


void r_setLimitTimeForAnim(char* cmd, Console* csl)
{
	if(strcmp(cmd,"r_setLimitTimeForAnim")==0)
	{
		csl->DispMsg(0,1,0,1,"Permet de selectionner le temps ecoule avant l'update d'une animation.");
		csl->DispMsg(0,1,0,1,"compromis rapidite d'affichage et qualite d'animation");
		csl->DispMsg(0,1,0,1,"    courant %f ; defaut %f",ModelMD2::getLimitTimeForAnim(),MD2_DEFAULT_LIMIT_TIME_FOR_ANIM);
	}
	else
	{
		float rep=0;
		sscanf(cmd,"r_setLimitTimeForAnim %f",&rep);
		ModelMD2::setLimitTimeForAnim(rep);
	}
}

void r_renderHiddenUnits(char* cmd, Console* csl)
{
	if(strcmp(cmd,"r_renderHiddenUnits")==0)
	{
		csl->DispMsg(0,1,0,1,"Permet d'afficher les unites au travers des arbres.");
		if(Renderer::getInstance().renderHiddenUnits)
			csl->DispMsg(0,1,0,1,"   courant 1 ; defaut 0");
		else
			csl->DispMsg(0,1,0,1,"   courant 0 ; defaut 0");
	}
	else
	{
		int rep=0;
		sscanf(cmd,"r_renderHiddenUnits %d",&rep);
		Renderer::getInstance().renderHiddenUnits = (rep!=0);
	}
}

void r_fogOfWarUpdateTime(char* cmd, Console* csl)
{
	if(strcmp(cmd,"r_fogOfWarUpdateTime")==0)
	{
		csl->DispMsg(0,1,0,1,"Permet de regler le temp d'update du brouillard de guerre.");
		csl->DispMsg(0,1,0,1,"courant %f : default 1000 (en milliseconde)",Renderer::getInstance().getVisibilityUpdateTime());
	}
	else
	{
		float rep=0;
		sscanf(cmd,"r_fogOfWarUpdateTime %f",&rep);
		Renderer::getInstance().setVisibilityUpdateTime(rep);
	}
}

void r_renderParticles(char* cmd, Console* csl)
{
	if(strcmp(cmd,"r_renderParticles")==0)
	{
		csl->DispMsg(0,1,0,1,"Permet d'afficher les particules.");
		if(Renderer::getInstance().renderParticles)
			csl->DispMsg(0,1,0,1,"   courant 1 ; defaut 1");
		else
			csl->DispMsg(0,1,0,1,"   courant 0 ; defaut 1");
	}
	else
	{
		float rep=0;
		sscanf(cmd,"r_renderParticles %f",&rep);
		Renderer::getInstance().renderParticles = (rep!=0);
	}
}

void r_renderDecors(char* cmd, Console* csl)
{
	if(strcmp(cmd,"r_renderDecors")==0)
	{
		csl->DispMsg(0,1,0,1,"Permet d'afficher les decors.");
		if(Renderer::getInstance().renderDecors)
			csl->DispMsg(0,1,0,1,"   courant 1 ; defaut 1");
		else
			csl->DispMsg(0,1,0,1,"   courant 0 ; defaut 1");
	}
	else
	{
		float rep=0;
		sscanf(cmd,"r_renderDecors %f",&rep);
		Renderer::getInstance().renderDecors = (rep!=0);
	}
}

void r_lowQuality(char* cmd, Console* csl)
{
	if(strcmp(cmd,"r_lowQuality")==0)
	{
		Renderer::getInstance().renderHiddenUnits = false;
		Renderer::getInstance().renderParticles = false;
		Renderer::getInstance().renderTreeLeaf = false;
		Renderer::getInstance().renderTreeTrunk = false;
		Renderer::getInstance().renderWaterZone = false;
		Renderer::getInstance().renderDecors = false;
		Renderer::getInstance().useGLFog = false;
		Renderer::getInstance().useGLlighting = false;
		Renderer::getInstance().useGroundTexture = true;
		Renderer::getInstance().setFogOfWarAttributes(0.4f,1.0f);
	}
	else
	{
		csl->DispMsg(0,1,0,1,"Permet de passer en mode d'affichage de quality minimum.");
	}
}

void r_highQuality(char* cmd, Console* csl)
{
	if(strcmp(cmd,"r_highQuality")==0)
	{
		Renderer::getInstance().renderHiddenUnits = true;
		Renderer::getInstance().renderParticles = true;
		Renderer::getInstance().renderTreeLeaf = true;
		Renderer::getInstance().renderTreeTrunk = true;
		Renderer::getInstance().renderWaterZone = true;
		Renderer::getInstance().renderDecors = true;
		Renderer::getInstance().useGLFog = true;
		Renderer::getInstance().useGLlighting = true;
		Renderer::getInstance().useGroundTexture = true;
		Renderer::getInstance().setFogOfWarAttributes(0.2f,1.0f);
	}
	else
	{
		csl->DispMsg(0,1,0,1,"Permet de passer en mode d'affichage de quality maximum.");
	}
}

void z_showGraph(char* cmd, Console* csl)
{
	if(strcmp(cmd,"z_showGraph")==0)
	{
		csl->DispMsg(0,1,0,1,"Permet d'afficher le graph de zones de la map.");
		if(Renderer::getInstance().showGraph)
			csl->DispMsg(0,1,0,1,"   courant 1 ; defaut 0");
		else
			csl->DispMsg(0,1,0,1,"   courant 0 ; defaut 0");
	}
	else
	{
		float rep=0;
		sscanf(cmd,"z_showGraph %f",&rep);
		Renderer::getInstance().showGraph = (rep!=0);
	}
}

void found_number(char* cmd, Console* csl)
{
	if(strcmp(cmd,"found_number")==0)
	{
		csl->DispMsg(0,1,0,1,"nouvelle partie de trouvage de nombre.");
		csl->DispMsg(0,1,0,1,"le nombre à trouver est entre 0 et 100");
		gameNumberToFound = rand() % 100;
	}
	else
	{
		int rep=0;
		if (sscanf(cmd,"found_number %d",&rep) == 1){
			if (rep < gameNumberToFound){
				csl->DispMsg(0,1,0,1,"le nombre est superieur");
			}else if (rep > gameNumberToFound){
				csl->DispMsg(0,1,0,1,"le nombre est inferieur");
			}else{
				csl->DispMsg(1,0,0,1,"bravo vous avez trouve le nombre");
			}
		}else{
			csl->DispMsg(1,0,0,1,"jeux consistant a trouver un nombre tire au hasard");
			csl->DispMsg(1,0,0,1,"found_number : lance une nouvelle partie");
			csl->DispMsg(1,0,0,1,"found_number [number] : essaye un chiffre");
		}
	}
}


void addFonctionnalityToConsole()
{
	//console->addCommand("loadMap",loadMap);
	
	console->addCommand("g_cameraFree",g_cameraFree);
	console->addCommand("g_cameraSpeed",g_cameraSpeed);
	console->addCommand("r_debugElevation",r_debugElevation);
	console->addCommand("r_fogOfWarUpdateTime",r_fogOfWarUpdateTime);
	console->addCommand("r_renderHiddenUnits",r_renderHiddenUnits);
	console->addCommand("r_renderTree",r_renderTree);
	console->addCommand("r_renderTreeLeaf",r_renderTreeLeaf);
	console->addCommand("r_renderTreeTrunk",r_renderTreeTrunk);
	console->addCommand("r_renderWater",r_renderWater);
	console->addCommand("r_renderParticles",r_renderParticles);
	console->addCommand("r_renderDecors",r_renderDecors);
	console->addCommand("r_changeTileSet",r_changeTileSet);
	console->addCommand("r_highQuality",r_highQuality);
	console->addCommand("r_lowQuality",r_lowQuality);
	console->addCommand("r_showModeleLocalAABB",r_showModeleLocalAABB);
	console->addCommand("r_showModeleWorldAABB",r_showModeleWorldAABB);
	console->addCommand("r_showUnitLife",r_showUnitLife);
	console->addCommand("r_setLimitTimeForAnim",r_setLimitTimeForAnim);
	console->addCommand("r_showQuadTree",r_showQuadTree);
	console->addCommand("r_showParticleAABB",r_showParticleAABB);
	console->addCommand("r_showWireGround",r_showWireGround);
	console->addCommand("r_skipFrustumUpdate",r_skipFrustumUpdate);
	console->addCommand("r_timeFactor",r_timeFactor);
	console->addCommand("r_useGLFog",r_useGLFog);
	console->addCommand("r_useGLlighting",r_useGLlighting);
	console->addCommand("r_useGroundTexture",r_useGroundTexture);
	console->addCommand("showBlockCases",showBlockCases);
	console->addCommand("who",who);
	console->addCommand("z_showDangerZoneIntensity",z_showDangerZoneIntensity);
	console->addCommand("z_showNaturelAxeIntensity",z_showNaturelAxeIntensity);
	console->addCommand("z_showNaturelAxeZoneCases",z_showNaturelAxeZoneCases);
	console->addCommand("z_showStrongZoneIntensity",z_showStrongZoneIntensity);
	console->addCommand("z_showStrongZoneCases",z_showStrongZoneCases);
	console->addCommand("z_showForestZoneCases",z_showForestZoneCases);
	console->addCommand("z_showGraph",z_showGraph);
	console->addCommand("z_zette",cache);
	console->addCommand("found_number",found_number);
}


