diff options
Diffstat (limited to 'src/ui.c')
| -rw-r--r-- | src/ui.c | 32 |
1 files changed, 25 insertions, 7 deletions
@@ -237,31 +237,49 @@ void ui_display_wnd_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 + * @param[in] h The hand that will be displayed. h must be sorted in ascending order * @param[in] highlight If true, a card will be highlighted * @param[in] highlighted_card The card to highlight. Only used, if highlight is true */ void ui_display_wnd_hand_cards(const hand h, const bool highlight, const uint8_t highlighted_card) { + uint8_t num_zero_cards = 0; + wattron(w_hand_cards, A_BOLD); mvwprintw(w_hand_cards, 0, 0, "Hand Cards:"); wattroff(w_hand_cards, A_BOLD); + // Clear old cards from screen first + for (uint8_t i = 0; i < MAX_HAND_CARDS; i++) + { + if (i - num_zero_cards < 5) // Start with the first row of cards + draw_card(w_hand_cards, 1, (i - num_zero_cards) * 8, false, 0); + else // And then draw the second row + draw_card(w_hand_cards, 6, (i - num_zero_cards - 5) * 8, false, 0); + } + for (uint8_t i = 0; i < MAX_HAND_CARDS; i++) { + // Cound all 0 cards and don't draw them + if (0 == h[i]) + { + num_zero_cards++; + continue; + } + 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]); + if (i - num_zero_cards < 5) // Start with the first row of cards + draw_card(w_hand_cards, 1, (i - num_zero_cards) * 8, true, h[i]); else // And then draw the second row - draw_card(w_hand_cards, 6, (i-5)*8, true, h[i]); + draw_card(w_hand_cards, 6, (i - num_zero_cards - 5) * 8, true, h[i]); continue; } - if (i < 5) // Start with the first row of cards - draw_card(w_hand_cards, 1, i*8, false, h[i]); + if (i - num_zero_cards < 5) // Start with the first row of cards + draw_card(w_hand_cards, 1, (i - num_zero_cards) * 8, false, h[i]); else // And then draw the second row - draw_card(w_hand_cards, 6, (i-5)*8, false, h[i]); + draw_card(w_hand_cards, 6, (i - num_zero_cards - 5) * 8, false, h[i]); } wrefresh(w_hand_cards); |
