From 3c336f65b489cdc145ec60ee4a02d74ab3cb3676 Mon Sep 17 00:00:00 2001
From: Henri Montjoie <henri.montjoie@insa-rennes.fr>
Date: Wed, 11 May 2016 22:57:19 +0200
Subject: [PATCH] ajout du bouton lancer la partie

---
 src/affichage.c | 40 ++++++++++++++++++++++++++++++++--------
 1 file changed, 32 insertions(+), 8 deletions(-)

diff --git a/src/affichage.c b/src/affichage.c
index 9f9062a..d0992bf 100644
--- a/src/affichage.c
+++ b/src/affichage.c
@@ -232,7 +232,6 @@ int affichage_ecran_accueil()
     SDL_Surface* ecran = SDL_SetVideoMode(LARGEUR_CARTE*(LARGEUR_CASE+1), HAUTEUR_CARTE*(HAUTEUR_CASE+2), 32, SDL_HWSURFACE|SDL_DOUBLEBUF);
     SDL_WM_SetCaption("Elder Internal Ignition",NULL);
     SDL_Event event;
-    SDL_Surface* rectangle = NULL;
     SDL_Surface* logo = NULL;
     SDL_Surface* texte = NULL;
     TTF_Font *police = NULL;
@@ -245,7 +244,6 @@ int affichage_ecran_accueil()
     texte = TTF_RenderText_Shaded(police, "Entrez dans le Royaume !", couleurDoree,couleurBleue);
     pos_texte.x=(ecran->w-texte->w)/2;
     pos_texte.y=ecran->h-200;
-    rectangle=SDL_CreateRGBSurface(SDL_HWSURFACE,texte->w,texte->h,0,0,0,255,0);
 
     logo = SDL_LoadBMP("../resources/Skins/logo.bmp");
     if (!logo)
@@ -258,7 +256,6 @@ int affichage_ecran_accueil()
     SDL_FillRect(ecran,NULL,SDL_MapRGB(ecran->format,0,0,0));
     SDL_BlitSurface(logo,NULL,ecran,&pos_logo);
     SDL_BlitSurface(texte,NULL,ecran,&pos_texte);
-    SDL_BlitSurface(rectangle,NULL,ecran,&pos_texte);
     SDL_Flip(ecran);
 
     while(etat==LANCEMENT)
@@ -278,13 +275,11 @@ int affichage_ecran_accueil()
         }
         SDL_BlitSurface(logo,NULL,ecran,&pos_logo);
         SDL_BlitSurface(texte,NULL,ecran,&pos_texte);
-        SDL_BlitSurface(rectangle,NULL,ecran,&pos_texte);
         SDL_Flip(ecran);
     }
     TTF_CloseFont(police);
     SDL_FreeSurface(ecran);
     SDL_FreeSurface(logo);
-    SDL_FreeSurface(rectangle);
     SDL_FreeSurface(texte);
     return 0;
 }
@@ -300,6 +295,7 @@ int affichage_menu_configuration()
     SDL_Surface* ecran = SDL_SetVideoMode(LARGEUR_CARTE*(LARGEUR_CASE+1), HAUTEUR_CARTE*(HAUTEUR_CASE+2), 32, SDL_HWSURFACE|SDL_DOUBLEBUF);
     SDL_WM_SetCaption("Elder Internal Ignition",NULL);
     SDL_Event event;
+    SDL_Surface* lancer_partie = NULL;
     SDL_Surface* map_choisie = NULL;
     SDL_Surface* texte = NULL;
     SDL_Surface* texte2 = NULL;
@@ -310,6 +306,7 @@ int affichage_menu_configuration()
     SDL_Surface* images_persos[NB_PERSO][NB_JOUEURS]={{NULL}};
     SDL_Rect positions_images[NB_PERSO][NB_JOUEURS];
     SDL_Rect posTextes[NB_JOUEURS*NB_PERSO];
+    SDL_Rect pos_bouton;
     SDL_Rect pos_texte;
     SDL_Rect pos_texte2;
     SDL_Rect pos_texte3;
@@ -319,13 +316,18 @@ int affichage_menu_configuration()
     TTF_Font *petite_police = NULL;
     SDL_Color couleurNoire = {0, 0, 0};
     SDL_Color couleurBlanche = {255, 255, 255};
+    SDL_Color couleurBleue = {10, 30, 80};
+    SDL_Color couleurDoree = {190, 190, 120};
     int i,j,p,k,c;
 
     SDL_FillRect(ecran,NULL,SDL_MapRGB(ecran->format,0,0,0));
 
-    police=TTF_OpenFont("../resources/fonts/OLDENGL.ttf",44);
+    police=TTF_OpenFont("../resources/fonts/OLDENGL.ttf",46);
     petite_police=TTF_OpenFont("../resources/fonts/OLDENGL.ttf",32);
 
+    lancer_partie= TTF_RenderText_Shaded(police, "Lancer la partie", couleurDoree, couleurBleue);
+    pos_bouton.y=ecran->h-lancer_partie->h-25;
+    pos_bouton.x=(ecran->w-lancer_partie->w)/2;
     texte= TTF_RenderText_Shaded(police, nom_1, couleurBlanche,couleurNoire);
     texte2= TTF_RenderText_Shaded(police, nom_2, couleurBlanche, couleurNoire);
     texte3= TTF_RenderText_Shaded(petite_police, "choisissez vos personnages", couleurBlanche, couleurNoire);
@@ -367,7 +369,7 @@ int affichage_menu_configuration()
     }
 
     char** path_images=obtenirSkinsClasses();
-    int numClassePerso[3][2]={{-1,-1},{-1,-1},{-1,-1}};
+    int numClassePerso[NB_PERSO][NB_JOUEURS]={{-1,-1},{-1,-1},{-1,-1}};
     j=0; /*numero du joeuur*/
     p=0; /*numero du personnage*/
     char *classeChoisie;
@@ -421,12 +423,32 @@ int affichage_menu_configuration()
                 return 0;
                 break;
             case SDL_MOUSEBUTTONDOWN:
+                if(event.button.x>pos_bouton.x&&event.button.x<pos_bouton.x+lancer_partie->w&&event.button.y>pos_bouton.y&&event.button.y<pos_bouton.y+lancer_partie->h){
+                    for(i=0;i<NB_PERSO;i++){
+                        for(k=0;k<NB_JOUEURS;k++){
+                            if(numClassePerso[i][k]==-1){
+                                p=-1;
+                            }
+                        }
+                    }
+                    if(p==0&&c!=-1){
+                        //etat=TOUR_J1P1;
+                        printf("c'est parti!\n");
+                    }
+                    if(c==-1){
+                        printf("choisissez une carte\n");
+                    }
+                    if(p==-1){
+                        p=0;
+                        printf("selectionnez des personnages\n");
+                    }
+                }
                 for(i=0;i<5;i++)
                 {
                     if(event.button.x>position_carte[i].x&&event.button.x<position_carte[i].x+previsualisation[0]->w&&event.button.y>position_carte[i].y&&event.button.y<position_carte[i].y+previsualisation[0]->h)
                     {
                         c=i;
-                        //selectionnerCarte(obtenirNomsCartes()[c]);
+                        selectionnerCarte(obtenirNomsCartes()[c]);
                     }
                 }
                 if(event.button.x>posTextes[0].x&&event.button.x<posTextes[0].x+textes[0]->w)
@@ -466,6 +488,7 @@ int affichage_menu_configuration()
                 }
             }
         }
+        SDL_BlitSurface(lancer_partie,NULL,ecran,&pos_bouton);
         SDL_BlitSurface(texte,NULL,ecran,&pos_texte);
         SDL_BlitSurface(texte2,NULL,ecran,&pos_texte2);
         SDL_BlitSurface(texte3,NULL,ecran,&pos_texte3);
@@ -487,6 +510,7 @@ int affichage_menu_configuration()
     SDL_FreeSurface(texte);
     SDL_FreeSurface(texte2);
     SDL_FreeSurface(texte3);
+    SDL_FreeSurface(lancer_partie);
     for(i=0;i<5;i++){
         SDL_FreeSurface(previsualisation[i]);
     }
-- 
GitLab