summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMario Kilies <MarioKilies@GMX.net>2011-01-13 20:44:05 +0100
committerMario Kilies <MarioKilies@GMX.net>2011-01-13 20:44:05 +0100
commit6ef4011ecfdf58726c76a60e858dc8e53d1ba5a8 (patch)
tree1ea72df722f212ce41dea248bcc52cd10f279f5d
parentf53ac238c3a7318e50dc7183630762a6aa23e4b4 (diff)
Implemented current state window.
-rw-r--r--src/display.c50
-rw-r--r--src/display.h3
-rw-r--r--src/player.h6
-rw-r--r--src/player_name_open_card_tuple.h13
4 files changed, 66 insertions, 6 deletions
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)
diff --git a/src/display.h b/src/display.h
index 8e9b3c4..8bbcb9e 100644
--- a/src/display.h
+++ b/src/display.h
@@ -6,10 +6,11 @@
#include "cardstack.h"
#include "tablestacks.h"
#include "hand.h"
+#include "player_name_open_card_tuple.h"
void display_window_table_cards(const tablestacks ts);
void display_window_stack_points(const tablestacks ts);
-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);
void display_window_hand_cards(const hand h);
void display_init(void);
void display_fini(void);
diff --git a/src/player.h b/src/player.h
new file mode 100644
index 0000000..8b9059f
--- /dev/null
+++ b/src/player.h
@@ -0,0 +1,6 @@
+#ifndef OXEN_PLAYER_H
+#define OXEN_PLAYER_H
+
+#define MAX_PLAYER_NAME_LENGTH 10
+
+#endif // OXEN_PLAYER_H
diff --git a/src/player_name_open_card_tuple.h b/src/player_name_open_card_tuple.h
new file mode 100644
index 0000000..b856e80
--- /dev/null
+++ b/src/player_name_open_card_tuple.h
@@ -0,0 +1,13 @@
+#ifndef OXEN_PLAYER_NAME_OPEN_CARD_TUPLE_H
+#define OXEN_PLAYER_NAME_OPEN_CARD_TUPLE_H
+
+#include "player.h"
+#include "card.h"
+
+typedef struct
+{
+ char player_name[MAX_PLAYER_NAME_LENGTH+1]; // Player name length + 1 for string termination
+ card open_card;
+} player_name_open_card_tuple;
+
+#endif // OXEN_PLAYER_NAME_OPEN_CARD_TUPLE_H