From 6ef4011ecfdf58726c76a60e858dc8e53d1ba5a8 Mon Sep 17 00:00:00 2001 From: Mario Kilies Date: Thu, 13 Jan 2011 20:44:05 +0100 Subject: Implemented current state window. --- src/display.c | 50 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 5 deletions(-) (limited to 'src/display.c') diff --git a/src/display.c b/src/display.c index c6163e3..04afd05 100644 --- a/src/display.c +++ b/src/display.c @@ -137,10 +137,27 @@ void display_window_stack_points(const tablestacks ts) * Displays the current state window. * @param[in] score The players score */ -void display_window_current_state(const uint32_t score) +void display_window_current_state(const player_name_open_card_tuple pnoc[], const uint8_t num_players, const uint32_t score) { mvwprintw(w_current_state, 0, 0, "Current state:"); - mvwprintw(w_current_state, 0, 23, "Your Score: %3d", score); + mvwprintw(w_current_state, 0, 22, "Your Score: %3d", score); + mvwprintw(w_current_state, 1, 1, "Player Card"); + mvwprintw(w_current_state, 1, 22, "Player Card"); + mvwvline(w_current_state, 1, 19, ACS_VLINE, 6); // Vertical line + + for (uint8_t i = 0; i < num_players; i++) + { + if (i < 5) + { + mvwprintw(w_current_state, 2+i, 1, "%-s", pnoc[i].player_name); + mvwprintw(w_current_state, 2+i, 13, "%3d", pnoc[i].open_card); + } + else + { + mvwprintw(w_current_state, 2+(i-5), 22, "%-s", pnoc[i].player_name); + mvwprintw(w_current_state, 2+(i-5), 34, "%3d", pnoc[i].open_card); + } + } wrefresh(w_current_state); } @@ -187,22 +204,45 @@ void display_init(void) clear(); refresh(); + // Window positions and sizes w_table_cards = newwin(21, 15, 0, 0); w_stack_points = newwin(19, 4, 0, 17); w_current_state = newwin(10, 38, 0, 24); w_hand_cards = newwin(11, 39, 10, 24); + // Example data set for table cards window const tablestacks ts = {{1, 2, 3, 4, 101}, {6, 7, 53, 0, 0}, {11, 55, 0, 0, 0}, {17, 29, 36, 42, 0}}; + + // The stack points window uses ts, too, so there is no separate data set + + // Example data set for hand cards window const hand h = {12, 13, 22, 25, 27, 69, 77, 85, 100, 103}; + + // Example data set for current state window + const player_name_open_card_tuple pnoc[10] = { + {"$you", 10}, + {"1234567890", 23}, + {"baz", 38}, + {"foo_bar", 14}, + {"lolcat", 60}, + {"blablub123", 15}, + {"abcdefg", 103}, + {"hello", 98}, + {"hornoxe", 33}, + {"1337nick", 74} + }; + const uint8_t num_players = 10; const uint32_t score = 10; + + // Draw user interface mvvline(0, 22, ACS_VLINE, 21); // Vertical line refresh(); display_window_table_cards(ts); display_window_stack_points(ts); - display_window_current_state(score); + display_window_current_state(pnoc, num_players, score); display_window_hand_cards(h); - //refresh(); - sleep(3); + + sleep(4); } void display_fini(void) -- cgit v1.2.3