Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==========ШАБЛОН ПЕЧАТИ МЕНЮ==========
- void print_menu(int sym, const string items[], const int N_ITEMS) {
- for (int i = 1; i <= N_ITEMS; i++) {
- SetColor(7, 0);
- gotoxy((width / 2) - 6, (height / 2) + i - 3); // ставим меню в центр
- if (i == sym) {
- SetColor(7, 5);
- }
- cout << items[i - 1] << endl;
- SetColor(7, 0);
- }
- }
- // ==========МЕНЮ==========
- int menu(int& active, const string items[], int num_el) {
- wint_t buf;
- do {
- cls();
- print_menu(active, items, num_el - 1);
- buf = _getwch();
- switch (buf) {
- case up: // клавиша вверх
- if (active > 1) active--;
- break;
- case down: // клавиша вниз
- if (active < num_el - 1) active++;
- break;
- case enter: // клавиша enter
- return active;
- case esc: // клавиша escape
- return -1;
- case del:
- return -active;
- }
- } while (1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement