1 | #include <ncurses.h> |
2 |
|
3 | #include "../state.h" |
4 | #include "pages.h" |
5 | #include "text.h" |
6 |
|
7 | const char *help_screen_title = "HELP"; |
8 |
|
9 | const char *help_screen_info[10] = {"Minesweeper is a logic game where mines are hidden in a grid of ", |
10 | "squares. The object is to open all the safe squares in the shortest", |
11 | "time possible.", |
12 | "", |
13 | "Use the <ENTER> key or the spacebar to select menu items or open", |
14 | "unopened squares. Use <hjkl> to move around. Use <f> to toggle flags", |
15 | "on squares. Use <g> on a numbered square if enough surrounding", |
16 | "squares are flagged in order to open remaining surrounding squares.", |
17 | "", |
18 | "A minimum terminal resolution of 80x20 is recommended."}; |
19 |
|
20 | const char *help_screen_back = "Back"; |
21 |
|
22 | int draw_help_screen(game_state *state, int ch) { |
23 | // input handling |
24 | if (ch == 10 || ch == ' ' || ch == KEY_ENTER) { |
25 | state->page = Title; |
26 | return draw_title_screen(state, 0); |
27 | } else if (ch == 'k' || ch == 'K' || ch == 'j' || ch == 'J') |
28 | beep(); |
29 |
|
30 | // draw help screen |
31 | int mid = centery(); |
32 |
|
33 | attron(A_BOLD); |
34 | mvaddstr(mid - 7, centerx(help_screen_title), help_screen_title); |
35 | attroff(A_BOLD); |
36 |
|
37 | int x = centerx(help_screen_info[0]); |
38 | int y = mid - 5; |
39 | for (int i = 0; i < 10; i++) mvaddstr(y++, x, help_screen_info[i]); |
40 |
|
41 | attron(A_STANDOUT); |
42 | mvaddstr(mid + 7, centerx(help_screen_back), help_screen_back); |
43 | attroff(A_STANDOUT); |
44 |
|
45 | return 0; |
46 | } |
47 |
|