1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
| #include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
#include <ctype.h>
#include <dos.h>
#ifndef LIST_H
#include "LIST.H"
#endif
#ifndef COMPET_H
#include "COMPET.H"
#endif
#ifndef MENU_H
#include "MENU.H"
#endif
#ifndef CONCUR_H
#include "CONCUR.H"
#endif
#ifndef COMMUN_H
#include "COMMUN.H"
#endif
void crecarval(char **men,char *chval,char csel)
{ int x=0,i=0;
char *ptr;
do { if ((ptr=strchr(men[x],csel))!=NULL) {chval[i]=ptr[1];i++;}
x++;
}
while (strcmp(men[x],"//"));
chval[i]='\0';
};
void affich(char **men)
{ int i=0;
clrscr();
do { printf("%s\n",men[i]);i++;}
while (strcmp(men[i],"//"));
printf("\n");
printf("Votre choix : ");
};
void choix(char *chval,char *ch1)
{ int j,x,y,test;
x=wherex();y=wherey();
do
{ fflush(stdin);
gotoxy(x,y);
clreol();
test=0;
*ch1=toupper(getche());
for (j=0;j<strlen(chval);j++) if (*ch1==chval[j]) test=1;
}
while (!test);
};
void fonctions(int nummenu1,char ch1,int *msuiv1,list *listcompet2,list *listconcur2)
{ switch(nummenu1)
{ case 1 : { switch(ch1)
{ case 'E' : *msuiv1=2;break;
case 'S' : *msuiv1=3;break;
};
break;
}
case 2 : { switch(ch1)
{ case 'C' : encodecompet(listcompet2);*msuiv1=2;break;
case 'N' : encodeconcur(listconcur2);*msuiv1=2;break;
};
break;
}
case 3 : { switch(ch1)
{ case 'C' : enlevecompet(listcompet2);*msuiv1=3;break;
case 'N' : enleveconcur(listconcur2);*msuiv1=3;break;
};
break;
}
}
};
void appelmenu(list *listcompet1,list *listconcur1)
{ int j,mprec=0,msuiv=1,nummenu=1;
char ch,cs='[',chvalide[3],**menu;
char *menu1[]=
{" MENU GENERAL",
"-============-\n",
"Choisissez parmi les options suivantes :","",
"- [E]ncodage (Competition / Concurent)",
"- [S]uppression (Competition / Concurent)","",
"- [Q]uitter","",
"//"};
char *menu2[]=
{" Encodage",
"-========-\n",
"Choisissez parmi les options suivantes :","",
"- [C]ompetition",
"- Co[N]curent","",
"- [Q]uitter","",
"//"};
char *menu3[]=
{" Suppression",
"-===========-\n",
"Choisissez parmi les options suivantes :","",
"- [C]ompetition",
"- Co[N]curent","",
"- [Q]uitter","",
"//"};
clrscr();
do
{ ch=' ';
strcpy(chvalide,NULL);
menu=NULL;
switch (nummenu)
{ case 0 : break;
case 1 : menu=menu1;mprec=0;msuiv=1;break;
case 2 : menu=menu2;mprec=1;msuiv=2;break;
case 3 : menu=menu3;mprec=1;msuiv=3;break;
}
if (nummenu)
{ crecarval(menu,chvalide,cs);
affich(menu);
choix(chvalide,&ch);
if (ch!='Q')
{ fonctions(nummenu,ch,&msuiv,listcompet1,listconcur1);
nummenu=msuiv;
}
else nummenu=mprec;
}
}
while (ch!='Q' || mprec!=0);
}; |
Partager