-
Notifications
You must be signed in to change notification settings - Fork 0
/
menu.c
59 lines (46 loc) · 1.05 KB
/
menu.c
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
#include <ncurses.h>
#include <stdlib.h>
int menu(){
char* choices[] = {
"Game",
"Editeur",
"Exit"
};
int nb_choices = sizeof(choices) / sizeof(char *);
int ch = 0;
int choice = 0;
while(1){
switch (ch)
{
case KEY_DOWN:
if(choice == nb_choices -1){
choice = 0;
}else
choice ++;
break;
case KEY_UP:
if(choice == 0){
choice = nb_choices;
}
choice --;
break;
case 10: // touche entrer
return choice;
break;
default:
break;
}
for(int i = 0; i < nb_choices; i++){
if(i == choice){
attron(A_REVERSE);
mvaddstr(5+ i, 5, choices[i]);
attroff(A_REVERSE);
}else
mvaddstr(5+ i, 5, choices[i]);
}
ch = getch();
}
refresh();
//getch();
return 1;
}