X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=lib%2Fui.c;h=be739aaa037d89ff66b96f7ec788425db1ece497;hb=45ce2fe369cead248855111baa5fe0c0495acf69;hp=c75e3b01ca69f981a1544455fc6aaf51494968b3;hpb=54f1c58cef6764fdd611eedc267e7491e777c09b;p=Project_algorithmic_C.git diff --git a/lib/ui.c b/lib/ui.c index c75e3b0..be739aa 100644 --- a/lib/ui.c +++ b/lib/ui.c @@ -56,6 +56,12 @@ void print_board(int y, int x) { mvprintw(y+25, x, " -----+----+----+----+----+----+----+-----"); } +static void set_default_colors() { + + init_pair(1, COLOR_WHITE, COLOR_BLACK); + attron(COLOR_PAIR(1)); +} + static void print_o(int y, int x, unsigned int type) { if (type == black) { @@ -69,8 +75,7 @@ static void print_o(int y, int x, unsigned int type) { mvprintw(y, x, "/\\"); mvprintw(y+1, x, "\\/"); /* reset to default */ - init_pair(1, COLOR_WHITE, COLOR_BLACK); - attron(COLOR_PAIR(1)); + set_default_colors(); } /* will be used for pawn placement hints */ @@ -86,8 +91,7 @@ static void print_x(int y, int x, unsigned int type) { mvprintw(y, x, "\\/"); mvprintw(y+1, x,"/\\"); /* reset to default */ - init_pair(1, COLOR_WHITE, COLOR_BLACK); - attron(COLOR_PAIR(1)); + set_default_colors(); } /* y = 1: y -> 0 x = 1: 1 -> 1 @@ -125,7 +129,7 @@ void print_pawns(int base_y, int base_x, unsigned int pawn_array[board_size][boa } } -int map_col_letter_to_int(char c) { +int map_col_letter_to_index(char c) { if (c == 'a' || c == 'A') { return 1; @@ -148,6 +152,30 @@ int map_col_letter_to_int(char c) { } } +/* return capital letters */ +char map_col_index_to_letter(int index) { + + if (index == 1) { + return 'A'; + } else if (index == 2) { + return 'B'; + } else if (index == 3) { + return 'C'; + } else if (index == 4) { + return 'D'; + } else if (index == 5) { + return 'E'; + } else if (index == 6) { + return 'F'; + } else if (index == 7) { + return 'G'; + } else if (index == 9) { + return 'H'; + } else { + return -1; + } +} + int prompt_values(WINDOW* windows, int base_y, int base_x, const char* msg, int* y, char* x) { mvwprintw(windows, base_y, base_x, "%s\n", msg); int retVal = mvwscanw(windows, base_y + 1, base_x + strlen(msg)/2, "%d%c", y, x);