| 1 | #include <ncurses.h> |
| 2 |
|
| 3 | #include "../state.h" |
| 4 |
|
| 5 | #include "pages.h" |
| 6 | #include "text.h" |
| 7 | #include "winsize.h" |
| 8 |
|
| 9 |
|
| 10 | int draw(game_state *state, int ch) { |
| 11 | clear(); |
| 12 | int ret = 0; |
| 13 | switch (state->page) { |
| 14 | case Title: { |
| 15 | ret = draw_title_screen(state, ch); |
| 16 | break; |
| 17 | } |
| 18 | case Game: { |
| 19 | ret = draw_game(state, ch); |
| 20 | break; |
| 21 | } |
| 22 | case Options: { |
| 23 | ret = draw_options_screen(state, ch); |
| 24 | break; |
| 25 | } |
| 26 | case Help: { |
| 27 | ret = draw_help_screen(state, ch); |
| 28 | break; |
| 29 | } |
| 30 | default: |
| 31 | return 1; |
| 32 | } |
| 33 | draw_winsize(); |
| 34 | refresh(); |
| 35 | return ret; |
| 36 | } |
| 37 |
|
| 38 | void draw_loop(game_state *state) { |
| 39 | int ch = 0; |
| 40 | while ((ch = getch())) { |
| 41 | if (draw(state, ch)) break; |
| 42 | } |
| 43 | } |
| 44 |
|