From f4e9a105729948afd30bf18b104e4bd376ed916b Mon Sep 17 00:00:00 2001 From: Murilo Pereira Date: Sun, 15 May 2011 20:39:22 -0300 Subject: [PATCH] Smarter stack erasing. --- lib/display.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/lib/display.c b/lib/display.c index 1c6f21d..67160a1 100644 --- a/lib/display.c +++ b/lib/display.c @@ -55,11 +55,19 @@ static char *card_value(enum value value) { return(card_value); } +void erase_card(struct card *card) { + werase(card->frame->window); + wbkgd(card->frame->window, WHITE_ON_GREEN); + wrefresh(card->frame->window); +} + void erase_stack(struct stack *stack) { - for (; stack; stack = stack->next) { - werase(stack->card->frame->window); - wbkgd(stack->card->frame->window, WHITE_ON_GREEN); - wrefresh(stack->card->frame->window); + if (maneuvre_stack(stack)) { + for (; stack; stack = stack->next) { + erase_card(stack->card); + } + } else { + erase_card(stack->card); } } @@ -111,13 +119,8 @@ void draw_card(struct card *card) { void draw_stack(struct stack *stack) { erase_stack(stack); if (empty(stack)) { - WINDOW *empty_stack = newwin(FRAME_HEIGHT, - FRAME_WIDTH, - stack->card->frame->begin_y, - stack->card->frame->begin_x); - box(empty_stack, 0, 0); - wrefresh(empty_stack); - delwin(empty_stack); + box(stack->card->frame->window, 0, 0); + wrefresh(stack->card->frame->window); } else { if (maneuvre_stack(stack)) { struct stack *reversed_stack = reverse(stack);