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