diff options
| author | Mario Kilies <MarioKilies@GMX.net> | 2011-01-14 04:32:35 +0100 |
|---|---|---|
| committer | Mario Kilies <MarioKilies@GMX.net> | 2011-01-14 04:32:35 +0100 |
| commit | 9c855d16f1a737ddd9bde72e0fc51f4fd0a1e042 (patch) | |
| tree | 6d7f46a8aef12232c7ffd12fc9369d3f339444f6 /src/ui.c | |
| parent | 0dfe9ff514cb6e3ffe9bfd394aebeb54445edc03 (diff) | |
Implemented hand_sort(). ui_choose_card() now pre-selects the card with lowest index, if at index 0 is no card. draw_card() now draws empty placeholder cards, to clear old screen content.
Diffstat (limited to 'src/ui.c')
| -rw-r--r-- | src/ui.c | 30 |
1 files changed, 24 insertions, 6 deletions
@@ -26,6 +26,17 @@ static void draw_card(WINDOW *w, const uint8_t row, const uint8_t col, const boo { unsigned color_pair = 0; + // If card is 0, draw a placeholder (empty space) instead of a card. This is used to remove a card that does not longer exist but has visible remains on the screen. + if (0 == c) + { + mvwhline(w, row, col, ' ', 7); + mvwhline(w, row+1, col, ' ', 7); + mvwhline(w, row+2, col, ' ', 7); + mvwhline(w, row+3, col, ' ', 7); + mvwhline(w, row+4, col, ' ', 7); + return; + } + if (highlight) wattron(w, A_BOLD); @@ -231,10 +242,6 @@ void ui_display_wnd_hand_cards(const hand h, const bool highlight, const uint8_t for (uint8_t i = 0; i < MAX_HAND_CARDS; i++) { - // Skip empty card slots in hand - if (0 == h[i]) - continue; - if (highlight && i == highlighted_card) { if (i < 5) // Start with the first row of cards @@ -253,16 +260,27 @@ void ui_display_wnd_hand_cards(const hand h, const bool highlight, const uint8_t wrefresh(w_hand_cards); } -uint8_t ui_choose_card(const hand h) +uint8_t ui_choose_card(hand h) { int key; uint8_t chosen_card_idx = 0; + int8_t i; // Has to be signed for modulo calculation + + hand_sort(h); + + // Select card with lowest index as default + if (0 == h[chosen_card_idx]) + { + i = (chosen_card_idx + 1) % MAX_HAND_CARDS; + while(0 == h[i]) + i = (i + 1) % MAX_HAND_CARDS; + chosen_card_idx = i; + } ui_display_wnd_hand_cards(h, true, chosen_card_idx); while (KEY_RETURN != (key = wgetch(w_hand_cards))) { - int8_t i; // Has to be signed for modulo calculation switch (key) { case KEY_VI_LEFT: |
