
#include <oslib/oslib.h>


//variable
extern OSL_FONT *maFonte, *maFonte2;

//possition initiale du menu
int PossMenu = 0;
//Menu Par Defaut Activer
int Menu = 1;




//gestion des touches
void Touche_menu()
{
 oslReadKeys();


 if (osl_keys->pressed.up)if (PossMenu)PossMenu = 0;else PossMenu = 1;

 if (osl_keys->pressed.down)if (PossMenu)PossMenu = 0;else PossMenu = 1;

 if (osl_keys->pressed.cross)
 {
	 //si on et sur le menu Commencer alors on quitte le menu
	 if (!PossMenu)Menu = 0;
	 //ou alors on et sur quitter alors on quitte
	 else {oslEndGfx();oslQuit();}	
 }

}



//Gestion et affichage du menu
void menu()
{

		while (Menu)
		{
			oslStartDrawing();
			oslCls();

			Touche_menu();

			//affichage du degrader
			oslDrawGradientRect(0, 40, OSL_SCREEN_WIDTH, 140, RGB(34,61,67), RGB(12,66,120), RGB(12,66,120), RGB(34,61,67));
			oslDrawLine(0, 39, OSL_SCREEN_WIDTH, 39, RGB(255,255,255));
			oslDrawLine(0, 141, OSL_SCREEN_WIDTH, 141, RGB(255,255,255));

			//Affichage du Titre
			oslSetTextColor(RGBA(255,255,255,255));
			oslSetBkColor(RGBA(0,0,0,0));
			//utilise une fonte
			oslSetFont(maFonte2);
			oslPrintf_xy((OSL_SCREEN_WIDTH/2)-(oslStringLength("PONG DEVSLIB")/2), 85, "PONG DEVSLIB");

			//Affichage du menu en lui meme
			//utilise une fonte
			oslSetFont(maFonte);
			if (!PossMenu)
			{
				oslPrintColorShadow((OSL_SCREEN_WIDTH/2)-(oslStringLength("COMMENCER")/2), 170,JAUNE, "COMMENCER",0);
				oslPrintColorShadow((OSL_SCREEN_WIDTH/2)-(oslStringLength("QUITTER")/2), 210,BLANC, "QUITTER",0);
			}
			else
			{
				oslPrintColorShadow((OSL_SCREEN_WIDTH/2)-(oslStringLength("COMMENCER")/2), 170,BLANC, "COMMENCER",0);
				oslPrintColorShadow((OSL_SCREEN_WIDTH/2)-(oslStringLength("QUITTER")/2), 210,JAUNE, "QUITTER",0);
			}


			
			oslSynchronization();

		}	


}



