diff --git a/conf.c b/conf.c index a10e903..38eb1e4 100644 --- a/conf.c +++ b/conf.c @@ -51,4 +51,4 @@ void addListener(ptListener listenerChain, char name[], int age, int level) { px -> next = (ptListener) malloc(sizeof(tListener)); px -> next -> next = NULL; px -> next -> prev = px; -} +} \ No newline at end of file diff --git a/main.c b/main.c index a1bf7ad..cc9faff 100644 --- a/main.c +++ b/main.c @@ -31,4 +31,4 @@ int main() menu(); return 0; -} +} \ No newline at end of file diff --git a/main.exe b/main.exe index d0e4955..c928904 100644 Binary files a/main.exe and b/main.exe differ diff --git a/screenManager.c b/screenManager.c index 17151b9..80fb1bd 100644 --- a/screenManager.c +++ b/screenManager.c @@ -13,124 +13,165 @@ void goToCoords(int x, int y) SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coords); } -void drawRectangle(int screenX, int screenY) +void drawHoryLine(char c, int lenght) { - int lenght = screenX * 2 / 3, height = screenY * 1 / 2; + int i = 0; - int i; + while (i != lenght) + { + printf("%c", c); + i++; + } +} - system("cls"); - goToCoords(screenX * 1 / 6, 3); +void drawVertiLine(char c, int lenght) +{ + CONSOLE_SCREEN_BUFFER_INFO info; + GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &info); + int x = info.dwCursorPosition.X; + int y = info.dwCursorPosition.Y; + + int i = 0; + + while (i != lenght) { + goToCoords(x, y + i); + printf("%c", c); + i ++; + } +} + +void drawRectangle(int x, int y, int lenght, int height) +{ + goToCoords(x, y); printf("%c", 201); - i = lenght - 2; - while (i > 0) - { - printf("%c", 205); - i--; - } + drawHoryLine(205, lenght - 2); printf("%c", 187); - i = height - 2; - while (i > 0) - { - goToCoords(screenX * 1 / 6, 3 + i); - printf("%c", 186); - goToCoords(screenX * 1 / 6 + lenght - 1, 3 + i); - printf("%c", 186); - i--; - } - goToCoords(screenX * 1 / 6, 2 + height); + goToCoords(x, y + 1); + drawVertiLine(186, height - 2); + goToCoords(x + lenght - 1, y + 1); + drawVertiLine(186, height - 2); + goToCoords(x, y + height - 1); printf("%c", 200); - i = lenght - 2; - while (i > 0) - { - printf("%c", 205); - i--; - } + drawHoryLine(205, lenght - 2); printf("%c", 188); } -void drawMenu(int screenX, int screenY) { - goToCoords(screenX * 1/6 + 3, 4); - printf("1/ Gestion des conferences"); - goToCoords(screenX * 1/6 + 3, 5); - printf("2/ Gestion des abonnes"); - goToCoords(screenX * 1/6 + 3, 6); - printf("3/ Participer a une conference"); - goToCoords(screenX * 1/6 + 3, 7); - printf("4/ Voir la meilleure conference"); - goToCoords(screenX * 1/6 + 3, 8); - printf("5/ Voir la participation a une conference"); - goToCoords(screenX * 1/6 + 3, 9); - printf("6/ Quitter"); +void drawMenu(char *options[], int lenght) { + int max = strlen(options[0]); + + for (int i = 0; i < lenght; i++) { + if (strlen(options[i]) > max) { + max = strlen(options[i]); + } + } + + CONSOLE_SCREEN_BUFFER_INFO info; + GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &info); + int columns = info.srWindow.Right - info.srWindow.Left + 1; + int rows = info.srWindow.Bottom - info.srWindow.Top + 1; + + drawRectangle((columns - max - 4) / 2, 2, max + 4, lenght + 4); + + for (int i = 0; i < lenght; i++) { + goToCoords((columns - max - 4) / 2 + 2, 4 + i); + printf("%s", options[i]); + } + +} + +void menuConf() { + char *options[] = {"1/ Voir la liste des conferences", "2/ Ajouter une conference", "3/ Suprimer une conference", "4/ Retour"}; + system("cls"); + drawMenu(options, 4); + goToCoords(0, 12); + printf("Que voulez-vous faire ? : "); + int choice; + scanf("%d", &choice); + + switch (choice) + { + case 1: + break; + + case 2: + break; + + case 3: + break; + + case 4: + menu(); + break; + + default: + menu(); + break; + } +} + +void menuAbo() { + char *options[] = {"1/ Voir la liste des abonnes", "2/ Ajouter un abonne", "3/ Suprimer un abonne", "4/ Retour"}; + system("cls"); + drawMenu(options, 4); + goToCoords(0, 12); + printf("Que voulez-vous faire ? : "); + int choice; + scanf("%d", &choice); + + switch (choice) + { + case 1: + break; + + case 2: + break; + + case 3: + break; + + case 4: + menu(); + break; + + default: + menu(); + break; + } } void menu() -{ - CONSOLE_SCREEN_BUFFER_INFO info; - int columns, rows; - - GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &info); - - columns = info.srWindow.Right - info.srWindow.Left + 1; - rows = info.srWindow.Bottom - info.srWindow.Top + 1; - - drawRectangle(columns, rows); - drawMenu(columns, rows); - goToCoords(0, rows / 2 + 5); - printf("Que voulez vous choisir ? "); +{ + char *options[] = {"1/ Gestion des conferences", "2/ Gestion des abonnes", "3/ Participer a une conference", "4/ Voir la meilleure conference", "5/ Voir la participation a une conference", "6/ Quitter"}; + system("cls"); + drawMenu(options, 6); + goToCoords(0, 14); + printf("Que voulez-vous faire ? : "); int choice; scanf("%d", &choice); + + switch (choice) + { + case 1: + menuConf(); + break; + + case 2: + menuAbo(); + break; + + case 3: + break; + + case 4: + break; + + case 5: + break; + + case 6: + break; -} - -/* -int i=0; - - ////////////////////////// Menu 1 //////////////////////////////// - - printf("\n 1/ Gestion des conferences\n 2/ Gestion des abonnes\n 3/ Participer a une conference"); - printf("\n 4/ Voir la meilleure conference\n 5/ Voir la participation a une conference"); - printf("\n 6/ Quitter\n"); - - - scanf("%d",&i); - - ////////////////////////////////////////////////////////////////// - - switch (i){ - - //////////////////////// Menu conf ///////////////////////// - - case 1:{ - printf("\n 1/ Voir la liste des conferences\n 2/ Ajouter une conference \n 3/ Suprimer une conference\n 4/ Retour\n"); - break; - } - - /////////////////////// Menu abonne ///////////////////////// - - case 2: { - printf("\n 1/ Voir la liste des abonnes\n 2/ Ajouter un abonne \n 3/ Suprimer un abonne\n 4/ Retour\n"); - break; - } - - case 3: { - printf("\n Nom de l'abonne : \n Nom de la conference : \n Note de la conference : "); - break; - } - - case 4: { - printf("\n Nom : \n Note : "); - break; - } - - - case 5: { - printf("\n Entrer le nom de la conference : "); - break; - } - - case 6: { - break; - } + default: + break; } -*/ \ No newline at end of file +} \ No newline at end of file