summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMario Kilies <MarioKilies@GMX.net>2011-01-25 23:02:40 +0100
committerMario Kilies <MarioKilies@GMX.net>2011-01-25 23:02:40 +0100
commitb3125e386140a040d8eff57ab9258eaafc60d983 (patch)
tree37f2dd7bf2c4cf45010be7b55de4dcaa0d020ab8
parent92f8870fa7a75be8458e35fb8de51965c5c33d91 (diff)
Added optional highlighting of messages in the message window.
-rw-r--r--src/client_game_states.c13
-rw-r--r--src/ui.c9
-rw-r--r--src/ui.h2
3 files changed, 16 insertions, 8 deletions
diff --git a/src/client_game_states.c b/src/client_game_states.c
index 49870ed..3fe262f 100644
--- a/src/client_game_states.c
+++ b/src/client_game_states.c
@@ -2,12 +2,13 @@
#include "net/comm.h"
#include "ui.h"
#include "data_store.h"
+#include <unistd.h>
game_state_t state_client_wait_for_hand_cards(const int sock, const uint8_t round)
{
data_store_t *d = data_store();
- ui_display_wnd_messages("Waiting for hand cards from server");
+ ui_display_wnd_messages("Waiting for hand cards from server", false);
if(round == 1)
{
@@ -29,7 +30,7 @@ game_state_t state_client_select_open_card(const int sock)
data_store_t *d = data_store();
uint8_t open_card_idx;
- ui_display_wnd_messages("Please choose the card you want to play");
+ ui_display_wnd_messages("Please choose the card you want to play", true);
// Select open card
open_card_idx = ui_choose_card(&d->hand);
@@ -49,7 +50,7 @@ game_state_t state_client_wait_for_open_cards(const int sock)
{
data_store_t *d = data_store();
- ui_display_wnd_messages("Waiting for the other players to pick their cards"); // The two spaces between 'pick' and 'their' are intentionally and used for poor man's word wrap
+ ui_display_wnd_messages("Waiting for the other players to pick their cards", false); // The two spaces between 'pick' and 'their' are intentionally and used for poor man's word wrap
net_recv(sock, msg_type_selected_card_all);
player_list_sort_by_open_card(&d->player_list, d->player_list.count); // sort in ascending order
@@ -79,12 +80,12 @@ game_state_t state_client_play_cards(const int sock)
{
if(our_turn) // our turn to select stack
{
- ui_display_wnd_messages("Please choose a stack");
+ ui_display_wnd_messages("Please choose a stack", true);
ds->stack_index = ui_choose_stack(&ds->table_stacks);
net_send(sock, msg_type_selected_stack_c, NULL);
}
- ui_display_wnd_messages("Waiting for chosen stack");
+ ui_display_wnd_messages("Waiting for player to choose stack", false);
net_recv(sock, msg_type_selected_stack_s);
ds->player_list.players[i].score += card_stack_get_points(&ds->table_stacks.stacks[ds->stack_index]);
card_stack_replace(&ds->table_stacks.stacks[ds->stack_index], c);
@@ -121,7 +122,7 @@ game_state_t state_client_play_cards(const int sock)
// Wait between player turns, but not after the last one
if (i != ds->player_list.count - 1)
- sleep(3);
+ sleep(2);
}
if(hand_count_cards(&ds->hand) > 0) // still cards in hand?
diff --git a/src/ui.c b/src/ui.c
index a0b8913..08ab64a 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -265,12 +265,19 @@ void ui_display_wnd_current_state(const player_list_t *pl, const uint8_t num_pla
/**
* Displays the message window.
* @param[in] message The message to display
+ * @param[in] highlight If true, the message will be highlighted
*/
-void ui_display_wnd_messages(const char *message)
+void ui_display_wnd_messages(const char *message, const bool highlight)
{
wclear(w_messages);
+
+ if (highlight)
+ wattron(w_messages, COLOR_PAIR(CP_YELLOW_ON_BLACK));
mvwprintw(w_messages, 0, 0, "%s", message);
+
+ if (highlight)
+ wattroff(w_messages, COLOR_PAIR(CP_YELLOW_ON_BLACK));
wrefresh(w_messages);
}
diff --git a/src/ui.h b/src/ui.h
index 4532ab3..cfe88d1 100644
--- a/src/ui.h
+++ b/src/ui.h
@@ -10,7 +10,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 player_list_t *pl, const uint8_t num_players, const bool highlight, const uint8_t highlighted_player, const uint32_t score);
-void ui_display_wnd_messages(const char *message);
+void ui_display_wnd_messages(const char *message, const bool highlight);
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);