1 | /* ncurses-minesweeper Copyright (c) 2021 Joshua 'joshuas3' Stockin |
2 | * <https://joshstock.in> |
3 | * <https://git.joshstock.in/ncurses-minesweeper> |
4 | * |
5 | * This software is licensed and distributed under the terms of the MIT License. |
6 | * See the MIT License in the LICENSE file of this project's root folder. |
7 | * |
8 | * This comment block and its contents, including this disclaimer, MUST be |
9 | * preserved in all copies or distributions of this software's source. |
10 | */ |
11 |
|
12 | #include <ncurses.h> |
13 |
|
14 | #include "../state.h" |
15 | #include "../strings.h" |
16 | #include "pages.h" |
17 | #include "text.h" |
18 |
|
19 | int draw_help_screen(game_state *state, int ch) { |
20 | // input handling |
21 | switch (ch) { |
22 | case -1: |
23 | return 0; |
24 | case KEY_RESIZE: |
25 | clear(); |
26 | break; |
27 | case 10: |
28 | case ' ': |
29 | case KEY_ENTER: { |
30 | clear(); |
31 | state->page = Title; |
32 | return draw_title_screen(state, 0); |
33 | break; |
34 | } |
35 | case 0: |
36 | break; |
37 | default: |
38 | beep(); |
39 | } |
40 |
|
41 | // draw help screen |
42 | int top = centery() - (HELP_SCREEN_INFO_LEN / 2) - 3; |
43 | if (top < 0) top = 0; |
44 |
|
45 | attron(A_BOLD | COLOR_PAIR(2)); |
46 | mvaddstr(top, centerx(help_screen_title), help_screen_title); |
47 | attroff(A_BOLD); |
48 |
|
49 | int x = centerx(help_screen_info[0]); |
50 | int y = top + 2; |
51 | for (int i = 0; i < HELP_SCREEN_INFO_LEN; i++) mvaddstr(y++, x, help_screen_info[i]); |
52 |
|
53 | attron(A_STANDOUT); |
54 | mvaddstr(top + 3 + HELP_SCREEN_INFO_LEN, centerx(help_screen_back), help_screen_back); |
55 | attroff(A_STANDOUT | COLOR_PAIR(2)); |
56 |
|
57 | return 0; |
58 | } |
59 |
|