From f11615206afc02bdc911fed5828ab881e3046380 Mon Sep 17 00:00:00 2001 From: Mario Kilies Date: Tue, 25 Jan 2011 09:05:07 +0100 Subject: ui_display_wnd_current_state() has now optional highlighting of a player in the table and is able to display '-' if the player has not played an open card (This is used to display the window before the actual gameplay has begun). --- src/game.c | 3 ++- src/ui.c | 21 ++++++++++++++------- src/ui.h | 2 +- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/game.c b/src/game.c index 845f826..9ba1835 100644 --- a/src/game.c +++ b/src/game.c @@ -104,7 +104,7 @@ static void main_loop_client(int sock) net_recv(sock, msg_type_selected_card_all); pnoc_sort(data->players.players, data->players.count); // sort in ascending order - ui_display_wnd_current_state(data->players.players, data->players.count, 0, 0); // TODO fix parameters + ui_display_wnd_current_state(data->players.players, data->players.count, true, 0, 0); // TODO fix parameters //state = STATE_CLIENT_PLAY_CARDS; //sleep(2); @@ -339,6 +339,7 @@ void start_game(const bool servermode, const char* addr, const char* port) // Display all windows ui_display_wnd_table_cards(&data->table_stacks, false, 0); ui_display_wnd_stack_points(&data->table_stacks, false, 0); + ui_display_wnd_current_state(data->players.players, data->players.count, false, 0, 0); ui_display_wnd_hand_cards(&data->hand, false, 0); main_loop_client(sock); diff --git a/src/ui.c b/src/ui.c index dbcdf52..5dd7196 100644 --- a/src/ui.c +++ b/src/ui.c @@ -178,7 +178,7 @@ void ui_display_wnd_table_cards(const table_stacks_t *ts, const bool highlight, /** * Displays the stack points window. * @param[in] ts The table stacks used for calculation of stack points - * @param[in] highlight If true, stack poins will be highlighted + * @param[in] highlight If true, stack points will be highlighted * @param[in] highlighted_points The stack points to highlight. Only used, if highlight is true */ void ui_display_wnd_stack_points(const table_stacks_t *ts, const bool highlight, const uint8_t highlighted_points) @@ -209,10 +209,11 @@ void ui_display_wnd_stack_points(const table_stacks_t *ts, const bool highlight, * Displays the current state window, showing all player names and their open cards and the client player's score. * @param[in] pnoc Array of (player name, open card) tuples. Array has to be sorted by open card, lowest open card first * @param[in] num_players The number of players to show a player name and open card for - * @param[in] active_players The currently active player + * @param[in] highlight If true, a player in the player table will be highlighted + * @param[in] highlighted_player The player to highlight * @param[in] score The players score */ -void ui_display_wnd_current_state(const pnoc_t pnoc[], const uint8_t num_players, const uint8_t active_player, const uint32_t score) +void ui_display_wnd_current_state(const pnoc_t pnoc[], const uint8_t num_players, const bool highlight, const uint8_t highlighted_player, const uint32_t score) { assert(pnoc != NULL); uint8_t pos = 0; @@ -230,21 +231,27 @@ void ui_display_wnd_current_state(const pnoc_t pnoc[], const uint8_t num_players if (pnoc[i].player_id == 0) // invalid player continue; - if (i == active_player) + if (highlight && i == highlighted_player) wattron(w_current_state, COLOR_PAIR(CP_YELLOW_ON_BLACK)); if (pos < 5) { mvwprintw(w_current_state, 2+pos, 1, "%-s", pnoc[i].player_name); - mvwprintw(w_current_state, 2+pos, 13, "%3d", pnoc[i].open_card); + if (0 == pnoc[i].open_card) + mvwprintw(w_current_state, 2+pos, 15, "-"); + else + mvwprintw(w_current_state, 2+pos, 13, "%3d", pnoc[i].open_card); } else { mvwprintw(w_current_state, 2+(pos-5), 22, "%-s", pnoc[i].player_name); - mvwprintw(w_current_state, 2+(pos-5), 34, "%3d", pnoc[i].open_card); + if (0 == pnoc[i].open_card) + mvwprintw(w_current_state, 2+(pos-5), 36, "-"); + else + mvwprintw(w_current_state, 2+(pos-5), 34, "%3d", pnoc[i].open_card); } - if (i == active_player) + if (highlight && i == highlighted_player) wattroff(w_current_state, COLOR_PAIR(CP_YELLOW_ON_BLACK)); pos++; diff --git a/src/ui.h b/src/ui.h index 40252ce..47a45b0 100644 --- a/src/ui.h +++ b/src/ui.h @@ -9,7 +9,7 @@ void ui_display_wnd_table_cards(const table_stacks_t *ts, const bool highlight, const uint8_t highlighted_stack); void ui_display_wnd_stack_points(const table_stacks_t *ts, const bool highlight, const uint8_t highlighted_points); -void ui_display_wnd_current_state(const pnoc_t pnoc[], const uint8_t num_players, const uint8_t active_player, const uint32_t score); +void ui_display_wnd_current_state(const pnoc_t pnoc[], const uint8_t num_players, const bool highlight, const uint8_t highlighted_player, const uint32_t score); void ui_display_wnd_hand_cards(const hand_t *h, const bool highlight, const uint8_t highlighted_card); uint8_t ui_choose_card(hand_t *h); uint8_t ui_choose_stack(const table_stacks_t *ts); -- cgit v1.2.3