-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMenu.cpp
More file actions
59 lines (48 loc) · 1.31 KB
/
Menu.cpp
File metadata and controls
59 lines (48 loc) · 1.31 KB
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 "Menu.hpp"
Menu::Menu(WINDOW * win){
this->win = win;
getmaxyx(this->win, yMax, xMax);
highlight = 0;
xHalf = xMax/2;
yHalf = yMax/2;
}
int Menu::getChoice(){
keypad(win, true);
while(1){
int x[3] = {xHalf - 6, xHalf - 5, xHalf - 2};
int y = yHalf - 2;
wattron(win, A_BOLD);
mvwprintw(win, 2, xHalf - 13, "tetris-cli di Emre e Simone");
wattroff(win, A_BOLD);
for(int i = 0; i < 3; i++){
if(i == highlight){
wattron(win, A_BOLD);
wattron(win, A_ITALIC);
}
mvwprintw(win, y, x[i], "%s", choices[i].c_str());
wattroff(win, A_BOLD);
wattroff(win, A_ITALIC);
wrefresh(win);
y += 2;
}
int ch = wgetch(win);
switch(ch){
case KEY_UP:
if(highlight == 0)
highlight = 2;
else
highlight--;
break;
case KEY_DOWN:
if(highlight == 2)
highlight = 0;
else
highlight++;
break;
default:
break;
}
if(ch == 10)
return highlight;
}
}