summaryrefslogtreecommitdiff
path: root/src/ui.c
diff options
context:
space:
mode:
authorMario Kilies <MarioKilies@GMX.net>2011-01-14 05:58:05 +0100
committerMario Kilies <MarioKilies@GMX.net>2011-01-14 05:58:05 +0100
commitf17b691fb70ec73b9413e91d881b9dcb3ffdfa2c (patch)
tree7ee14eaf3c04bb78b66a44c3995c46b2f6f3f0a9 /src/ui.c
parenta59958312ffb1e2cb368b5acb57b3376276c39ea (diff)
ui_display_wnd_hand_cards() will now show placeholders in hand cards after all other cards.
Diffstat (limited to 'src/ui.c')
-rw-r--r--src/ui.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/src/ui.c b/src/ui.c
index c9409df..3500f93 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -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);