diff options
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 42 |
1 files changed, 4 insertions, 38 deletions
@@ -3,52 +3,18 @@ #include <curses.h> #include <time.h> #include "carcassonne.h" +#include "gui.h" -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 row = 0; row < BOARD_ROW_UNITS; row++) { - for (int i = 0; i < BOARD_ROW_UNITS; i++) { - int index = BOARD_ROW_UNITS * row + i; - if (board[index].feature == EMPTY && is_center_index(index)) waddch(win, '.'); - else waddch( - win, - board[index].feature - | get_player_color(get_structure_dominator(board[index].structure_group, meeple_map)) - ); - } - } - wrefresh(win); -} int main() { /* initialize curses */ initscr(); cbreak(); - use_default_colors(); srand(time(NULL)); + initialize_colors(); - /* colors */ - start_color(); - for (int i = 1; i < 6; i++) init_pair(i, COLOR_BLACK + i, COLOR_BLACK); - - /* create board window */ - WINDOW* board_box = newwin(BOARD_ROW_UNITS + 2, BOARD_ROW_UNITS + 2, 0, 0); - WINDOW* board_win = derwin(board_box, BOARD_ROW_UNITS, BOARD_ROW_UNITS, 1, 1); - box(board_box, 0, 0); - mvwaddstr(board_box, 0, 1, "Board"); - wrefresh(board_box); - - /* create messages window */ - WINDOW* messages_box = newwin(BOARD_ROW_UNITS + 2, 60, 0, BOARD_ROW_UNITS + 3); - WINDOW* messages_win = derwin(messages_box, BOARD_ROW_UNITS, 60 - 2, 1, 1); - box(messages_box, 0, 0); - mvwaddstr(messages_box, 0, 1, "Log"); - wrefresh(messages_box); - + WINDOW* board_win = create_framed_window("Board", BOARD_ROW_UNITS + 2, BOARD_ROW_UNITS + 2, 0, 0); + WINDOW* messages_win = create_framed_window("Log", BOARD_ROW_UNITS + 2, 80, 0, BOARD_ROW_UNITS + 3); int meeple_map[MAX_STRUCTURES * PLAYERS]; BoardUnit board[BOARD_UNITS]; |