summaryrefslogtreecommitdiff
path: root/ui.c
diff options
context:
space:
mode:
Diffstat (limited to 'ui.c')
-rw-r--r--ui.c31
1 files changed, 21 insertions, 10 deletions
diff --git a/ui.c b/ui.c
index b6d38be..8693119 100644
--- a/ui.c
+++ b/ui.c
@@ -29,31 +29,42 @@ void printmap(char** map, int y, int x, int mapH, int mapW) {
for (int r = 0; r < mapH; r++) {
for (int c = 0; c < mapW; c++) {
if (map[r][c] == '+') {
- mvaddch(y + r + 1, x + 2 * c + 1, (' ' | A_REVERSE));
+ mvaddch(y + r, x + 2 * c, (' ' | A_REVERSE));
addch(' ' | A_REVERSE);
+ } else {
+ mvaddch(y + r, x + 2 * c, (' '));
+ addch(' ');
}
}
}
refresh();
}
-void printpieces(struct piece** hand, int y, int x, int nhand) {
+void printpiece(struct piece* pc, int y, int x, int color_pair) {
+ attron(COLOR_PAIR(color_pair));
+ for (int r = 0; r < pc->h; r++) {
+ for (int c = 0; c < pc->w; c++) {
+ if (pc->blocks[r * pc->w + c] == '+') {
+ mvaddch(y + r, x + 2 * c, (' ' | A_REVERSE));
+ addch(' ' | A_REVERSE);
+ }
+ }
+ }
+ attroff(COLOR_PAIR(color_pair));
+}
+
+void printpieces(struct piece** hand, int y, int x, int nhand, int highlight) {
for (int i = 0; i < nhand; i++) {
if (hand[i] == NULL)
continue;
struct piece* pc = hand[i];
move(y, x);
+
printw("%d", i);
printrect(y + 1, x, pc->h + 2, pc->w + 2);
- for (int r = 0; r < pc->h; r++) {
- for (int c = 0; c < pc->w; c++) {
- if (pc->blocks[r * pc->w + c] == '+') {
- mvaddch(y + r + 3, x + 2 * c + 3, (' '| A_REVERSE));
- addch(' ' | A_REVERSE);
- }
- }
- }
+ printpiece(pc, y + 3, x + 3, (i == highlight ? 1 : 0));
+
x += 2 * pc->w + 8;
}
refresh();