Пример #1
0
/**
* menustate(void)
*
* @brief
* @param void
* @return void
*/
void menustate(void)
{
	sbool run = TRUE;

	while(run){
		if(widget_get_uip()->root->shown.count > 0 || widget_get_uip()->root->hidden.count > 0)
			widget_unload(widget_get_uip()->root);

		switch(menu_state){
		case MENU_STATE_MAIN:
			init_main_menu();//initializes the first menu for use.
			main_menu();//Start the First Menu, Menu main loop.
			break;
		case MENU_STATE_CREDITS:
			init_credits();
			credits();
			break;
		case MENU_STATE_LOGIN:
			init_login();
			login();
			break;
		case MENU_STATE_CREATE:
			init_new_account();
			new_account();
			break;
		case MENU_STATE_INGAME:
			init_ingame();
			ingame();
			break;
		case MENU_STATE_STATUS:
			if(!statusloader)
				init_status("Log in successful.");
			else {
				init_status("Widget System Initialized.");
				statusloader = FALSE;
			}

			status();
			break;
		case MENU_STATE_EXIT:
			run = FALSE;
			break;
		}
	}
}
Пример #2
0
int main() {
	
	char pseudo[100], ratio[100], nb_mots_txt[100];
	char *readSav = NULL;
	int choix = 0;
	t_context *menu = NULL, *popup = NULL;
	
	memset(pseudo, 0, sizeof(pseudo));
	//strcpy(pseudo, "NoName");
	savegame = SDL_initProfil("crossword.sav");
	
	readSav = SDL_readParam(savegame, "username");
	if (!readSav) {
		strcpy(pseudo, "NoName");
	}else{
		strcpy(pseudo, readSav);
	}
	
	// Aléatoirité
	srand(time(NULL));
	
	SDL_initWindow(800, 600, 0, "CrossWords ESDL", NULL, 1, "global.ttf", 20, 1); //800x600 +tff_support +audio_support
	
	
	generateIndex();
	
	menu = SDL_newContext("CrossWords SDL", 0, 0, 800, 600);
	SDL_newImage(menu, NULL, "APP_BG_SAMPLE.png", 0, 0);
	
	SDL_newObj(menu, NULL, 0, "Nouvelle partie", ALIGN_CENTER, NULL, NONE, 50, 550);
	SDL_newObj(menu, NULL, 0, "Options", ALIGN_CENTER, NULL, NONE, 280, 550);
	SDL_newObj(menu, NULL, 0, "Quitter", ALIGN_CENTER, NULL, NONE, 510, 550);
	SDL_newText(menu, NULL, pseudo, colorBlack, 550, 40);
	sprintf(ratio, "Score : %i d'XP", EXP_J1);
	SDL_newText(menu, NULL, ratio, colorRed, 550, 60);
	
	while (1) {
		
		sprintf(ratio, "Score : %i d'XP", EXP_J1);
		SDL_editText(menu, 0, pseudo, colorBlack, 550, 40);
		SDL_editText(menu, 1, ratio, colorRed, 550, 60);
		
		choix = SDL_generate(menu);
		
		switch (choix) {
			case 0:
				
				popup = SDL_newContext("Mon compte", 200, 200, 500, 250);
				memset(nb_mots_txt,0,sizeof(nb_mots_txt));
				SDL_newImage(popup, NULL, "popup.png", 0, 0);
				SDL_newText(popup, NULL, "Preciser le nombre de mots (de 10 a 40)", colorWhite, 10, 40);
				SDL_newObj(popup, NULL, 1, "Mots", ALIGN_LEFT, nb_mots_txt, NUMERIC, 70, 70);
				
				SDL_newObj(popup, NULL, 0, "Generer", ALIGN_CENTER, NULL , NONE, 150, 200);
				
				SDL_generate(popup);
				SDL_freeContext(popup);
				
				if (atoi(nb_mots_txt) >= 10 && atoi(nb_mots_txt) <= 40) {
					limite_mots = atoi(nb_mots_txt);
					generateGrille();
					ingame();
				}
				
				break;
			case 1:
				//Options
				popup = SDL_newContext("Mon compte", 200, 200, 500, 250);
				
				SDL_newImage(popup, NULL, "popup.png", 0, 0);
				SDL_newText(popup, NULL, "Voici le recapitulatif de votre session", colorWhite, 10, 40);
				SDL_newObj(popup, NULL, 1, "Pseudo", ALIGN_LEFT, pseudo, NONE, 70, 70);
				
				SDL_newText(popup, NULL, ratio, colorWhite, 80, 110);
				SDL_newObj(popup, NULL, 0, "Fermer", ALIGN_CENTER, NULL , NONE, 150, 200);
				
				SDL_generate(popup);
				SDL_freeContext(popup);
				
				SDL_writeParam(savegame, "username", pseudo);
				break;
			case 2:
				SDL_freeContext(menu);
				flushIndex();
				SDL_saveProfil(savegame);
				SDL_freeProfil(savegame);
				exit(0);
				break;
		}
		
	}
	
	SDL_saveProfil(savegame);
	SDL_freeProfil(savegame);
	SDL_freeContext(menu);
	flushIndex();
	
	return 0;
	
}