diff options
| author | Mario Kilies <MarioKilies@GMX.net> | 2011-01-13 21:11:38 +0100 |
|---|---|---|
| committer | Mario Kilies <MarioKilies@GMX.net> | 2011-01-13 21:11:38 +0100 |
| commit | 5fee7e02c53c627b64479074f3a97d24d808dd87 (patch) | |
| tree | c0ff95ee148a5f6daee4ef14ec9ac2a16a7b05a3 | |
| parent | 01cb12bdc0ce66abe47552247d5a2d82c4a12d31 (diff) | |
Implemented highlighting of card and cardstack.
| -rw-r--r-- | src/display.c | 44 | ||||
| -rw-r--r-- | src/display.h | 4 |
2 files changed, 36 insertions, 12 deletions
diff --git a/src/display.c b/src/display.c index da12eae..cbc9eb1 100644 --- a/src/display.c +++ b/src/display.c @@ -14,10 +14,13 @@ static WINDOW *w_stack_points; static WINDOW *w_current_state; static WINDOW *w_hand_cards; -static void draw_card(WINDOW *w, const uint8_t row, const uint8_t col, const card c) +static void draw_card(WINDOW *w, const uint8_t row, const uint8_t col, const bool highlight, const card c) { unsigned color_pair = 0; + if (highlight) + wattron(w, A_BOLD); + if (colors) { switch (card_get_points(c)) @@ -96,26 +99,38 @@ static void draw_card(WINDOW *w, const uint8_t row, const uint8_t col, const car { wattroff(w, COLOR_PAIR(color_pair)); } + + if (highlight) + wattroff(w, A_BOLD); } -static void draw_cardstack(WINDOW *w, const uint8_t row, const uint8_t col, const cardstack cs) +static void draw_cardstack(WINDOW *w, const uint8_t row, const uint8_t col, const bool highlight, const cardstack cs) { for (uint8_t i = 0; i < MAX_CARDSTACK_SIZE; i++) { if (cs[i] != 0) { - draw_card(w, row, i*2, cs[i]); + draw_card(w, row, i*2, highlight, cs[i]); } } } -void display_window_table_cards(const tablestacks ts) +void display_window_table_cards(const tablestacks ts, const bool highlight, const uint8_t highlighted_stack) { mvwprintw(w_table_cards, 0, 2, "Table Cards:"); for (uint8_t i = 0; i < NUM_TABLESTACKS; i++) { - draw_cardstack(w_table_cards, 1 + i*5, 0, ts[i]); + if (highlight) + { + if (i == highlighted_stack) + { + draw_cardstack(w_table_cards, 1 + i*5, 0, true, ts[i]); + continue; + } + } + + draw_cardstack(w_table_cards, 1 + i*5, 0, false, ts[i]); } wrefresh(w_table_cards); @@ -168,16 +183,25 @@ void display_window_current_state(const player_name_open_card_tuple pnoc[], cons * Displays the hand cards window. * @param[in] h The hand that will be displayed. h must not contain 0 */ -void display_window_hand_cards(const hand h) +void display_window_hand_cards(const hand h, const bool highlight, const uint8_t highlighted_card) { mvwprintw(w_hand_cards, 0, 0, "Hand Cards:"); for (uint8_t i = 0; i < MAX_HAND_CARDS; i++) { + if (highlight && i == highlighted_card) + { + if (i < 5) // Start with the first row of cards + draw_card(w_hand_cards, 1, i*8, true, h[i]); + else // And then draw the second row + draw_card(w_hand_cards, 6, (i-5)*8, true, h[i]); + continue; + } + if (i < 5) // Start with the first row of cards - draw_card(w_hand_cards, 1, i*8, h[i]); + draw_card(w_hand_cards, 1, i*8, false, h[i]); else // And then draw the second row - draw_card(w_hand_cards, 6, (i-5)*8, h[i]); + draw_card(w_hand_cards, 6, (i-5)*8, false, h[i]); } wrefresh(w_hand_cards); @@ -239,10 +263,10 @@ void display_init(void) // Draw user interface mvvline(0, 22, ACS_VLINE, 21); // Vertical line refresh(); - display_window_table_cards(ts); + display_window_table_cards(ts, true, 1); display_window_stack_points(ts); display_window_current_state(pnoc, num_players, score); - display_window_hand_cards(h); + display_window_hand_cards(h, true, 8); sleep(4); } diff --git a/src/display.h b/src/display.h index 8bbcb9e..8cfb217 100644 --- a/src/display.h +++ b/src/display.h @@ -8,10 +8,10 @@ #include "hand.h" #include "player_name_open_card_tuple.h" -void display_window_table_cards(const tablestacks ts); +void display_window_table_cards(const tablestacks ts, const bool highlight, const uint8_t highlighted_stack); void display_window_stack_points(const tablestacks ts); void display_window_current_state(const player_name_open_card_tuple pnoc[], const uint8_t num_players, const uint32_t score); -void display_window_hand_cards(const hand h); +void display_window_hand_cards(const hand h, const bool highlight, const uint8_t highlighted_card); void display_init(void); void display_fini(void); |
