diff options
Diffstat (limited to 'src/gui.c')
-rw-r--r-- | src/gui.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/gui.c b/src/gui.c new file mode 100644 index 0000000..29ad554 --- /dev/null +++ b/src/gui.c @@ -0,0 +1,34 @@ +#include "gui.h" +#include "meeple.h" + +void initialize_colors() { + use_default_colors(); + start_color(); + for (int i = 1; i < 6; i++) init_pair(i, COLOR_BLACK + i, COLOR_BLACK); +} + +int get_player_color(int player) { + return player ? COLOR_PAIR(player + 2) : COLOR_PAIR(0); +} + +void draw_board(BoardUnit* board, int* meeple_map, WINDOW* win) { + wmove(win, 0, 0); + for (int i = 0; i < BOARD_UNITS; i++) { + if (board[i].feature == EMPTY && is_center_index(i)) waddch(win, '.'); + else waddch( + win, + board[i].feature + | get_player_color(get_structure_dominator(board[i].structure_group, meeple_map)) + ); + } + wrefresh(win); +} + +WINDOW* create_framed_window(char* name, int lines, int cols, int x, int y) { + WINDOW* frame = newwin(lines, cols, x, y); + WINDOW* window = derwin(frame, lines - 2, cols - 2, 1, 1); + box(frame, 0, 0); + mvwaddstr(frame, 0, 1, name); + wrefresh(frame); + return window; +} |